Start here.
A program is a set of instructions for a computer. JavaScript is one way to write those instructions. Source code is the text you read; an engine is the software that reads that text and carries out its meaning. The engine works through statements in order unless an instruction changes that order. A blank line helps a human reader but does not perform an action. A semicolon marks the end of a statement; modern JavaScript can often insert one automatically, but writing it makes the boundary visible here.
The line const answer = 6 * 7; has three pieces. const creates a named place called answer for a value. The equals sign assigns the result of the expression on its right; it is not a mathematical claim that both sides are always equal. The star means multiplication, so the right side becomes the number 42. The next line, console.log(answer), asks the console to display the current value of answer. Parentheses pass information into a function call, and the dot in console.log selects the log function from console.
You can read the examples without running anything. Code blocks show what a program would do, and the explanation follows the value through each line. When later chapters mention a browser, think of it as the program that displays a web page. Node.js is a different environment that can run JavaScript outside a browser. The same language rules apply in both, while the tools each environment provides can differ.
Build the model.
JavaScript describes computations. An engine reads those instructions and performs them. The browser or Node.js supplies the surrounding world: timers, network requests, files, and the document are host features, not the language itself.
This distinction explains why the same expression works in many places while document.querySelector only works where a document exists. When you meet a new API, ask whether it belongs to JavaScript or to its environment. That question tells you where to look for its rules.
How it works.
Start with a plain expression such as 6 * 7. The JavaScript engine parses the source, applies the multiplication rule to two number values, and produces 42. No page, file, or network connection is needed for that rule. To see the result, however, the program needs a way to communicate with the outside world. console.log is one such capability, made available by the host.
A browser host supplies document, window, fetch, and timers. Node.js supplies its own globals and APIs, including access to files. Both run JavaScript, but they offer different surroundings. Before using a name you did not define, identify its owner. This keeps you from treating a browser API as though it were available in every JavaScript program.
Read it line by line.
const answer = 6 * 7;
console.log(answer);First notice. The multiplication is language behavior. The console is supplied by the environment.
The first line creates a binding named answer. The right side is evaluated before the binding receives the result: 6 and 7 are numbers, so * produces the number 42. On the next line, answer is read and passed to console.log. The console call displays the value; it does not change the multiplication or turn answer into text in your program.
See the rule again.
const total = 10 + 5;
console.log(total);total holds the number 15. The addition and binding are language behavior. The host provides console.log so the value can be displayed. In a browser you can paste this into DevTools; in Node.js you can put it in a .js file and run node file.js.
One thing to remember.
Language rules describe values and operations; hosts provide capabilities.