Skip to content

Commit 5ec2f78

Browse files
committed
add remoce falsy value sniped
1 parent f1f3b6a commit 5ec2f78

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: Remove Falsy Values
3+
description: Removes falsy values like null, undefined, and false from an array.
4+
author: mubasshir
5+
tags: javascript,array,falsy,filter
6+
---
7+
8+
```js
9+
const removeFalsy = (arr) => arr.filter(Boolean);
10+
11+
// Usage:
12+
const array = [0, 1, false, 2, "", 3, null];
13+
console.log(removeFalsy(array)); // Output: [1, 2, 3]
14+
```

0 commit comments

Comments
 (0)