Thay setTimeout() dùng function reference. Hoạt động vì function có sẵn tại thời điểm tham chiếu.
Tham chiếu sẽ chuyển cho timeout event callback thay vì string reference:
window.setTimeout(startNow, 2000);
Đặt như sau:
setTimeout(startNow, 1000); function startNow () { alert(‘Working correctly!'); }