Jim Cheung

Chapter 1, Introduction

(no notes)

Chapter 2, Essentials

(no notes)

Chapter 3, Literals and Constructors

(no notes)

Chapter 4, Functions

currying

function schonfinkelize(fn) {
  var slice = Array.prototype.slide,
      stored_args = slice.call(arguments, 1);
  return function () {
    var new_args = slide.call(arguments),
        args = stored_args.concat(new_args);
    return fn.apply(null, args);
  };
}
// usage
function add(x, y) {
    return x + y;
}
var newadd = schonfinkelize(add, 5);
newadd(4); // 9

// or:
schonfinkelize(add, 6)(7); // 13
// more parameters:
function add(a, b, c, d, e) {
    return a + b + c + d + e;
}
schonfinkelize(add, 1, 2, 3)(5, 5); // 16

Chapter 5, Object Creation Patterns

namespace

var MYAPP = MYAPP || {};

MYAPP.namespace = function (ns_string) {
  var parts = ns_string.split('.'),
      parent = MYAPP,
      i;

  if (parts[0] === 'MYAPP') {
    parts = parts.slice(1);
  }

  for (i = 0; i < parts.length; i += 1) {
    if (typeof parent[parts[i]] === 'undefined') {
      parent[parts[i]] = {};
    }
    parent = parent[parts[i]];
  }
  return parts;
};
// usage:

MYAPP.namespace('once.upon.a.time.there.was.this.long.nested.property');

Chapter 6, Code Reuse Patterns

(no notes)

Chapter 7, Design Patterns

(no notes)

Chapter 8, DOM and Browser Patterns

(no notes)