Test if something is not undefined in JavaScript

前端 未结 11 1851
礼貌的吻别
礼貌的吻别 2020-11-30 19:50

I\'m checking if(response[0].title !== undefined), but I get the error:

Uncaught TypeError: Cannot read property \'title\' of undefined.<

11条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-30 20:11

    Check if you're response[0] actually exists, the error seems to suggest it doesn't.

提交回复
热议问题