== is normal equality
it will check the values of variable and convert them to a common type and returns true if both are equals. So comparing number with string having the same value will return true.
=== is strict equality
three equals not made the implicit conversion so it not only compare values but also the type of variable that's why it is also called strict comparison.
JavaScript
var alert = function (str) {
var st = document.createTextNode(str);
var p = document.createElement('p');
p.appendChild(st);
document.querySelector('body').appendChild(p);
}
alert(23 == "23"); // true number to string
alert(1 == true); // true boolean to number
alert(23 === "23"); // false
alert(1 === true); // false
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.