Initializing default value with not-undefined-check

Sorry I'm looking a bit at Yanfly's scripts to learn how to do stuff.

I see this code:

Yanfly.Param = Yanfly.Param || {};
Basically he wants to create a new object if it is not already initialized. However, if for some strange reason the Yanfly.Param would evaluate as false. Wouldn't it be slightly better to:

if (typeof Yanfly.Param === 'undefined')  {  Yanfly.Param = {}; }

// Yanfly.Param = (typeof Yanfly.Param === 'undefined') ? 'default' : Yanfly.Param;
Of course this is an insanely strange scenario. But wouldn't this be very slightly better?

Stumbled upon this while looking how to set default values for function parameters.
In this case it doesn't matter, since Yanfly.Param can only ever be undefined or an object. JavaScript considers the following values as "falsy":

Code:
false, null, undefined, 0, NaN, '' (empty string)
The "=== undefined" check is useful, when you want, for example, a number variable to default to a non-0 zero value. Take this for example:
Code:
var myNumber = params['My Number'] || 40;
It would be impossible to actually specify 0 for that parameter, since 0 is considered falsy and the expression would default to 40.
var myNumber = params['My Number'] || 40;It would be impossible to actually specify 0 for that parameter, since 0 is considered falsy and the expression would default to 40.
Nitpicking, but the way this is presented, 0 actually would work fine due to the parameters being received as string, and how "0" (string) differs form 0 (int) in JavaScript.

console.log(0 || 14); //Should output 14console.log("0" || 14); //Should output 0;(But "0" == false still evaluates as true - a weird gotcha from the language)

--------

var myNumber = Number(params['My Number']) || 40This one would never be 0.

-----

var myNumber = Number(params['My Number'] || 40)This one can be 0 again, since the OR operation happens before the conversion to number.
Either way, i don't like setting default values in this way. They are already stated in the @default tag belonging to that parameter, so i would define a constant at 2 places, which is never good. I usually default to 0 in this case, just so i have a valid number and make my code work with it.

Original thread: https://forums.rpgmakerweb.com/threads/initializing-default-value-with-not-undefined-check.49036/