I want to store object property value inside the array .I have objects inside a object .I need to store skey property inside the array.But I tried like this
var obj ={
aa:{
name:"test"
},
bb:{
name:"test",
skey:"ctr+d"
},
cc:{
name:"test",
skey:"ctr+m"
},
dd:{
name:"test"
}
}
var newArray=[]
for (var key in obj) {
// skip loop if the property is from prototype
var ob = obj[key];
for (var prop in ob) {
// skip loop if the property is from prototype
if(ob.hasOwnProperty('skey')){
newArray.push(ob.skey)
}
}
}
console.log(newArray)
https://jsfiddle.net/x4ra3yso/3/ It add dublicate item in array .
My expected outtput is this
**['ctr+d','ctr+m']**