Reusing a Section of an Array

1 week ago 8
ARTICLE AD BOX

I need to pass into a function an array of arrays, like:

L.polyline([[0, 0], [1, 1], [2, 1], [2, 2], [4, 9], [4, 10], [10, 10]]);

However, I have a sequence that often repeats that I'd like to save and reuse:

var sequence = [[1, 1], [2, 1], [2, 2], [4, 9], [4, 10]];

Is there a way I can change how I save or use this sequence to allow me to properly pass it into the function? This doesn't work:

var sequence = [[1, 1], [2, 1], [2, 2], [4, 9], [4, 10]]; L.polyline([[0, 0], sequence, [10, 10]]);
Read Entire Article