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

  • Home
  • SEARCH
  • 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 8310327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:25:15+00:00 2026-06-08T19:25:15+00:00

Am experimenting with an anonymous function : var a:Object = new Object() ; a.b

  • 0

Am experimenting with an anonymous function :

var a:Object = new Object() ;
a.b = new Function()

a.b =function()
{
    trace("hello");
}

trace(a.b())

Output :
hello
undefined

What’s undefined ??

  • 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-08T19:25:16+00:00Added an answer on June 8, 2026 at 7:25 pm

    You have two trace statements running:

    trace("hello");
    
    trace(a.b());
    

    When you call trace(a.b()) first a.b() is called. a.b is simply this function:

    function()
    {
        trace("hello");
    }
    

    So that runs and outputs “hello”.

    Now the second trace (trace(a.b()) tries to output the result of a.b(). The problem is that you do not return anything in a.b(), so the result is undefined.

    Edit: As JonatanHedborg points out in his comment, the line a.b = new Function() is really not needed as you overwrite it on the next line.

    If you change this to:

    var a:Object = new Object() ;
    
    a.b = function()
    {
        return "Hello";
    }
    
    trace(a.b())
    

    You should now see “hello” as the output.

    Alternatively, if you change it to this:

    var a:Object = new Object() ;
    
    a.b = function()
    {
        trace("hello");
    }
    
    trace(a.b)
    

    so that you are tracing the value of a.b instead of the value of the result of a.b() then you should see “hello” and “Function function” (or something similar) as the result.

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

Sidebar

Related Questions

Experimenting with new features of T-SQL, I've run into a puzzle. Here is some
Was experimenting with interface inheritance and found this: interface String{} interface Object{} interface Exception{}
Im experimenting with the following code private void timer1_Tick(object sender, EventArgs e) { Thread
After experimenting with a handful of new addons for Firefox, I've managed to permanently
While experimenting with C++ and the reinterpret_cast function I tried to convert a short
Experimenting with Scala... I'm trying to define something analogous to the @ hack in
Experimenting with android game development. I'm using PNG format for images, and was wondering
While experimenting with pixel shaders in WPF I decided to draw some pixels onto
When experimenting with (embedded) Apache Derby DB, I noticed that a fresh database, with
I experimenting with twitter streaming API, I use Phirehose to connect to twitter and

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.