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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:29:01+00:00 2026-06-15T22:29:01+00:00

var foo = function(){alert(‘foo’)} function bar(){alert(‘bar’)} Why does foo.prototype point to Object, but the

  • 0
var foo = function(){alert('foo')}
function bar(){alert('bar')}

Why does foo.prototype point to Object, but the named function bar.prototype points to itself?

I should add that this behavior is observed from browser console.

  • 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-15T22:29:02+00:00Added an answer on June 15, 2026 at 10:29 pm

    If you’re using a console such a Chrome to log the value of a prototype object then I suggest you don’t. The Chrome console, like other browser consoles, formats the output of the prototype object.

    So for a named function it will log the name of the function, but for an unnamed function it will simply log Object. This does not mean that the prototype of the function points to Object or the function itself. It’s just that that’s what the console is showing you (someone should sue them for that). See for yourself: http://jsfiddle.net/2xkpC/

    How does it know the name of a function from it’s prototype? Well, the prototype of a function has a property called constructor which points back to the function itself, and the name of the function is stored as a string in a property called name on the function. So if you log a prototype object then it will display prototype.constructor.name || "Object":

    var foo = function(){alert('foo')}
    console.log(foo.prototype); // logs "Object"
    
    function bar(){alert('bar')}
    console.log(bar.prototype); // logs bar.prototype.constructor.name
    

    See the demo here: http://jsfiddle.net/4bWfn/

    If you open your console and click that triangle near the logged output then you’ll see the constructor and the __proto__ properties of the prototype object. Under constructor you’ll also see the name property.

    To know more about inheritance in JavaScript and the prototype object read this answer: https://stackoverflow.com/a/8096017/783743

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

Sidebar

Related Questions

var objs = new Array(); function Foo(a) { this.a = a $(#test).append($(<button></button>).html(click).click(this.bar)); } Foo.prototype.bar
Consider this javascript code: var bar = function () { alert(A); } var foo
You can do this with JavaScript: function bar(test) { alert(test); } var foo =
var message = 'Spoon!'; $('#foo').bind('click', function() { alert(message); }); message = 'Not in the
I have the following structure $('foo').click( function() { var bool = false; $('bar').animate( function()
I show us the code: (function (){ var element = document.getElementById('bar'), hideElement = document.getElementById('foo'),
In the code: slider.init({ foo: bar }); var slider={ init:function(data){ } } If I
$('#remove').click(function() { var foo = []; $('#FeatureLists :selected').each(function(i, selected) { foo[i] = $(selected).text(); alert(foo[i]);
var foo = function(){}; foo.prototype.value = 5; foo.prototype.addValue = function(){ foo.value = 6; }
Let us say I have the following: var foo = (function(){ var bar =

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.