Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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