Thursday, December 11, 2025
HomeLanguagesJavascriptShorthand Syntax for Object Property Value in ES6

Shorthand Syntax for Object Property Value in ES6

Objects in JavaScript are the most important data-type and forms the building blocks for modern JavaScript. These objects are quite different from JavaScript primitive data-types (Number, String, Boolean, null, undefined, and symbol) in the sense that while these primitive data-types all store a single value each (depending on their types).

The shorthand syntax for object property value is very popular and widely used nowadays. The code looks cleaner and easy to read. The shorthand property makes the code size smaller and simpler.

Example: This example displaying the details of object using shorthand Syntax for object property value in ES6.




// Object property shorthand
const name = 'Raj'
const age = 20
const location = 'India'
  
// User with ES6 shorthand
// property 
const user = {
    name,      
    age,
    location
}
  
console.log(user) 


Output:
Output of above command

Example: This example displaying the details of the object without using shorthand Syntax for object property value.




// Object property shorthand
const name = 'Raj'
const age = 20
const location = 'India'
  
// User without ES6 
// shorthand property 
const user = {
    name: name,      
    age: age,
    location: location
}
  
console.log(user) 


Output:
Output of above command

RELATED ARTICLES

Most Popular

Dominic
32440 POSTS0 COMMENTS
Milvus
105 POSTS0 COMMENTS
Nango Kala
6811 POSTS0 COMMENTS
Nicole Veronica
11950 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12023 POSTS0 COMMENTS
Shaida Kate Naidoo
6943 POSTS0 COMMENTS
Ted Musemwa
7194 POSTS0 COMMENTS
Thapelo Manthata
6889 POSTS0 COMMENTS
Umr Jansen
6880 POSTS0 COMMENTS