Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

重学js —— 控制抽象对象之AsyncFunction对象 #132

Open
lizhongzhen11 opened this issue Jul 18, 2020 · 0 comments
Open

重学js —— 控制抽象对象之AsyncFunction对象 #132

lizhongzhen11 opened this issue Jul 18, 2020 · 0 comments
Labels
js基础 Good for newcomers 重学js 重学js系列 规范+MDN

Comments

@lizhongzhen11
Copy link
Owner

lizhongzhen11 commented Jul 18, 2020

AsyncFunction对象

// 不是全局对象,需要如下代码获取
Object.getPrototypeOf(async function(){}).constructor

构造器

  • %AsyncFunction%
  • 属于 Function 子类
  • ...

AsyncFunction ( p1, p2, … , pn, body )

  1. 定义 C活跃的函数对象
  2. 定义 args 为通过 [[Call]][[Construct]] 方法传递给函数的 参数列表
  3. 返回 CreateDynamicFunction(C, NewTarget, async, args)

构造器上的属性

  • 标准内置 函数对象,继承自函数构造器
  • [[Prototype]] 内置插槽其值为 %Function%
  • "name" 属性,其值为 "AsyncFunction"

AsyncFunction.length

属于 数据属性,值为 1.属性描述符为 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }

AsyncFunction.prototype

初始值为 %AsyncFunction.prototype%。属性描述符为 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }

原型对象上的属性

注意

一般情况下,我们不会直接用 AsyncFunction 去创建异步函数,我们更多的是直接采用 #86 中定义的写法去创建异步函数。

@lizhongzhen11 lizhongzhen11 added js基础 Good for newcomers 重学js 重学js系列 规范+MDN labels Jul 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
js基础 Good for newcomers 重学js 重学js系列 规范+MDN
Projects
None yet
Development

No branches or pull requests

1 participant