self invoked function javascript
(function(){
//Bunch of code...
})();
self invoked function javascript
(function(){
//Bunch of code...
})();
self invoking function javascript es6
(() => {
console.log('Ok');
})()
why do we use self invoking functions in javascript
(function(){
// your code here
/* self invoking functions are used to avoid any name scope collision
of variables and functions, specially when you have a huge code in your
file and you also need to add a third party library. Because there is
a high chance of repeating names of variables and functions.
Using these functions help solve this problem and names can be used
again and again. Also, this way there is very little clutter in the code
and its easily understandable.
you alos do not need to call this function in order to make your code work,
it runs automatically.
*/
})();
anonymous function javascript
//Anonymous function; It's not assigned to an indentifier
Array.forEach((arguments) => {
//This is an anonymous function
})
function forEach(arguments) {
//This is NOT an anonymous function
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us