Skip to content

Instantly share code, notes, and snippets.

@simondell
Created October 18, 2013 09:37
Show Gist options
  • Save simondell/7039095 to your computer and use it in GitHub Desktop.
Save simondell/7039095 to your computer and use it in GitHub Desktop.
An example "class", or a "type", or a "module". The example was created to highlight "private static functions", and their placement in the file. General JS community dialog favours highlighting the effect of variable and function "hoisting" by writing such object definitions at the top of their scope. For larger objects intended as classes or m…
var MyStructure = (function () {
return {
str: 'rush',
go: function () {
doThisFirst();
doThisNext( this );
return this;
}
}
function doThisFirst () {
console.log( 'first' );
}
function doThisNext ( obj ) {
console.log( 'oh wow second ' + obj.str );
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment