I'm trying to get a better understanding of how JavaScript is executed in a web browser environment.
In terms of Node.js, I understand that the JavaScript code written in a Node.JS program is compiled with C++ code (V8), and ultimately becomes machine code. Since Node.js can interact with the filesystem and other machine level tasks, to me it makes sense why it has to eventually become machine code.
I feel differently about the web browser environment. From my understanding, the main goal is to interact with the DOM. Does JavaScript need to be compiled into machine code to just interact with the DOM?
I'm puzzled by this. Node.js and Chrome both run on V8. V8 is written in C++ and to my knowledge, compiles JavaScript code into machine code a processor can understand.
You need a JavaScript engine to implement ECMA-262, that is the whole purpose of an engine (I think?). But, does a web browser need JavaScript to be compiled to a Machine Language Level, what machine operations is it performing?
Here are a few articles I've researched, unfortunately, I haven't found an answer to my question in them: