当想要在循环中判断某个值 为空或者怎么样时,不要使用forEach,使用
1. for...of / for...in loops 2. Array.prototype.every() 3. Array.prototype.some() 4. Array.prototype.find() 5. Array.prototype.findIndex() Array methods: every(), some(), find(), and findIndex() test the array elements with a predicate returning a truthy value to determine if further iteration is required.
以上方法适用
filter 不会遍历空数组