JS Basic Three

Source: Internet
Author: User
Tags bitwise bitwise operators

1. Delete Deletes the definition of the object's properties and methods. forces a reference to it to be set to undefined

The delete operator cannot delete properties and methods that are not defined by the developer.

2,The void operator returns undefined for any value. This operator is often used to avoid output values that should not be output, and functions that do not return a value actually return undefined.

3, the former increment operator, is the number plus 1, the form is placed before the variable two plus (+ +):

var iNum = 10;++inum;

The second line of code adds iNum to 11, which is essentially equivalent to:

var iNum = 10;inum = INum + 1;

Similarly, the pre-decrement operator is reduced by 1 in the form of a two minus sign (--) before the variable:

var iNum = 10;--inum;

In this example, the second line of code reduced the value of INum to 9.

When using the prefix operator, note that both the increment and decrement operators occur before the expression is evaluated.

4, the post-increment operator also adds 1 to the value, in the form of two plus signs after the variable (+ +): Unlike the prefix operators, the postfix operators do not increment or decrement operations until they have evaluated the expressions that contain them.

5 . Bitwise operators operate at the bottom of the number (that is, the 32 digits of a number).

6 . There are two types of integers, namely signed integers (which allow positive and negative numbers) and unsigned integers (only positive numbers are allowed). signed integers use 31-bit numeric values that represent integers, a 32nd digit symbol for integers, 0 for positive numbers, and 1 for negative numbers. Values range from 2147483648 to 2147483647.

7. The bitwise operation not is represented by a negative number (~), which is one of the few operators associated with binary arithmetic in ECMAScript.

Bitwise arithmetic NOT is a three-step process:

    1. Convert the operand to a 32-digit number
    2. Converts a binary number to its binary counter code
    3. Convert binary numbers to floating point numbers

8. The Boolean operator has three types: not, and and OR.

9.

The abstract operation ToBoolean converts its arguments to logical values according to the rules in the following table:

parameter Type Results
Undefined False
Null False
Boolean The result equals the input parameter (not converted)
Number If the argument is +0,-0, or NaN, the result is false, otherwise true.
String If the argument is an empty string, the result is false, otherwise true.
Object True

10.

The logical NOT operator behaves as follows: denoted by an exclamation point (!)

    • Returns False if the operand is an object
    • Returns true if the operand is the number 0
    • Returns False if the operand is any number other than 0
    • Returns true if the operand is null
    • Returns true if the operand is NaN
    • If the operand is undefined, an error occurs

11. If an operand is not the original Boolean value, the logical AND operation does not necessarily return a Boolean value

    • If one operand is an object and the other is a Boolean value, the object is returned.
    • If the two operands are objects, the second object is returned.
    • Returns null if one of the operands is null.
    • If an operand is Nan, a nan is returned.
    • If an operand is undefined, an error occurs.

12 . The logical AND operator is represented by the double ampersand (&&).

13. The logical OR operator is represented by a double vertical bar (| | Said

14, multiplication also has some special behavior:

    • If the result is too large or too small, the resulting result is Infinity or-infinity.
    • If an operand is Nan, the result is Nan.
    • Infinity times 0 and the result is NaN.
    • Infinity is multiplied by any number other than 0, resulting in Infinity or-infinity.
    • Infinity times Infinity, the result is Infinity.

15. The division operator also has some special behaviors:

    • If the result is too large or too small, the resulting result is Infinity or-infinity.
    • If an operand is Nan, the result is Nan.
    • The Infinity is Infinity and the result is NaN.
    • Infinity is removed by any number, and the result is Infinity.
    • 0 The result is NaN, except for a number of any non-infinite size.
    • Infinity is removed by any number other than 0, resulting in Infinity or-infinity.

16. the Division (remainder) operator is represented by a percent semicolon (%):

The modulo operator also has special behavior:

    • If the divisor is Infinity, or the divisor is 0, the result is NaN.
    • The Infinity is Infinity and the result is NaN.
    • If the divisor is an infinite number, the result is dividend.
    • If the divisor is 0, the result is 0.

17, addition also has some special behavior:

    • One of the operands is Nan, and the result is Nan.
    • -infinity plus-infinity, the result is-infinity.
    • Infinity plus-infinity, the result is NaN.
    • +0 plus +0, the result is +0.
    • -0 plus +0, with a result of +0.
    • -0 Plus-0, the result is-0.
    • If the two operands are all strings, concatenate the second string to the first one.
    • If only one operand is a string, the other operand is converted to a string, and the result is a string of two strings concatenated into it.

18. The subtraction operator also has some special behaviors:

    • One of the operands is Nan, and the result is Nan.
    • Infinity minus Infinity, the result is NaN.
    • -infinity minus-infinity, the result is NaN.
    • Infinity minus-infinity, the result is Infinity.
    • -infinity minus Infinity, the result is-infinity.
    • +0 minus +0, and the result is +0.
    • -0 minus-0, the result is-0.
    • +0 minus-0, the result is +0.
    • An operator is not a number, then the result is NaN.

19, the relational operator is less than, greater than, less than or greater than or equal to the execution of a comparison operation of two numbers, the comparison is the same as the arithmetic comparison operation.

20, equals and non-equals are used to process the original value, and the full and non-equal equals are used to process the object. The equals sign is represented by a double equal sign (= =), which returns True when and only if two operands are equal. A non-equal sign is represented by an exclamation mark plus an equals sign (! =), which returns True when and only if the two operands are not equal. To determine whether the two operands are equal, both operators perform type conversions.

21 . Rules for type conversions:

    • If one of the operands is a Boolean value, convert it to a numeric value before checking for equality. False converts to 0,true to 1.
    • If one operand is a string and the other is a number, try converting the string to a number before checking for equality.
    • If one operand is an object and the other is a string, try to convert the object to a string before checking for equality.
    • If one operand is an object and the other is a number, try converting the object to a number before checking for equality.

22. Operators also adhere to the following rules:

    • The value null and undefined are equal.
    • When checking for equality, null and undefined cannot be converted to other values.
    • If an operand is NaN, the equal sign returns false, and the non-equal sign returns TRUE.
    • If the two operands are objects, then their reference values are compared. If two operands point to the same object, then the equals sign returns TRUE, otherwise two operands are not equal.

Important: Even though two numbers are Nan, the equals sign still returns false because Nan is not equal to Nan, according to the rule.

Special cases, and their results:

An expression value
Null = = undefined True
"Nan" = = Nan False
5 = = NaN False
Nan = = Nan False
Nan! = Nan True
false = = 0 True
true = = 1 True
true = = 2 False
undefined = = 0 False
Null = = 0 False
"5" = = 5 True

23, equals and non-equal operators are all equals and non-equals. the equals sign is represented by three equals (= = =) and returns true only if the type conversion operand is not required to be equal.

24 . The non-full equals sign is represented by an exclamation point plus two equal signs (!==), which returns true only if no type conversion operand is required.

25 . The simple assignment operator is implemented by an equal sign (=), but assigns the value to the right of the equal sign to the variable to the left of the equals sign.

26, arithmetic operations, and several other operations have compound assignment operators:

    • Multiplication/Assignment (*=)
    • Division/Assignment (/=)
    • Modulo/Assignment (%=)
    • Addition/Assignment (+ =)
    • Subtraction/Assignment (-=)
    • Shift Left/Assignment (<<=)
    • Signed Right Shift/Assignment (>>=)
    • Unsigned Right Shift/assignment (>>>=)

27 . Use the comma operator to perform multiple operations in a single statement.

28. The break statement can immediately exit the loop and prevent repeated execution of any code.

While the continue statement simply exits the current loop, it also allows the next loop to continue, depending on the control expression.

29.

30.

31.

32.

33.

34.

35.

36.

37.

38.

39.

40.

41.

42.

43.

44.

45.

46.

47.

48.

49.

50.

51.

52.

53.

54.

55.

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.