Here is my returned array:
>0: RectangularNode {children: Array(0), position: {…}, size: {…}, strokeWidth: 0, selected: true, …}
[Directly captured from the browser]
When expanded above array I have:
>0: RectangularNode args: {radiusBottomLeft: 5, radiusTopLeft: 5, radiusTopRight: 5, radiusBottomRight: 5} canConnect: (routable, role) => {…} children: [] direction: "XX" features: Set(10) {…} hoverFeedback: true id: "_1234HGGD554" isContainableElement: element => {…} **name: "wstchieve"** opacity: 1 parent: GLSPGraph {children: Array(2), canvasBounds: {…}, scroll: {…}, zoom: 1, position: {…}, …} position: {x: 370, y: 130} selected: true size: {width: 128, height: 128} strokeWidth: 0 type: "signal" anchorKind: (...) bounds: (...) incomingEdges: (...) index: (...) outgoingEdges: (...) root: (...) [[Prototype]]: SNode
Here my requirement is to fetch only the name property inside of the array object and store it in the variable.
Please suggest how can I achieve this in Javascript.
CodePudding user response:
Blockquote
Loop your array and try
for (var index = 0; index < yourarray.length; index ) {
console.log("name=" yourarray[index].name);
}enter code here
CodePudding user response:
I think it would be nice to have some code to actually look at I'm not fully understanding your question. But i guess you just need to find the index you need? maybe something like this ?
var oObject = {} ;
oObject["aaa"] = "AAA" ;
oObject["bbb"] = "BBB" ;
oObject["ccc"] = "CCC" ;
oObject["ddd"] = "DDD" ;
oObject["eee"] = "EEE" ;
var strName, strValue ;
for(strName in oObject)
{
strValue = oObject[strName] ;
alert("name : " strName " : value : " strValue) ;
}
CodePudding user response:
you can use Object.keys(responseData)
if you need only object property .
if you need both keys and values use Object.entries(responseData)
.