我可以以某种方式以编程方式访问当前作用域的激活对象吗?
Can I access activation object of the current scope programmatically somehow?
我正在尝试了解如何理解闭包内部发生的事情并使用其中创建的变量和函数。
我的限制是我可以向现有闭包添加任意多行代码,但不能编辑任何现有闭包。
这可以做到吗?
<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.
我正在尝试了解如何理解闭包内部发生的事情并使用其中创建的变量和函数。
我的限制是我可以向现有闭包添加任意多行代码,但不能编辑任何现有闭包。
这可以做到吗?
<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.