相关疑难解决方法(0)

你如何在JavaScript中找到调用函数?

function main()
{
   Hello();
}

function Hello()
{
  // How do you find out the caller function is 'main'?
}
Run Code Online (Sandbox Code Playgroud)

有没有办法找出调用堆栈?

javascript callstack

838
推荐指数
23
解决办法
42万
查看次数

如何从该函数中获取函数名?

如何从该函数内部访问函数名?

// parasitic inheritance
var ns.parent.child = function() {
  var parent = new ns.parent();
  parent.newFunc = function() {

  }
  return parent;
}

var ns.parent = function() {
  // at this point, i want to know who the child is that called the parent
  // ie
}

var obj = new ns.parent.child();
Run Code Online (Sandbox Code Playgroud)

javascript function

242
推荐指数
12
解决办法
21万
查看次数

我可以在JavaScript中获取当前运行的函数的名称吗?

是否有可能做到这一点:

myfile.js:
function foo() {
    alert(<my-function-name>);
    // pops-up "foo"
    // or even better: "myfile.js : foo"
}
Run Code Online (Sandbox Code Playgroud)

我的堆栈中有Dojo和jQuery框架,所以如果其中任何一个更容易,它们就可用了.

javascript jquery dojo

172
推荐指数
10
解决办法
11万
查看次数

标签 统计

javascript ×3

callstack ×1

dojo ×1

function ×1

jquery ×1