Undefined variable as function argument javascript

前端 未结 2 1571
北恋
北恋 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条回答
  •  闹比i
    闹比i (楼主)
    2021-01-27 22:11

    A completely undeclared variable can't be passed in JS; you can only pass declared variables or undeclared properties of other variables.

    In other words:

    var a; // you can do _.defined(a)
    var a = undefined; // you can do _.defined(a)
    a.b; // you can do _.defined(a.b), even though we never defined b
    

提交回复
热议问题