JavaScript data type and operator __java

Source: Internet
Author: User
Tags string to number

1. Original type (6 kinds): Number,string,boolean,null,undefined,object (Function,array,date)


2. Implicit conversion: "37"-7//30

"37" +7//377

Note the use of-+-rule conversion type:

(1) num-0: Converts num type to number;

(2) num+ "": Converts the NUM type to a string;


2. = = operator

"1.23" = 1.23: Strings and numbers are compared, the strings are converted to numbers and then compared;

0 = false;

Null = = undefined;

New Object () = new Object ();

[1,2] = = [1,2];


3. = = = Strictly equal To

A = = = B:

Returns False if the type is different;

The same type: (1) NULL = = NULL;

(2) undefined = = undefined;

(3) Nan!= nan; (Neither Nan nor any number is equal);

(4) New Object ()!= new Object ();


4.a==b

same type, same = = =

Type is different, try type conversions and comparisons:

(1) NULL = = undefined equal;

(2) Number = = String: Converts a string to number, 1== "1.0"//true;

(3) Boolean = =? : Converts Boolean to number, true to 1,false conversion to 0, and then comparison;

(4) Object = = Number|string: Attempt to convert object to base type, new string ("hi") = = "HI"


GitHub home: https://github.com/chenyufeng1991. You are welcome to visit.

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.