JavaScript data types

Source: Internet
Author: User

Raw data type: Undefined, Null, Boolean, number, and String.

Complex data type: Object 1.Undefined TypeThe Undefined type has only one value, that is, a special Undefined.    When you declare a variable using VAR, but you do not initialize it, the value of the variable is undefined. It is not necessary to explicitly assign a variable to undefined, because a variable that does not have an assignment implicitly (automatically) assigns a value of undefined; 2.Null Type a null type has only one value, which is special null. that represents an empty object reference (meaning The typeof operator detects that NULL returns an object. undefined are derived from null, so ECMA-262 specifies that their equivalence is measured try to return true. alert (undefined = = null); True   3.Boolean Type     The Boolean type has two values (literal): true and False.    Boolean literals have only true and false two, but values of all types in ECMAScript have values equivalent to these two Boolean values. Other types are converted to Boolean rules (implicit conversions):
Data type The value converted to true Value converted to False
Undefined Undefined
Number Any non-0 numeric value (including infinity) 0 and NaN
String Any non-empty string Empty string
Object Any object Null
4.Number Type   The number type contains two values: integer and float. For those values that are too large or too small, they can be represented by scientific and technical law (e notation).     The exponent of the preceding 10 of the value is denoted by E. var box = 4.12e9; i.e. 4120000000 var box = 0.00000000412; That is 4.12e-9 5.String TypeThe string type is used to represent a sequence of characters consisting of 0 or more 16-bit Unicode characters, that is, a string.    The string can be represented by double quotation marks (") or single quotation marks (').    There is no difference between the two representations of single and double quotes, but they must appear in pairs, not interspersed, or they will go wrong.        Special character literal (escape character) of type String: \ n newline \ t tab \b Space \ r Enter \f feed \ Slash \ ' single quote \ "Double quotation mark \xnn a character (0~f) in hexadecimal code NN. Example: \x41 \unnn a Unicode character (0~f) represented as a hexadecimal code nnn. Example: \U03A3 6.Object TypeAn object is actually a set of data and functions.    An object can be created by executing the new operator followed by the name of the object type to be created. var obj = new Object ();

JavaScript data types

Related Article

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.