splice remove others except the referenced index code example
Example 1: remove element from array javascript
let fruit = ['apple', 'banana', 'orange', 'lettuce'];
// ^^ An example array that needs to have one item removed
fruit.splice(3, 1); // Removes an item in the array using splice() method
// First argument is the index of removal
// Second argument is the amount of items to remove from that index and on
Example 2: javascript remove all objects from array of objects except first
var input = ['a','b','c','d','e','f'];
input.length = 1;
console.log(input);