I'm trying to turn the values of an array inside an object to a normal array.
Right now I'm doing something like this in my AJAX success function:
var obj = data
console.log(obj)
var array = Object.keys(obj)
.map(function(key) {
return obj[key];
});
console.log(array)
This is what I get in my console:
{jaar: Array(2)}
jaar: Array(2)
0: YEAR(Scan): "2020"
[[Prototype]]: Object
1: YEAR(Scan): "2021"
[[Prototype]]: Object
length: 2
[[Prototype]]: Array(0)
[[Prototype]]: Object
I want to have something simply as this
["2020", "2021"]
How can I achieve this and what am I doing wrong right now?
console.log(obj) at the start gives this output in the console:
jaar: Array(2)
0: {YEAR(Scan): '2020'}
1: {YEAR(Scan): '2021'}
length: 2
[[Prototype]]: Array(0)
[[Prototype]]: Object ```
objvariable contain?Object.values(obj.jaar)? developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…