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, 2022 in Web Development by gaurav
• 23,260 points
910 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, 2022 by rajatha
• 7,640 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, 2022 in Web Development by gaurav
• 23,260 points
679 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, 2022 in Web Development by gaurav
• 23,260 points
1,038 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, 2022 in Web Development by gaurav
• 23,260 points
250 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, 2022 in Web Development by gaurav
• 23,260 points
592 views
0 votes
0 answers

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

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

Jun 29, 2022 in Web Development by gaurav
• 23,260 points
1,690 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
996 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,880 points
14,281 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,880 points
22,449 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, 2022 in Web Development by rajatha
• 7,640 points
306 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, 2022 in Web Development by rajatha
• 7,640 points
367 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