Adds set functions to arrays in JavaScript