gpt4 book ai didi

javascript - 如何在javascript中输出调用对象?

转载 作者:行者123 更新时间:2023-11-30 10:51:15 26 4
gpt4 key购买 nike

当我在阅读一本 javascript 书时,我阅读了以下句子。

“调用对象使用名为 arguments 的属性初始化,该属性引用函数的 Arguments 对象”

我是否允许使用 console.log 或 alert() 方法在 javascript 中输出调用对象的结构(或值?)?

当人们说“调用对象”时,它是一个概念还是一个对象?

最佳答案

“调用对象”在 ECMAScript 规范中称为“激活对象”,不能直接访问。这允许 ECMAScript/JavaScript 引擎以最佳方式实现它,因为它们只需要确保它始终正确运行,即使实际上不存在具有参数属性、变量属性等的对象。

这是规范中的描述(添加了强调):

10.1.6 Activation Object

When control enters an execution context for function code, an object called the activation object is created and associated with the execution context. The activation object is initialised with a property with name arguments and attributes { DontDelete }. The initial value of this property is the arguments object described below.

The activation object is then used as the variable object for the purposes of variable instantiation.

The activation object is purely a specification mechanism. It is impossible for an ECMAScript program to access the activation object. It can access members of the activation object, but not the activation object itself. When the call operation is applied to a Reference value whose base object is an activation object, null is used as the this value of the call.

关于javascript - 如何在javascript中输出调用对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5177271/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com