Preloader
Javascript
  • Estimated reading time: 1 Minute

Object Literal Property Value Shorthands, New feature of ES6

Object Literal Property Value Shorthands, New feature of ES6

There are many ways to declare an object in javascript and some people rather the literal way instead the declaration way, for example :

// We declare the variable MyAuto literal
var MyAuto = {type:"Fiat", model:"500", color:"black"};
// Remember that the spaces and line breaks are not important
var Another = {
    firstName:"John",
    lastName:"Doe"
};

var other = new Object(); // It supposed to slow down the code and make it more complex

Now in the new ECMASCRIPT6 a new notation is available, this allows to set properties to an object without define a key value structure, we would be writing them as an array, play and analize the following example :

As you can see, the literal variables are stored automatically as key-value in our object ,the computed values (the key is declared in a string variable) are also available and the new syntax of the declaration of a function inside the object (which is very similar to Coffescript), we don't need to write "key is equal to function".

The new ES6 brings many interessant features that you can learn and you can read them here.

Share:
Carlos Delgado

Carlos Delgado

Senior Software Engineer at Software Medico. Interested in programming since he was 14 years old, Carlos is a self-taught programmer and founder and author of most of the articles at Our Code World.

Related articles
JavaScript vs. Python for Data Analysis: Key Differences
30 Jan, 2026
  • Estimated reading time: 5 Minutes
Is Framevuerk Still Relevant in 2026?
3 Jan, 2026
  • Estimated reading time: 5 Minutes
The Best JavaScript i18n Libraries Compared
31 Oct, 2025
  • Estimated reading time: 8 Minutes
How to Build a Simple Photo Editor in the Browser with JavaScript
14 Sep, 2025
  • Estimated reading time: 5 Minutes
Weekly trending
Our Sponsors

Our blog is proudly supported by industry-leading sponsors.