I am trying to understand how to use logical operators with my code and be as efficient as possible.
Let's say I have this variable:
var key = localStorage.getItem('keyName');
And this is my conditional:
if (key !== null && key !== '' && key !== ' ') { // localStorage key exists and is not empty or a single space
// Do something with key
}
Is there a way to write it more efficiently? I tried this, but it's not working:
if (key !== null && '' && ' ') {
// Do something with key
}