Is there a suitable equivalent to `Function.caller` in modern JS?

So, as MDN (Mozilla Developer Network) says, Function.caller is not only deprecated, but removed from the Relevant Web Standards.
But, this isn’t good for me, as I want to know what function is calling a function I have.
I have a set of private variabl…


This content originally appeared on DEV Community and was authored by Calin Baenen

So, as MDN (Mozilla Developer Network) says, Function.caller is not only deprecated, but removed from the Relevant Web Standards.
But, this isn't good for me, as I want to know what function is calling a function I have.

I have a set of private variables, and I only want "friend functions" to see those variables without having to return every function from another function. (Also because these private variables are user-defined, and thus can't be predicted, or written in advance.)

So, I was wondering, does modern JS provide anything similar to Function.caller?

Thanks!
Cheers!


This content originally appeared on DEV Community and was authored by Calin Baenen


Print Share Comment Cite Upload Translate Updates
APA

Calin Baenen | Sciencx (2021-11-19T01:20:19+00:00) Is there a suitable equivalent to `Function.caller` in modern JS?. Retrieved from https://www.scien.cx/2021/11/19/is-there-a-suitable-equivalent-to-function-caller-in-modern-js/

MLA
" » Is there a suitable equivalent to `Function.caller` in modern JS?." Calin Baenen | Sciencx - Friday November 19, 2021, https://www.scien.cx/2021/11/19/is-there-a-suitable-equivalent-to-function-caller-in-modern-js/
HARVARD
Calin Baenen | Sciencx Friday November 19, 2021 » Is there a suitable equivalent to `Function.caller` in modern JS?., viewed ,<https://www.scien.cx/2021/11/19/is-there-a-suitable-equivalent-to-function-caller-in-modern-js/>
VANCOUVER
Calin Baenen | Sciencx - » Is there a suitable equivalent to `Function.caller` in modern JS?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/11/19/is-there-a-suitable-equivalent-to-function-caller-in-modern-js/
CHICAGO
" » Is there a suitable equivalent to `Function.caller` in modern JS?." Calin Baenen | Sciencx - Accessed . https://www.scien.cx/2021/11/19/is-there-a-suitable-equivalent-to-function-caller-in-modern-js/
IEEE
" » Is there a suitable equivalent to `Function.caller` in modern JS?." Calin Baenen | Sciencx [Online]. Available: https://www.scien.cx/2021/11/19/is-there-a-suitable-equivalent-to-function-caller-in-modern-js/. [Accessed: ]
rf:citation
» Is there a suitable equivalent to `Function.caller` in modern JS? | Calin Baenen | Sciencx | https://www.scien.cx/2021/11/19/is-there-a-suitable-equivalent-to-function-caller-in-modern-js/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.