Hello World in Logo

Our first program will print the classic “hello world” message. Here’s the full source code.

console.log("hello world");

To run the program, save the code in a file named hello-world.js and execute it using Node.js.

$ node hello-world.js
hello world

In JavaScript, programs are typically interpreted and run directly by the JavaScript engine in the browser or Node.js runtime. There’s no need to explicitly compile JavaScript code.

Sometimes we’ll want to build our programs into more manageable and distributable forms, especially for larger JavaScript applications. We can use bundlers like webpack or tools like npm to package our applications.

An example of how to install and run JavaScript using npm:

  1. Initialize a new npm project:
$ npm init -y
  1. Create and run a script in package.json:

Add the following scripts section to your package.json:

"scripts": {
    "start": "node hello-world.js"
}
  1. Execute the script using npm:
$ npm start
hello world

Now that we can run and build basic JavaScript programs, let’s learn more about the language.