JS reference Type--object type

Source: Internet
Author: User

Object is the most used type in ECMAScript, and although instances of object do not have much functionality, they are ideal for storing and transmitting data in an application.

There are two ways to create an instance of an object:

The 1.new operator is followed by the object constructor

var New  = "Nicholas"= 29;

2. Literal notation

Object literals are shorthand forms of object definitions to simplify the creation of object procedures that contain a large number of attributes.

var person = {    "Nicholas",    +};
 function   DisplayInfo (args) { var  output = "" ;  if  (typeof  Args.name = = "string" Span style= "color: #000000;"    {Output  + = "Name:" + args.name + "\ n"  if  (typeof  args.age = "number" Span style= "color: #000000;"    {Output  + = "Age:" + args.age + "\ n"  "Nicholas"  20} );d Isplayinfo ({name:  "Greg"  

In this example, the function DisplayInfo () takes a parameter. This parameter may have a property named name or age. Use literal to specify different data when calling a function.

JS reference Type--object type

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: info-contact@alibabacloud.com 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.