Which approach is more effective and why?
Option 1: Declaring a variable
exampleFunction(requestData: Object) {
const username = requestData.username;
doSomething(username);
}
Option 2: Accessing the object property directly
exampleFunction(requestData: Object) {
doSomething(requestData.username);
}
Consider a scenario where the code exceeds 50 lines and the 'username' variable is utilized multiple times. In such cases, is it more efficient to use the 'username' variable repeatedly or access 'requestData.username' multiple times?