Created
August 28, 2011 04:07
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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