Setting up your environment for JavaScript development

Choose a JavaScript runtime

In order to run example scripts on your machine you will first need a JavaScript runtime. There are a few different options, such as: NodeJS and Deno.

NodeJS has been around longer and is more widely used.

Deno was created by the same creator as NodeJS (Ryan Dahl), taking on-board a lot of lessons learned from NodeJS. Many people believe that this will be a successor to NodeJS. Deno is my preference due to its inbuilt TypeScript support, TypeScript is a powerful language that introduces a powerful Typed system to JavaScript. Once you have learnt JavaScript, I highly recommend learning TypeScript.

For the purposes of this course it does not matter which you choose as the topics covered will be pure JavaScript not applicable to one runtime in particular.

Getting started with NodeJS

Download the latest copy of NodeJS from the official website here.

In order to run a JavaScript file, you will be using the following command from the terminal:

node main.js

Getting started with Deno

Download the latest copy of Deno from the official website here.

In order to run a JavaScript file, you will be using the following command from the terminal:

deno run main.js

Choose a JavaScript editor

There are many options available.

I recommend Visual Studio Code (not to be confused with Visual Studio,) as this is currently the most used by JavaScript developers. It is free and has a huge number of third-party extensions to improve developer quality of life with a number of different frameworks, languages and workflows.

Run your first JavaScript application

Create a new file called main.js and add the following line of code:

console.log("hello world...");

This line of code will output the string hello world... when it is executed.

Use your chosen runtimes command from above to run your own file to ensure you have things running ok. This will be very useful as it will allow you to copy other examples from other sections in this guide to your main.js file or other files with a .js extension and run them yourself. I highly recommend playing with the JavaScript yourself to gain some practical experience.