Map over an object, array or string in JavaScript