Syntax error What is the syntax for leading bang! in JavaScript function?

What is the syntax for leading bang! in JavaScript function?



To execute an anonymous function you need to use the leading bang! or any other symbol −

!function(){
   // do stuff
}();

You can also write it like −

+function(){
   // do stuff
}();

Even the following is an acceptable syntax −

~function(){
   // do stuff
   return 0;
}( );
Updated on: 2020-06-12T09:31:51+05:30

183 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements