Skip to content

Instantly share code, notes, and snippets.

@shamoons
Created August 28, 2014 18:58
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 shamoons/4c8847719b7affa96426 to your computer and use it in GitHub Desktop.
Save shamoons/4c8847719b7affa96426 to your computer and use it in GitHub Desktop.
function Employee(name) {
this.counter = 1;
this.name = name;
this.getId = function() { return counter++; }
}
var emp = new Employee("abc");
emp.getId();
emp.getId();
@Syedgit
Copy link

Syedgit commented Aug 28, 2014

Uncaught ReferenceError: counter is not defined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment