ES6 - Accessing properties

0 votes
377 views
added Feb 27, 2019 in ES6 by LC Marshal Captain (25,790 points)
let numbers = [1,2,3,4];
let [first,second,yerra,fourth] = numbers;
console.log(first,second,yerra);
//output 1 2 3

 

2 Responses

0 votes
responded Feb 27, 2019 by LC Marshal Captain (25,790 points)
let property  = ['ahmad','selangor',4456,'commercial area'];
let [name,state,agentid,proptype] = property;
console.log(name);
// output "ahmad"

 

0 votes
responded Feb 27, 2019 by LC Marshal Captain (25,790 points)
let property  = ['ahmad','selangor',4456,'commercial area'];
let [name,state,...theRest] = property;
console.log(theRest);
//output [4456, "commercial area"]

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...