1 varBook = {2"Main title": "JavaScript",//There are spaces in the attribute name and must be represented by a string3"Sub-Title": "The Definitive Guide",//there are hyphens in the attribute name and must be represented by a string4' For ': ' All audiences ',//"for" is a reserved word, so you must use quotation marks5Author: {//Note that the attribute names here are not quoted6FirstName: "David",7Surname: "Flanagan"8 }9 }; - //Object Get Property the //Console.log (book.author); - - //Add Property - //book.date = "2017.7.27"; + //Console.log (book.date); - + //Delete Property A Deletebook.date; at - //Object Traversal - for(varIteminchBook ) { -Console.log (typeof(Book[item])); - Switch(typeof(Book[item])) { - Case' Object ': in - Console.log (Book[item]); to Break; + default: -Console.log (item + "= =" +Book[item]); the Break; * $ }Panax Notoginseng - } the + //Object Replication A the //copies the member property of O to P and returns the P + - functioncopy (o) { $ varp = O | | {};//if no object is passed to the parameter p, a newly created object is used $ returnp; - } - the varBook1 =copy (book); - //Console.log (BOOK1);
JavaScript authoritative Guide (sixth Edition) first reading notes-objects