[Wikiwyg-dev] BUG: Subclass (JS constructor) shouldn't return anything



In JavaScript, a constructor function should never have a return statement. When a constructor returns a value, the JavaScript environment effectively ignores the new keyword.

From Mozilla's xpcshell (a command-line JavaScript engine) :

js> function foo() {
 return bar.prototype;
}
js>
js> function bar() {
}
js>
js> var x = new foo();
js> var y = new foo();
js> x == y
true
js> function test() {}
js> var a = new test();
js> var b = new test();
js> a == b
false

Subclass, in returning a value, is probably not doing what you want.






This archive was generated by a fusion of Pipermail (Mailman edition) and MHonArc.