Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
//Enhanced object literals
var name = 'chuck', age = '24';
var person = {
name : name,
age : age,
hi : function() {return 'hi';}
var person = {
name, age, hi() {return 'hi';}
var rand = Math.random();
var obj = {};
obj[rand] = 'value';
var obj = {[rand]: 'value'};
// Object {0.2180616082623601: "value"}
var obj2 = {[Math.ramdom()]: 'value'};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment