Skip to content

refactor default options merge to avert side effects. #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 17, 2011

Conversation

jonstorer
Copy link
Contributor

setting options this way:

$.extend(defaults, options);

will overwrite the default variable with the param options.

For example, If there are two endless scrolls on the page, the 2nd endless scroll could receive 'dirty' defaults from the first call.

This:

$.extend({}, defaults, options);

won't do that. It keeps defaults clean and separate from the intended options.

```
   $.extend(defaults, options);
```
will overwrite the default variable with ```options```. So if there are two endless scrolls on the page, the 2nd endless scroll could receive 'dirty' defaults from the first call.

This:
```
$.extend({}, defaults, options);
```
won't do that.  It keeps defaults clean and separate from the intended options.
fredwu added a commit that referenced this pull request Nov 17, 2011
refactor default options merge to avert side effects.
@fredwu fredwu merged commit 63c1c45 into fredwu:master Nov 17, 2011
@fredwu
Copy link
Owner

fredwu commented Nov 17, 2011

Merged and tagged a new release! Thanks! :)

@jonstorer
Copy link
Contributor Author

welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants