# Prefer default parameters over reassignment 💼 This rule is enabled in the ✅ `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). 🔧💡 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). Instead of reassigning a function parameter, default parameters should be used. The `foo = foo || 123` statement evaluates to `123` when `foo` is falsy, possibly leading to confusing behavior, whereas default parameters only apply when passed an `undefined` value. This rule only reports reassignments to literal values. ## Fail ```js function abc(foo) { foo = foo || 'bar'; } ``` ```js function abc(foo) { const bar = foo || 'bar'; } ``` ## Pass ```js function abc(foo = 'bar') {} ``` ```js function abc(foo) { foo = foo || bar(); } ```