U
U
user_of_toster2021-07-18 10:46:20
JavaScript
user_of_toster, 2021-07-18 10:46:20

Why is control flow different in browser and node?

The code

'use strict';

function mutator(obj) {
  obj.someProp = 0
};

const A = {a: 3};

console.log('before', A);
mutator(A);
console.log('after', A);


Result in browser:
before {a: 3, someProp: 0}
after {a: 3, someProp: 0}


Result in node:
before { a: 3 }
after { a: 3, someProp: 0 }


Why does browser code run asynchronously?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2021-07-18
@user_of_toster

That's right. When you "expand" an object in the browser, it mutates to the current state (there is even a mark next to it).
60f3de1685db2530525583.png

I
Ivan Shumov, 2021-07-18
@inoise

They both run asynchronously. Nobody said that the order of asynchronous operations will be the same) we must not forget that node is not js, but a virtualization environment

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question