this.method Is not function with setInterval
问题 I have this simple code: var Modules = (function() { 'use strict'; return { TIMER: function (){ var timer = null; return { time: 100, init: function() { this.counter(); this.timer = window.setInterval(this.counter, 1000); }, counter: function() { this.time -= 1; if (this.time <= 0) { window.clearInterval(this.timer); alert('Time expired'); } console.log(this.time); this.viewer(); }, viewer: function() { document.getElementById('timer').innerHTML = this.time; } } } }; }()); Modules.TIMER()