JavaScript
History and Definition of JavaScript
What is JavaScript?
JavaScript is the programming language of the web - a high-level, interpreted programming language used to make web pages interactive, dynamic, and responsive.
It can calculate, manipulate, and validate data.
It can update and change both HTML and CSS.
Brief History of JavaScript
| Year | Event |
|---|---|
| 1995 | JavaScript was created by Brendan Eich at Netscape Communications in just 10 days. Originally called Mocha, then LiveScript, and finally JavaScript. Back then, it was mainly for marketing reasons, to ride on Java’s popularity. |
| 1996 | Microsoft created its own version called JScript for Internet Explorer, leading to compatibility issues. |
| 1997 | JavaScript was standardized under ECMA International as ECMAScript, ensuring all browsers could implement the same core language features. |
| 2000s | JavaScript became essential for modern web development. The rise of AJAX allowed dynamic, asynchronous loading of content (used heavily by Google and Facebook). |
| 2009 | Node.js was released, enabling JavaScript to run outside the browser, on servers — turning it into a full-stack language. |
| 2015 | ECMAScript 6 (ES6) introduced major improvements like classes, arrow functions, promises, and modules — making JavaScript more powerful and modern. |
| Today | JavaScript is the most widely used programming language in web development and the foundation for popular frameworks and libraries like React, Angular, and Vue. |
Summary
JavaScript is the core language of the web, evolving from a simple scripting tool in the 1990s to a versatile, full-stack technology that powers everything from websites to mobile apps and even desktop software.
Key Features of JavaScript
- Client-side scripting language
- Can manipulate HTML and CSS
- Supports events (click, hover, drag)
- Used for validation, animations, and dynamic content
- Used for backend development with Node.js
- Supports object-oriented programming (OOP)
- Supports asynchronous programming (promises, async/await)
Why JavaScript Is Important
- It runs in every web browser
- No installation needed
- Fast and efficient
- Essential for interactive UIs
- Large ecosystem and community support
How to Insert JavaScript Into an HTML File
1. Internal JavaScript (Inside <script> Tag)
Syntax:
<script>
// your JavaScript here
</script>
Example:
<script>
alert("Hello from JavaScript!");
</script>
2. External JavaScript File
This is the cleaner and recommended method.
Syntax:
<script src="script.js"></script>
Example:
HTML:
<script src="main.js"></script>
main.js:
console.log("External JS loaded!");
3. JavaScript Inside HTML Elements (Event Handlers)
Syntax:
<element onclick="yourJSCode">
Example:
<button onclick="alert('Button clicked!')">Click Me</button>
4. Where to Place JavaScript
- Inside <head> → runs before page loads
- Before </body> → recommended, runs after page loads
Example:
<body>
...content...
<script src="app.js"></script>
</body>