js从数组中过滤出虚假值

0undefinednullfalse""''可以很容易地通过以下方法省略

const array = [3, 0, 6, 7, '', false];
array.filter(Boolean);
// 输出
(3) [3, 6, 7]

猜你喜欢

转载自blog.csdn.net/z591102/article/details/123898566