How to Run Modern JavaScript
Explore how to execute modern JavaScript code efficiently across different environments. Learn to use Node.js for running scripts and REPL for quick experiments. Understand how browser consoles aid in development and how Babel transpiles code to support various browser versions, ensuring compatibility and ease of testing.
JavaScript has evolved considerably, but the runtime engines are still catching up. Different browsers have varied support for the newer versions of JavaScript’s different features.
Here are a few options for running JavaScript in general and, in particular, to practice.
Run in Node.js
The easiest way to practice the code is in Node.js. Versions 8.5 and later support most of the latest features. This course will guide you along where necessary if you need to use a command-line experimental option or an additional tool.
Installing Node.js
First, verify that Node.js is installed on your system. Point your browser to https://nodejs.org and download the latest version if you don’t have it or if you have a fairly old version. To avoid colliding with versions of Node.js already installed on your system, use Node Version Manager5 (NVM) if it’s supported on your operating system.
Once you install the latest version of Node.js, open a command prompt and type:
node --version
The version of Node.js used to run the examples in this course is:
v10.0.0
The version installed on your machine may be different.
-
If your version is very old compared to ...