JavaScript data type

Source: Internet
Author: User
Tags javascript array

string, number, Boolean, array, object, Null, Undefined

JavaScript Array

The following code creates an array named cars:

var cars=new Array ();
Cars[0]= "Audi";
Cars[1]= "BMW";
Cars[2]= "Volvo";

or (condensed array):

var cars=new Array ("Audi", "BMW", "Volvo");

or (literal array): instance

var cars=["Audi", "BMW", "Volvo"];

JavaScript Objects

Objects are delimited by curly braces. Within parentheses, the object's properties are defined in the form of name and value pairs (name:value). Properties are separated by commas:

var person={firstname: "Bill", LastName: "Gates", id:5566};

The object (person) in the example above has three properties: FirstName, LastName, and ID.

Spaces and folding lines are irrelevant. Declarations can span multiple lines:

var person={
FirstName: "Bill",
LastName  : "Gates",
ID        :  5566
};

There are two ways to address an object property: an instance

Name=person.lastname;
name=person["LastName"];



Everything in JavaScript is an object: A string, a number, an array, a date, and so on.

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: 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.