How does the counter increment in this example?

var studentNew = (function(){ var counter = 0; var student = function Student(name, hometown){ this.name = name; this.hometown = hometown; var that = this; function initialize(){ counter++; that.id = counter; app.student.all.push(that) }; initialize(); } return student }())

Tags: closures   

Hand raised by: MichelleMik

Group Page