搜索引擎会忽略[ ] "__,所以我无法得到答案。我参加了一个测试,发现他们的结果是一样的,但我是一个js新手,我不知道他们是如何平等的。
发布于 2022-04-17 10:45:39
fromCharCode 'lives‘作为String对象的静态方法。这样的方法有一个键和一个值,可视化的:{fromCharCode: function() {...}}。您可以直接使用它的键String.fromCharCode或‘括号’样式的String['fromCharCode']检索(访问)方法。这对所有对象都是正确的。
当键包含特殊字符时,括号表示法可能有用,请参阅片段。
const someObj = {
dotNotation: 'hello world',
'non dot Notation': 'hello world you too',
};
console.log(someObj.dotNotation);
// the last property can not be retrieved with dot notation
// console.log(someObj.non dot Notation);
// so
console.log(someObj['non dot Notation']);
https://stackoverflow.com/questions/71901100
复制相似问题