Posted By

codernator on 12/29/12


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

pibot77


ObjectBoilerPlateModule - some methods to assist creating objects


 / Published in: JavaScript
 

addMethod - By John Resig (MIT Licensed)

Add a method to an object. Creates function overloading scenario based entirely on length of argument list. Won't work to overload functions according to argument "type".

inherit

Create parameter-less inheritance chain for situations in which the parent object takes arguments in its "constructor".

Usage:

function A(a, b) { }
function B() { A.call(this, 1, 2); }
B.prototype = inherit(A.prototype);

Report this snippet  

You need to login to post a comment.