|
|
|
|
|
by pbhjpbhj
4053 days ago
|
|
I'm a non-programmer [I've only made programs in BASIC, Fortran, C, C++, assembler, smalltalk, javascript, BASH, probably a couple I forgot (does Maple count), and most recently python (lol - I mean to say my level is 'interested amateur')] but I found this [1] quite a nice reintroduction to javascript the other day. It gives a good review of javascript syntax, goes over the intricacies of the loose typing system and variable scope, covers some detail on avoiding memory leaks and some browser specifics (which I think are probably out of date; I didn't review it thoroughly I was playing Minecraft at the time) and gets up to anonymous functions and closures. Aside: Incidentally if someone would like to explain closures to me I'd appreciate it - I don't really understand them. Code Academy's [2] javascript looks very basic but Code School [3] seems to have better beginner stuff - I've done their git/jQuery courses before and they were quite well done. HTH. [1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_re... [2] Avoid for javascript, very basic: http://www.codecademy.com/courses/getting-started-v2/0/1?cur... [3] https://www.codeschool.com/courses/javascript-best-practices |
|
If you truly want to understand how it works then you'd probably want to write a compiler that supports closures; you'd then need to cover issues like how to allocate functions on the heap, the difference between locally allocated (typically on the stack) data bound to functions and globally allocated (typically on the heap) data bound to functions.
The second part to closures is understanding the theory, or the why and the high level functionality that it enables, such as callbacks with state or interactions with the likes of recursive (y-combinator like) functions.
EDIT: minor grammar fix