JavaScript

JavaScript

Made by DeepSource

Found duplicate arguments in function definitions JS-0006

Bug risk
Major

If more than one parameter in the function definition has the same name, the last occurrence "shadows" the preceding occurrences. A duplicated name might be a typo, and may confuse anyone reading the code.

Bad Practice

// Here are two parameters named 'a'
function func(a, b, a) {
    console.log("value of the second a:", a);
}

const logger = function (a, b, a) {
    console.log("value of the second a:", a);
};

Recommended

function func(a, b, c) {
    console.log(a, b, c);
}

const logger = function (a, b, c) {
    console.log(a, b, c);
};