// construct an object using the constructor // a) // constructor object functions var obj = new new Object (); obj.name = "Tom" ; obj.age = 16 ; obj.gender = "MALE" ; the console.log ( obj); // point accessors the console.log (obj.name); // brackets accessors the console.log (obj [ "Gender" ]); // 2) // constructor object functions var obj = {}; obj.name = "Lucy" ; obj.age = 18 is ; obj.gender= "FEMALE" ; the console.log (obj); // object serialization and serialization return // convert js json string object var json = the JSON.stringify (obj); the console.log (obj); // js subject to convert a string json var obj = the JSON.parse (json); the console.log (obj); // . 3) // object literal var obj = { name: "Lily" , Age: 15 , Gender: " MALE " }; console.log (obj); // delete attribute the delete obj.name; the console.log (obj); // . 4) // object literal var obj = { name: "Lisa" , Age: 20 is , clazz: 1903 , QQ: 123456 , Gender: "MALE" }; the console.log (obj ); // constructor who created the current object var RESULT1 = obj.constructor (); the console.log (RESULT1); // returns a string describing information about the object var result2 = obj.toString (); the console.log (result2); // returns the description information of the digital object var= result3 obj.valueOf (); the console.log (result3); // enhanced for loop, traverse the object for ( var Key in obj) { // get property values var value = obj [Key]; the console.log (value) ; }
JS objects and basic properties or methods
Guess you like
Origin www.cnblogs.com/lidyfamily/p/11426192.html
Recommended
Ranking