Created
March 31, 2016 21:19
-
-
Save goodbedford/dd934559b539ff6f1e8f971baeaf1fcb to your computer and use it in GitHub Desktop.
js-comparison-operator.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// strict equality comparison operator is the triple equals ( === ) | |
// this checks for exact equality in value and type | |
var a = 4; | |
var b = 4; | |
var c = "4"; | |
// both a and b are numbers | |
console.log("a === b is:", a === b); | |
// a is a number and c is string should not be true | |
console.log("a === c is:", a === c); | |
// equality comparison is double equals ( == ) | |
// the equality comparison is a type-converting comparison | |
// meaning it follows some rules for how to convert value to other values to be compared | |
// a is a number and c is string should true | |
console.log("a == c is:", a == c); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment