Since I’ve been working in and around ReactJS for several months, I’ve come to know (and love) the JavaScript idiom of using logical operators && and || as simple control-flow statements.

Since JavaScript types are loosey-goosey, logical operators mustn’t be too particular about the values they compare.

A statement like true && “troof” will ultimately return troof because it’s not falsey. We can use this to our advantage to make a tiny equivalent of an if conditional statement.

let isIt = "nope",
    itIs = ['it', 'is'];

Array.isArray(isIt) && isIt.push('yep');
Array.isArray(itIs) && itIs.push('indeed');

console.log('Is this an array?', isIt);
console.log('Is this an array?', itIs);