Introduction to the object:
Description: Object is a reference type, and a reference type is a data structure used to organize data and functionality together, such as var newObj = new Object (), which creates a new instance of the Object reference type, saved in NewObject, The constructor used is object, which defines the default properties and methods for the new object only.
Object-Related:
Description: Although the object instance does not have much functionality, it is an ideal choice for storing and transmitting data in an application.
/* * Create object Mode */// support construction Parameters Var newobj = new object ()// Support parameterless construction without () var newObj = new Object// support for literal generation var newobj = { // key support without quotes, will automatically be converted to string name: "Li full", // key support quotes, is automatically converted to string ' age ': 25, // key supports literal values and is automatically converted to strings true: true,}console.log (NEWOBJ)/* * Add attribute method */// commonly used in unknown property name newobj[' Name '] = ' li full// often newobj.name = ' Liu Jianjin '/* * How to get properties when individually accessed */var name = newobj[' name ']console.log (name) var name = newobj.nameconsole.log (name)/* * Traverse All Properties * */for (key in newobj) { console.log (' key -> ' + key, ' val -> ' + newobj[key])}/* * Delete related properties * */delete Newobj.name
Note: An object can be passed as an argument to a function, and an object can carry countless attributes, so the preferred way to pass an optional parameter to a function is commonly used in real-world development
This article is from the "ζ Automated operation and maintenance development Road ζ" blog, please be sure to keep this source http://xmdevops.blog.51cto.com/11144840/1851599
Site front-end _javascript-basics. 0009.JavaScript Object Type