by simon_renoult · 12y ago · 0 comments
function doFoo(bar) {
bar = (bar !== undefined) ? bar : "default_value";
}
Over : function doFoo(bar) {
bar = bar || "default_value";
}
Coercion avoidance ?Keep in mind that you will have to go for the first option (or other better options) if you expect 'falsy' values to be passed as arguments.