javascript - Why are anonymous, self-executing function used instead of just writing the commands -
i have searched similar questions on site dont answer particular query.
hey, wondering why use:
(function(){a+b;})();
instead of:
a+b;
thing see used in tutorial i'm following:
link
edit:
"real code better context":
(function() {var requestanimationframe = window.requestanimationframe || window.mozrequestanimationframe || window.webkitrequestanimationframe || window.msrequestanimationframe; window.requestanimationframe = requestanimationframe; })();
edit:
didn't know called iife, thank links.
just encapsulation.for not visible in outer scope.
Comments
Post a Comment