How does the console window control JavaScript arithmetic assignment inside? Where does the return value come from?

I’ve been playing with JavaScript a lot more lately, and this course that I am taking has constantly emphasized the importance of knowing JavaScript from the inside out.

So, I have such a strange question, basically I'm just trying to figure out how JavaScript works inside.

Let's say I do the following calculation in the console:

>> x = 1
<  1
>> x = x + 2
<  3

"3", which returns to where it comes from for sure?

How does he first evaluate "x + 2" and then return 3 and set the x value in memory to 3? Or will it evaluate "x + 2", store it in memory x, and then return the value x from the same memory space?

Or maybe just change the value of x in your memory space without moving it, and then return the value of x?

I would also appreciate any source on how I could learn more about the inner workings of JavaScript to answer other questions like these.

Thank!

+4
source share
2 answers

If you have ever worked on a terminal system such as Unix, it would be easier to understand what is happening. Think of the console as a terminal bash. If you enter a command in the command line terminal and press the enter key, it will respond with an exit or several times even with an error.

Chrome. , Chrome, , . , .

, -

>> x = 1

, , , , x, window. , x = 1 window.x = 1. , .

, , .

0

, ,

>> x = 1
<  1
>> y = x = x + 2
<  3
>> x == y
<  true

. , , Javascript. , .

0

All Articles