Supplement to the prototype object
. 1 <! DOCTYPE HTML> 2 <HTML> . 3 <head> . 4 <title> </ title> . 5 </ head> . 6 <body> . 7 <Script type = "text / JavaScript"> . 8 function Fun () {} . 9 = fun.prototype.name "Fun apos value" ; 10 var obj = new new Fun (); . 11 the console.log (obj.name); 12 is 13 is // used in checking whether the object contains an attribute, but if the object is not there prototype, 14 // will return to true 15 console.log ( "name" in obj); 16 17 = obj.sex "FEMALE" ; 18 is // use hasOwnProperty object () to check whether the object itself containing the attribute 19 // only when the attributes contained in the object itself, using this method will return true 20 is the console.log (obj.hasOwnProperty ( "Age")); // to false 21 is the console.log (obj.hasOwnProperty ( "Sex")); // to true 22 is the console.log (obj.hasOwnProperty ( "hasOwnProperty")); // to false 23 is 24 the console.log (obj._proto_.hasOwnProperty ( "hasOwnProperty"));// should be false, but now seems to have no proto, so will complain 25 26 // prototype object is an object, so it also has a prototype 27 // When we use the property or method of an object, it will be first in itself Looking 28 // itself if there is a direct use 29 // if not then go find the prototype object, the prototype object if there is, then use 30 // if not then go to the prototype of the prototype looking until you find the object's prototype object 31 // prototype object object no prototype, if the object is still not found, returns undefined 32 33 is 34 is </ Script> 35 </ body> 36 </ HTML>