Destruct object in javascript es6 when keys are integer

I know when we have an object like

var obj = {a: "apple", p: "pen"};

then we can destroy it like var {a, p} = obj; /* a = 'apple', p = 'pen' */

if the keys are integer var obj = {0: 'pineapple', 1: 'pen'};

since we cannot declare integers as a variable name, how to destroy it?

+4
source share
1 answer

Like any other assignment of new variable names

var {0:a, 1:b} = obj;
+9
source

Source: https://habr.com/ru/post/1663808/


All Articles