Ensure that you can run the following commands:
Create a directory for your code:
Add a simple log statement in a new js file:
Execute the JavaScript using NodeJS:
Enjoy free content straight from your inbox 💌
00:00
A key reason for the success of JavaScript is the fact that it is the language of the web, which means that you don't necessarily even need to set up for it. You can just stop playing around with it in your browser. For example, within Chrome you can click the Triple Dots hidden way up over here on the side, select more tools and then select developer tools. It's a good idea at this point to also memorize the shortcut. For this, for my particular operating system, it is Option Command I. Now this will open up the developer tools and one of the features of all of these developer tools is the console. This is where you can enter some arbitrary JavaScript and execute that within
00:35
the context of the currently open page. So let's use JavaScript's built-in console log function, and pass in a simple string like Hello World. The browser will execute the JavaScript and no surprise we see Hello World on the console. Now of course, if you are thinking of doing JavaScript professionally, we are going to need a more professional developer setup. The first thing that we will install is a node jss and you can simply head on over to nodejs.org. You can download straight from the homepage or go into downloads for the current version and then select the download that is appropriate for your operating system.
01:09
Mac as various windows come with the very nice installers that will guide you through the whole installation process. Once we have it installed, we can verify it quite easily by opening up the terminal or the command prompt and then executing node passing in a minus minus version. This will log the version of the node jss that is currently installed. Now Node JSS also comes with additional boundaries called N P M and N P X N P M is used to install packages and N P X is used to execute various scripts and it's good to make sure that they are available on the terminal as well. Now the specific versions of Node N P M and N P X doesn't really matter because
01:45
they have been very stable for a number of years at this point. So any version that you have will be fine. Now the next step is to install a nice I D E, and for that I recommend Visual Studio Code. It is a free open source i d e from Microsoft and it is available for all the popular platforms. Head on over to code do visual studio.com. From here, you can go into the download section and grab an installer specific for your oss once you have it installed and boot it up for the first time. You can see some nice walkthroughs on your right hand side that you can use to
02:19
learn more about this i D E. Now that we have our I D E and node JS setup, let's just create a very basic hello world application and execute it through Node jss. Now, running a code through no JS allows us to think about JavaScript in isolation without slowing us down with concepts that we do not need when we are simply trying to master JavaScript by itself. So we create a nice folder for all of the code that we will be working with. And then once we have this directory, we see the into it and open it up within Visual Studio Code, let's create a first JavaScript file.
02:52
We will call this index js and it is conventional to call the entry point of our application as index. And Within that we write that same sample statement that we saw before, which is console log. Hello World. Now we can execute this code from node JS by opening of the terminal, executing the node command and this time passing in the path to the file that we want to execute, which of course is index jss. This executes the code through node and outputs the result, and of course we see what we would expect, which is that string. Hello, world. Now that we have our I D E and Node J set up and verified,
03:27
we can start playing around with more and more JavaScript language features.