Skip to content

Instantly share code, notes, and snippets.

@iegorov
Created August 14, 2013 03:00
Show Gist options
  • Save iegorov/6227664 to your computer and use it in GitHub Desktop.
Save iegorov/6227664 to your computer and use it in GitHub Desktop.
using that example
var add = function (a, b) {
return a + b;
};
var myObj = {value: 0,
increment: function (inc) {
this.value += typeof inc === 'number' ? inc : 1;
}
};
myObj.double = function () {
var that = this;
var helper = function () {
that.value = add(that.value, that.value);
};
helper();
};
$(function () {
myObj.increment(3);
myObj.double();
console.log(myObj.value);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment