13

What does an exclamation mark before a function do?

Example:

return !loadDynamicBlock(); 
0

2 Answers 2

30

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; 
Sign up to request clarification or add additional context in comments.

Comments

8

The ! in JavaScript inverts a Boolean expression.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.