This question has already been answered:
Tell me why this code does not display any errors, and does not display anything in the console.
Trying to do a consistent execution of functions.
I wonder why this particular code does not work?
In the debugger, it is not even included in the runF() function.
function Queue() { Queue.prototype.constructor = function() {}; this._this = this; this.funccollect = []; } Queue.prototype.addFunc = function(callback) { this.funccollect.push(callback); return this; } Queue.prototype.runF = function() { this.funccollect[1].apply(this, arguments); } var queue = new Queue(); queue.addFunc(function() { setTimeout(function() { console.log('Первая функция'); queue.runF(); }, 2000); }) .addFunc(function() { console.log('Вторая функция'); });