What is JavaScript and Running It

Site Admin · 11 Sep 2026 · 8 views

What is JavaScript and Running It

JavaScript is the programming language of the web. It runs in every browser, enabling interactive pages, dynamic content, and complex applications. With Node.js, it also runs on the server.

A Brief History

JavaScript was created in 1995 by Brendan Eich at Netscape in just ten days. Despite its rushed origin, it evolved into the most widely used programming language in the world. Modern JavaScript (ES6+) is powerful, expressive, and nothing like the language of the 1990s.

Running JavaScript in the Browser

Add a <script> tag in your HTML. The browser executes the code when it reaches the tag.

<!DOCTYPE html>
<html lang="en">
<head><title>JS Demo</title></head>
<body>
    <h1 id="greeting">Hello</h1>
    <script>
        document.getElementById("greeting").textContent = "Hello, JavaScript!";
    </script>
</body>
</html>

Running JavaScript with Node.js

Node.js lets you run JavaScript outside the browser. Install it, create a .js file, and run it from the terminal:

// hello.js
const name = "World";
console.log(`Hello, ${name}!`);

Run it with node hello.js and the output is Hello, World!.

The Console

The console object is your primary debugging tool. It works in both browsers and Node.js.

console.log("Simple message");
console.info("Informational");
console.warn("Warning!");
console.error("Something broke");
console.table([{name: "Alice", age: 30}, {name: "Bob", age: 25}]);

External Scripts

Keep JavaScript in separate .js files for organization:

<script src="app.js" defer></script>

The defer attribute loads the script after the HTML is parsed, preventing blocking of page rendering.

Key Points

  • JavaScript runs in browsers and on servers (Node.js).
  • Use <script> tags to run code in HTML pages.
  • node filename.js runs JavaScript from the command line.
  • console.log() outputs debugging information.
  • Use defer on external scripts to avoid blocking page rendering.
Share this post:

Comments (0)

Please login or register to comment.