JavaScript Operators


The relational operator is used to compare two values, Returns a boolean value。 Relational operators include operators greater than(>), less than, <(=), less than, < tantamount to(3;

1.Attempts to convert two operators to numbers.

2.If both operators are strings, then a comparison of strings is performed

3.Returns false if either expression is NaN.

4.-0 equals +0.

5.Negative infinity is smaller than any number including itself

6.Positive infinity is greater than any number including itself

The equal operator, used to determine whether two variables are equal. Equality comparisons of strings, values, and booleans are simple; comparisons of objects are complex. Equal and unequal, first converted to the same type and then compared. All-equal and not-all-equal, without conversion, are compared directly.

1.Equivalent and unequal

The equal operator consists of two equal signs (==) and returns true if the two operands are equal. Inequality consists of an exclamation mark and an equal sign (! =), and returns true if the two operands are not equal. Both of these operators will convert the type first and then compare it.

If two expressions are of different types, try to convert them to strings, numbers or boolean values; NaN is not equal to any value including itself.

Negative zero is equal to positive zero; nul is equal to null and undefined.

The following are considered equivalent: identical strings, numerically equivalent numbers, the same object, identical boolean values, or values that can be forcibly converted to one of the above when the types are different.

2.Equality and inequality

The full equality operator consists of 3 equal signs (====) and the imperfect equality operator (! ==). All-equal and not-all-equal are pretty much the same as above, except that no type conversions are performed.

as if var result= null===undefined;//false var num= "55"==55;//true var num1= "55"===55;//false

The conditional operator is a ternary operator, similar to the conditional operator in it java. The format is as follows

test ? expression1 : expression2

varnum=5>3?5:3;console.log(num);// exports5

The assignment operator consists of an equal sign (=) and serves to assign the value on the right to the variable on the left. Also contains some complex assignment operators such as *=, +=, -=, /=,%=.

var num=10;

num%=2 tantamount to num=num%2;num*=2;num+=3;num/=3;num-=2;

The comma operator, which allows multiple operations to be performed in a single statement using the comma operator, e.g. var num=12, num2=13.


Recommended>>
1、Blockchain Short pressure eases for now market to rebound volatile
2、MJSP Unlimited Ordering System
3、Community promotion of smart express boxes makes it no longer difficult for couriers to get through the door
4、AI Report 2017 7 Industry Applications 100 Startups
5、Carsharing pickup and return drone program to be piloted in Two Rivers New Area

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号