Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get function name in strict mode [proper way]

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

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

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

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

like image 260
Firanolfind Avatar asked Feb 26 '17 19:02

Firanolfind


People also ask

How do you define a function called f name?

A function is most often denoted by letters such as f, g and h, and the value of a function f at an element x of its domain is denoted by f(x); the numerical value resulting from the function evaluation at a particular input value is denoted by replacing x with this value; for example, the value of f at x = 4 is ...

What is correct way to run a JavaScript in strict mode?

Using Strict mode for a function: Likewise, to invoke strict mode for a function, put the exact statement “use strict”; (or 'use strict';) in the function's body before any other statements. Examples of using Strict mode: Example: In normal JavaScript, mistyping a variable name creates a new global variable.

What is function form of use strict?

The "use strict" Directive It is not a statement, but a literal expression, ignored by earlier versions of JavaScript. The purpose of "use strict" is to indicate that the code should be executed in "strict mode". With strict mode, you can not, for example, use undeclared variables.


Video Answer


1 Answers

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

No, there is not.

Or will it be in future plans for ES?

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).

like image 126
Bergi Avatar answered Oct 21 '22 12:10

Bergi