JavaScript的===与== 比较运算符

比较运算符
比较运算符在逻辑语句中使用,以测定变量或值是否相等。
给定 x=5,下面的表格解释了比较运算符:
== 等于 x==8 为 false
=== 全等(值和类型) x===5 为 true;x==="5" 为 false
!= 不等于 x!=8 为 true
> 大于 x>8 为 false
< 小于 x<8 为 true
>= 大于或等于 x>=8 为 false
<= 小于或等于 x<=8 为 true

The Comparison operators is use to get a Boolean value indicating the result of the comparison.

Syntax

expression1 comparisonoperator expression2

The Comparison operator syntax has these parts:

Part

Description

expression1

Any expression.

comparisonoperator

Any comparison operator.

expression2

Any expression.

Return boolean

Returns a Boolean value indicating the result of the comparison.

Example

When comparing strings, JavaScript uses the Unicode character value of the string expression.

The following describes how the different groups of operators behave depending on the types and values of expression1 and expression2:

Relational (<, >, <=, >=)

Attempt to convert both expression1 and expression2 into numbers.

If both expressions are strings, do a lexicographical string comparison.

If either expression is NaN, return false.

Negative zero equals Positive zero.

Negative Infinity is less than everything including itself.

Positive Infinity is greater than everything including itself.

Equality (==, !=)

If the types of the two expressions are different, attempt to convert them to string, number, or Boolean.

NaN is not equal to anything including itself.

Negative zero equals positive zero.

null equals both null and undefined.

Values are considered equal if they are identical strings, numerically equivalent numbers, the same object, identical Boolean values, or (if different types) they can be coerced into one of these situations.

Every other comparison is considered unequal.

Identity (===. !==)

These operators behave identically to the equality operators except no type conversion is done, and the types must be the same to be considered equal.

英文解释来自
http://www.c-point.com/javascript_tutorial/jsgrpComparison.htm
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值