Undefined identifier identifier. Global object will be used to locate the identifier. |
function main () { obj = new Object(); // obj is created without being // declared with var. } main ();
|
An undeclared variable created within a function is not locally defined. Instead, it is created as a property of the Global object. |
Calling function function_label with insufficient number of arguments. |
function main () { // It is a warning condition // instead of an error if the // missing argument is not // strongly typed.*/ var c = fn (); }
function fn (a, b) { return a+b; } main ();
|
|
variable variable is double declared. |
1. function fn () { for (var n = 0 ; n < 3 ; n++) { ...; } for (var n = 0 ; n < 3 ; n++) // n is double declared within // the scope of fn. { ...; } fn ();
2. function main () { var string1 = "a string"; var string1 = "another string"; // string1 should not be redeclared. } main ();
|
A local variable is declared more than once. To avoid this warning for the common case in Example 1, declare the counter variable outside of the for definition and use the counter variable without var in the for definition. For example: function fn () { var n; for (n = 0 ; n < 3 ; n++) { ... } for (n = 0 ; n < 3 ; n++) { ...
The multiple declarations like that in Example 2 have the net effect of all declarations after the first declaration being interpreted as simple assignments, but with the unnecessary overhead of variable declarations. Instead, use simple assignments after the first declaration; for example:
string1 = "another string".
|