JavaScript has both strict and
type-converting equality comparison.
For strict equality the objects being
compared must have the same type and:
- Two strings are strictly equal when they have the same sequence of
characters, same length, and same
characters in corresponding positions.
- Two numbers are strictly equal when they are numerically equal (have
the same number value). NaN is not
equal to anything, including NaN.
Positive and negative zeros are equal
to one another.
- Two Boolean operands are strictly equal if both are true or
both are false.
- Two objects are strictly equal if they refer to the same Object.
- Null and Undefined types are == (but not ===).
-
-
0==false // true
0===false // false, because they are of a different type
1=="1" // true, auto type coersion
1==="1" // false, because they are of a different type
-
>>> new String("aa")===new String("aa")
false
>>> new String("aa")==new String("aa")
false
-
>>> "aa"=="aa"
true
>>> "aa"==="aa"
true
-
>>>
NaN===NaN //false
-
>>> var user1 = {name : "nerd", org: "dev"};
var user2 = {name : "nerd", org: "dev"};
console.log(user1==user2)
false
For furthur information, please check
-
http://stackoverflow.com/questions/1068834/object-comparison-in-javascript
分享到:
相关推荐
在压缩包"develop in IE and Firefox"中,可能包含的是针对这两种浏览器开发的示例代码、测试用例或解决兼容性问题的策略,可以帮助开发者更好地理解并处理IE和Firefox之间的差异。通过深入研究这些文件,开发者可以...
–The difference between primitive and reference values –What makes JavaScript functions so unique –The various ways to create objects –How to define your own constructors –How to work with and ...
Unboxed Values**: Explains the difference between primitive values and their boxed counterparts and the implications for equality checks and other operations. 7. **Silent Failures**: Lists scenarios ...
console.log('Days between:', difference); ``` 四、时间日期特效 1. 动态时钟:通过定时器(setTimeout或setInterval)更新页面上显示的当前时间,实现动态实时显示。 ```javascript function displayTime() { ...
justify-content: space-between; font-family: Arial, sans-serif; } .countdown-value { font-size: 2em; margin-right: 10px; } .countdown-label { font-size: 1.5em; } ``` 在压缩包的`countDown-main`...
Duration difference = Duration.between(now, futureTime); System.out.println(difference); ``` 3. **JavaScript**: JavaScript中的`Date`对象可以用来获取当前时间: ```javascript let now = new Date...
You will progress from a rudimentary knowledge of JavaScript and server-side development to being able to create, maintain, deploy and test your own Node.js application.You will understand the ...
* Calculates difference between two arrays. * Returns array of { item: T, state: int }. * Where state means: 0 - not modified, 1 - created, -1 - deleted. * @param { Array } newList * @param { ...
but generate feature rich, cutting edge HTML5 web applications ready for the mobile market. The fundamental difference between Smart and other rapid application development (RAD) systems is that ...
This fundamental difference necessitates a new approach to modeling and generating AJAX applications, which traditional web modeling tools do not adequately address. #### AJAX and Its Impact on Web ...
Understand the difference between the Yii 1.x.x versions using useful examples from real web applications Book Description Yii is a free, open source web application development framework written in ...
Intersection and set difference (A-B) on text files 97 Finding and deleting duplicate files 100 Making directories for a long path 103 File permissions, ownership, and sticky bit 104 Making files ...
Parse the difference between functional and object-oriented programming Understand Clojure performance and capabilities Develop reactive web pages using ClojureScript Adopt an REPL-driven development ...
Learn the difference between Bootstrap's version 3 and 4 of the framework Extend your knowledge on Bootstrap's external plugins, their incorporation and usage In Detail Bootstrap is a free, open ...
Period difference = Period.between(date1, date2); System.out.println(difference.getDays()); // 输出:31 ``` 4. **SQL** 在SQL中,不同数据库系统有不同的方式来计算日期差。以MySQL为例,可以使用`...
The selected text compare allows you to select portions of text between 2 files and execute a compare on ONLY the se Using the SSH/telnet console A tutorial for UltraEdit/UEStudio's SSH/telent ...
long daysDiff = java.time.temporal.ChronoUnit.DAYS.between(startOfYear, date); int weekNumber = (int) (daysDiff / 7) + 1; return weekNumber; } ``` JavaScript中的实现则可以这样: ```javascript ...
What's the difference between SUIPack and SUISkin? SUISkin is the easiest way of making an application skinned. SUISkin provides only one component, you don't need to learn anything about using it. ...