Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6333177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:24:38+00:00 2026-05-24T18:24:38+00:00

function MyFunction() { closure = function() { alert(‘my parent function name is: ‘/* now

  • 0
function MyFunction() {
  closure = function() {
    alert('my parent function name is: '/* now what here ? */);
  }
  closure();
}
MyFunction();

Result should be my parent function name is: MyFunction

(To moderators: I do not know why stackoverflow is preventing me from sending this question claiming it doesn’t meet quality standards. Do I must type some superfluous text to be allowed to send this.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T18:24:39+00:00Added an answer on May 24, 2026 at 6:24 pm

    That is/was possible, but it is restricted. First restriction, not all Javascript engines support the following pattern and second (more dramatic), ES5 strict mode does not support it either.

    Some Javascript engines allow you to access the .__parent__ property which is a reference to the parent scope. That should look like

    alert('my parent is ' + this.__parent__.name );
    

    where you would have to call new closure(), or give the function a name and use that name instead of this.

    However, most implementations removed that access for security concerns. As you may noticed, you’re able to breach the ‘allmighty’ closure security by beeing able to access the parent context.


    Another way to accomplish it, is to access arguments.callee.caller, which also is not accessible in ES5 strict mode. Looks like:

    function MyFunction() {
      closure = function f() {
        alert('my parent function name is: ' +  arguments.callee.caller.name);
      }
     closure();
    }
    MyFunction();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I tell closure compiler that an anonymous function should not be removed
I need to pass a string literal to a function myfunction(arg1 DEF_CHAR arg1); now
Inside my template function I have the following code: TypeName myFunction() { TypeName result;
I have the following code function myFunction(items) { // this prints out 11 alert(items.length);
I have a JQuery function: function MyFunction() { //I need a command here to
Why is 100 being logged here instead of 101? function myFunction() { var i=100;
<script type=text/javascript> function myfunction() { if (document.getElementById('myform').value == yes) { document.getElementById('yesinput').style.display = ''; }
Suppose I have a C function: void myFunction(..., int nObs){ int myVec[nObs] ; ...
In C++, I have a function: void MyFunction(int p) { p=5; } Assume, I
I have a function like this: MyFunction(double matrix[4][4]) {/*do stuff*/} I am calling this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.