- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
- Related Articles
- Is it possible to change the value of the function parameter in JavaScript?
- How to set a default parameter value for a JavaScript function?
- How to check whether column value is NULL or having DEFAULT value in MySQL?
- Is it possible to instantiate Type-parameter in Java?
- Python - Get sum of tuples having same first value
- Does Java support default parameter values for a method?
- Is love at first sight possible?
- Is it possible to select text boxes with JavaScript?
- How to set default parameter values to a function in Python?
- What is a default value in Python?
- Replace null values with default value in Java Map
- Remove tuples having duplicate first value from given list of tuples in Python
- What is JSlint error "missing radix parameter" in JavaScript?
- Setting a default variable value to undefined in a function - JavaScript?
- Sorting an array object by property having falsy value - JavaScript

Advertisements