The Golden Crema: Appendices and Afterwords

La Marzocco
La Marzocco

How to run the examples

At the time this book was written, ECMAScript 2015 was not yet widely available. All of the examples in this book were tested using either Google Traceur Compiler, Babel, or both. Traceur and Babel are both transpilers, they work by parsing ECMAScript 2015 code, then emitting valid ECMAScript-5 code that produces the same semantics.

For example, this ECMAScript 2015 code:

const before = (decoration) =>
  (method) =>
    function () {
      decoration.apply(this, arguments);
      return method.apply(this, arguments)
    };

Is translated into this ECMAScript-5 code:

"use strict"

var before = function (decoration) {
  return function (method) {
    return function () {
      decoration.apply(this, arguments);
      return method.apply(this, arguments);
    };
  };
};
The Babel "try it out" page
The Babel “try it out” page

If we make it even more idiomatic, we could write:

const before = (decoration) =>
    (method) =>
      function (...args) {
        decoration.apply(this, args);
        return method.apply(this, args)
      };

And it would be “transpiled” into:

var before = function (decoration) {
  return function (method) {
    return function () {
      for (let _len = arguments.length, args = Array(_len), _key = 0; _key < _le\
n; _key++) {
        args[_key] = arguments[_key];
      }

      decoration.apply(this, args);
      return method.apply(this, args);
    };
  };
};

Both tools offer an online area where you can type ECMAScript code into a web browser and see the ECMAScript-5 equivalent, and you can run the code as well. To see the result of your expressions, you may have to use the console in your web browser.

So instead of just writing:

(() => 2 + 2)()

And having 4 displayed, you’d need to write:

console.log(
  (() => 2 + 2)()
)

And 4 would appear in your browser’s development console.

You can also install the transpilers on your development system and use them with Node on the command line. The care and feeding of node and npm are beyond the scope of this book, but both tools offer clear instructions for those who have already installed node.

Thanks!

Daniel Friedman and Matthias Felleisen

The Little Schemer
The Little Schemer

JavaScript Allongé was inspired by The Little Schemer by Daniel Friedman and Matthias Felleisen. But where The Little Schemer’s primary focus is recursion, JavaScript Allongé’s primary focus is functions as first-class values.

Richard Feynman

QED: The Strange Theory of Light and Matter
QED: The Strange Theory of Light and Matter

Richard Feynman’s QED was another inspiration: A book that explains Quantum Electrodynamics and the “Sum of the Histories” methodology using the simple expedient of explaining how light reflects off a mirror, and showing how most of the things we think are happening–such as light travelling on a straight line, the angle of reflection equalling the angle of refraction, or that a beam of light only interacts with a small portion of the mirror, or that it reflects off a plane–are all wrong. And everything is explained in simple, concise terms that build upon each other logically.

Reading JavaScript Allongé on Kindle

JavaScript Allongé has over 400 pages and many photographs. For this reason, the .mobi version of the book is too big to be sent to your Kindle via email, and that is the feature that LeanPub uses when you purchase the book.

Send to Kindle
Send to Kindle

So, if you wish to read JavaScript Allongé on your Kindle:

  • Download it to your Windows or OS X device (a/k/a “PC” or “Macintosh”).
  • Use Send to Kindle for PC or Send to Kindle for Mac to send it to the Kindle.
  • From time to time while editing, an uncompressed image sneaks into the manuscript. When this happens, the .mobi may exceed the 50MB limit for the Send to Kindle desktop application. If this happens, please attach your Kindle to your computer with a USB cable and synchronize directly.

Thank you!

The original words in this book are (c) 2012-2015, Reginald Braithwaite. All rights reserved.

images

About The Author

When he’s not shipping JavaScript, Ruby, CoffeeScript and Java applications scaling out to millions of users, Reg “Raganwald” Braithwaite has authored libraries for JavaScript, CoffeeScript, and Ruby programming such as Allong.es, Method Combinators, Katy, JQuery Combinators, YouAreDaChef, andand, and others.

He writes about programming on “Raganwald,” as well as general-purpose ruminations on “Braythwayt Dot Com”.

contact

Twitter: @raganwald Email: reg@braythwayt.com

Reg "Raganwald" Braithwaite
Reg “Raganwald” Braithwaite