Notes on JavaScript Allongé by raganwald, Part 1


Here are some unstructured notes on what I’ve learned reading raganwald’s excellent and free JavaScript Allongé, which you can read here: This is the “Six” edition, which reflects major updates to JavaScript currently being rolled out, usually called ES6.

Reg Braithwaite is an excellent writer. I’ve been putting off learning ES6 for a while, so I’m pretty stoked to find he’s written a fairly comprehensive piece on it. Anyways, notes:

  • I never knew about the “arguments” keyword in JS. That’s not even a new ES6 thing. Well.
  • All values are expressions. i.e., “a café Cubano is an expression (you can use it to place an order) and a value (you get it back from the barista).” You give the computer expressions, and it returns values. Okay. Cool.
  • “Value” and “primitive type” are fairly interchangeable in JS. They are numbers, strings, or bools.
  • In some languages like Lisp, expressions are values. Not so in JS.
  • “A literal is a notation for representing a fixed value in source code.”
  • 042 === 34; // starting literals with 0 turns it into an octal.
  • Node’s –harmony mode is pretty useful while reading this book.
  • If you want to return undefined, return “void 0”.
  • Statements, like return, exist only within blocks.
  • JS evaluates expressions to values before passing them as arguments.
  • “A free variable is one that is not bound within the function.”, e.g. those produced by closures.
  • Invocation is much more expensive than expression evaluation.
  • “[const statements] shadow values bound within environments created by blocks”
  • ES6 allows for incredible self-indulgence:
    ((diameter_fn) =>
    ((PI) =>
    ((PI) =>
    (diameter) => diameter * PI
  • WordPress didn’t format that last thing very nicely and neither will I.
  • An anonymous function can be bound to a named reference. Functions can also be named. These are two independent things. A function’s name is a property of the function and has no effect on the environment, but the name of its reference is the environment’s concern, not the function’s.
  • A named function is available to be invoked within that function, like for recursion if ya wanna.
  • Function declaration refers to the following syntax:
    function someName () {
    // ...
  • Function expressions look like this (among other ways):
    const a = function () {
    // ...
  • It’s relevant to note that the above is an anonymous function. Naming it would look like this:
    const a = function someName () {
    // ...
  • Only declared functions are hoisted to the top of their scope.
  • Function declaration is not supposed to occur inside a block. It might work, but it’s a bad and un-guaranteed thing. Only use it at the top scope.
  • If a function is declared inside an expression, that function is an expression. Not a declaration.  Because.
  • The last few code examples weren’t ES6-specific, just JS things I had never bothered to really learn. You can get pretty far with only a shallow knowledge of JavaScript.
  • Here’s a simple combinator function:
    const compose = (a, b) =>
    (c) => a(b(c))

    “Combinators are useful when you want to emphasize what you’re doing”.
  • Decorator functions accept a function and return a modification of that function.

Okay that’s as far as I got today. Adios!


Leave a comment

Filed under Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s