Classification of data-javascript data types

Source: Internet
Author: User

JavaScript data type 1. What is the data type?

The vast majority of the programming languages we touch, the data are categorized, including numbers, characters, logic and authenticity: Int,long,string,boolean .... And so on, we all know that computers use binary methods when it comes to data processing. Load data into memory, and the final result is computed by CPU scheduling, so is the type of data recorded when memory is stored? I think the answer is no, in-memory data should be based on the size of the memory to be differentiated and calculated, two different types of data calculation, for the CPU only dispatched two of the memory size of the data to calculate, so for the CPU, the data only 1 and 0. Then there is a problem here, some people will say that the Java language some two kinds of data can not be calculated directly, must be converted to calculate. Here, the difference between the strong type and the weak type, the strongly typed language will check each kind of data strictly, that is, for each type of memory occupied space to check, if not meet the requirements, it is not allowed to compile or run. Weak types do not have a rigorous check of the data, allowing most data types to be computed directly, and JavaScript to beweakly typed .

What are the 2.JavaScript types?

Includes the following:

        • Number: That is, numbers include floating-point
        • Boolean: False (True or false)
        • String: Strings
        • NULL: null object pointer indicating that the memory space pointed to does not exist
        • Undefined: Undefined, indicating that the pointing memory space exists, but there is no data
        • Object: A complex data type that should be well understood if you are familiar with similar Java object-oriented languages

By the above 6 types, you can classify the data, and for the container JavaScript of the data is unified with the keyword var Declaration, then how to determine the type of a variable? This is going to use the keyword typeof

Here, it is necessary to note that typeof is an operator (like + 、-、 *,/) and not function You can typeof a directly Use (although this is not recommended). The null and undefined are equal when the size is compared. Because undefined is derived from null.

Below is an example of typeof

1 varMesage= ' some string ';2 varobj=NewObject ();3 varA;4Alerttypeofmessage);//' String '5Alerttypeof(message));//' String '6Alerttypeof(95));//' number '7Alerttypeof(a));//' undefined '8Alerttypeof(NULL==undefined));//' Boolean '9AlertNULL==undefined);//' true 'Tenalert (obj);//' object ' OneAlertNULL);//' object ' (may also be ' null ' in different browsers)

Classification of data-javascript data types

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.