One of the greatest virtues of JavaScript is its near-zero barrier to entry. Unlike languages such as C, C++, or Java that require compilers, build tools, path environment variables, and SDK configurations, JavaScript is ready to run immediately inside any modern web browser on your computer.
Every modern browser includes professional Developer Tools. The Console provides a full Read-Eval-Print Loop (REPL) where you can execute JavaScript expressions in real-time:
// Run this directly in your browser console:
console.log("Veewom JavaScript Console Active!");
let score = 95;
let bonus = 10;
console.log("Total Calculated Score:", score + bonus);
In web development, JavaScript is embedded into HTML using the <script> element. There are three recognized approaches:
Ideal for small, single-page experiments and university lab assignments:
<!DOCTYPE html>
<html>
<head>
<title>Internal JS Demo</title>
</head>
<body>
<h2>Internal JavaScript Example</h2>
<script>
console.log("Executing from internal script tag");
</script>
</body>
</html>
In professional engineering, JavaScript logic is separated into dedicated .js files. This enables browser caching, code reusability, and clean separation of concerns:
<!-- index.html -->
<!DOCTYPE html>
<html>
<head>
<title>External JS Demo</title>
</head>
<body>
<h1 id="demo">Original Text</h1>
<!-- Link external script at bottom of body -->
<script src="app.js"></script>
</body>
</html>
// app.js
document.addEventListener("DOMContentLoaded", () => {
document.getElementById("demo").textContent = "Updated via External app.js File!";
console.log("app.js loaded cleanly.");
});
Written directly inside HTML element attributes (e.g., onclick="alert('Hello')"). Note: This is considered legacy and discouraged in modern clean-code architecture.
To run JavaScript scripts from your computer's terminal without a browser:
# Check Node.js and NPM versions
node -v
npm -v
# Run interactive Node REPL
node
> console.log("Hello from Node.js runtime!");
> 10 + 25
35
> .exit
We strongly recommend Visual Studio Code (VS Code) by Microsoft. Install these free productivity extensions:
Viva Question: "Where should the <script> tag be placed in an HTML document: in the <head> or at the bottom of the <body>? Explain the modern solution."
Answer: Traditionally, scripts were placed at the very bottom of the <body> tag so the browser could parse and display HTML elements first without script blocking. In modern HTML5, the recommended approach is placing scripts in the <head> with the defer attribute (<script src="app.js" defer></script>). The defer attribute downloads the file asynchronously in parallel without blocking HTML parsing, then executes it in strict document order once parsing finishes.
With your coding environment ready, let us explore the grammar and structural conventions of JavaScript code. Proceed to: JavaScript Syntax, Rules & Strict Mode →