Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Operator precedence for JS spread and rest operators?

I'm curious what the precedence of the Spread and Rest operators are in Javascript: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator

I was trying to find them on MDN's Operator Precedence table (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence#Table) but unless they are a subcategory of an existing operator type, I don't see them. I couldn't find any other obvious documentation about it.

like image 512
Scotty Waggoner Avatar asked Feb 07 '18 05:02

Scotty Waggoner


Video Answer


1 Answers

Spread syntax is not an operator and therefore does not have a precedence.

It is part of the array literal and function call (and object literal) syntax.

Similarly, rest syntax is part of the array destructuring and function parameter (and object destructuring) syntax.

like image 60
Bergi Avatar answered Oct 24 '22 10:10

Bergi