0
const arr = [10]

console.log(arr == 10) // true
console.log(arr < 10) // false
console.log(arr > 2) // true

arr is array but comparing with the number is possible

How is this operation possible?

nr2p
  • 1
  • 4
    Because the array is coerced to a number. – VLAZ Aug 17 '21 at 10:13
  • [Wat?!](https://www.destroyallsoftware.com/talks/wat) – deceze Aug 17 '21 at 10:19
  • Also relevant: [Javascript equality triple equals but what about greater than and less than?](https://stackoverflow.com/q/12143520) | [How do I compare arrays in JavaScript?](https://stackoverflow.com/q/16566772) | [Empty arrays seem to equal true and false at the same time](https://stackoverflow.com/q/5491605) – VLAZ Aug 17 '21 at 10:22

0 Answers0