If passing params or an object full of properties into function, it’s useful to check for undefined params and give default values to those that are undefined.
Without using a library function like jQuery extent, what would be the shortest about of code to do this kind of assigning defaults?
Here is the shortest I can think of:
var test;
var output = (typeof test != "undefined") ? test : "Default";
Before someone suggests:
var test;
var output = test || "Default";
That will not work with false, 0 or “”
Try this:
I.g: