今天不小心又掉进坑了,来来吧,看看是什么坑吧。
错误提示:
Warning: referenceerror: dePRecated caller usage (firefox) Warning: ReferenceError: deprecated arguments usage (Firefox) typeError: 'callee' and 'caller' cannot be accessed in strict mode. (Safari)
错误类型
仅在严格模式下出现的 ReferenceError 警告。javascript 的执行将不会停止。
发生了什么?
实例
废弃的
function.caller or arguments.callee.caller
Function.caller 和 arguments.callee.caller 都是已废弃的。
"use strict";
function myFunc() {
if (myFunc.caller == null) {
return "The function was called from the top!";
} else {
return "this function's caller was " + myFunc.caller;
}
}
myFunc();
// Warning: ReferenceError: deprecated caller usage
// "The function was called from the top!"
Function.arguments
Function.arguments 已被废弃。
"use strict";
function f(n) {
g(n - 1);
}
function g(n) {
console.log("before: " + g.arguments[0]);
if (n > 0) {
f(n);
}
console.log("after: " + g.arguments[0]);
}
f(2);
console.log("returned: " + g.arguments);
// Warning: ReferenceError: deprecated arguments usage
了解完,是不是懵逼了,其实是自己技术没更新迭代啊。




网友评论文明上网理性发言 已有0人参与
发表评论: