I'm wondering if it's possible to pull a certain number of elements out of a Javascript array and insert them into a new array, while using one of the elements as a reference point?
This is what I'm trying to do, imagine I have an array like this:
var firstarray = [
475387453,
286235425,
738264536,
196792345,
834532623,
253463455,
535273456];
And then I have a variable that equals the number 286235425:
var element = 286235425;
I have another variable that equals the number 3:
var thenumber = 3;
What I want to do is go through the array, select the 3 elements that come after the ''var element'' number, and store them in a new array named "second array". So with the above example the result should be:
var secondarray = [
738264536,
196792345,
834532623];
I've seen some questions that talked about filtering array elements, but I haven't been able to find anything about selecting elements in the above way. Is such a thing even possible? I know it's possible to trim elements from the beginning and end of the array, but as the array will always be a different length whenever the function runs, this method isn't suitable for this problem.
Any help with this would be really appreciated, Thank you in advance!