简体   繁体   English

这些是子属性吗? 正确的术语是什么?

[英]Are these subproperties? What is the correct term?

I have a question over terminology. 我对术语有疑问。 In JavaScript, I have an array made up of properties that are themselves objects, delimited by braces. 在JavaScript中,我有一个由属性组成的数组,这些属性本身就是对象,由花括号分隔。 Would the properties of the object properties of the array object be the array's subproperties? 数组对象的对象属性的属性是否是数组的子属性? Is there a specific term for this? 为此有一个特定的术语吗?

Here's an example: 这是一个例子:

 var arrayObject = [
      {subproperty1: ["value1", "value2", "value3"], subproperty2: value}, 
      {subproperty1: ["value4", "value5", "value6"], subproperty2: value},
      {subproperty1: ["value7", "value8", "value9"], subproperty2: value},
 ];

If I use the Object.keys function to get the property names of arrayObject, the property names are the index values--0, 1, 2. 如果我使用Object.keys函数获取arrayObject的属性名称,则该属性名称是索引值--0、1、2。

 console.log(Object.keys(arrayObject)); // ["0", "1", "2"]

Would the properties of the objects 0, 1, and 2 that are the properties of arrayObject be defined as the subproperties of arrayObject? 是否将对象0、1和2的属性(即arrayObject的属性)定义为arrayObject的子属性? I just want to be terminologically accurate. 我只是想在术语上准确。

not really. 并不是的。 also I would not say that an array is made up of properties but contains elements . 我也不会说数组是由属性组成包含元素的 Objects have properties, arrays have elements. 对象具有属性,数组具有元素。

subproperty as a term sounds strange. 子财产一词听起来很奇怪。 I don't think there is a term for what you want, also consider that theese objects may have properties that are other objects. 我不认为您想要的是什么,也不要认为这些对象可能具有其他对象的属性。

I would describe your structure as an array with elements where each element has the properties subproperty1 and subproperty1 . 我将您的结构描述为带有元素的数组,其中每个元素都具有属性subproperty1subproperty1

Also consider that not every object in an array must have the same properties. 还应考虑并非数组中的每个对象都必须具有相同的属性。

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

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