Reputation: 75137
What are the differences of that iterations:
var recordId;
for(recordId in deleteIds){
...
}
and
for(var recordId in deleteIds){
...
}
It says implicit definition(what is it), is there a performance difference between them?
Upvotes: 2
Views: 50
Reputation: 2335
the two samples are equivalent, however the first may come from following a recommended pattern in JavaScript which is declaring all variables at the top of every function.
Sample:
var recordId,
i = 0;
for(recordId in deleteIds){
...
i++;
}
More explanation on this can be found here JSLint error: Move all 'var' declarations to the top of the function
Upvotes: 1
Reputation: 75317
An "implicit declaration" is a variable that is assigned a value before it is declared using a var
. The scenario leaves the variable declared in the largest possible scope (the "global" scope).
However, in both your code examples, recordId
is declared before it is assigned (var recordId
), so there's no problem.
As to your other question, no, there is no noticeable performance difference.
Upvotes: 1