Your IIFE is returning another function, which is not being called. If you want to print 1,2,3, do this:
var arr = [];
for (var i = 0; i < 3; i++) {
arr.push(
(function(j) {
return function() {
console.log(j);
}
}(i)())
)
}
You're getting 3 because the method push adds the element to the end of the array and returns the new length for the array. Some reference: developer.mozilla.org/en-US/docs/Web/JavaScript/R…
If your IIFE doesn't return another function, then you don't need the double parenthesis at the end.