Node.js by Example: Hello World

Node.js uses console.log to log to stdout. It can take string any many different values.

console.log("hello world");

We pass multiple arguments.

console.log("Number of times our build failed today:", 0);

To run the program, put the code in hello-world.js and use node hell-world.js.

$ node hello-world.js
hello world

We can also omit the “js” extension and run with only the filename.

$ node hello-world
hello world

Next example: .