aQuos
05-05-2007, 08:03 AM
I have this:
function foo() {
alert( 'default constructor' ) ;
// methods and properties
}
function bar() {
alert( 'new constructor' ) ;
}
foo.prototype.constructor = bar ;
new foo() ;
I wanna change the default constructor with new constructor, leaving all foo's methods and properties unchanged, but when create a new instance of foo, still alert 'default constructor'... what's wrong?
function foo() {
alert( 'default constructor' ) ;
// methods and properties
}
function bar() {
alert( 'new constructor' ) ;
}
foo.prototype.constructor = bar ;
new foo() ;
I wanna change the default constructor with new constructor, leaving all foo's methods and properties unchanged, but when create a new instance of foo, still alert 'default constructor'... what's wrong?