Re: [JSON] Changing the class of an object after its construction
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: [JSON] Changing the class of an object after its construction

From: Thomas 'PointedEars' Lahn <PointedEars@web.de>
Date: Sun Nov 20 2005 - 16:02:31 CET

Thomas 'PointedEars' Lahn wrote:

> In fact, it MUST NOT work. `obj1' does not refer to a constructor
> (i.e. a Function object), so that does not have a `prototype' property.
> You are creating one with no intrinsic functionality here.
>
> To make the prototype chain work, you need another prototype.
> I found two ways for this:
>
> a)
> obj1.__proto__ = new myClass(); // JavaScript only, preserves properties

or

obj1.__proto__ = myClass.prototype;
 

PointedEars
Received on Mon Nov 21 11:15:19 2005