我调用该命令:
arguments.callee
我得到了错误:
(node:1956) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them
(node:1956) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
我有点困惑于如何使用arguments.callee?
我想要做什么?我在试着操纵堆栈跟踪。我想删除最新的函数调用(如果可能的话?)。
我读过https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments/callee,但它并没有让我变得更聪明。
发布于 2017-01-16 13:27:11
“修改”调用堆栈的唯一方法是调用函数并从函数返回。
您看到的错误是由在严格模式下运行的代码引起的。这意味着在这个函数的作用域中有"use strict"
。目前还不清楚你是否真的需要使用它来做任何你想做的事情。
如果您试图将当前调用堆栈作为一个字符串进行一些修改,那么您可以对该字符串进行这些修改,而不是在调用堆栈上:
var stack = Error().stack; // ... modify stack
https://stackoverflow.com/questions/41675986
复制相似问题