+ 1
Ambiguity of vars in functions objects and methods?
Is there a purposes for using the same name for variables in object constructors, within the object code and within the methods contained inside the object; when calling them is handled differently for each? ie function confusing(a, b) { this.a = a; this.b = b; this.confused = function (a) { this.a = a; } } var c = new confusing("Yes", "No"); document.write("a is "+ c.a); c.confused("No"); document.write(" and a is "+c.a);
1 Antwort
+ 2
Now that you have seen that this can be confusing, take it as a lesson, and evade such practices in your own codes 👍