Duplicate parameters in JavaScript Functions

CapsCode: Empowering Innovation Through Education and Technology
CapsCode is a pioneering edtech and web development company committed to transforming the lives of students and businesses alike. Founded with the vision of creating a brighter, tech-driven future, CapsCode empowers students by providing world-class coding education while enabling businesses to achieve their goals with cutting-edge IT solutions.
For Students At CapsCode, we believe that coding is the language of tomorrow. Through engaging and industry-relevant courses, personalized mentoring, and hands-on workshops, we help students develop: Problem-solving skills: Preparing them for real-world challenges. Technical expertise: Equipping them with practical knowledge of coding and web development. Confidence in technology: Making them future-ready for careers in IT and beyond.
We foster an environment where students not only learn to code but also learn to innovate, collaborate, and think critically.
For Businesses CapsCode offers bespoke IT solutions tailored to the unique needs of businesses. From responsive web development to advanced digital marketing strategies, our services are designed to help companies grow their online presence and streamline their operations. Our key offerings include: Custom website and software development E-commerce platform creation Lead generation and digital marketing Professional email and Google Business setup
We act as partners in innovation, helping businesses leverage technology to reach new heights.
Our Mission Our mission is to empower individuals and organizations by bridging the gap between technology and accessibility. We aim to inspire a new generation of coders while helping businesses thrive in a competitive digital landscape.
Why Choose CapsCode? Over 9 years of IT industry expertise. A blend of education and professional IT services under one roof. A commitment to fostering growth, innovation, and success.
Join us in shaping the futureโwhether you're a student eager to unlock your potential or a business ready to embrace the possibilities of technology.
Learn. Build. Grow. With CapsCode.
Duplicate parameters in JavaScript Functions
Firstly we will see duplicating parameters in regular JavaScript function.
In non-strict mode, regular JavaScript functions allow duplicate named parameters
function Func (first, second, first){
console.log(first, second, first);
}
// first => 1
// second => 2
// first => 3
Func(1, 2, 3); // 3 2 3
// first => 1
// second => 2
// first => undefined
Func(1,2); //undefined [undefined, 2, undefined]
Lets check this in strict mode,
function Func(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 Errorto be thrown._
// Always throws a syntax error
const Func = (first, second, first) =>
{
console.log(first, second);
}
CONGRATULATOIONS, YOU HAVE LEARNET ONE NEW TOPIC TODAY. VISIT https://www.capscode.in/#/blog TO LEARN MORE...




![Difference between __proto__, [[Prototype]] & .prototype in JavaScript](https://cdn.hashnode.com/res/hashnode/image/upload/v1748159626406/69c8f1f2-2e84-4bd4-8abb-dc14ace2464a.png)

