What does an exclamation mark before a function do?
Example:
return !loadDynamicBlock(); Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about CollectivesStack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
Explore Stack InternalWhat does an exclamation mark before a function do?
Example:
return !loadDynamicBlock(); A ! negates an expression.
In your example, if loadDynamicBlock() returned true, the function calling it would return false, and vice-versa: !true == false
It can also be used to create actual booleans from JavaScript's ideas of truthy and falsy.
var a = 5; !!(a - 5) === false; !!(a + 5) === true; The ! in JavaScript inverts a Boolean expression.