InterviewHubPRO
Section Overview
Q322

Question 322 of 521

Part 5: ES6+ Modern Syntax, Classes, Modules & Destructuring (254 - 328)

62%
JavaScript Internals (521 Qs)•Part 5: ES6+ Modern Syntax, Classes, Modules & Destructuring (254 - 328)

What are enhanced object literals

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
  //ES6
  var x = 10,
    y = 20;
  obj = { x, y };
  console.log(obj); // {x: 10, y:20}
  //ES5
  var x = 10,
    y = 20;
  obj = { x: x, y: y };
  console.log(obj); // {x: 10, y:20}