This link has been bookmarked by 13 people . It was first bookmarked on 26 Aug 2008, by zz_james Safetycat.
-
23 Mar 11
-
24 Nov 10
-
28 Aug 10
-
Dynamic Prototype Modification
The objects you use for your prototypes are just normal objects. If you modify them then the changes are immediately visible in any other objects that were constructed with that prototype object. So using the prototype object
<script> // set up dynam with a hidden prototype pointer to baseProto var dynam = new constructorFn9(); function testadd() { baseProto.testfn = function() { alert('testfn exists!'); }; } function testdel() { delete baseProto.testfn; } function testcall() { if (typeof dynam.testfn == 'function') { dynam.testfn(); } else { alert('testfn doesnt exist on dynam!'); } } </script>baseProtoby calling the constructorconstructorFn9from the previous example:// set up dynam with a hidden prototype pointer to baseProto var dynam = new constructorFn9(); function testadd() { baseProto.testfn = function() { alert('testfn exists!'); }; } function testdel() { delete baseProto.testfn; } function testcall() { if (dynam.testfn) { dynam.testfn(); } else { alert('testfn doesnt exist on dynam'); } }
-
-
10 May 10
-
the only way you can set the hidden prototype reference in JavaScript is to use the
newoperator. -
Only when you use the
newkeyword in conjunction with the function does theprototypeproperty get used in a special way -
The only way to set the hidden prototype reference is to use the new keyword in conjuntion with a constructor function.
-
A constructor function is just a normal function, with a property called prototype set to the parent prototype object you want to use.
-
-
14 Feb 10
-
03 Aug 09
-
30 Oct 08
-
02 May 08
-
21 Apr 08
Would you like to comment?
Join Diigo for a free account, or sign in if you are already a member.