Skip to content

函数中隐含的变量声明 #10

@yongheng2016

Description

@yongheng2016
function foo(a){
    //此处隐含一个变量声明:var a;
}

函数名称解析顺序:

在JavaScript中,一个作用域(scope)中的名称(name)有以下四种:

  1. 语言自身定义(Language-defined): 所有的作用域默认都会包含this和arguments。

  2. 函数形参(Formal parameters): 函数有名字的形参会进入到函数体的作用域中。

  3. 函数声明(Function decalrations): 通过function foo() {}的形式。

  4. 变量声明(Variable declarations): 通过var foo;的形式。

参考:yongheng2016/blog#34

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions