Comparison with the Strict Equality Operator - Difference between "==" and "===" wording
See original GitHub issueChallenge Comparison with the Strict Equality Operator has an issue.
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36
.
Please describe how to reproduce this issue, and include links to screenshots if possible.
My code:
// Setup
function testStrict(val) {
if (val) { // Change this line
return "Equal";
}
return "Not Equal";
}
// Change this value to test
testStrict(10);
The explanation for the difference between “==” and “===” is incorrect. They both test for the data type of the compared elements, but “===” does not allow the elements to be converted to other data types if they are not the same, where as “==” (a.k.a. coercion), does allow the elements to be converted.
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (9 by maintainers)
Top Results From Across the Web
Strict equality (===) - JavaScript - MDN Web Docs
The strict equality (===) operator checks whether its two operands are equal, returning a Boolean result. Unlike the equality operator, the strict equality ......
Read more >Javascript – Equality (==) Operator VS Strict Equality ...
When using strict equality (===) to compare two operands there is no conversion on any of the operands. This is also known as...
Read more >Difference between == and === Equal Operator in JavaScript
3) While comparing variable using strict equality operator in Java, two object are strictly equal to each other if both are of same...
Read more >Difference Between =, ==, and === in JavaScript [Examples]
=== (Triple equals) is a strict equality comparison operator in JavaScript, which returns false for the values which are not of a similar...
Read more >JavaScript Comparison Operators: Loose Equality (==) vs ...
Loose equality and strict equality operators are totally different from each other. It depends on you to choose which type is best suited...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I agree with @dhcodes, however, I think there should be another module added for users to implement with the equality operator (==) and the strict equality operator (===) in the same module to hit home the difference. I think that would be a good place for @dhcodes example. Right now you learn and practice with them separately and it would be good to have a module that you are required to use both to make sure you understand the difference between them.
These links may also be helpful to include for the new said module. They are directly from the Ecmascript Specification website: == Equality Algorithm ( http://www.ecma-international.org/ecma-262/5.1/#sec-11.9.3 ) === Strict Equality Algorithm ( http://www.ecma-international.org/ecma-262/5.1/#sec-11.9.6 )
@dakshshah96 I think your description is sufficient. The only update I think I may make is to say ‘data type’ instead of ‘type’ to match the wording used in the modules.
I think in addition to what @dakshshah96’s suggestion, what really helps with this concept are examples. Something like: