Notes on JavaScript Syntax

by nex on 2005-04-11 03:49 in

Short code snippets for reference purposes. To be expanded later.

Constructor:
function Foo(value) {
this.setValue(value);
}


Constructing an object:
var bar = new Foo(value);

Method definition:
Foo.prototype[methodName] = function;

Inheritance (not quite):
Subclass.prototype = new Superclass();

Check this out:
prototype.constructor
call/apply
arguments
OMFG(functions)(may)(return)(functions)


comment! |