JS data type Getting started with typeof operator

Source: Internet
Author: User

Standard data type partitioning:

Basic type:

Number (numeric), string (string), Undefined, Boolean (Boolean), null (NULL object)

The biggest difference between an empty object and a non-empty object is that you cannot perform property operations

Object type (composite type):

Object (Objects)

There is no function in the object type and the function does not belong to the data;

typeof Operator:

is the data type used to detect variables, for values or variables. typeof The operator returns the string as follows. The code is as follows

var nub = ten; Console.log (typeof nub); Number number    /* numbers from negative infinity to positive infinity, and Nan (not a digit) */
var str = "Asdsadsad"; String string Console.log (typeof str);/* any string of characters enclosed in quotation marks are strings */
var is = true; Boolean Boolean value Console.log (typeof is);/* true and false*/
var arr = []; Object Object Console.log (typeof arr); Console.log (null = = arr);//Note empty array is not equal to null object var obj = null; Object Console.log (typeof obj); var el = document; Object Object Console.log (typeof el);/* objects: array, NULL, Element object, Object*/var u;//undefined undefined Console.log (typeof u); var fn = function () {//function alert (1);} Console.log (typeof fn), function fn2 () {//function alert (2);} Console.log (typeof fn2);

The data types in typeof are divided into:

    • Number
    • String
    • Undefined
    • Boolean
    • Object
    • function

JS data type Getting started with typeof operator

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.