2

As a beginner in Javascript, I have a question which may seem a bit weird. I am using an external lib I found on the web in which I found the code below :

if('useHoles' in c){
   this.config.useHoles = !!c.useHoles;
}

Is there an interest to use the double exclamation mark or is it just some clumsy code ?

Couldn't find any answer yet so I guess I can just remove them but I wanted to be 100% sure.

ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97
EtienneG
  • 300
  • 5
  • 14

1 Answers1

3

With the double ! you force an object to return something that is "boolean-able", even if null or something else, that can be evaluated as bool true or false.

ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97