手写loadsh函数的第一天
<script>
const arr = ["0", "1", 2, 3, "", undefined];
function compact(array) {
const newArr = [];
for (const item of array) {
if (item) {
newArr.push(item);
}
}
return newArr;
}
console.log(compact(arr));
</script>