5th Chapter-javascript Operator

Source: Internet
Author: User

5.1 operator Type: ① arithmetic operator ② assignment operator ③ comparison operator ④ logical operator ⑤ bitwise operator ⑥ SPECIAL operator

5.2 Arithmetic operators: +,-, *,/,%,++,--, + (unary Plus),-(one yuan minus)

5.2.1 (+): ① coercion type conversion (low precision to high precision) ② number + number + string (add first after join) ③ string + string = string ④ If one operand is a special value Nan (not a number) and the other is a number, the result is Nan

5.2.2 (-): ① If one of the operands is Nan, the result will be nan② if one of the operands is a non-numeric type (such as a string, Boolean, and so on), then JavaScript will attempt to convert it to a number, and if not cast, the result will become Nan. For example: "7"-"3" =4 (string-Cast for numbers)

5.2.3 (*): ① If one of the operands is Nan, the result will be nan② if one operand is a non-numeric type, then JavaScript will attempt to convert it to a number, and if not cast, the result will become Nan.

5.2.4 (/): If one of the operands is Nan, the result will be nan② if you divide by 0 by 0, the result will be nan③ if any finite number is divided by 0, the result will be a special value Infinity④ if one of the operands is a non-numeric type, JavaScript will attempt to convert it to a number, and if it cannot be cast, the result will become Nan

5.2.8 (unary Plus +): ①4+ "7" = "47" ②4+ (+ "7") =11

5.3 Assignment Operator: =,+=,-=,*=,/=,%=

5.4 Comparison operators: ==,!=,=== (Identity),!== (not identical), >,<,>=,<=

5.4.1 (==,! =): ① If one operand is a number and the other is a string, JavaScript will attempt to convert the string to a number ② if an operand is a Boolean, then it will be strongly converted to the number 1 and 0③ if one operand is null and the other is undefined, The result of the comparison is True④ if one or two operands is Nan, the result is false

5.4.3 (===,! = =): Not only compare the values on both sides, but also compare their types, for example: ①7== "7" result is true, and 7=== "7" result is false

5.4.5 (>,<,>=,<=): Where the operand involves a string, converts it to ASCII comparison, and if both sides are strings, the comparison size starts from the first character (the length is different, how long it is)

5.5 Logical operators: &&,| |,!

5.6-bit operator:&,^,|,~,<<,>>,>>>

5.7 Special operators:?: (condition), comma (the statement that executes both sides of the operator, returns the result of the second statement), delete (used to delete an object, property, or an element in an array), in (if the property returns true in the specified object), Instanceof (Returns True if the object is the specified object type), New (creates an instance of an object), this (referring to the current object), Typeof (returns a string that describes the value type), Void (allows the expression to be executed without returning a value)

5.8 Operator Precedence:

5th Chapter-javascript 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.