小伙看你根骨奇佳,潛力無限,來學PHP伐。
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... }