In JavaScript, like, say, in Python, functions are also objects. It gives developer the opportunity to write pure (or not so, since there are no native monads support ;) ) functional code. Most people among us do easily forget about this fact, but it is still true and, what’s truly great, it was true from the start.
These slides are supposed to re-introduce to you the mighty power of functions in JS. No map / filter, since they’re trivial, but it’s more about deferring, queueing and composing functions with few-lined chunks of code, plus some general tricks with them, and also what profit you may take out of all of this stuff. No techniques that will only come in new versions or, instead, just were introduced: totally plain old [good] JavaScript.
However, a bit of basics at the start are also there, of course.
OK, Here we go:
Links
Links to the examples:
-
Deferred functions:
- codepen.io/shamansir/pen/HskmE (parser example)
- codepen.io/shamansir/pen/kBzJe
- Partial applications:
- Queues of functions:
- Composed functions:
Lyfe.js: bitbucket.org/balpha/lyfe
Article on lyfe.js: Introducing Lyfe: yield in JavaScript