- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Is having the first JavaScript parameter with default value possible?
You can use destructed array in this case.
Example
function multiply(firstParameterDefaultValue=10, secondParameterValue) { return firstParameterDefaultValue * secondParameterValue; } console.log("The result="+multiply(...[,10]));
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo173.js.
Output
This will produce the following output −
PS C:\Users\Amit\javascript-code> node demo173.js The result=100
Advertisements