Skip to content

Instantly share code, notes, and snippets.

@workmajj
Last active December 11, 2015 19:48
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 workmajj/4650474 to your computer and use it in GitHub Desktop.
Save workmajj/4650474 to your computer and use it in GitHub Desktop.
Writing JS in object-literal style.
;(function(window, undefined) {
'use strict';
var SomeObj = function(opts) {
if (opts.whatever) this.isWhatever = true;
// do some constructor stuff
this.init(opts.thing);
};
SomeObj.prototype = {
FOO_CONST: '1337',
BAR_CONST: 'baz',
isWhatever: null,
otherInstanceProperty: null,
init: function(thing) {...},
_localFuncFoo: function() {...},
_localFuncBar: function() {...},
_localFuncBaz: function() {...},
};
window.My.App.Namespace.SomeObj = SomeObj;
}(window));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment