Hello World in Mercury
Our first program will print the classic “hello world” message. Here’s the full source code.
To run the program, save the code in a file named hello-world.js
and use node
to execute it.
Sometimes we’ll want to package our JavaScript programs in a way that makes them easier to distribute. In JavaScript, this often involves bundling the code using a tool like Webpack.
First, install Webpack and Webpack CLI globally:
Then, create a configuration file named webpack.config.js
:
Now, you can bundle your JavaScript code:
This will create a bundle.js
file in the dist
directory. You can then execute or include this bundled file in your HTML.
Now that we can run and bundle basic JavaScript programs, let’s learn more about the language.