Lesson 4.1: Introduction to JavaScript & How It Runs in Browser
What is JavaScript?
JavaScript (JS) is a programming language that allows you to add interactivity, dynamic content, and logic to web pages. While HTML provides structure and CSS styles the page, JavaScript makes the page alive and responsive to user actions.
How JavaScript Runs in the Browser:
-
Browsers like Chrome, Firefox, and Edge have a built-in JavaScript Engine (e.g., V8 in Chrome) that reads and executes JavaScript code.
-
JS can be included in web pages in three ways:
a) Inline JavaScript
b) Internal JavaScript (within <script> tag)
c) External JavaScript (separate .js file)
script.js:
Where JavaScript Runs:
-
Client-side: JS runs directly in the browser for immediate interaction.
-
Server-side: Using Node.js, JS can also run on servers.
Why Use JavaScript?
-
Respond to user actions (click, hover, input).
-
Update HTML content dynamically without reloading the page.
-
Validate form data before submission.
-
Create animations, interactive games, and applications.
✅ Summary:
-
JS is the programming language of the web.
-
Runs in browser engines like Chrome V8.
-
Can be added inline, internally, or externally.
-
Essential for making web pages interactive and dynamic.
