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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:01:16+00:00 2026-06-13T13:01:16+00:00

What is going on here? var x = {length:3, ‘0’:’foo’, ‘1’:’bar’,’2′:’f’, splice:function(){}} This actually

  • 0

What is going on here?

var x = {length:3, '0':'foo', '1':'bar','2':'f', splice:function(){}}

This actually creates an array:

["foo", "bar", "f"]

Where is the documentation for this structure syntax?

It’s also smart:

changing to: (notice 0 , 1 , 3)

 var x = {length:3, '0':'foo', '1':'bar','3':'f', splice:function(){}}

will mess up the array and it will be:

["foo", "bar", undefined × 1]

Also, removing the splice function:

var x = {length:3, '0':'foo', '1':'bar','2':'f'}

yields: (regular object)

Object
0: "foo"
1: "bar"
2: "f"
length: 3
__proto__: Object

So I have two questions:

  • What is this structure? length , element , splice

  • Say I have ['john','paul','yoko'] and now I want to create the object

    var x = {length:3, '0':'john', '1':'paul','2':'yoko', splice:function(){}}

    How would I do this?

  • 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-13T13:01:17+00:00Added an answer on June 13, 2026 at 1:01 pm

    An array is nothing else than an object, with some methods implemented, when you make console.log(x), your console recognizes the model of an array, and display it like it has been configured to do so.

    Array is an object available by default in Javascript, and it is handled a bit differently than other objects by the browser (see @MathiasSchwarz comment), but in its structure, it is an object like the others (there’s methods that you can call, and you can add indexes. Though, you don’t usually use string indexes like in “normal” objects, because it’s not aimed to be used like that).

    But your object is not really an Array, you can do whatever you want without referring to what is displayed in the console.

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

Sidebar

Related Questions

Can someone visually explain what's going on here please. var stack = []; function
I don't understand what's going on here: $ node > var f = function()
Not sure whats going on here, or what could be the integer in this
Every time I pass an array to this function, when it hits a null
I have this JS code: var recipesPost = function(name, ingredients, steps) { $.post('/api/recipes', {
function tournamentViewModel(){ var self= this; self.name = ko.observable(); self.districts = ko.observableArray([new district('Provo',1),new district('Salt Lake
I've created this example here... http://jsfiddle.net/rhvbG/5/ var buttons=[ '<svg version=1.1 id=Layer_1 xmlns=http://www.w3.org/2000/svg xmlns:xlink=http://www.w3.org/1999/xlink x=0px
I have a page going here that uses jQuery: http://treethink.com/services What I am trying
So I have a simple setup going here where I load up a file
What might be going on here? I get Unhandled exception at 0x5081f508 (msvcr100d.dll) in

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.