JavaScript Data types

Source: Internet
Author: User

JavaScript Data types

First, the basic data type:

String, number, Boolean, date, and time

JavaScript has a dynamic type

JavaScript has a dynamic type. This means that the same variables can be used for different types:

1 var x                //  x is undefined2var x = 6;           // x is a number 3 var x = "Bill";      // x is a string
JavaScript string

A string is a variable that stores characters (such as "Rose").

The string can be any text in quotation marks. You can use single or double quotation marks:

var treename= "Rose"; var treename= ' Rose ';
JavaScript numbers

JavaScript has only one numeric type. Numbers can be with decimal points or without:

1 var x1=34.00; // use a decimal point to write 2 var x2=34; // do not use the decimal point to write

JavaScript Boolean

Boolean (logic) can have only two values: TRUE or FALSE.

JavaScript arrays

The following code creates an array named cars:

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

JavaScript Data types

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.