Skip to content

Instantly share code, notes, and snippets.

@shamoons
Created August 28, 2014 18:58
Show Gist options
  • 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