gpt4 book ai didi

javascript - 我可以以某种方式以编程方式访问当前作用域的激活对象吗?

转载 作者:行者123 更新时间:2023-11-28 18:34:04 26 4
gpt4 key购买 nike

我正在尝试了解如何理解闭包内部发生的情况并使用其中创建的变量和函数。

我的限制是我可以向现有闭包添加任意多行代码,但无法编辑任何现有代码。

这可以做到吗?

<script>

var scopeClone = {};
(function(scopeClone){
//Activation Object {}
scopeClone.a = "a";
var b = "b"
//Activation Object {b:"b"}

//my custom code here
//We want to copy activation object properties to scope obj

})(scope);
//At this stage, we want to get -> scopeClone.b = "b"
</script>

最佳答案

不确定是否可以做到:

http://interglacial.com/javascript_spec/a-10.html

10.1.6 Activation Object

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.



也从这里开始:
https://www.reddit.com/r/javascript/comments/2tdwcv/are_there_any_backdoor_ways_to_access_the/

Note that Activation object is an internal mechanism and is never really accessible by program code.

关于javascript - 我可以以某种方式以编程方式访问当前作用域的激活对象吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37464044/

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