avoiding javascript pitfalls through tree hugging
DESCRIPTION
Slides of the talk given at MeetJS Summit (http://summit.meetjs.pl). The TreeHugger playground can be found here: http://ajaxorg.github.com/treehugger/test.htmlTRANSCRIPT
![Page 1: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/1.jpg)
Avoiding JavaScript PitfallsThrough Tree Hugging
Zef Hemel (@zef)
![Page 2: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/2.jpg)
![Page 3: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/3.jpg)
JavaScript Developer
![Page 5: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/5.jpg)
we’re building#1 JavaScript IDE
![Page 6: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/6.jpg)
![Page 7: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/7.jpg)
~400,000
![Page 8: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/8.jpg)
![Page 9: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/9.jpg)
![Page 10: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/10.jpg)
![Page 11: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/11.jpg)
![Page 12: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/12.jpg)
Iterating using undeclared variable
![Page 13: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/13.jpg)
![Page 14: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/14.jpg)
Warning: you are in an anonymous inner function with its own “this” pointer -- ya sure this is what you mean?
![Page 15: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/15.jpg)
![Page 16: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/16.jpg)
Did you mean “length”?
![Page 17: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/17.jpg)
How?
![Page 18: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/18.jpg)
Unleash the awesome power of...
![Page 19: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/19.jpg)
tatic
![Page 20: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/20.jpg)
taticX
![Page 21: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/21.jpg)
program analysis
![Page 22: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/22.jpg)
Whatcan you do with it?
![Page 23: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/23.jpg)
![Page 24: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/24.jpg)
code outlines
code navigation
...
code completion (intellisense)
![Page 25: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/25.jpg)
Parse
Analyze
![Page 26: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/26.jpg)
ParserCode AST
![Page 27: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/27.jpg)
Abstract Syntax Tree
a * 10 Parser
Op
Var Num“*”
“a” “10”
![Page 28: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/28.jpg)
Zeon
UglifyJS
Narcissus
Esprimalanguage.js
![Page 29: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/29.jpg)
performance (speed/memory)
AST datastructure
traversal tools
![Page 30: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/30.jpg)
performance (speed/memory)
AST datastructure
traversal tools
JavaSc
ript s
pecific
![Page 31: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/31.jpg)
treehugger.js
![Page 32: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/32.jpg)
“The JQuery of AST analysis.”
![Page 33: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/33.jpg)
Standard AST Datastructure
![Page 34: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/34.jpg)
Standard Traversals
Pattern Matching
+
![Page 35: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/35.jpg)
a * 10
Op
Var Num“*”
“a” “10”
![Page 36: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/36.jpg)
Op("*", Var("a"), Num("10"))
Op
Var Num“*”
“a” “10”
![Page 37: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/37.jpg)
Op("*", Var("a"), Num("10"))
ATerm
Op
Var Num“*”
“a” “10”
![Page 38: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/38.jpg)
Constructors
Lists
Strings
Var(_)
[_, _]
"hello"
Placeholders x
![Page 39: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/39.jpg)
![Page 40: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/40.jpg)
http://github.com/ajaxorg/treehugger
![Page 41: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/41.jpg)
![Page 42: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/42.jpg)
![Page 43: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/43.jpg)
![Page 44: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/44.jpg)
![Page 45: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/45.jpg)
![Page 46: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/46.jpg)
![Page 47: Avoiding JavaScript Pitfalls Through Tree Hugging](https://reader034.vdocuments.mx/reader034/viewer/2022051412/548292d85806b5f2048b469c/html5/thumbnails/47.jpg)
http://c9.io @zef @cloud9ide
http://github.com/ajaxorg/treehugger