Skip to content

Instantly share code, notes, and snippets.

@goodbedford
Created March 31, 2016 21:19
Show Gist options
  • Save goodbedford/dd934559b539ff6f1e8f971baeaf1fcb to your computer and use it in GitHub Desktop.
Save goodbedford/dd934559b539ff6f1e8f971baeaf1fcb to your computer and use it in GitHub Desktop.
js-comparison-operator.js
// 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