HACKER Q&A
📣 bbby

Console.log Output


can someone explain why the console.log output is not all zeros? Why the async process?

` result = [[0,0],[0,0]]; console.log(result); result[1][0] = 99 `

Using console in Chrome DevTools, the output is: '[[0,0],[99,0]]'

Expected output is: '[[0,0],[0,0]]'


  👤 firebaze Accepted Answer ✓
This is because the object is dumped as a whole. If you could halt the browser directly after the console.log, you'd see your expected output. Then execution continues, the content gets mutated and the browser refreshes its object view with the current contents.