JavaScript variables and data types

Source: Internet
Author: User

Variable

Variables in JavaScript are represented by a variable name, which is a combination of uppercase and lowercase English, numeric, $ and, and _ can only be preceded by letters, underscores, and $ . The variable name cannot be a JavaScript keyword, such as if , and while so on. Declare a variable var关键字 , for example:

var  // declaring variable a var  b = Ten;  // declaring variables and assigning values var  $a = "string";  // declaring a variable starting with a $ character var  true;  // Declare variables with _ var NULL ; var $b = undefined;

Note: variables are strictly case-sensitive.

Writing Specifications for variables:

1, Camel style--the first word lowercase, the rest of the first letter of the word capital. such as: Mynameislee

2. Underline style--the word is unified lowercase and the word is separated from the word by an underscore. such as: My_name_is_lee

Note: In the development process, you should keep the entire project consistent regardless of which writing specification is used.

Data type

in JavaScript, there are 6 types of data, namely numeric (number), Boolean (Boolean), String-type (string)    , undefined, null, object type. The first four are basic data types, and Null is a special type, and object is a composite data type.

  Number

  JavaScript does not distinguish between integers and floating-point numbers, and is uniformly represented by number, and the following are valid number types:

// integer 1234 // floating point 1.456 // scientific notation means 1.235x1000, equivalent to 123.5 // Negative number // Nan means not a number, which is represented by Nan when the result cannot be evaluated // Infinity is infinitely large, and is represented as infinity when the value exceeds the maximum value that JavaScript can represent.

JavaScript variables and 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.