JavaScript Learning Notes 1 data Types _ Basics

Source: Internet
Author: User
Only one form of code type is a function.

Undefined: Undefined, we can also call it non-existent, typeof (undefined) =undefined.

Null: null. Undefined is non-existent, and Null is present, but none. typeof (null) =object, but null is not object, which is the magic and uniqueness of NULL.

Boolean:true or False.

Number:nan and Infinity are two special numbers, and Nan represents a number that cannot be represented by a number, while the infinity represents an infinite number, and in contrast, the-infinify represents negative infinity. Here are two special places: Nan!=nan,infinity/infinity=nan. In the number type, there is a very useful method: ToString (), he can accept a digit from 2 to 36, and then convert our number to the corresponding binary.

String: Strings, the concept of no characters in JavaScript, and the string is the smallest unit representing text. In a string, there are two functions such as Charat (index) and charCodeAt (index) that return the character and character Unicode encoding of the corresponding index, respectively. In our peacetime, may often use the subscript way to visit, such as s[10], but this is not ECMAScript standard, should try to avoid.

All types of JavaScript are built up based on these five simple types. There is a myriad of complex relationships between these five types, and undefined,null,0, "" is false when converted to Boolean, and all of these four are true. But among these five, except Undefined==null, the others are not equal.

Here again we have this and strongly typed language, such as 123== "123". So how can we distinguish between types? This time: all equal: = = = To play a useful role.

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.