Document return value of `_.defaults` #2625

Closed
philfreo opened this Issue Nov 9, 2016 · 1 comment

Projects

None yet

2 participants

@philfreo
Contributor
philfreo commented Nov 9, 2016 edited

I understand that _.defaults modifies its first argument (object) and also returns that value. However the return value of this function is not documented on http://underscorejs.org/#defaults

It's nice to be able to rely on the return value, e.g. in Backbone this is done:

https://github.com/jashkenas/backbone/blob/c3a829a91aa656582b372f924cd87057ff8b3641/backbone.js#L403

Wouldn't it make sense to document the return value so people can feel comfortable relying on this behavior?

EDIT: I suppose it is somewhat documented by the => line in the code sample there, however I would still propose just using the word "returns" in the description, like you do with other similar functions.

@captbaritone
Collaborator

Yeah, technically the => notation indicates the return value. If you want to open a pull request to make the docs more explicit, I'd merge it.

@philfreo philfreo added a commit to philfreo/underscore that referenced this issue Dec 27, 2016
@philfreo philfreo Docs: more explicit return value of _.defaults; Closes #2625 616386f
@jashkenas jashkenas closed this in #2640 Dec 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment