OMG JavaScript

2,673 views
2,363 views

Published on

Published in: Technology, Business
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,673
On SlideShare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
17
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

OMG JavaScript

  1. 1. About duck typing in dynamiclanguages:“My god how you can write a real programwhen you just assigning random crap toanother crap and expecting it to work” – John Carmack, founder of id Software, developer ofpopular game titles like Wolfenstein , Doom, Quake and Rage, well-known open source advocate, millionaire.
  2. 2. JavaScript is reallycomplicated language…
  3. 3. var a = 012console.log( a )→ 10 OMG!
  4. 4. console.log( "3" + 1 )→ "31"console.log( "3" – 1 )→2 OMG!!console.log( "222" - -"111" )→ "333" OMG!!!
  5. 5. console.log( 9999999999999999 )→ 10000000000000000 OMG!!!!console.log( 111111111111111111111 )→ 111111111111111110000
  6. 6. console.log( Math.max() )→ -Infinityconsole.log( Math.min() )→ Infinityconsole.log( new Array([], null, undefined, null) == ",,,"; )→ truevar foo = [0];console.log(foo == !foo);console.log(foo == foo);→ true→ true
  7. 7. console.log( 3.toString() )console.log( 3..toString() )→ SyntaxError: identifier starts immediately after numeric literal→ "3"var a = new Number;console.log(a == 0)var a = new String;console.log(a == "")var a = new Object;console.log(a == {})var a = new Array;console.log(a == [])→ true→ true→ false→ false
  8. 8. var a = {};console.log( a == {} );var a = [];console.log( a == [] );→ false→ falseconsole.log( (!+[]+[]+![]) );→ "truefalse"console.log((![]+[])[+[]]+(![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]] )→ "fail"
  9. 9. console.log( {} + {} );→ NaNconsole.log( [] + [] );→ ""console.log( [] + {} );→ "[object Object]"console.log( {} + [] );→0console.log( 1 < 2 < 3 );console.log( 3 < 2 < 1);→ true→ true
  10. 10. JavaScript. Just be smarter!
  11. 11. Links WTF JavaScript: http://www.wtfjs.com/ Destroy All Software Screencasts: http://www.destroyallsoftware.com/ JavaScript Tutorial: http://www.javascript.info/ JavaScript Specification: http://www.ecma- international.org/publications/standards/Ecma- 262.htm

×