办法
严格模式arguments.callee.caller不给使用了
歪路子截取new Error()的报错字符串stack
const getCall = ()=>{
let callArr = new Error().stack.split("\n");
callArr.splice(0, 3);
const pattern = /at (\w+)/;
callArr = callArr.map(it=>(it.match(pattern)[1]))
return callArr;
}
参考
https://zhuanlan.zhihu.com/p/520565433?utm_id=0
标签:const,函数,pattern,js,callArr,new,调用者 From: https://www.cnblogs.com/dingshaohua/p/17462785.html