Javascript study Note 1 Data Type

Source: Internet
Author: User

CodeThere is only one type of function.

Undefined: Undefined. We can also call it nonexistent. typeof (undefined) = undefined.

Null: null. Undefined does not exist, but null does. Typeof (null) = object, but null is not an object. This is the magic and uniqueness of null.

Boolean: true or false.

Number: Nan and infinity are two special numbers. Nan represents a number that cannot be expressed by a number, while Infinity represents an infinite number, and-infinify represents negative infinity. There are two special points here: Nan! = Nan, infinity/infinity = Nan. In the number type, there is a very useful method: tostring (), he can accept a number from 2 to 36, and then convert our number to the corresponding hexadecimal number.

String: string, which is the smallest unit of text in JavaScript. In a string, there are two such functions: charat (INDEX) and charcodeat (INDEX), which respectively return the character and character unicode encoding of the corresponding index. In normal times, we may often use the following access method, such as S [10]. However, this is not the ecmascript standard and should be avoided as much as possible.

All types of JavaScript are built up based on these five simple types. There are thousands of complex relationships between these five types. When undefined, null, 0, "" is converted to boolean, it is false. All except these four types are true. However, among the five, except for undefined = NULL, none of them are equal.

We have such a strong type of language, such as 123 = "123 ". How can we differentiate data types? In this case, all equal: = is used.

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.