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
