Linked Questions
14 questions linked to/from How to create a hash or dictionary object in JavaScript
418
votes
17
answers
819k
views
JavaScript hashmap equivalent
As made clear in update 3 on this answer, this notation:
var hash = {};
hash[X]
does not actually hash the object X; it actually just converts X to a string (via .toString() if it's an object, or ...
1
vote
2
answers
6k
views
Is there a Map type in javascript similar to what is in Java? [duplicate]
I did some research and it seems that we can either use Jquery.map() or create a javascript object: var Map = {}; But both of them don't seem to provide rich functionalities to easily manipulate a ...
0
votes
0
answers
71
views
Create map <key,value> on JQuery [duplicate]
Let´s say I have some DOM elements , then I have some events associated with those elements, event1->div1, event2->div1, event3->div2, event4->div2.
Now what I want is create an structure where I ...
4137
votes
33
answers
3.8m
views
Checking if a key exists in a JavaScript object?
How do I check if a particular key exists in a JavaScript object or array?
If a key doesn't exist, and I try to access it, will it return false? Or throw an error?
14
votes
8
answers
11k
views
Merge two arrays into one javascript object
I have an array of data. In a there are 10 fields and in b there are 10 fields
var a = [ "siddharth", "sid", "anything", "something", "nothing", ]
var b = [ "23", "67", "10", "10", "90" ]
I am trying ...
19
votes
2
answers
18k
views
Fast way to find if a string is in an array
In Ruby, finding out if a string is in an array (.include? x) is very slow. If you change that array into a set, then BAM, lightning fast lookups.
In JavaScript, where there are no sets, array ...
0
votes
3
answers
2k
views
Javascript: Optimizing `reduce` for performance
I'm using a .reduce method to iterate thru an array of objects in order to return the array index for the object that best fits certain conditions. My array has around 30,000 indexes right now and I'm ...
-2
votes
4
answers
2k
views
JS - getting the sum of numbers assigned to the letters
I'm trying to solve a problem in JavaScript i.e. to assign numbers to the alphabets so that when a user types a string, it returns the sum of the numbers assigned to the alphabets. How can I solve it? ...
0
votes
1
answer
358
views
How to get all the HTML elements affected by an event
I have assigned a "mousemove" event on some div elements. Those elements might overlap each other due to an animation process, so several "mousemove" events could be called at once by moving the mouse ...
0
votes
1
answer
148
views
How to iterate through a JavaScript string without using charAt(), or does it even matter?
JavaScript n00b here. I have the following block of code in the webpage I'm making:
for (var k = 0, n = startingText.length; k < n; ++k)
{
if (startingText[k] in map1)
...
-1
votes
4
answers
148
views
Find object in array and then edit it
Let's say I have the following array:
var things = [
{
id: "12345",
name: "Bryan"
},
{
id: "55555",
name: "Justin"
}
]
I want to search for the object ...
1
vote
2
answers
212
views
Doing Calculations with multiple options in Javascript
I'm quite new to Javascript and have started to do simple calculations, but have run into a barrier with <select>.
I want the code to get what the user has selected in the drop-down menu and ...
0
votes
1
answer
86
views
check and remove duplicate coordinate x, y canvas
I would like to check the coordinate x and y which is duplicated, then remove those existing objects and generate the new one in Canvas world objects. Could anyone kindly gimme a solution. A simple ...
0
votes
2
answers
42
views
Create image categorie array of object from images object of array
I have following array of Object
$scope.images = [
{key: 'shop1/images/a1.jpg'},
{key: 'shop2/images/a2.jpg'},
{key: 'shop1/images/a3.jpg'},
{key: 'shop3/images/a4.jpg'}
...