Object.prototype.toString.call(val) == '[object Array]' ? val.some(e => e != undefined && e != null && e != '') : false;
val
是通过splice(0, 1)
操作后的数组,我想让下图这个情况时val.some
返回false
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
Array.prototype.some
会跳过值为 undefined 的元素如果需要考虑 undefined 就要写 for 循环来遍历了。
的确some的话,不会执行回调方法。