Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
69
rated 0 times [  75] [ 6]  / answers: 1 / hits: 36710  / 13 Years ago, fri, november 4, 2011, 12:00:00

What does an exclamation mark before a function do?



Example:



return !loadDynamicBlock();

More From » javascript

 Answers
0

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;

[#89299] Wednesday, November 2, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
andrewb

Total Points: 259
Total Questions: 124
Total Answers: 90

Location: Ivory Coast
Member since Sun, Mar 7, 2021
3 Years ago
;