Skip to content

Instantly share code, notes, and snippets.

@cocodrino
Created June 16, 2012 17:24
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 cocodrino/2942012 to your computer and use it in GitHub Desktop.
Save cocodrino/2942012 to your computer and use it in GitHub Desktop.
blog codes -clausuras part 4
var myObject = (function ( ) {
var value = 0;
return {
increment: function (inc) {
value += typeof inc === 'number' ? inc : 1;
},
getValue: function ( ) {
return value;
}
};
}( ));
myObject.increment();
myObject.increment();
console.log(myObject.getValue()); //2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment