Revision: 2655
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at March 20, 2007 09:56 by 1man
Initial Code
//used below in "secret" linking function object(o){//new function, argument o function F() {}//define function F(empty) F.prototype = o;//add the custom property/method passed through o return new F();//return the new function with the added property/method } //Old object var myObject = { name: "Matt", dob: "12/12/1913", age: "95", ocupation: "Web Developer" } //Secret link new object to old object var myNewObject = object(myObject); //add values to the new object myNewObject.name = "new name"; myNewObject.crime = "crime"; //it can't find "age" in new object, it looks at the old object via the link. console.info(myNewObject.crime);//firebug console.info(myNewObject.age);//firebug //delete info in an object delete myObject.ocupation; console.warn(myObject.ocupation);//firebug
Initial URL
Initial Description
Shows you how to link 2 objects together via the object function. If a value isn't found in the object, it will look for it in the linked object.
Initial Title
Linking Objects & Deleting Info in Objects
Initial Tags
javascript, object, link
Initial Language
JavaScript