About 51 results
Open links in new tab
  1. javascript - Get the last item in an array - Stack Overflow

    var newT = document.createTextNode(unescape(capWords(loc_array[loc_array.length-2]))); linkElement.appendChild(newT); Currently it takes the second to last item in the array from the URL. …

  2. How do I check if an array includes a value in JavaScript?

    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;...

  3. Loop (for each) over an array in JavaScript - Stack Overflow

    Feb 17, 2012 · JavaScript has powerful semantics for looping through arrays and array-like objects. I've split the answer into two parts: Options for genuine arrays, and options for things that are just array- …

  4. javascript - How can I find and update values in an array of objects ...

    The splice() method changes the contents of an array by removing or replacing existing elements and/or adding new elements in place. N.B : In case you're working with reactive frameworks, it will update …

  5. Loop through an array in JavaScript - Stack Overflow

    Jun 10, 2010 · In the case of an array, the callback is passed an array index and a corresponding array value each time. (The value can also be accessed through the this keyword, but Javascript will …

  6. javascript - How to append something to an array? - Stack Overflow

    Dec 9, 2008 · How do I append an object (such as a string or number) to an array in JavaScript?

  7. How to create an array containing 1...N - Stack Overflow

    We'll use that fact later. Array.apply(null, [undefined, undefined, undefined]) is equivalent to Array(undefined, undefined, undefined), which produces a three-element array and assigns …

  8. How do I check if a variable is an array in JavaScript?

    variable.constructor === Array This is the fastest method on Chrome, and most likely all other browsers. All arrays are objects, so checking the constructor property is a fast process for JavaScript engines. …

  9. How can I create a two dimensional array in JavaScript?

    Assuming a somewhat pedantic definition, it is technically impossible to create a 2d array in javascript. But you can create an array of arrays, which is tantamount to the same.

  10. What is the way of declaring an array in JavaScript?

    It actually creates an array of size 5 (all elements undefined), assigning it to the variable a, and then immediately throws that array away and assigns to the variable a another, brand new array of size 5, …