- 浏览: 1092317 次
文章分类
- 全部博客 (379)
- S2SH (16)
- stuts2 (0)
- java语言 (81)
- JSP (17)
- <html>元素 (11)
- javaweb (4)
- web容器 (3)
- ext (23)
- javaScript (48)
- ant (1)
- liferay (1)
- sql (9)
- css (42)
- 浏览器设置 (3)
- office_world (1)
- eclipse (4)
- 其它 (28)
- 操作系统 (5)
- android (6)
- Struts2 (11)
- RegEx (3)
- mysql (5)
- BigDATA (1)
- Node.js (1)
- Algorithm (10)
- Apache Spark (1)
- 数据库 (5)
- linux (2)
- git (1)
- Adobe (3)
- java语言,WebSocket (1)
- Maven (3)
- SHELL (1)
- XML (2)
- 数学 (2)
- Python (2)
- Java_mysql (1)
- ReactJS (6)
- 养生 (4)
- Docker (1)
- Protocols (3)
- java8 (2)
- 书籍 (1)
- Gradle (2)
- AngularJS (5)
- SpringMVC (2)
- SOAP (1)
- BootstrapCSS (1)
- HTTP协议 (1)
- OAuth2 (1)
最新评论
-
Lixh1986:
Java并发编程:自己动手写一把可重入锁https://blo ...
Java之多线程之Lock与Condition -
Lixh1986:
http://win.51apps.com.cn/https: ...
temp -
ztwsl:
不错,支持很好
HttpServletRequest和ServletRequest的区别 -
guodongkai:
谢谢您能将知识精华汇编总结,让初学者们从原理中学会和提高。
javaScript之function定义 -
kangwen23:
谢谢了,顶顶
struts2中的ValueStack学习
一、Comparison Overview
1. Speed Compare(运行速度比较):
=== will never be slower than ==.
They both do type checking, so === doesn't do anything extra compared to ==,
but the type check may allow === to exit sooner when types are not the same.
2. How do they work(它们是如何工作的?):
=== :
compare both type and value
== :
only compare value.
if there are different types, then convert the value.
Example:
Exception:
二、How they work?
1、How "===" compare values?
"Type Checking" is the first step !
11.9.6 The Strict Equality Comparison Algorithm
The comparison x === y, where x and y are values, produces true or false. Such a comparison is performed as follows:
1. If Type(x) is different from Type(y), return false.
2. If Type(x) is Undefined, return true.
3. If Type(x) is Null, return true.
4. If Type(x) is not Number, go to step 11.
5. If x is NaN, return false.
6. If y is NaN, return false.
7. If x is the same number value as y, return true.
8. If x is +0 and y is −0, return true.
9. If x is −0 and y is +0, return true.
10. Return false.
11. If Type(x) is String, then return true if x and y are exactly the same sequence of characters (same length and same characters in corresponding positions); otherwise, return false.
12. If Type(x) is Boolean, return true if x and y are both true or both false; otherwise, return false.
13. Return true if x and y refer to the same object or if they refer to objects joined to each other (see 13.1.2). Otherwise, return false.
http://stackoverflow.com/a/1813267/2893073
2. When use "==", how is the converstion?(不同类型的值如何转换?)
三. Summary(总结)
Always use 3 equals unless you have a good reason to use 2.
Reference:
http://stackoverflow.com/questions/359494/does-it-matter-which-equals-operator-vs-i-use-in-javascript-comparisons
http://dorey.github.io/JavaScript-Equality-Table/
-
1. Speed Compare(运行速度比较):
=== will never be slower than ==.
They both do type checking, so === doesn't do anything extra compared to ==,
but the type check may allow === to exit sooner when types are not the same.
2. How do they work(它们是如何工作的?):
=== :
compare both type and value
== :
only compare value.
if there are different types, then convert the value.
Example:
if(true == 1); //true, because 'true' is converted to 1 and then compared if(true === 1); // false if("4" == 4); //true, because "4" is converted to 4 and then compared if("4" === 4); // false if(true == 2); //false, because 'true' is converted to 1
Exception:
var a = new String("abc"); var b = "abc"; if(a==b); // true if(a===b); // false, because typeof a is object, type of b is String
二、How they work?
1、How "===" compare values?
"Type Checking" is the first step !
引用
11.9.6 The Strict Equality Comparison Algorithm
The comparison x === y, where x and y are values, produces true or false. Such a comparison is performed as follows:
1. If Type(x) is different from Type(y), return false.
2. If Type(x) is Undefined, return true.
3. If Type(x) is Null, return true.
4. If Type(x) is not Number, go to step 11.
5. If x is NaN, return false.
6. If y is NaN, return false.
7. If x is the same number value as y, return true.
8. If x is +0 and y is −0, return true.
9. If x is −0 and y is +0, return true.
10. Return false.
11. If Type(x) is String, then return true if x and y are exactly the same sequence of characters (same length and same characters in corresponding positions); otherwise, return false.
12. If Type(x) is Boolean, return true if x and y are both true or both false; otherwise, return false.
13. Return true if x and y refer to the same object or if they refer to objects joined to each other (see 13.1.2). Otherwise, return false.
http://stackoverflow.com/a/1813267/2893073
2. When use "==", how is the converstion?(不同类型的值如何转换?)
三. Summary(总结)
Always use 3 equals unless you have a good reason to use 2.
Reference:
http://stackoverflow.com/questions/359494/does-it-matter-which-equals-operator-vs-i-use-in-javascript-comparisons
http://dorey.github.io/JavaScript-Equality-Table/
-
发表评论
-
Javascript 测试框架之 隐式声明 之 describe
2019-06-25 15:26 2451为什么使用 javascript 测试框架时,没有显式导入 d ... -
JavaScript之ECMAScript6新特性之_03_箭头函数(Arrow Function)
2018-01-25 13:46 1053一、简介 箭头函数(Arrow Function)是 ES6 ... -
JavaScript之ECMAScript6新特性之_02_线程异步阻塞: Promise, Async / await
2018-01-12 16:51 2261刚出来不久的 ES8 包含了 async 函数,它的出现,终于 ... -
JavaScript之ECMAScript6新特性之_01_开篇
2017-08-17 02:54 564点此查看全部: http://es6-features.org ... -
jQuery Versions - browser support
2017-08-12 04:19 1554jQuery 3.2.1 Support Deskto ... -
基于HTML5实现的中国象棋游戏
2017-06-24 02:24 1626HTML5实现中国象棋游戏 http://www.w2bc.c ... -
JavaScript之跨域请求解决方案
2017-06-07 11:03 3898浏览器处于安全原因,在使用 Ajax 进行请求访问时,不允许跨 ... -
JavaScript之 25 道面试题
2017-04-17 17:05 91425 Essential JavaScript Intervi ... -
JavaScript小应用之分页算法
2017-03-16 12:56 629效果图: function getPagina ... -
jQuery之empty() VS. remove()
2017-03-16 10:32 689jQuery empty() vs remove() Wh ... -
jQuery之 prop() VS. attr()
2017-03-14 16:43 624attr() 用于自定义属性,id ; prop() 用于 ... -
jQuery之mouseover,mouseover,mouseout,mouseleave
2017-03-14 10:20 621Jquery mouseenter() vs mouseove ... -
javascript之JS操作iframe
2017-02-28 14:56 2135JS操作iframe 1. 获得iframe的w ... -
javascript之面向对象编程之原型继承
2017-01-02 15:34 1045前文讲到“属性继承” ... -
HTML5之Cookie,localStorage 与 sessionStorage
2016-12-22 18:35 810详说 Cookie, LocalStorage 与 ... -
jquery之live(), delegate(), on() 方法
2016-11-26 23:48 883通过下面的一个实例理解 jQuery 的 live(), de ... -
javascript之小应用:网页在线聊天
2016-11-08 11:48 4213概览 这款使用 PHP 和 javascript 搭建的 ... -
javascript之编程序题目
2016-11-06 17:30 10031. 判断两个字符串是否:字母相同切长度相同(空格不算)。 ... -
javascript之面向对象编程之属性继承
2016-10-23 21:09 835函数继承可以分为两种:1、继承其 this 属性 2、继承其 ... -
javascript 之 undefined
2016-08-12 11:01 659一、用法 undefined 关键字有两种用法: 1. 如 ...
相关推荐
第8章javascript介绍=创新教育基础与实践=大连理工大学.ppt
很实用的方法,刚学的分享下!<script type="text/javascript">
第8章javascript介绍=创新教育基础与实践=大连理工大学.pptx
南京华信智原javascript中“==”和“===”区别完美版资料.ppt
1)不同类型间比较,==之比较“转化成同一类型后的值”看“值”是否相等,===如果类型不同,其结果就是不等 2)同类型比较,直接进行“值”比较,两者结果一样 2、对于Array,Object等高级类型,==和===是没有区别的...
最好的脚本编辑器javascript asp html,自动提示语法.自动纠错。好东西一般人我不告诉他
用javascript地址栏显示源码: javascript:s=document.documentElement.outerHTML;document.write('<body></body>');document.body.innerText=s;
主要介绍了JavaScript的==运算,通过一张简单的图,让你彻底地搞明白,需要的朋友可以参考下
Difference Between ( == vs === ) In Javascript 目前正在开发中!! :-灵感来自于:-https:
<script language=”JavaScript”> JavaScript code goes here 2 隐藏脚本代码 <script language=”JavaScript”> <!-document.write(“Hello”); // --> 在不支持 JavaScript 的浏览器中将不执行相关代码 3。...
本篇文章简略说明了Javascript中的= =(等于)与= = =(全等于)区别,有需要的朋友可以参考一下
2.5 在C++中“声明”“Javascript类”, 供Javascript实例化 2.6 封装完整的C++类到Javascript中,供Javascript实例化 三、Google v8的开源应用 3.1 Node.js 3.2 v8cgi 四、参考资料 五、本文源码
ASCII键盘 <!...<!... charset=gb2312"> content="java, javascript, js, scripts, free, dHTML, HTML,...type=text/javascript> <A href="http://www.wanxu.com/" target=_blank>技术支持:万旭网</A> </BODY></HTML>
<script type="text/javascript" src="KindEditor.js"> <script type="text/javascript"> var editor = new KindEditor("editor"); editor.hiddenName = "new"; editor.width = "700px"; editor.height = ...
<script type="text/javascript" src="image/ie_png.js"> <script type="text/javascript"> ie_png.fix('.png, .menu ul li a span'); // 第二个参数为含有png的标签id(css) ie_png.fix('.png, .logo span');...
15、分析javascript代码段,输出结果是: B var a="125.8765"; c=parseInt(a); d=parseFloat(a); document.write(c+" "+d) A) 125.8765 126 B) 125 125.8765 C) 125.8765 125 D) 126 125.8765
最牛Javascript 日历控件 很棒! 两步骤完全搞定 1.引用 <script language="javascript" type="text/javascript" src="My97DatePicker/WdatePicker.js"> 2.使用 onClick="WdatePicker()
主要介绍了JavaScript中==与+的使用方法,帮助大家更好的理解和学习JavaScript,感兴趣的朋友可以了解下