Instantly share code, notes, and snippets.

@drnugent /equality.js Secret
Last active Jul 4, 2016

Embed
What would you like to do?
@getify MIN_VALUE exmple
[] == ![]; //true
function foo() {
try {
return 2;
}
finally {
return 3;
}
}
foo(); // 3 <— wtf? where’s the 2?
Number.MAX_VALUE > 0; //true
Number.MIN_VALUE < 0; //false
Number({}); // NaN
Number([]); // 0
o1 = { hello: “world” };
o2 = Object.create(null);
o2.hello = “world”;
o1 + “”; // “[object Object]”
o2 + “”; // TypeError!
s = Symbol(“that’s cool”);
s; // Symbol(that’s cool)
String(s); // "Symbol(that’s cool)”
s + “”; // TypeError!
{
typeof a; // undefined
typeof b; // TDZ error!
//
let b;
}
42.toFixed(2); // Syntax Error
42. toFixed(2); // Syntax Error
42 .toFixed(2); // “42.00”
42 . toFixed(2); // “42.00”
42.0.toFixed(2); // “42.00”
42..toFixed(2); // “42.00”
Number(“0.”); // 0
Number(“.0”); // 0
Number(“.”); // NaN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment