function to get subarray in javascript code example
Example 1: js subarray
let subArray = array.slice(startIndex, endIndex)
// ['a', 'b', 'c'].slice(0, 2) === ['a', 'b']
Example 2: javascript get sub array
var fruits = ["Banana", "Orange", "Lemon", "Apple", "Mango"];
var citrus = fruits.slice(1, 3);
// ["Orange", "Lemon"]