I want to call a function inline from a variable, but respecting the case, when the variable is null / undefined or not a function.
var f;
if(typeof(f) == 'function') {
f(); // don't get executed
}
f(); // this is of course not working, but it is executing
var fn = function() { console.warn('fn'); }
fn(); // working because fn is a function
Basically I want the if statement, with checking whether the variable is a function or not in one line.
I saw this and thought there has to something for undefined / non functions:
var screenSize = screen.width || 1024;