3 ms·
Right, they don't, and they shouldn't. If I'm not mistaken, we already agree completely. I'm saying that functions should return either primitives or objects t
by andrewstuart2 12y ago
Right, they don't, and they shouldn't. If I'm not mistaken, we already agree completely.
I'm saying that functions should return either primitives or objects that have properties (or keys, since in JS all objects are just hashmaps) that uphold some appropriate abstraction, completely separate from whatever the variables might have been called inside the function body.
For example, the return object from some function `getDate()` might have a .year property, or .toUnix method, etc.
If all I'm given is an array of arbitrarily typed values, I have solely the array indexes and values (or to go to the docs or implementation) to clue me into the semantic meaning of what was returned.