Answer the question
In order to leave comments, you need to log in
How to put object values into an array?
Hello, I have an array like this:
const arr = [
{
value: 'aaa'
},
{
value: 'bbb'
},
{
value: 'ccc'
},
{
value: 'ddd'
},
]
const arr2 = ['aaa', 'bbb', 'ccc', 'ddd'];
for (let el of arr) {
this.arr2.push(el.value);
}
ERROR TypeError: Cannot read property 'push' of undefined
at SafeSubscriber._next (main-graph.component.ts:87)
at SafeSubscriber.__tryOrUnsub (Subscriber.js:183)
at SafeSubscriber.next (Subscriber.js:122)
at Subscriber._next (Subscriber.js:72)
at Subscriber.next (Subscriber.js:49)
at TakeSubscriber._next (take.js:35)
at TakeSubscriber.next (Subscriber.js:49)
at TakeSubscriber._next (take.js:35)
at TakeSubscriber.next (Subscriber.js:49)
at MapSubscriber._next (map.js:35)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question