JavaScript in the browser
As said in the previous section, JavaScript was originally designed to run in web browsers so every browser has a JavaScript Engine that executes JavaScript code. In this section, we will be talking about how to run JavaScript in the browser.
In order to quickly test JavaScript code in the browser, you can use the browser's built-in developer tools. Here's how you can do it:
- Open your web browser (e.g. Google Chrome, Mozilla Firefox, Microsoft Edge).
- Right-click on the web page and select "Inspect" or press
Ctrl+Shift+I
on your keyboard. - Click on the "Console" tab in the developer tools.
- Type your JavaScript code in the console and press
Enter
to run it. - You should see the output of your JavaScript code in the console.
In the console, let's write a simple JavaScript code to display a message in the browser:
console.log('Hello, World!');
You are now ready to write, run and debug JavaScript. We keep going 🚀
Made with ❤️ by Fasakin Henry