

- 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
What are Rest parameters in JavaScript?
rest
ES6 brought rest parameter to ease the work of developers. For arguments objects, rest parameters are indicated by three dots … and precedes a parameter.With this, set indefinite number of arguments as an array, which areArray instances.
Example
Let’s see the following code snippet:
<html> <body> <script> function addition(…numbers) { var res = 0; numbers.forEach(function (number) { res += number; }); return res; } document.write(addition(3)); document.write(addition(5,6,7,8,9)); </script> </body> </html>
- Related Questions & Answers
- What are Rest parameters in JavaScript functions?
- What are default-parameters for function parameters in JavaScript?
- What are Default parameters in JavaScript?
- What are function parameters in JavaScript?
- What is the difference between default and rest parameters in JavaScript functions?
- What are default function parameters in JavaScript?
- What is the difference between rest parameters and the arguments object in Javascript?
- Effective Function Signatures with Default and Rest Parameters in JavaScript
- How to arguments object with Rest, default, and destructured parameters in JavaScript?
- What are named parameters in C#?
- What is “Parameters without defaults after default parameters in JavaScript”
- JavaScript Function Parameters
- What are different methods of passing parameters in C#?
- What are different Parameters available in Newman using Postman?
- Parameters & Arguments in JavaScript.
Advertisements