In this video, we will revisit our REPL and try to access the variables and functions that we had declared in the video contained in the previous segment and see what happens.
You saw that when we tried to access the variable name or the function foo, we got a reference error. This was because the variable name and the function foo did not exist in the memory heap, as the variables are stored for the current session only and the contents of the memory heap last only for the current session.
In the next video, let's see how you can persist your code.
In the last video, you saw how you can save your code inside a Node file and then execute it using the following command on your Terminal inside the Visual Studio Code:
node <file_name>.js
(Do not write the angular brackets.)
Remember that the extension of the file in which you write Node.js code is .js. You can omit writing this extension with the node command. The command for the same will be:
node <file_name>
(Do not write the angular brackets.)
Writing code in files definitely helps you save your code for later, deploy your code to the production and share it with other developers.
Downloads: