Object Property Value Shorthand in JavaScript with ES6

New in JavaScript with ES6/ES2015, if you want to define an object who's keys have the same name as the variables passed-in as properties, you can use the shorthand and simply pass the key name.

Hereโ€™s how you can declare an object with the new ES6 / ES2015 syntax:

let cat = 'Miaow';
let dog = 'Woof';
let bird = 'Peet peet';

let someObject = {


//  cat: "Miaow",
//  dog: "Woof",
//  bird: "Peet peet"

And hereโ€™s how to do the same thing with the older ES5 syntax:

var cat = 'Miaow';
var dog = 'Woof';
var bird = 'Peet peet';

var someObject = {
  cat: cat,
  dog: dog,
  bird: bird
  Tweet It

๐Ÿ•ต Search Results

๐Ÿ”Ž Searching...

Sponsored by #native_company# โ€” Learn More
#native_title# #native_desc#