简体   繁体   English

javascript中的obj ['']是什么意思?

[英]What is meant by obj[''] in Javascript?

Toward the bottom of this javascript file , there is a line 此javascript文件的底部,有一行

return map[""];

where map is an associative array of objects with parent/child relationships. 其中map是具有父/子关系的对象的关联数组。 After calling map[""] the returned structure is a transformation into a hierarchical array. 调用map[""] ,返回的结构是到分层数组的转换。 What is really going on under the hood here and where is this syntax documented? 这到底是怎么回事,该语法在哪里记录? (It's hard searching for such empty strings on the net.) (很难在网上搜索这样的空字符串。)

It just reads the empty string property of map , just like how this: 它只是读取map的空字符串属性,就像这样:

map["a"]

is the same as 是相同的

map.a

However, you can't just do 但是,你不能只是做

map.

so that's why they do 这就是为什么他们这样做

map[""]

This is generated by the function find which ends when the strings become empty, which is why the final element will be found in map[""] . 这是由函数find生成的,该函数在字符串为空时结束,这就是为什么在map[""]找到最终元素的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM