Is it valid to use && instead of if?
问题 I am using && like this and it works typeof foo === 'function' && foo(); //if foo exist then call it instead of if (typeof foo === 'function') { foo(); } Is it wrong to do or just a matter of style and taste? For me it is natural and I want to use && , but now a linter complained: Expected an assignment or function call and instead saw an expression. Can there be any real issues here or is it just a matter of convention? Here is a code snippet: function foo(x) { console.log("foo say " + x) }