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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:40:48+00:00 2026-06-13T10:40:48+00:00

I need a high performance map in Javascript (hashmap or whatever) that maps int

  • 0

I need a high performance map in Javascript (hashmap or whatever) that maps int(s) to string(s). The map would be used to build some sections of the webpage after dom is ready. I know simple javascript object also works like a map but I need to work with best performance.

I would like to initialize the map with all data pairs just at once by appending a string to the webpage while generating the response page from server.

Any ways how to improve performance of javascript map for int- string pairs or are there any implementations for the same ?

—

Using jQuery 1.7

  • 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-13T10:40:48+00:00Added an answer on June 13, 2026 at 10:40 am

    Ok, I’ll post it here since it’s more of an answer:

    Use an array. Taken into account that any implementation will have to use js primitives and objects, you’ll be hard pressed to find something more performant than that.

    Arrays in most (all?) implementations of javascript can be sparse. So array.length will return the index of last element + 1, but in sparse case the array will not have all elements allocated and will use object property semantics to access it’s elements (meaning, it’s effectively a hashtable with ints as keys).

    It basically gives you the behavior you’re looking for.

    In case of negative ints, use a second array.

    In relation to a single statement initialization: you can’t do it in general, since it bases itself on implicitly knowing the item index.

    What you can do is to append something along the lines:

     var arr = [];
    
     arr[int1] = val1;
     arr[int2] = val2;
     arr[int3] = val3;
     arr[int4] = val4;
     ...
     arr[intn] = valn;
    

    I mean you have to list (Number, String) pairs somehow anyway.

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

Sidebar

Related Questions

I have some high-performance C++ that I need to interface with Objective-C, is there
I need to do alot of high-performance case-insensitive string comparisons and realized that my
I have a need for a high-performance string hashing function in python that produces
if you would need to write a high performance server how would you do
That's pretty much it. I don't need high precision in the Paleolithic Era, but
I'm bumbling my way through creating a Silverlight 3 application. I need some high
I need to create a process with integrity level high, so that it can
I am developing a Firefox extension and I need to perform some high-speed calculations
Isn't there a Design Pattern who describes how to high cohesion? I need some
a quick, simple question from me about for-loops. Situation I'm currently writing some high-performance

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.