What is the most concise and efficient way to find out if a JavaScript array contains a value?  This is the only way I know to do it:  function contains(a, obj) {     for (var i = 0; i < a.length; i++) {         if (a[i] === obj) {             r...
I threw some code together to flatten and un-flatten complex/nested JSON objects. It works, but it's a bit slow (triggers the 'long script' warning).  For the flattened names I want "." as the delimiter and [INDEX] for arrays....
Which algorithm does the JavaScript Array#sort() function use?  I understand that it can take all manner of arguments and functions to perform different kinds of sorts, I'm simply interested in which algorithm the vanilla sort uses....
I have a simple JavaScript Array object containing a few numbers.  [267, 306, 108]   Is there a function that would find the largest number in this array?...
I need the fastest way to get the first day of the week. For example: today is the 11th of November, and a Thursday; and I want the first day of this week, which is the 8th of November, and a Monday. I need the fastest method for MongoDB map functi...
How would you implement the Cartesian product of multiple arrays in JavaScript?  As an example,  cartesian([1, 2], [10, 20], [100, 200, 300])    should return  [   [1, 10, 100],   [1, 10, 200],   [1, 10, 300],   [2, 10, 100],   [2, 10, 200]   ... ]...
I am working on an isometric game engine and have already created an algorithm for pixel perfect click detection. Visit the project and notice that click detection is able to detect which edge of the tile was clicked. It is also checks the y-index...
Code in question with syntax highlighting here: via Friendpaste  rot13.js:     ERRONEOUS  <script> String.prototype.rot13 = rot13 = function(s)  {     return (s = (s) ? s : this).split('').map(function(_)      {         if (!_.match(/...
I've seen versions of this question for other languages, but not for JS.  Is it possible to do this recursively in one function?  I understand that I need to take the first element in the string, and then append it to each solution to the recur...
Requirement: Algorithm to generate all possible combinations of a set , without duplicates , or recursively calling function to return results.  The majority , if not all of the Answers provided at Permutations in JavaScript? recursively call a fun...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.