|
|
|
|
|
by sarciszewski
4188 days ago
|
|
Some WTF moments in Javascript, courtesy of Gary Bernhardt: var foo = ["10", "10", "10"];
foo.map(parseInt);
// Returns [ 10, NaN, 2 ]
[] + [] // ""
[] + {} // {}
{} + [] // 0
{} + {} // NaN
var a = {};
a[[]] = 2;
alert(a[""]); // alerts 2
alert(Array(16).join("wat" - 1) + " Batman!");
Press F12 and use the Console to verify these if you're skeptical. |
|