Skip to content

Instantly share code, notes, and snippets.

@ismyrnow
Created March 23, 2012 18:22
Show Gist options
  • Save ismyrnow/2173458 to your computer and use it in GitHub Desktop.
Save ismyrnow/2173458 to your computer and use it in GitHub Desktop.
Creating a local unobtrusive JS object
$(function() {
...
var exampleObject = (function() {
var privateVariable = null;
function privateMethod() { ... }
this.publicMethodOne = function() { ... }
this.publicMethodTwo = function() { ... }
return this
})();
exampleObject.publicMethodOne();
...
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment