Как возможно изучить название функции, в которой я нахожусь?
Ниже кода предупреждает 'Объект'. Но я должен знать, как предупредить "Внешний".
function Outer(){
alert(typeof this);
}
Я думаю, что вы можете это сделать :
var name = arguments.callee.toString();
Для получения более подробной информации об этом взгляните на эту статью .
function callTaker(a,b,c,d,e){
// arguments properties
console.log(arguments);
console.log(arguments.length);
console.log(arguments.callee);
console.log(arguments[1]);
// Function properties
console.log(callTaker.length);
console.log(callTaker.caller);
console.log(arguments.callee.caller);
console.log(arguments.callee.caller.caller);
console.log(callTaker.name);
console.log(callTaker.constructor);
}
function callMaker(){
callTaker("foo","bar",this,document);
}
function init(){
callMaker();
}
Это будет работать:
function test() {
var z = arguments.callee.name;
console.log(z);
}