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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:40:41+00:00 2026-05-27T08:40:41+00:00

i constructed a nested object below: var outerMost = { inner1: { innerCall: alert(

  • 0

i constructed a nested object below:

var outerMost = {

    inner1: {

    innerCall: alert( "i'm the call from inner1" ),

        inner2: {

        innerCall: alert( "i'm the call from inner2" ),

            inner3: {

            innerCall: alert( "i'm the call from inner3" ),

                inner4: {

                innerCall: alert( "i'm the call from inner4" ),

                    inner5: {

                    innerCall: alert( "i'm the call from inner5" ),

                    }
                }
            }
        }
    }
};

All i want is to hear the call form inner4 by using this:

outerMost.inner1.inner2.inner3.inner4.innerCall();

But i got calls form every inner alert and was threw an error message pointing to the last expression from the debugger:

Property 'innerCall' of object #<Object> is not a function

What’s wrong with my outerMost?

  • 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-27T08:40:42+00:00Added an answer on May 27, 2026 at 8:40 am

    Note: I’m not going to keep repeating your entire object literal, I’ll just use an abbreviated form…

    Each time you said this:

    { innerCall: alert( "i'm the call from inner1" ) }
    

    You weren’t creating a property innerCall that was the alert() function, you were creating a property innerCall that was assigned the result of actually calling the alert() function at that moment. The return from alert() is undefined.

    So nesting that structure five levels deep called alert() five times all in the process of creating your object, but the actual innerCall properties were all set to undefined. So then this:

    outerMost.inner1.inner2.inner3.inner4.innerCall();
    

    Was like saying undefined(); – which of course doesn’t work.

    What you need is for innerCall to reference a function which in turn calls alert():

    { innerCall : function() { alert("I'm the call from inner1"); } }
    

    That is more or less equivalent to doing this:

    function myInnerCallFunction1() {
       alert("I'm the call from inner1");
    }
    
    { innerCall : myInnerCallFunction1 }
    

    (Note that in the object literal myInnerCallFunction1 does not have parentheses so it is a reference to the function rather than executing the function.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Greetings, I have a particular object which can be constructed from a file, as
I'm trying to access instance variables from within a nested object ('action'). The only
Python Decimal doesn't support being constructed from float; it expects that you have to
In the following code, the object constructed in the last line of 'main()', seems
Is there any way in OpenJPA to get hold of a nested object property
I am using watir-webdriver to scrape from a page with nested table based layout.
INITIAL QUESTION (UPDATED BELOW) I'm using an AutoPopulatingList list to instatiate an object invoking
How would you extract nested try/finally blocks from a routine into a reusable entity?
I'm having trouble implementing a nested class who's constructor is initialized with some of
I have constructed an XML tree structure of an XML file. I am able

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.