JSFiddle - React, Tailwind, and code Playground

JavaScript

function wrapper(arg){
    return function(){
        console.log(arg);
    };
}


var ar = [];

console.log("pushing functions");

ar.push(wrapper(1));
ar.push(wrapper(2));
ar.push(wrapper('three'));

console.log("done pushing functions");

while (ar.length){
    var fn = ar.shift();
    console.log("calling ", fn);
    fn();
}