Home > Q&A > body text
为情所困2017-06-27 09:21:24
Because the object may be an undefined or null value, and the undefined or null value does not have a length attribute
undefined
null
undefined or null value
You can write it like this
if (listVal && listVal.length == 0) { // do something... }