Something you have to know about JavaScript.

Source: Internet
Author: User

The template string 1, JavaScript does not distinguish between integers and floating-point numbers, is uniformly represented by number.

2. NaN This special number is not equal to all other values, including itself:

Nan===nan; False

The only way to judge NaN is through the isNaN() function:

IsNaN (NaN); True

3 null . Represents an "empty" value, which, 0 unlike an empty string ‘‘ , 0 is a numeric value that ‘‘ represents a string of length 0 and null represents "null". The undefined expression value is undefined.

4. JavaScript arrays can include arbitrary data types.

[1, 2, 3.14, ' Hello ', NULL, true];

Another way to create an array is through a Array() function:

New Array (1, 2, 3); Array created [1, 2, 3]

5. The way to enable strict mode is to write on the first line of the JavaScript code:

6, because the multi-line string to \n write up more trouble, so the latest ES6 standard added a multi-line string representation method, with anti-quote ' ... ' means:

' This is a multi-line string ';

The results of the operation are as follows:

7. Template string

To concatenate multiple strings, you can connect them with a + number:

var name = ' Xiaoming '; var age = 20;var message = ' Hello, ' + name + ', you are this year ' + Ages + ' old! '; alert (message);

If there are many variables that need to be connected, + it is more troublesome to use the number. It is convenient to use ES6 template strings.

var name = ' Xiaoming '; var age = 20;var message = ' Hello, ${name}, you ${age} year old! '; alert (message);

The result is exactly the same:

8. JavaScript provides some common methods for strings, note that calling these methods does not alter the contents of the original string, but instead returns a new string:

  toUpperCase()Turn a string into uppercase;

  toLowerCase()Turn a string into lowercase;

Something you have to know about JavaScript.

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.