# Spread vs Rest Operators in JavaScript

> Spread and Rest operators both uses triple dot(...) but what's the difference in both Let's Understand it in this blog

## Spread Operator

![](https://cdn.hashnode.com/uploads/covers/695fd39dab4430d734c14156/9518833a-9731-48ba-bf91-24437ffb876e.png align="center")

Spread operator means as it's word say spread means expanding , like this also spread operator expands the values,it shows multiple values of array or objects,also it used for creating data

It is used right side of the assignment operator

```javascript
let nums = ...nums;
OR
let sum = fn(){};
fn(...nums);
```

It is like getting out the values from a collection, means individuals value comes together and form a collection,it passes individually values to a function

## Rest Operator

![](https://cdn.hashnode.com/uploads/covers/695fd39dab4430d734c14156/2a3e1b2f-7802-4024-9367-e128371c4c76.png align="center")

rest operators are opposite of spread operator it makes a single collection in which all the values are given.

```javascript
function(...nums){};
```

It passed in function argument as a single collection of all values

## Spread Operator VS Rest Operator

![](https://cdn.hashnode.com/uploads/covers/695fd39dab4430d734c14156/1f4b343b-ca90-48b7-b681-6e31641b93bb.png align="center")
