Syntax error What is the difference between rest parameters and the arguments object in Javascript?

What is the difference between rest parameters and the arguments object in Javascript?



Rest parameters

With rest parameter, you can represent a number of arguments as an array. ES6 brought rest parameter to ease the work of developers. For arguments objects, rest parameters are indicated by three dots … and precedes a parameter.

Arguments object

Arguments object in JavaScript is an object, which represents the arguments to the function executing.

Here is the difference between rest parameters and the arguments object.

  • Arguments object includes all arguments passed to the function, whereas rest parameters are those, which are not given another name.
  • The rest parameters are Array instances, whereas arguments object isn’t an array. Array instances are the following methods: map, sort, pop, etc
Updated on: 2020-06-16T08:03:52+05:30

758 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements