简体   繁体   English

获取对象属性的长度,该对象属性是对象数组的属性

[英]Getting length of an object property which is a property of an array of objects

So, I want to get the length of an object property which is a property of an array of objects. 因此,我想获取对象属性的长度,该对象属性是对象数组的属性。

I want to get the length of actionDetails . 我想获得actionDetails的长度。

I tried the following: message[0].actionDetails[0].length; 我尝试了以下操作: message[0].actionDetails[0].length; but this is resulting in undefined. 但这导致未定义。

The data goes like this: 数据如下:

message=   [  
       {  
          "data":"1",
          "actionDetails":[  
             {  
                "type":"action",
                "url":"http:\/\/localhost\/app\/dashboard"
             },
             {  
                "type":"action",
                "url":"http:\/\/localhost\/app\/dashboard"
             },
             {  
                "type":"action",
                "url":"http:\/\/localhost\/app\/dashboard"
             }
    ]

I tried the following: message[0].actionDetails[0].length; 我尝试了以下操作:message [0] .actionDetails [0] .length; but this is resulting in undefined. 但这导致未定义。

Almost there, you don't need to get 0 th index of the array first whose length you are looking for 几乎在那里,您不需要先获取要查找其长度的数组的第0个索引

message[0].actionDetails.length;

暂无
暂无

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

相关问题 按一个对象属性的长度对对象数组进行排序 - Sorting an array of objects by length of one object property 获取具有给定属性的最大数组长度的对象 - Getting an object with maximum array length for a given property 按属性长度排序对象数组 - Sort array of objects by property length 对象数组的对象。 获取具有相同属性的所有值的长度 - Object of array of objects. Get the length of all values with the same property 如何根据 object 属性(即数组)对对象数组进行排序 Javascript - How to sort array of objects based on object property (which is Array) Javascript JavaScript中的哪些对象具有.length属性? (又名为什么Underscore _.each将我的函数对象视为数组?) - Which Objects in JavaScript have a .length property? (aka Why does Underscore _.each treat my Function Object like an Array?) 我有一系列对象,这些对象的长度根据所选城市而异。 如何选择持有具有特定属性的对象的元素? - I have an array of objects with varying length based on selected city. How to select the element which hold an object with certain property? 对象数组,用于累积另一个属性相同的所有对象属性 - Array of objects to accumulate all object properties for which another property is the same 如何将对象的属性与对象数组的属性匹配? - How to match a property of an object to a property of an array of objects? 如果一个属性等于另一个 object 的属性,如何过滤位于对象数组中的 object 的少数属性 - How to filter few properties of an object which is in Array of objects if one property equals property from another object
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM