-1

when I console this combination of logical NOT and empty array ![]+!![]+!![] it returns 2.

console.log(![]+!![]+!![])
  • 1
    See this [javascript-adding-booleans](https://stackoverflow.com/questions/20555321/javascript-adding-booleans) – flyingfox Oct 16 '22 at 11:08
  • `[]` is an empty array, which is a truthy value. `!` negates a value. So we have `false + true + true`. The `+` operator converts its operands, to numbers if possible or to strings if not. `false` converts to `0`, `true` converts to `1`. Thus: 2. – T.J. Crowder Oct 16 '22 at 11:13
  • Thanks T.J. Crowder I got this now – Kamlesh Soni Oct 16 '22 at 18:41

1 Answers1

0

console.log(![]+!![]+!![])

⬇️

console.log(false+true+true)

⬇️

console.log(0+1+1)

⬇️

console.log(2)

console.log(![] + !![] + !![])
Not A Bot
  • 2,474
  • 2
  • 16
  • 33
rrr63
  • 219
  • 9