This is a flat view of a mindmap.
You may prefer to switch to
a tree view,
a mindmap view, or download the original file
and edit it with Freeplane
or FreeMind.
This is a tree view of a mindmap.
You may prefer to switch to
a flat view,
a mindmap view, or download the original file
and edit it with Freeplane
or FreeMind.
This is a mindmap (sort-of), displayed with a java applet.
You may prefer to switch to
its flat view,
its tree view, or download the original file
and edit it with Freeplane
or FreeMind.

Test-Driven
Javascript
Development

headless workflow... running in the browser
function afunc(p1, p2){
afunc.attr++;
return true;
}
afunc.attr = 0; var afunc = function aname(p1, p2){
afunc.attr++;
return true;
}
afunc.attr = 0; var afunc = new Function(p1, p2, ..., pn, body);
var anotherfunc = Function("p1,p2", pn, body);Array.prototype.slice.call(arguments, 1)
var result = fun.apply(thisArg, [argsArray]);
var result = fun.call(thisArg[, arg1[, arg2[, ...]]]);

func(); // this will be the global object obj.func(); // this will be obj
func.call({prop: "value"});
func.apply(obj); function fibonacci(x) {
if (x < 2) {return 1;}
return fibonacci(x - 1) + fibonacci(x - 2);
}
3. undefined if[[Prototype]] is null
if (typeof Array. prototype. sum == " undefined" ) {
Array. prototype. sum = function ( ) {
unexpectedfor ... in
results
the new object has the [[Prototype]]
property defined by the prototype property
of the constructor
a constructor property is
created and assigned
Circle.prototype = {...}(function (p) {
p.method1 = function ( ) {...};
p.method2 = function ( ) {...};
} (Circle.prototype));Circle.prototype.method1 = function() {...};
Circle.prototype.method2 = function() {...};function Circle(radius) {
if (!(this instanceof Circle)) {
return new Circle(radius) ;
}
this. radius = radius;
}if (!Object.create) {
(function () {
function F() {}
Object.create = function (object) {
F.prototype = object;
return new F();
};
}());
}function Sphere(radius) {
this.radius = radius;
}
Sphere.prototype = (function () {
function F() {};
F.prototype = Circle.prototype;
return new F();
}());
// Don't forget the constructor - else it will resolve as
// Circle through the prototype chain
Sphere.prototype.constructor = Sphere;if (!Function.prototype.inherit) {
(function () {
function F() {}
Function.prototype.inherit = function (superFn) {
F.prototype = superFn.prototype;
this.prototype = new F();
this.prototype.constructor = this;
this.prototype._super = superFn.prototype;
};
}());
}function Circle(radius) {
this.radius = radius;
}
(function (circleProto) {
// Functions declared in this scope are private, and only
// available to other functions declared in the same scope
function ensureValidRadius(radius) {...}
function getRadius() {return this.radius;}
function setRadius(radius) {}
// Assigning the functions to properties of the prototype
// makes them public methods
circleProto.getRadius = getRadius;
circleProto.setRadius = setRadius;
}(Circle.prototype));function Circle(radius) {
this.radius = radius;
function ensureValidRadius(radius) {}
function getRadius() {return this.radius;}
function setRadius(radius) {}
// Expose public methods
this.getRadius = getRadius;
this.setRadius = setRadius;
}function Circle(radius) {
function getSetRadius() {
if (arguments.length > 0) {radius = arguments[0];}
return radius;
}
function diameter() {return radius * 2;}
function circumference() {}
// Expose privileged methods
return {
radius: getSetRadius,
diameter: diameter,
area: area,
circumference: circumference
};
}tddjs.extend = (function () {
function extend(target, source) {
target = target || {};
if (!source) {return target;}
tddjs.each(source, function (prop, val) {
target[prop] = val;
});
}
return extend;
}());Object.defineProperty(obj, id,
{value: xx,
get: function() {...},
set: function(x) {...},
writeable: true,
configurable: false});"use strict";
function sum(numbers) {
"use strict";
var sum = 0;
for (i = 0; i < numbers.length; i++) {
sum += numbers[i];
}
return sum;
}
// ES3: Property i is created on global object
// ES5 strict mode: ReferenceErrocaller and callee properties throw a TypeError
this not coerced into an object
delete doesn't fail silently
with is gone
tddjs.isHostMethod = (function () {
function isHostMethod(object, property) {
var type = typeof object[property];
return type == "function" ||
(type == "object" && !!object[property]) ||
type == "unknown";
}
return isHostMethod;
}());tddjs.isEventSupported = (function () {
var TAGNAMES = {
select: "input",
change: "input",
submit: "form",
reset: "form",
error: "img",
load: "img",
abort: "img"
};
function isEventSupported(eventName) {
var tagName = TAGNAMES[eventName];
var el = document.createElement(tagName || "div");
eventName = "on" + eventName;
var isSupported = (eventName in el);
if (!isSupported) {
el.setAttribute(eventName, "return;");
isSupported = typeof el[eventName] == "function";
}
el = null;
return isSupported;
}
return isEventSupported;
}());
xUnit Test Patterns:
Refactoring Test Code