remove if data in array falsy in javascript

falsy javscript

const value = ''
const example = [5,!!value&&value]

expectation result is [5]
reality result is [5,false]

is there any other way to check falsy in javascript ? I want to set the value is the value is valid

>Solution :

you can use spread operator like this
for example

const value = "test"
[5, ...value]

Leave a Reply