As you know in Javascript, it's very common to use the following expression as an IIFE (Immediately Invoked Function Expression) :
(function(){
//code ...
})();
I'm wondering if we can say that the following expression is an IIFE (when no return value needed):
new function(){
//code ...
}
Or
new function(global){
//code..
}(this);
Even though it's an object . Thanks .
Answer :
[ Thanks to @le_m , @vol7ron and @Bergi , here is the short answer ] Can we say that he following expression is an IIFE (Immediately Invoked Function Expression) ?
new function(){
//code ...
}
Or
new function(global){
//code..
}(this);
The answer is NO. And what's that ? It's just an unnamed object with an anonymous constructor, so we're not talking about functions here (plain and simple).