I found a similar function from lodash but the documentation says:
_.values({ 'one': 1, 'two': 2, 'three': 3 });
// → [1, 2, 3] (property order is not guaranteed across environments)
For my use, it is important that the order is preserved, my object will come from a result of mongoose.
I checked the source code:
function values(object) {
var index = -1,
props = keys(object),
length = props.length,
result = Array(length);
while (++index < length) {
result[index] = object[props[index]];
}
return result;
}
It seems to me that it does keep the order, but why the warning on their documentation?
If objects don't have order then how would this work?
(function() { return _.toArray(arguments).slice(1); })(1, 2, 3, 4);
// → [2, 3, 4]
Isn't the order of the arguments important?