Linked Questions

418 votes
17 answers
819k views

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 ...
Claudiu's user avatar
  • 231k
1 vote
2 answers
6k views

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 ...
jlp's user avatar
  • 1,706
0 votes
0 answers
71 views

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 ...
paul's user avatar
  • 13.6k
4137 votes
33 answers
3.8m views

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?
Adam Ernst's user avatar
  • 54.3k
14 votes
8 answers
11k views

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 ...
Siddharth's user avatar
  • 545
19 votes
2 answers
18k views

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 ...
JJJollyjim's user avatar
  • 6,297
0 votes
3 answers
2k views

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 ...
snowfrogdev's user avatar
  • 7,023
-2 votes
4 answers
2k views

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? ...
bfoley_teamug's user avatar
0 votes
1 answer
358 views

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 ...
Backslash36's user avatar
0 votes
1 answer
148 views

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) ...
user3461018's user avatar
-1 votes
4 answers
148 views

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 ...
bryan's user avatar
  • 9,489
1 vote
2 answers
212 views

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 ...
John Field81's user avatar
0 votes
1 answer
86 views

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 ...
pler_programmer's user avatar
0 votes
2 answers
42 views

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'} ...
Mehul Mali's user avatar
  • 3,284