Data types and variables for JavaScript

Source: Internet
Author: User

 JavaScript data types

1. Original Data type:

numeric , such as decimal number, hexadecimal number, octal number, and special value (Infinity, nan), note: NaN cannot compare itself with

String type , such as delimiter, escape character;

the Boolean type .

2. Composite Data type:

Objects (object );

Arrays (array );

function .

3. Special Data Types:

no defined data type undefined;

The null value is Null.

The difference between null and undefined is that undefined means that the variable is not assigned, and null means that the variable is given a null value, and Null is equivalent to a placeholder.

 JavaScript Data type conversions

1. Implicit conversion:

Convert to Boolean type false:

Convert to Numeric Data:

Convert to String Data:

2. Explicit conversion:

Convert to numeric value (by number () to numeric value, converted to integer by parseint (string,radix), parsefloat (tring) to floating-point values):

Convert to a string (converted to a string through a string function):

Convert to Boolean type (cast to Boolean by Boolean function):

 JavaScript variables

1. Declare variables:

Declare variables with the Var keyword;

Variables can be declared at the same time to assign values;

You can declare one variable at a time, or you can declare multiple variables at once;

If only the variable is not assigned a value, the default value is undefined;

If the name of the variable produces an overlay.

Precautions:

Variables are strictly case-sensitive;

Variable names do not contain special characters;

Variable names are best followed by hump marking or underline method;

Variable names are best understood.

2. Storage and release of variables in memory:

Collection method: useless storage unit collection, automatic

Collect content:

Recovery Algorithm.

Data types and variables for JavaScript

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.