javascript - How to determine the length of empty array elements in JS
淡淡烟草味
淡淡烟草味 2017-05-19 10:12:26
0
2
542
Object.prototype.toString.call(val) == '[object Array]' ? val.some(e => e != undefined && e != null && e != '') : false;

val is the array after the splice(0, 1) operation. I want val.some to return in the situation shown below. false

淡淡烟草味
淡淡烟草味

reply all(2)
漂亮男人

Array.prototype.some will skip elements with value undefined

If you need to consider undefined, you need to write a for loop to traverse it.

我想大声告诉你

If indeed some, the callback method will not be executed.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template