Closed jonschlinkert closed 11 years ago
Yeah, I was thinking of that when I wrote it originally. But I didn't use that method because I'm already creating a new object literal when calling _extend
. Since I'm doing it that way, there isn't a reference to an original object that would get changed.
I don't know if there's a performance impact on creating 2 object literals or creating a defaults
object, then passing those in. I might just go for readability and do this...
var defaults = {
order: 'asc'
};
var opts = _extend({}, defaults, options);
Yeah I see what you mean, I just use it as a best practice
Closing per tests done in #9
Rather than overwriting the "default" options object (https://github.com/helpers/sort-object/blob/master/sort-object.js#L18) it's better to add an empty object as the first paramter, and then extend that.
Essentially, what's happening is something like this: