I have an object and need to get an array for each keys and values. I used Object.keys (also tried Object.getOwnPropertyNames()) and Object.values() but both returned zero length array. I confirmed that the object does has values in it.
Below codes worked fine in jFiddle, but returned zero length array for Object.keys and Object.values calls on my environment. Working jFiddle here: https://jsfiddle.net/ca2xL0bf/
My environment: Eclipse Neon, Tomcat 8.5. Browser: Tested on both Chrome and IE11.
What could be wrong with the code or environment specific?
Thanks,
Alex
function countPLines(data){
var pl = data.split(',');
pl.forEach(function(entry){
pLines[entry] = (pLines[entry] || 0) + 1;
});
}
function createChartData(){
console.log(pLines);
console.log(Object.keys(pLines));
console.log(Object.values(pLines));
}
var pLines = {};
var data = ['a', 'b', 'c,a,b', 'a,b'];
data.forEach(function(ele) {
countPLines(ele);
});
createChartData();