Read JavaScript Advanced Programming (third Edition) Thoughts:
There are two ways to create an instance of an object, the first with the new operator followed by the object constructor, as follows:
var New Object (); = "Zoumm"; = "Web Development";
The second is the use of object literal notation, which is intended to simplify the process of creating objects that create a large number of properties. As shown below:
var bb = {name:"Zoumm", Age:
Adding a comma after the last attribute will cause an error in IE7 and earlier China.
When using object literals, the property name can also use a string, as follows:
var bb = { "name": "Zoumm", "Age: ' 12,
"True"}//the numeric attribute name here is automatically replaced with a string
For object literals, it is recommended to only consider the readability of object property names. Object literals are also the preferred way to pass a large number of optional parameters to a function, such as:
function aa (args) { if(typeof args.name== "string" ) { console.log (args.name); } if(typeof args.age== "number" ) { console.log (args.age); } } AA ({ name:"Zoumm", age : ()) AA ({ name:"DJ" })
JS creates an object instance in two ways (new operator and object literal)