Skip to content

Conversation

@manbomb
Copy link

@manbomb manbomb commented Oct 13, 2021

This change prevents the methods from changing the content of the "options" object passed as a parameter.

@brendanashworth
Copy link
Owner

Is this a problem? Not sure how this could cause a bug

@manbomb
Copy link
Author

manbomb commented Oct 14, 2021

This is not a problem, however, it is not good practice to change the parameters passed to a function or method, they should be immutable.

var innerOptions = {...options};

// Set defaults.
innerOptions = innerOptions || {};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to just change this line to be options = {...options} || {};? Then you don't need to rename it to innerOptions and most of the diff disappears.

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