Reputation: 1482
I'm trying to validate Javascript code through Sonar and I have some doubts about strict mode rules.
The rule I'm validating is about "eval" and "arguments" behavior in strict mode.
In reading this rule description, it seems I can not assign arguments to new variable for accessing it later or in a loop.
On reading some documentation, from strict mode on Firefox and strict mode on IE the rules I found basically are (that apply to this case):
But, the sample code above seems to be violating that Sonar rule:
var args = arguments;
So, is this a false-positive or is this piece of code violating strict mode?
Upvotes: 6
Views: 7102
Reputation: 1482
Based on the users answers and some researches, I've found this code (var args = arguments;
) to be valid, since it's not modifying arguments, but only assigning it to another variable.
Please note that, since args
now points to arguments
it can't be modified also. But it can be read normally.
Update: Fix will be available under new release Javascript plugin (1.5).
Upvotes: 6