Elementary Introduction to JavaScript Data type _ basic knowledge

Source: Internet
Author: User

1. What is the data type?

Most of the programming languages we touch, the data are classified, including numbers, characters, logic True and false: Int,long,string,boolean .... And so on; we all know that computers are used in binary mode for data processing. Loading data into memory and calculating the end result with CPU scheduling, is it the type of data that is recorded when the data is stored in memory? I think the answer is in the negative, in-memory data should be based on the size of the memory to be divided and calculated, two different types of data calculation, for the CPU is only two of the memory size of the data to calculate, so for the CPU, the data is only 1 and 0. Then there is the problem, some people will say that some of the Java language data can not be calculated directly, must be converted to calculate. Here, the difference between a strong type and a weak type, a strongly typed language checks each type of data rigorously, which means that the space for each kind of memory is checked and not compiled or run if it does not meet the requirements. Weak types do not rigorously examine the data, allowing most data types to be computed directly, and JavaScript is weakly typed.

What are the 2.JavaScript types?

Includes the following:

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

With these 6 types, the data can be categorized and the container JavaScript for the data is unified with the keyword VAR declaration, so how do you determine what type of variable is? This is going to use the keyword typeof.

Here, it should be explained that TypeOf is an operator (similar to + 、-、 *,/) instead of a function you can use directly typeof a (although this is not recommended). and null and undefined are equal when compared to the size. Because undefined is derived from null.

Below is an example of typeof.

Copy Code code as follows:

var mesage= ' some string ';
var obj=new Object ();
var A;
Alert (typeof message);//' String '
Alert (typeof (Message));//' String '
Alert (typeof);//' number '
Alert (typeof (a));//' undefined '
Alert (typeof (Null==undefined));//' Boolean '
alert (null==undefined);//' true '
alert (obj);//' object '
alert (null);//' object ' (may also be ' null ' in different browsers)

The above is all about JavaScript data type, I hope you can enjoy it.

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.