JS data type

Source: Internet
Author: User

One, the data types in JavaScript can be divided into basic data types and composite data types two kinds:

(1) The underlying data type has 5 data types: number, Boolean, Undefined, NULL, and string. Number type: Integers and floating-point numbers. Nan:not a number. This value is used to return a value, but it is not possible to put back a value to prevent an error. For example: 1/0 the return is Nan. Nan Features: 1. Any operation involving Nan will return Nan. 2. Nan is not equal to any value, including its own Nan itself. For the Nan attribute, JS has a built-in isNaN () function to determine whether the value is a Nan type. Boolean type: Only two literal literals are true and false. However, many variables in JS can be converted to a Boolean value using the Boolean () function. UndefinedThe type has only one value, that is, undefined, which declares the variable using VAR, but is not initialized, and this variable is the undefined type, for example: var i;                alert (i = = undefined);//true var i; var i = undefined; the two sentences are equivalent. variables that contain undefined values are not the same as undefined variables. the Null type also has only one value: Null.null represents a pointer to an empty object. StringType: Slightly(2) composite data types include the following: functionfunction Type [*] ObjectObject types, Object essence is a set of unordered name-value pairs. ArrayThe array type, which is a special type of object object, checks the data type of a variable
typeof operator: The type of the inferred variable for a variable, possibly returning the following string:
"undefined": if this value is undefined or initialized
"Boolean": Boolean value
"string": String
"number": Value
' object ': Object
"function": Functions
usage: typeof 95; or typeof (95); will return "number"Example code:

JS data type

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.