[Wikiwyg-dev] BUG: Subclass (JS constructor) shouldn't return anything
- To: wikiwyg-dev@wikiwyg.net
- Subject: [Wikiwyg-dev] BUG: Subclass (JS constructor) shouldn't return anything
- From: Alex Vincent <alex.vincent@corp.manyone.net>
- Date: Mon, 13 Feb 2006 14:17:05 -0800
- User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20060213 SeaMonkey/1.5a
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.