Example 1 — Official Sample
Put 'x' at index 2, as in the Ramda docs.
const result = R.insert(2, 'x', [1, 2, 3, 4]);
console.log(JSON.stringify(result)); // [1,2,"x",3,4] How It Works
- Argument order. Index first, item second, list last.
- Position 2. The item at index 2 is
3, so'x'goes just before it. - Shift.
3and4move one step right. - Longer list. The result has 5 items; the input still has 4.
