Skip to content
Advertisement

Tag: arrays

Javascript sort function. Sort by First then by Second

I have an array of objects to sort. Each object has two parameters: Strength and Name I want to sort first by Strength and then by name alphabetically. I am using the following code to sort by the first parameter. How do I sort then by the second? Thanks for your help. (I am using Array.sort() with the aforementioned sortF

How to get subarray from array?

I have var ar = [1, 2, 3, 4, 5] and want some function getSubarray(array, fromIndex, toIndex), that result of call getSubarray(ar, 1, 3) is new array [2, 3, 4]. Answer Take a look at Array.slice(begin, end)

Advertisement