Skip to content

Instantly share code, notes, and snippets.

@EhevuTov
Last active August 29, 2015 14:05
Show Gist options
  • Select an option

  • Save EhevuTov/dd371f6162e431c4bfb6 to your computer and use it in GitHub Desktop.

Select an option

Save EhevuTov/dd371f6162e431c4bfb6 to your computer and use it in GitHub Desktop.
// my class
function Parser() {
// I'd like this to remain a private variable
this.data = {
number:0
};
}
// my class function
Parser.prototype.test = function() {
// I'd like this function to accept a number and increment the number;
var inc = function(data) {
data.num++;
};
// this will be 0
console.log(this.data);
// increment the variable
inc(this.data.number);
// I want this to now show the variable as incremented
console.log(this.data);
};
// instance the class
var parse = new Parser();
// run the class function
parse.test();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment