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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:34:03+00:00 2026-05-28T02:34:03+00:00

I can easily create and object in a lot of different. For example like

  • 0

I can easily create and object in a lot of different. For example like this:

var myObject = {
    myFunction: function () {
        return "";
    }
};

So if I alert this object I get something this:

[object Object]

Now I’m if I alert the NaN object I get this:

NaN

And I can still call function from it:

alert(NaN.hasOwnProperty().toString());

So my question is how can I create a object like the NaN object?

  1. If I alert it, it should return something like myObject
  2. I should be able to create and call functions on it like myObject.myFunction();
  • 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-28T02:34:04+00:00Added an answer on May 28, 2026 at 2:34 am

    Only objects that are created using a constructor function get their class name displayed using console.log(), as shown in @Esalijia’s answer.

    Even then, it’ll be the class name that’s displayed, not the name of whatever variable you happened to assign the object to.

    Adding a toString() method to the object will however change the output of the alert() function, since that always looks for the presence of that method and use it if it exists.

    So, writing:

    var myObj = {
        toString: function() { return "boo"; }
    }
    alert(myObj)
    

    will show boo in the alert box, instead of [Object object].

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

Sidebar

Related Questions

In javascript you can easily create objects and Arrays like so: var aObject =
in C++, I can easily create a function pointer by taking the address of
I have the following method signature: public void MyFunction(Object[,] obj) I create this object:
Is there a good way to create a form in VB6 that can easily
In Bash I can easily do something like command1 && command2 || command3 which
Using scons I can easily set my include paths: env.Append( CPPPATH=['foo'] ) This passes
I have created an OOP environment for WebGL so I can easily create all
Suppose I create a custom object/javascript class (airquotes) as follows: // Constructor function CustomObject(stringParam)
Although the example below exploits ExtJS, one can easily extrapolate to another framework. I
I'm used to PHP, where I can easily do something like: $data = array(

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.