1

I am trying to check if an attribute is in a json file or not but the attribute has a value of 0 so the following

status.bytes_read

returns false though it should return true as it exists what is the best way of handling this case?

Learner
  • 1,686
  • 4
  • 19
  • 38
  • 2
    I'd use `status.bytes_read != null`, which will cover both `null` and `undefined`. Or you could use `if ("bytes_read" in status)`. – Pointy Jul 12 '23 at 15:48

0 Answers0