Are you first timer at lazacode.org? Why not join us and start exchange your programming knowledge with everyone. Register today!

ES6 - Accessing properties

0 votes
8 views
added Feb 27 in ES6 by LC Marshal Captain (20,510 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 by LC Marshal Captain (20,510 points)
let property  = ['ahmad','selangor',4456,'commercial area'];
let [name,state,agentid,proptype] = property;
console.log(name);
// output "ahmad"

 

0 votes
responded Feb 27 by LC Marshal Captain (20,510 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.
...