gpt4 book ai didi

javascript - 什么时候 JavaScript 属性不是标识符?

转载 作者:行者123 更新时间:2023-11-30 08:45:03 26 4
gpt4 key购买 nike

我正在阅读这篇文章:http://yehudakatz.com/2011/08/12/understanding-prototypes-in-javascript/ .

下面的语句:

Just like when looking up properties, if the property you are definingis an identifier, you can use dot syntax instead of bracket syntax.For instance, you could say man.sex = "male" in the example above.

我在 JavaScript 中查找标识符,因为我对这个语句有点困惑,并找到了这篇文章:http://coderkeen.com/old/articles/identifiers-en.html .它说:

An identifier is regarded as a value which is unique in relation toall the other identifiers in a system.

及以后:

Javascript makes no exclusion and identifiers are used for:

Variable namesFunction namesNames of formal parameters of functions

如标题所示:

我什么时候会得到一个 JavaScript 对象的属性,它不是标识符,因此无法使用 . 语法访问?还是我误读了什么?

最佳答案

var someobject = {};
someobject["I'm a turtle"] = true;

I'm a turtle 绝对不是标识符!

关于javascript - 什么时候 JavaScript 属性不是标识符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22693437/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com