Explore Library
Quiz

Closures, this & Prototype Methods

Understanding how closures capture this differently from prototype method invocation.

Consider: function Counter() { this.count = 0; } Counter.prototype.start = function () { setInterval(function () { this.count++; console.log(this.count); }, 1000); }; const c = new Counter(); c.start(); What does this log each second (non-strict mode, browser), and why?