First we will see duplicating parameters in regular JavaScript function.
//this is syntax of duplicating parameter in js functionfunctionFunc(first, second, first){console.log(first, second, first);}
In non-strict mode, regular JavaScript functions allow duplicate named parameters
functionFunc(first, second, first){console.log(first, second, first);}// first => 1 // second => 2// first => 3Func(1,2,3);// 3 2 3// first => 1// second => 2 // first => undefinedFunc(1,2);//undefined [undefined, 2, undefined]
Lets check this in strict mode,
functionFunc(first, second, first){"use strict";console.log(first, second, first);}//Throws an error because of duplicate parameters (Strict mode)
In Strict mode we cannot duplicate the parameter name.
How do arrow functions treat duplicate parameters?
Now here is something about arrow functions:
Unlike regular functions, arrow functions do not allow duplicate parameters, whether in strict or non-strict mode. Duplicate parameters will cause a Syntax Error to be thrown._
// Always throws a syntax errorconstFunc=(first, second, first)=>{console.log(first, second);}