What is JavaScript ?
JavaScript is a high-level, interpreted programming language that allows you to make web pages interactive and dynamic. Alongside HTML and CSS, it is one of the core technologies of web development.
- HTML → Builds the structure of a webpage (headings, paragraphs, buttons).
- CSS → Adds style and design (colors, fonts, layouts).
- JavaScript → Adds behavior and interactivity (clicks, animations, live updates).
Who Created JavaScript?
- Originally named Mocha, then LiveScript, and finally renamed to JavaScript.
- Amazingly, the first version was developed in just 10 days.
- Today, JavaScript is maintained by ECMA International under the standard ECMAScript (ES).
Latest versions (ES6 and beyond) introduced features like let, const, arrow functions, promises, and classes — making JavaScript more powerful and modern.
Why Use JavaScript?
JavaScript is used everywhere — from simple web pages to large-scale applications.
Here’s what you can do with it:
- Interactive Web Pages – Respond to user actions like clicks, hover, or form submissions.
- DOM Manipulation – Dynamically change HTML content or CSS styles.
- Web Applications – Build apps like Gmail, Facebook, or e-commerce websites.
- Server-Side Development – Use Node.js for backend tasks like APIs and databases.
- Games and Animations – Create browser games and animations.
- Event Handling – React to keyboard, mouse, or page events.
Example:
<!DOCTYPE html>
<html>
<head>
<title>JavaScript Example</title>
</head>
<body>
<h1 id="greeting">Hello!</h1>
<button onclick="changeText()">Click Me</button>
<script>
// JavaScript function to change text dynamically
function changeText() {
document.getElementById('greeting').innerText = "Hello, JavaScript!";
}
</script>
</body>
</html>Explanation:
onclick="changeText()"→ Executes the function when the button is clicked.document.getElementById()→ Selects an HTML element by ID..innerText→ Changes the visible text of the element.
When you click the button, the heading updates from “Hello!” to “Hello, JavaScript!” — no page reload needed.
Where Is JavaScript Used Today?
- Web Frontend – Adding interactivity to sites
- Backend (Node.js) – Creating APIs and servers
- Mobile Apps – With frameworks like React Native
- Desktop Apps – Using Electron.js (e.g., VS Code)
- Game Development – With libraries like Phaser.js
