Advertisement
728x90
Object literals make it easy to quickly create objects with properties inside the curly braces. For example, it provides shorter syntax for common object property definition as below.
javascript
1//ES6
2
3var x = 10,
4 y = 20;
5
6obj = { x, y };
7
8console.log(obj); // {x: 10, y:20}
9//ES5
10
11var x = 10,
12 y = 20;
13
14obj = { x: x, y: y };
15
16console.log(obj); // {x: 10, y:20}Advertisement
Responsive Ad
🎯 Practice NowRelated Challenge
JavaScript Coding Exercise 61
Test your knowledge with this interactive coding challenge.
Start CodingAdvertisement
728x90
318of476