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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:52:02+00:00 2026-06-13T14:52:02+00:00

It seems that JavaScript’s array indexes are actually all strings, so a[0] is the

  • 0

It seems that JavaScript’s array indexes are actually all strings, so a[0] is the same as a['0'] while a[1.0] is not a[1] but a['1.0'].
But at the same time, array has a length property; it will be updated automatically when you modify value of integer keys. So how does JavaScript know the key is an integer and it needs to change length?
If I do:

var a = 4/2;
var b=8/4; 
var c = 2; 
var d= 1*2;

are arr[2], arr[0+2], arr[1*2], arr[a], arr[b], arr[c], arr[d] same thing?

We often access array in a loop like this:

for (i=0; i<100; i++) {
  arr[i]=1;  // this is a[0],a[1] right?
  arr[i+0.0]=1;  // is this a[0] or a['0.0'] ?
}

If I write this:

for (i=0.1; i<100; i+=0.1) {
  arr[i*10]=1;  // what does it do?  a[1] = 1, a[1.0]=1 or a[1.00000] = 1 ?
}

what does the assignment in the loop do?

  • 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-13T14:52:03+00:00Added an answer on June 13, 2026 at 2:52 pm

    JavaScript arrays aren’t really arrays, they’re JavaScript objects that have prototype methods that cause them to act like arrays. arr['one'] = 1 is valid JavaScript.

    The way arr.length works is simply by looking at the array’s keys, finding the largest number (JavaScript doesn’t really do integers, just floats) and returning that number + 1.

    try:

    var arr = [];
    
    arr.one = 1;
    arr[8] = 1;
    console.log(arr.length);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It seems that JavaScript's Date() function can only return local date and time. Is
Visual studio seems intent that my javascript code is bad, mostly because it has
I am currently learning Object oriented Javascript but it seems that the alert is
I made some research and it seems that Javascript and MIDI are not going
I was just curious, looking around, it seems that Javascript does not have a
The javascript one seems pretty simple, just localStorage.clear(). Is there anything similar to that
Seems that This will be an easy question for you but this problem is
It seems that it is not advisable to use <meta http-equiv=REFRESH CONTENT=3;url=url> for redirects
It seems that javascript only can ready inline css if i want to check
I understand that Javascript doesn't have multiple threads, but I'd like to know if

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.