Last active
August 29, 2015 14:05
-
-
Save EhevuTov/dd371f6162e431c4bfb6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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