I have a list which is returning [null] but I want to replace that with []
I’m using useEffect() but I’m literally not able to find an expression that returns true when compared with null.
I’ve tried:
listToCompare === null // false
listToCompare[0] === null // false
listToCompare === undefined // false
listToCompare === [null] // error even before compiling
This is irritating because [null] returns .length as 1 when I need it to be 0.
Can someone help me find an expression to return true when compared to [null]
Really confused on what a [null] list even is 🙁
>Solution :
You could try
const listToCompare = [null];
const isNull = !listToCompare.filter(Boolean).length
console.log(isNull) // returns true