比较运算符
比较运算符在逻辑语句中使用,以测定变量或值是否相等。
给定 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
分享到:
相关推荐
javascript相等运算符与等同运算符
JavaScript常用运算符和操作符总结(教辅)JavaScript常用运算符和操作符总结(教辅)JavaScript常用运算符和操作符总结(教辅)JavaScript常用运算符和操作符总结(教辅)JavaScript常用运算符和操作符总结(教辅)...
使用JavaScript运算符;算术运算符;使用JavaScript运算符;使用JavaScript运算符;使用JavaScript运算符;使用JavaScript运算符;比较运算符;使用JavaScript运算符;逻辑运算符;使用JavaScript运算符;使用JavaScript运算符...
自己做的 课件 js运算符 可以参考 适用于15分钟的课件
==运算符是相等运算符,它采用比较宽松的同一特质定义比较两个运算数是否相等。 这样概念有个基本认识。 下面说下具体判定两个值是相等情况吧。 ===运算符两个值比较 1,如果两个值类型不同,它们就不相同 2,如果两...
Javascript常用运算符
JavaScript 假值与===运算符,学习js的朋友可以看下。
JavaScript 运算符
但是,ES2015规范引入了 Object.is(),其行为与严格的相等运算符几乎相同: Object.is(1, 1); // => true Object.is(1, '1'); // => false Object.is(1, true); // => false 主要问题是:什么时候使用 Object.is...
JavaScript运算符与表达式案例.pdf 学习资料 复习资料 教学资源
JS运算符算术运算符比较运算符关系运算符位运算符赋值运算符条件运算符typeof 运算符对象运算符 JavaScript支持一下几种运算符: 算术运算符 比较运算符 关系运算符 赋值运算符 条件运算符 算术运算符 运算符 ...
javascript运算符——位运算符全面介绍.docx
JavaScript运算符 ①算数运算符 ②关系运算符 ③逻辑运算符 ④赋值运算符 ⑤条件运算符 2.JavaScript运算符的优先级
javascript运算符-规律运算符全面解析_.docx
前端JavaScript运算符部分代码,适合基础学习
javascript运算符因为太极语言是一门编译成javascript的语言,因此,太极语言提供了javascript的各种运算符,包括一元运算符,二元运算符。
javaScript 运算符优先级,javaScript 运算符优先级快速查询
18JavaScript运算符和方法介绍包括: 1.使用算术运算符 2.递增变量和递减变量 3.创建比较表达式 4.创建逻辑表达式 5.使用条件运算符 6.识别数字 . . . . . . .
JavaScript的运算符知识图谱,有助于你更好的理解JavaScript运算符