如何在严格模式下获取函数名[正确的方式] [英] How to get function name in strict mode [proper way]

查看:1187
本文介绍了如何在严格模式下获取函数名[正确的方式]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

参数.callee unfortunatelly 已弃用,并使用它在严格模式中引发错误。

arguments.callee unfortunatelly deprecated, and using it throws an error in "strict mode".

是否有新的正确(标准)在实际功能中获取功能名称的替代方案
还是将来在未来的计划ECMA6,7?

Is there any new proper(standard) alternative for getting function name inside actual function? Or will it be in future plans ECMA6, 7?

最近的 answer 不过是肮脏的黑客,对我而言是不可接受的。

Recent answer is no more than dirty hack and not acceptable for me answer.

arguments.callee.caller.name 不工作(nodejs v7.5.0)

And arguments.callee.caller.name not working either (nodejs v7.5.0)

推荐答案


是否有任何新的正确(标准)替代方法来获取函数名称实际功能?

Is there any new proper (standard) alternative for getting function name inside actual function?

不,没有。

$ b $或者将来是ES的未来计划?

Or will it be in future plans for ES?

不,因为没有必要。在当前函数内部,你知道这个名字,并且可以使用一个字符串文字,在其他函数中你只需要一些引用(但不是 .callee )。

No, given that there is no need for it. Inside the current function, you know the name and could just as well use a string literal, in other functions you just need some reference (but not .callee).

这篇关于如何在严格模式下获取函数名[正确的方式]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆