Monday, May 21, 2012

JavaScript SUX or "Gimme more shit, please!"

Shit #1

Just try this:

console.log(0.1 + 0.2 == 0.3);

Output: false (!)
Why?
Because JavaScript sux and muzdie:

console.log(0.1 + 0.2);

Output: 0.30000000000000004 (!)

Shit #2

console.log(Number.MIN_VALUE < Number.MAX_VALUE);

Output: false (!)
Why?
Because JavaScript sux and muzdie:

console.log(Number.MIN_VALUE);
console.log(Number.MAX_VALUE);

Output: 5e-324
1.7976931348623157e+308

Shit #3 (secure scope)

Object.prototype.foo = 10; 
console.log(foo); // 10

Shit #4 (happy debugging)

var a = {};
console.log(a.b === undefined); // true because property b is not set
undefined = 42;
console.log(a.b === undefined); // false

Shit #5 (are you duck?)

"string" instanceof String; // false. 
    // 'course it isn't not a string, it may look like a string
    // but actually it's masquerading as a banana.

When is a string, not a string? When it’s a duck!!!

Gimme more shit, please!

console.log(NaN === NaN); // false
console.log(Math.min() < Math.max()); // false

Etc. etc. etc...
Do you like it? Look here for more shit.

No comments:

Post a Comment