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 7737589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:02:40+00:00 2026-06-01T08:02:40+00:00

I’m working in strict mode for the first time and, what-d’ya-know, it’s also the

  • 0

I’m working in strict mode for the first time and, what-d’ya-know, it’s also the first time in ages being able to use a non strict mode property would be useful. My question here outlines the exact problem I’m having, but the solution I’ve worked out could be adapted to something a lot more scaleable if I still had access to arguments.callee.

Without naming the function is there any way in strict mode that I can get a reference to the function whose scope I’m currently within?

  • 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-06-01T08:02:42+00:00Added an answer on June 1, 2026 at 8:02 am

    Without naming the function is there any way in strict mode that I can get a reference to the function whose scope I’m currently within?

    In 2012 when this answer was originally written, there were implementation bugs with the named function expressions you were using in your linked solution. There aren’t now, it’s been years since browsers with those bugs were still in significant circulation. So here in a (very) post-IE8 world, your named function expression approach is just fine:

    UsageGraph = Graph.extend({
       generateScale: function GS() {
           var parentMethod = this.constructor._super.generateScale;
           if(parentMethod === GS) {
               parentMethod = this.constructor._super.constructor._super.generateScale;
           }
           parentMethod.call(this); // run the parent's method
           //do additional stuff
       }
    });
    

    But the question asks if you can avoid having a name. In 2012, my solution if you really didn’t want the function to have a name was to assign an anonymous function to a variable:

    UsageGraph = Graph.extend(function(){
       var GS = function() {
           var parentMethod = this.constructor._super.generateScale;
           if(parentMethod === GS) {
               parentMethod = this.constructor._super.constructor._super.generateScale;
           }
           parentMethod.call(this); // run the parent's method
           //do additional stuff
       };
    
       return {generateScale: GS};
    }());
    

    But that doesn’t work anymore; since ES2015, even that function has a name, inferred from the name of the variable it’s assigned to:

    var GS = function() { };
    console.log(GS.name); // "GS"

    If you really don’t want it to have a name, it’s possible to avoid it, but you have to make an effort to defeat the automatic naming defined by the specification, for instance by making the function the return value of another function:

    var GS = (() => function() { })();
    console.log(GS.name); // ""

    So if avoiding the name is important, you’d do something like this:

    UsageGraph = Graph.extend(function(){
       const generateScale = (() => function() {
           let parentMethod = this.constructor._super.generateScale;
           if(parentMethod === generateScale) {
               parentMethod = this.constructor._super.constructor._super.generateScale;
           }
           parentMethod.call(this); // run the parent's method
           //do additional stuff
       })();
    
       return {generateScale};
    }());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka

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.