JS data type

Source: Internet
Author: User

The JavaScript data type is very concise, it only defines the basic data type in 6

  • Null: null, none. Represents a non-existent when the property of an object is assigned a value of null, which means that the property is deleted
  • Undefined: Not defined. This value is displayed when the declared variable is not assigned a value . You can assign a value of undefined to a variable
  • Number: Numeric value. The most primitive data type, the vector of expression computation
  • String: Strings. The most abstract data type, the carrier of information dissemination
  • Boolean: Boolean value. The most mechanical data type, the carrier of the logical operation
  • object: Objects. Object-Oriented Fundamentals
    #当弹出一个变量时: var aa;alert (aa);  // variable definition, popup undefined #当判断一个变量是否存在时: var str; if (str = = undefined)    // variable definition, so you can judge if(str = = undefined)     // variable undefined, error referenceerror:str is not defined  if typeof str = = ' undefined ')

    Use of typeof:

    typeof can be used to detect the data type of a given variable and to return a string that represents the data type of the expression.

    Alerttypeof1);//returns the string "number"Alerttypeof"1");//returns a string of "string"Alerttypeof true);//returns the string "Boolean"Alerttypeof{});//returns the string "Object"Alerttypeof[]);//returns the string "Object"Alerttypeof function(){});//returns the string "function"Alerttypeof NULL);//returns the string "Object"Alerttypeofundefined);//returns the string "undefined"

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.