So, we know the module pattern provides privacy in JS by creating closures and providing getters/setters to manage access to the variables. That's cool, but you have to remember that everything in JavaScript is passed by reference.
Since we're returning the actual array, the caller can have its way with it through splice. Dang, looks like we have to return a copy of the value instead.
No comments:
Post a Comment