How to create a simple map using JavaScript JQuery

0 votes

How can you create the JavaScript/JQuery equivalent of this Java code:

Map map = new HashMap(); //Doesn't not have to be a hash map, any key/value map is fine
map.put(myKey1, myObj1);
map.put(myKey2, myObj2); //Repeat n times

function Object get(k) {
    return map.get(k);
}

Jun 23 in Web Development by gaurav
• 18,960 points
52 views

1 answer to this question.

0 votes
var map = new Object(); // or var map = {};
map[myKey1] = myObj1;
map[myKey2] = myObj2;

function get(k) {
    return map[k];
}
answered Jun 27 by rajatha
• 7,440 points

Related Questions In Web Development

0 votes
0 answers

how to convert a decimal number to fraction using jquery

I want to convert the decimal number ...READ MORE

Jul 28 in Web Development by gaurav
• 18,960 points
43 views
0 votes
0 answers

How to convert UTC to CST using Javascript or Jquery

I would like to convert the below ...READ MORE

Aug 11 in Web Development by gaurav
• 18,960 points
72 views
0 votes
0 answers

How can I create a "Please Wait, Loading..." animation using jQuery?

I would like to place a "please ...READ MORE

Aug 11 in Web Development by gaurav
• 18,960 points
34 views
0 votes
0 answers

How can I create a "Please Wait, Loading..." animation using jQuery?

I would like to place a "please ...READ MORE

Aug 12 in Web Development by gaurav
• 18,960 points
22 views
0 votes
0 answers

JQuery $.ajax() post - data in a java servlet

I want to send data to a ...READ MORE

Jun 29 in Web Development by gaurav
• 18,960 points
310 views
0 votes
1 answer

What is jQuery?

Hey, jQuery is a fast and concise JavaScript ...READ MORE

answered Feb 14, 2020 in JQuery by kartik
• 37,510 points
340 views
0 votes
1 answer

Uncaught TypeError: Cannot read property 'msie' of undefined - jQuery tools

Hello, Use the following script tag in your ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,780 points
9,396 views
0 votes
1 answer

Uncaught Error: Bootstrap's JavaScript requires jQuery

Hello @kartik, You have provided wrong order for ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,780 points
16,625 views
0 votes
1 answer

How can I create a simple page vertical scroll bar without using jQuery?

Surprisingly, there is not a great, simple ...READ MORE

answered Jun 22 in Web Development by rajatha
• 7,440 points
72 views
0 votes
1 answer

How to place images using jQuery masonry plugin to start

You were just missing a css class that adjusts ...READ MORE

answered Jun 22 in Web Development by rajatha
• 7,440 points
33 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP