var username="zhangsan",age=78;
const add="plus";
var obj={
username,
age,
[add]:function(){
console.log("加法");
}
};
obj.plus();
obj.add();
let a = {
x:1,
y:2
}
a.x === a['x']
因为你下面方法名改成plus了
你的写法变成了es6中属性表达式,详情可参照阮一峰的这篇文章
https://www.bookstack.cn/read/es6-3rd/spilt.2.docs-object.md