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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:02:16+00:00 2026-06-10T18:02:16+00:00

If I open the console and enter… var f=function(a){ this.toString=function(){ return –>+a; } },i=new

  • 0

If I open the console and enter…

var f=function(a){
    this.toString=function(){
        return "-->"+a;
    }
},i=new f(5);
i;

…it returns ({toString:(function () {return "-->" + a;})}).

But if I enter…

var f=function(a){
    this.toString=function(){
        return "-->"+a;
    }
},i=new f(5);
alert(i);

…it alerts "-->5"

It doesn’t matter me very much, but I would prefer the first code to return "-->5". Is there a way to do that, or is it intentional that the console doesn’t use toString?

  • 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-10T18:02:18+00:00Added an answer on June 10, 2026 at 6:02 pm

    It’s intended for debugging use, so telling you all there is to say on an object is likely to be useful.

    After all, if you’d wanted the result of calling toString() you would have asked it, with i.toString() or "" + i, but if that was the default behaviour there wouldn’t be a way to get the deeper representation you do get.

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

Sidebar

Related Questions

For instance, open up a JS console, and type toString<Enter> . You'll get this:
Open up a Rails console and enter this: 2.weeks.ago.between? 2.weeks.ago, 1.week.ago Did it give
Open a page in Chrome, enter the JavaScript console, and type debugger; . Immediately
Hey all i am trying to understand how to keep my console app open
When I open the Chrome Developer Tools JavaScript console to get a REPL, the
I want eclipse console when clicked to open at the bottom ( south ).
Say I open Chrome and hop into the javascript console. If I run localStorage.setItem('test',
when I try to open a file for reading in my console application i
I have a console application which can also open winform under certain conditions.Processing(its a
I want to open file and read it that I pass from console. Like

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.