Answer the question
In order to leave comments, you need to log in
Is there a difference in declaring an anonymous javascript wrapper function?
When studying the coffee-script language, the question arose: is there a difference in the declaration of an anonymous wrapper function on javacript, in the form of a self-calling function without explicitly specifying the call context:
(function(){
//какой-то код
})();
(function(){
//какой-то код
}).call(this);
Answer the question
In order to leave comments, you need to log in
In the first one, in non-strict mode, this will be the global object. In strict mode - null (or undef, I don't remember).
In the second in the global scope, there will again be a global object. Inside a method, this is the method's this. Apparently, this is done to save the context inside the methods.
2016 is not the best year for learning cofeescript, learn es6 or typescript better.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question