Skip to content

Instantly share code, notes, and snippets.

@verekia
Created January 20, 2016 19:42
Show Gist options
  • Save verekia/92c0ae3f09a7cd2de5db to your computer and use it in GitHub Desktop.
Save verekia/92c0ae3f09a7cd2de5db to your computer and use it in GitHub Desktop.
var MyMath = (function(){
// With this pattern you can use the usual function notation:
function add(a, b){
return a + b;
}
return {
add:add // But don't forget to declare it in the returned object!
};
})();
console.log(MyMath.add(1, 2));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment