DEV Community

Enhanced Object Literals in ES6

Sarah Chima on November 01, 2017

Object literals make it easy to quickly create objects with properties inside the curly braces. To create an object, we simply notate a list of key...
Collapse
 
giliyoffe profile image
giliyoffe • • Edited

Thank you Sarah, I Liked it

typo:
think u meant to write es6 and not 5 in:

"
...
//ES5
function getLaptop(make, model, year) {
return{
sayModel() {
return model;
....
"

Collapse
 
sarah_chima profile image
Sarah Chima •

Thank you for the correction. 😊

Collapse
 
niralekshitij profile image
kshitij nirale • • Edited

hey Sarah,
don't you think it's time you should update this informative article with functioning of 'this'
keyword inside new es6 method declaration inside objects.

Collapse
 
aydinakcasuatquickenloans profile image
aydinakcasuAtQuickenLoans •

You could throw in a count, and the name, in case you want to iterate by index.

{
[name + ++i]: "Apple",
[name + ++i]: "Dell",
[name + ++i]: "HP",
count: i,
name
}

Collapse
 
captainwiseman profile image
CaptainWiseman •

Thanks! It was a great read!

Collapse
 
jejuro profile image
Jupeter •

Thank you, Sarah

Good reading

Collapse
 
rifaimartin profile image
Rifai Martin •

thanks sarah

Collapse
 
nahid570 profile image
Nahid Faraji •

Thank you so much

Collapse
 
sayopaul profile image
Sayo Paul •

awesome post. Really really explanatory . Good examples that further explain the concepts discussed . Excellent !

Collapse
 
ibadeecodes profile image
Ibad Ullah Shaikh •

Thanks Sarah for sharing such a good stuff..

Collapse
 
malib profile image
Ali •

I liked it but i did not get the advantage of computed properties. It looks weird to me :(