I've tried it, it returned true.
The function returns undefined
, and !undefined
is true.
!function(){}();
^ ^ ^
C A B
- A.
function(){}
is an empty anonymous function
- B.
()
executes the function (A), returning undefined
- C.
!
negates undefined
, which becomes true
I think they used that trick for a code golf or an obfuscated code. It is a bad practice to practially use that
Try javascript:alert(!function(){}())
in your browser address bar