JavaScript data types and variables to be aware of

Source: Internet
Author: User

1/3 = = = (1-2/3); False
Floating-point numbers generate errors during operation because the computer cannot accurately represent infinite loop decimals. To compare two floating-point numbers for equality, you can only calculate the absolute value of their difference to see if they are less than a certain threshold:
Math.Abs (1/3-(1-2/3)) <0.00001; True

ES6 new template string ' '
eg
var name = ' Xiao Ming ';
var age = 20;
Alert (' Hello, ${name}, you ${age} year old! ');

The string is immutable, and if you assign a value to an index of a string, there is no error, but there is no effect.

The concat () method does not modify the current array, but instead returns a new array. In fact, the concat () method can receive any element and array, and automatically takes the array apart and adds it all to the new array.

--a blog that was extracted from Liaoxuefeng

JavaScript data types and variables to be aware of

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.