1 // ----------tolocalestring ()--the use of methods--------------------------- 2 var New Date (); 3 document.write (now.tostring () + "<br/>"); 4 document.write (now.tolocalestring ()); // tolocalestring () returns the localized string representation of an object 5 6 7 Results: 8 Thu Jan 21:08:41 gmt+08009
1 //---------The use of the hasOwnProperty ()----method------------------------2 functionDwn (s) {3document.write (s+ "<br/>");4 }5 6 functionClassA () {7 This. A = 1;8 }9 Ten functionClassB () { One This. B = 5; A } - -Classb.prototype =NewClassA ();//mechanism for managing object inheritance the varOBJB =NewClassB (); - - Dwn (OBJB); -Dwn ("a"inchOBJB); +Dwn ("B"inchOBJB); -Dwn ("A" is a property inherited from the prototype of Object B?) "+objb.hasownproperty (" a ")); +Dwn ("B" is the property inherited from the prototype of Object B?) "+objb.hasownproperty (" B ")); A at - Results: - [Object Object] - true - true -is a property inherited from the prototype of object B?false inB is the property inherited from the prototype of object B?true
JavaScript Object Knowledge points