0

Could you please help me understand why 4 is pushed inside the arr (inside the brackets), while the pushed object is logged outside of the arr brackets?

const arr = [1, 2, 3];
arr.push(4);

fetch('https://jsonplaceholder.typicode.com/todos/')
  .then(data => data.json())
  .then(item => {
    item.forEach(entry => arr.push(entry));
  });

console.log(arr);

Object outside, 4 inside

Edgar
  • 1
  • 1

0 Answers0