Use of Plus Sign in Front of Function Name in JavaScript



The +function() {} notation is primarily used to force the parser to treat whatever follows the + as an expression. This is used for functions that are invoked immediately, for example,

+function() { alert("Demo!"); }();

However, + before a function is one of the symbols. You can add other options also like !, -, ~, also. Parentheses can also be used as shown below −

(function() { alert("Demo!"); })();

You can also use it like this −

(function() { alert("Demo!"); }());
Updated on: 2020-06-12T08:26:41+05:30

268 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements