Jul 20, 2017 · 1 min read
Great article, didn’t know about the funky sorting behaviour.
About the object by reference. I just make a habit out of it to write pure functions. And whenever I expect an object, my first reaction is to create an actual copy of it. This approach has the additional advantage that it makes refactoring/restructuring really easy. I can always take a function out of whatever framework I’m using and put it in a module because it never depends on it’s environment.
PS: for deep copying objects I find lodash’s merge to be very handy (as object.assign does not deep copy). For arrays I just Array.from.
