Skip to content

Instantly share code, notes, and snippets.

@jonkemp
Created August 28, 2011 04:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonkemp/1176229 to your computer and use it in GitHub Desktop.
Save jonkemp/1176229 to your computer and use it in GitHub Desktop.
Simple object oriented script for creating a global namespace and then extending via the prototype.
/*
Ex:
ftn.extend({
foo: function() {
console.log( "foo" );
}
});
ftn.foo();
*/
(function() {
var ftn, Prototype;
/** @constructor **/
function Futon() {
return this;
};
Prototype = Futon.prototype;
Prototype.extend = function( newMethods ) {
var prop;
for ( prop in newMethods ) {
if ( newMethods.hasOwnProperty( prop ) ) {
Prototype[prop] = newMethods[prop];
}
}
return Prototype;
};
ftn = window.ftn = new Futon;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment