The following code:
const [ ...routes, currentRoute ] = props.routes
Produces an unexpected token
error on such line.
Why is this?
You can use rest operator only at the end of the destructuring expression, eg:
const [ currentRoute, ...routes ] = props.routes.reverse()
It is stated in ECMAScript 2015 Spec.#Destructuring Assignment , it could be hard to read but look at ArrayAssignmentPattern
structure.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.