What are Object Literals? | ES6 Guide

Object literals are used to create an object in javascript. Enhancement in Object literals in ES2015 (ES6) release has made it a more powerful feature.

  • The object in javascript can be initialized by directly using the variable name. See Example 1 below.
  • Object’s method in ES5 requires function statement. This is no longer required in ES6, you can directly return statement. See Example 2 below.
  • Object literals key in ES6 can be dynamic. Any Express can be used to create a key.


There are three ways of creating an object in javascript.

  • Using Object literals
  • Using new keyword.
  • By defining object constructor and then create an object constructor type.

Let’s take a look at this example to see the working of Object literals.

Object Literals Without ES6 ( ES5 Supported )

# Example 1 

Object Literals with ES6

# Example 1

If you want to learn others concepts of ES6 please check out this, comprehensive guide to learn ES6.

Give some clap if you liked the article !!


Written by

SDE | Ex-FrontBench | Blogger. I write about Startup, Self-Improvement, JavaScript, React and Node.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store