let user = {
name: "John",
money: 1000,
[Symbol.toPrimitive](hint) {
alert(`hint: ${hint}`);
return hint == "string" ? `{name: "${this.name}"}` : this.money;
}
};
const methodName = 'bar';
const foo = {
[methodName](message) {
alert(message);
}
}
const foo = {
bar(message) {
alert(message);
}
}