
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What Does the Exclamation Mark Do Before a Function in JavaScript
The ! symbol shows that it is an immediately-invoked function expression.
The exclamation mark won’t invoke the function alone; you can put () at the end −
!function foo() {}()
() has higher precedence than ! and instantly calls the function.
You can also mention it like the following −
(function(){})();
The ! allows the expression to return true. This is because by default all immediately-invoked function expression return undefined, so, we’re left with ! undefined, which is true.
Advertisements