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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:55:41+00:00 2026-06-04T13:55:41+00:00

If you do console.log($(‘some selector’)) in the browser, it returns what looks like an

  • 0

If you do console.log($('some selector')) in the browser, it returns what looks like an array (first line):

picture from latest version of chrome web console on Github project page

But notice that it’s not an instanceof Array, but it’s actually the jQuery object.

When you do console.dir($('h1')), it shows it’s actually the jQuery object.

The question is, how are they making it look like it’s an array in the web console? I noticed in the jQuery source here they add reference to a few Array and Object methods, and here they add toArray (and slice and others) to the jQuery object. Is the web console somehow checking for these methods and if it finds one (toArray, indexOf, slice, etc.), it prints it as an Array? I would like to get this behavior out of any custom object, such as the Ember.ArrayProxy. Currently when you log the Ember.ArrayProxy it shows > Object or whatever, but it would be nice to show it as an array.

Any ideas?

  • 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-04T13:55:43+00:00Added an answer on June 4, 2026 at 1:55 pm

    You make your object inherit Array using the prototype, like so:

    function SomeType() {
        this.push(16);
    }
    
    SomeType.prototype = [];
    SomeType.prototype.constructor = SomeType; // Make sure there are no unexpected results
    
    console.log(new SomeType()); // Displays in console as [16]
    

    And, of course, all jQuery objects are instances of the jQuery function/constructor, so that’s how jQuery does it. As a bonus, because of the inheritance, you get all the methods from Array, and the indexing that comes with it too!

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

Sidebar

Related Questions

How can I log into the browser console, like console.log in JavaScript, from the
i know we can manally log any input value by its selector console.log('inputName='+$('#inputId').val()+'....) But
My userscript prints some information using console.log() . This works fine in Chrome, but
When I do console.log(someobject) , I see some __proto__ object things inside my object,
Here's my biopsis Works : :plain console.log(#{escape_javascript(render(@job_charge).html_safe)}); Does not work ( but should? )
I have lines in my js files like this console.log('FunctionName()'); The default Ajax Minifier
I'm using console.log to debug errors while I develop, but it cuts off my
If I console.log(result); I get {MSG:WRONG,QUESTIONID:182.0} But If I console.log(result.QUESTIONID); I get undefined What
Code: Sorter.prototype.init_bubblesort = function(){ console.log(this.rect_array); this.end = this.rect_array.length; this.bubblesort(); } Sorter.prototype.init = function(array,sort_type){ this.rect_array
I was using console.log() in some JavaScript I wrote and an error of: console

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.