AsyncFunction
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2017.
Đối tượng AsyncFunction cung cấp các phương thức cho hàm async. Trong JavaScript, mỗi hàm async thực ra là một đối tượng AsyncFunction.
Lưu ý rằng AsyncFunction không phải là đối tượng toàn cục. Nó có thể được lấy bằng đoạn code sau:
const AsyncFunction = async function () {}.constructor;
AsyncFunction là lớp con của Function.
Constructor
AsyncFunction()-
Tạo đối tượng
AsyncFunctionmới.
Thuộc tính instance
Cũng kế thừa các thuộc tính instance từ lớp cha Function.
Các thuộc tính này được định nghĩa trên AsyncFunction.prototype và được chia sẻ bởi tất cả các instance AsyncFunction.
AsyncFunction.prototype.constructor-
Hàm constructor đã tạo đối tượng instance. Đối với các instance
AsyncFunction, giá trị khởi tạo là constructorAsyncFunction. AsyncFunction.prototype[Symbol.toStringTag]-
Giá trị khởi tạo của thuộc tính
[Symbol.toStringTag]là chuỗi"AsyncFunction". Thuộc tính này được dùng trongObject.prototype.toString().
Note:
Các instance AsyncFunction không có thuộc tính prototype.
Phương thức instance
Kế thừa các phương thức instance từ lớp cha Function.
Đặc tả kỹ thuật
| Specification |
|---|
| ECMAScript® 2027 Language Specification> # sec-async-function-objects> |