Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (1.5k points)
recategorized by
I don't know Javacript a lot. I am still a begineer. Asking this just out of self curiosity why do we use self executing function in Javascript ?

1 Answer

0 votes
by (1.4k points)

Self-invoking expressions are automatically invoked (started) without being called. 

A self-invoking expression is invoked immediately after it has been created. This is basically used to avoid naming a conflict, as well as to achieve encapsulation. Outside of this function, the variables or declared objects are not available. To avoid problems of minimization (filename.min) always use self executed functions      

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...