Site front-end _javascript-basics. 0009.JavaScript Object Type

Source: Internet
Author: User

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.


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 =  ' 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 

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

Site front-end _javascript-basics. 0009.JavaScript Object Type

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.