I was wondering how to do the follow.
I have an array of objects and I'm trying to retrieve a set amount eg of them around a given index.
Here's an example.
var arr = [0,1,2,3,4,5,6,7,8,9,10];
var index = 0;
var max = 5;
If the index is 0 I want [0 - 4]
If the index is 4 I want [2 - 6]
If the index is 9 I want [6 - 10]
But I also want it to work if the array is smaller then the max too. Eg
var arr = [0,1,2];
var index = 0;
var max = 5;
Any index would return [0 - 2]
Any thoughts?