Search⌘ K
AI Features

Discussion: Truth or Fiction?

Learn to use the double negation !! operator to convert values to boolean in JavaScript. Understand truthy and falsy values and apply this knowledge to filter arrays efficiently with arrow functions, improving your coding clarity and precision.

Verifying the output

Now, it’s time to execute the code and observe the output.

Javascript (babel-node-es2024)
const arr = [1, 8, NaN, 15, ""];
const newArr = arr.filter(function(item) {
return !!item
});
console.log(newArr);

NOT NOT

...