Skip to content

Latest commit

 

History

History
31 lines (24 loc) · 415 Bytes

#46-谁在召唤我?.md

File metadata and controls

31 lines (24 loc) · 415 Bytes

题目描述:

实现一个函数 where,它返回它被调用的时候所在的函数的名字,例如:

function main () {
  where() // => 'main'
}

function a () {
  function b () {
    where() // => 'b'
  }
  b()
}

main()
a()

参考答案:

const where = function() {
  return where.caller.name;
}