0

So I was just reading the code of Loading Overlay plugin for jquery. At the beginning, I can see the following line of code.

! function(e) {
"function" == typeof define && define.amd ? define(["jquery"], e) : "object" == typeof module && module.exports ? e(require("jquery")) : e(jQuery)

}

What does it mean to write "!" in front of "function" and that too at the beginning of the file. As per my knowledge, "!" is a not operator.

-> So is this a JavaScript's inbuilt syntax or the Author is trying to create some logic?

Please explain this in simple layman terms as I have not found anything regarding this on Google.

himanshu
  • 45
  • 8
  • 1
    This is a type of [IIFE](https://en.wikipedia.org/wiki/Immediately_invoked_function_expression). There're many ways to create it, it's just one convention of them. – Hao Wu Mar 06 '20 at 10:17
  • See the ECMAScript specification: [Logical NOT Operator](https://www.ecma-international.org/ecma-262/5.1/#sec-11.4.9) – Quentin Mar 06 '20 at 10:19
  • 1
    *""!" is a not operator."* That's right. It is used to enforce the evaluation of the function definition as a function *expression* instead of a function *declaration*. – Felix Kling Mar 06 '20 at 10:21

0 Answers0