A couple of days ago I learned about the javascript method splice for arrays, which allows one to delete and replace elements of an array in one call. I’ve been using the immutable.js implementation of this method, and I’ve been quite pleased with how easy it is to e.g., move an element.

For example, given this List:

const ary = List(['a','b','c','d'])

If I want to move ‘b’ to in between ‘c’ and ’d’, I would do the following:

// ["a", "c", "b", "d", "e"]

Of course, now that I’m writing this, I think the clearer approach in this case would be:

// ["a", "c", "b", "d", "e"]