

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 Questions & Answers
- 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?
- Python - Get sum of tuples having same first value
- Is love at first sight possible?
- Is it possible to instantiate Type-parameter <T> in Java?
- Is it possible to select text boxes with JavaScript?
- Does Java support default parameter values for a method?
- Remove tuples having duplicate first value from given list of tuples in Python
- What is the default type of a hexadecimal value in MySQL?
- What is the default value of a local variable in Java?
- How to retrieve a value with MySQL count() having maximum upvote value?
- Changing the Default Display Value using CSS
- Display the result with not null value first and then with null value in MySQL
- Sorting an array object by property having falsy value - JavaScript
Advertisements