3

I can read and write some JavaScript, but today I came across a .js file starting with

!function() {
 /*
  code here
 */
}.call(window);

Question

what does ! infront of function means?

daydreamer
  • 87,243
  • 191
  • 450
  • 722

2 Answers2

2

It returns "not" (!) of the result of a calling the anonymous function with a "this" of window.

Peter Alfvin
  • 28,599
  • 8
  • 68
  • 106
1

Negating the result of .call(window). Not the function.

djechlin
  • 59,258
  • 35
  • 162
  • 290