Side navigation
#12212 closed enhancement (invalid)
Opened August 07, 2012 01:47PM UTC
Closed August 21, 2012 01:31AM UTC
Last modified October 15, 2012 07:47PM UTC
Document that $.extend will ignore null/undefined arguments
Reported by: | T.J. Crowder <tj@crowdersoftware.com> | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.8rc1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
This is a fairly common pattern for setting options, even if options
isn't provided:
function doSomethingCool(options) { options = $.extend(true, {}, defaultOptions, options); // ... }
...but it relies on the behavior that $.extend
will ignore the options
argument if it's null
or undefined
. $.extend
does indeed do that, and on purpose (with a comment, even), but it's not documented.
Recommend documenting it by adding this text:
In the arguments list,null
andundefined
''objectN'' arguments are skipped (they do not cause an error). For example, this works even if theoptions
variable isundefined
ornull
: \\\\options = $.extend(true, {}, defaultOptions, options);
...just before the paragraph starting with "On a deep
extend..." near the end.
Attachments (0)
Change History (4)
Changed August 21, 2012 01:31AM UTC by comment:1
keywords: | → needsdocs |
---|---|
resolution: | → invalid |
status: | new → closed |
Changed August 21, 2012 07:27AM UTC by comment:2
Replying to [comment:1 dmethvin]:
closing invalid but marking as needsdocs
For future reference, is there a better way to log documentation tickets?
Thanks,
-- T.J.
Changed August 21, 2012 12:20PM UTC by comment:3
https://github.com/jquery/api.jquery.com/issues (the new site hasn't launched yet).
Changed October 15, 2012 07:47PM UTC by comment:4
keywords: | needsdocs |
---|---|
summary: | Document that $.extend will ignore null/undefined arguments. → Document that $.extend will ignore null/undefined arguments |
closing invalid but marking as needsdocs