Programming

How do I start JavaScript? console.log

Write one sentence with console.log on your first HTML page.

All lessons · JavaScript lessons: learn from scratch

The first line: console.log

JavaScript is the language of the browser. The first program writes one sentence to the console. Name the file index.html and put the script inside it.

<!DOCTYPE html>
<html lang="en">
  <body>
    <h1>Hello</h1>
    <script>
      console.log("Hello, JavaScript");
    </script>
  </body>
</html>

Where to see the result

  1. Open the file in a browser.
  2. Press F12 and open the Console tab.
  3. You will see the text Hello, JavaScript there.

console.log does not put a button on the page. It is for checking: it shows what the program is thinking.

Questions

Where do I write JavaScript? In the browser, inside the script tag of an HTML file.

What does console.log do? It writes text or a number to the console.

Does it show on the page? No. It shows only in the Console panel.

Do I need to install a program? Not for the first step. A browser is enough.

Author: Nibras Code