Skip to content
View even-stevens.es6
const evenStevens = (n) => {
if (n === 0) {
return true;
}
else if (n == 1) {
return false;
}
else {
n = n - 2;
return evenStevens(n);
View naggum-on-xml.md

Many an idea or concept not only looks, but is good in its infancy, yet turns destructive later in life. Scaling and maturation are not the obvious processes they appear to be because they take so much time that the accumulated effort is easy to overlook.

To be successful, they must also be very carefully guided by people who can envision the end result, but that makes it appear to many as if it merely "happens." Take a good idea out of its infancy, let it age without guidance so it does not mature, and it generally goes bad.

Erik Naggum on XML

View fogus.rb
# See https://twitter.com/fogus/status/623312803345117184
def meth a, b, c
[yield(a), yield(b), yield(c)]
end
meth(1, 2, 3) { |x| x * x }
# => [1, 4, 9]
arr = [1962, 6, 14, lambda { |x| x.to_s }]
View private_function.js
let Person = (() = > {
let firstNameProperty = Symbol('firstName'),
lastNameProperty = Symbol('lastName'),
renameMethod = Symbol('rename');
return class Person {
constructor (first, last) {
this[renameMethod](first, last);
}
fullName () {
View javascript-allonge-kindle.md

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.

Send to Kindle

If you wish to read JavaScript Allongé on your Kindle, please:

  1. Download it to your PC or Mac.
  2. Use Send to Kindle for PC or Send to Kindle for Mac to send it to the Kindle.
View ring.es6
const SecretDecoderRing = {
encode: function (plaintext) {
return plaintext
.split('')
.map( char => char.charCodeAt() )
.map( code => code + 1 )
.map( code => String.fromCharCode(code) )
.join('');
},
decode: function (cyphertext) {
View invoke.md

Because combinators like this:

var __slice = Array.prototype.slice;

function invoke (fn) {
  var args = __slice.call(arguments, 1);

  return function (instance) {
    return fn.apply(instance, args)
View infinity.md

(from Hilbert's Grand JavaScript School)


day six

Bertie goes home, exhausted, and dreams that having graduated everyone at the end of Day Five, things are busier than ever. In his dreams he imagines an infinite number of galactic superclusters, each containing an infinite number of galaxies, each containing an infinite number of stars, each containing an infinite number of worlds, each containing an infinite number of oceans, each containing an infinite number of aircraft carriers, each containing an infinite number of buses, each containing an infinite number of students.

He awakens and reasons that what he is dealing with are powers of infinity. A simple infinity is infinity to the first power. Two infinities (buses and students) is infinity to the second power. Three infinities (aircraft carriers, buses, and students) is infinity to the third power. And so forth up to galactic superclusters, infinity to the eighth power.

View if-as-expression.coffee
something = if condition
value-if-truthy
else
value-if-falsy
View left-variadic.md

In JavaScript, you can make a right-variadic function by gathering parameters. For example:

const abccc = (a, b, ...c) => {
  console.log(a);
  console.log(b);
  console.log(c);
};

abccc(1, 2, 3, 4, 5)
Something went wrong with that request. Please try again.