Why assignment to property of function parameter is bad style.
See original GitHub issueNode.js web service
(req, res, next) => {
req.user = Guest;
return next();
};
Often used, can not be avoided. How should I do?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:14 (2 by maintainers)
Top Results From Across the Web
How to avoid no-param-reassign when setting a property on a ...
If you assign to a parameter and then try and access some of the parameters via the arguments object, it can lead to...
Read more >Why eslint throws "Assignment to property of function ... - Reddit
Reassigning arguments is considered harmful so there's and ESlint rule for that. But mutating object properties is fine in some cases, ...
Read more >Why it's bad practice to reassign function params - Medium
Reassigning the value of an argument variable mutates the arguments object. Mutation is the act of changing the source or the original element....
Read more >object oriented - Parameterizing vs property assignment
Nope. Your way is better. Here's why: the variables are properly confined to only the scope in which they are used.
Read more >JavaScript: Don't Reassign Your Function Arguments
The numbered properties of the Arguments Object are synonymous with the local variables that hold the named function parameters.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The next release of eslint-config-airbnb-base, and likely eslint-config-airbnb, will include this loosening of no-param-reassign.
Another example is
ctx
in Koa routing: