Skip to content

Instantly share code, notes, and snippets.

@ishiduca
Created September 3, 2011 12:50
Show Gist options
  • Save ishiduca/1191144 to your computer and use it in GitHub Desktop.
Save ishiduca/1191144 to your computer and use it in GitHub Desktop.
=== と ==
function test (a) {
console.log(a === false);
}
function test_near (a) {
console.log(a == false);
}
var arry = [ false, true, null, undefined, '', 0, '0' ];
arry.forEach(function (flg) {
test(flg);
});
arry.forEach(function (flg) {
test_near(flg);
});
// ('' == false) -> true;
// (0 == false) -> true;
// ('0' == false) -> true;
// ('' === false) -> false;
// (0 === false) -> false;
// ('0' === false) -> false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment