Now REPL stands for Read Evaluation Print Loop, and it basically allows you to execute code in bite sized
chunks, just like what we did with the Chrome Developer Tools Console inside Chrome.
We were able to write a single line of code and then hit enter and it would run that line of code and
then we could run another line of code etc..
So by installing Node, we also installed the Node REPL, and to access it all we do is write the command
node inside the command line and hit enter.
And once you see that little angle bracket, then you know you're inside the REPL.
So here we can write code directly.
So for example, I could write console.log
(“Hey there!”), and if I hit enter then it will execute it straight away.
And we should be pretty familiar with this already, as it works pretty much the same as our Chrome Console.
So we can also execute other bits of code, for example 3 + 5 equals 8, or “Angela “ +
“Yu” will be my name, Angela Yu, as a string.
And it's also got short cuts, like, for example, if we didn't feel like writing out the entirety of console.log
we can write con, tab,
and if one tab doesn't give you any results, you can tab again and that will give you all the possible
commands that you can use
at this point.
So you can use console, constructor, continue.
So we want console.
So console, and then we can write dot and I tap twice,
then I can see all of the different possibilities. Now
sometimes, while you're working in the command line, one of the most difficult things can be figuring
out how to exit the process that you're currently in.
Now, in order to exit the REPL, you can either say .exit and hit enter, or you can simply hit Control
C twice. And in a lot of cases in the future, when we're running servers, or when we’re starting processes, Control C
will usually get out of any process that you're running at that time.
And if you wanted to clear your console, you can simply just write clear, and it will delete all of the
previous commands.
Now that was a little brief intro into what you can do using the Node REPL.
Now in the next lesson, we're going to look at how you can use some native node modules, so packages of
code, that's been bundled into Node that we can use to make our lives easier and to perform some really
simple functionality.
So for all of that and more, I'll see you on the next lesson.