ES6
var key = "name"; var person = {[key]:"John"}; console.log(person); // should print Object { name="John"}
Before ES6
var person = {}; var key = "name"; person[key] /* this is same as person.name */ = "John"; console.log(person); // should print Object { name="John"}