javascript - When you use a string variable to set a properties name why would it ever use the name of the variable itself instead? -
this question has answer here:
we using new ecmascript stuff don't know if that's what's going on. do:
var key = "foo"; var obj = { key: "abc" };
and created , obj.key property instead of obj.foo property.
that's property name, not expression can variable.
in es6, can make expression:
var obj = { [key]: "abc" };