Undefined variable as function argument javascript

前端 未结 2 1602
北恋
北恋 2021-01-27 22:02

I\'ve looked a fair bit, so pardon me if this has already been answered.

I\'m also curious as to what the actual term is called; Is it \"Ambiguous\" for the type of argu

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-27 22:13

    Basically, so that variables can have default values.

    Why don't you just initialize the variable with a default value?

    Or, just initialise the variable before calling defined.

    var variable; // Note that this will not overwrite the variable if it is already set.
    

    Or, even better.

    var variable = variable || 'default';
    

提交回复
热议问题