JavaScript Fundamentals / Introduction

What is JavaScript?

🟑 Introduction to JavaScript

JavaScript (JS) is a lightweight, high-level, programming language used to make web pages interactive, dynamic, and functional.

It runs directly in the browser, making it a core technology of the web along with HTML and CSS.


🧩 Why do we use JavaScript?

JavaScript brings life to a webpage. Without it:

  • HTML ➝ Only structure

  • CSS ➝ Only design

  • JavaScript ➝ Adds behavior


Things JavaScript can do:

βœ” Change HTML content dynamically

βœ” Change CSS styles on the fly

βœ” Show/hide elements

βœ” Validate forms

βœ” Fetch data from APIs

βœ” Move/animate elements

βœ” Build full web applications


πŸš€ Where does JavaScript run?

1. In the Browser

Every modern browser has a JavaScript Engine:

  • Chrome β†’ V8

  • Firefox β†’ SpiderMonkey

  • Safari β†’ JavaScriptCore

  • Edge β†’ Chakra (old) / V8 (new)

2. On the Server

With Node.js, JavaScript can run:

  • server-side

  • handle APIs

  • connect databases

  • build backend services


🧠 Key Features of JavaScript

πŸ”Ή High-level language

You don’t manage memory manually β€” JS handles it.

πŸ”Ή Interpreted language

Code runs line by line in the browser (no need to compile).

πŸ”Ή Dynamic typing

Variables can store any type:

let x = 10;     // number
x = "Hello";    // now a string

πŸ”Ή Prototype-based OOP

Uses prototypes instead of classes (though modern JS has class syntax).

πŸ”Ή Event-driven

JavaScript reacts to user actions:

  • clicks

  • scrolls

  • keyboard typing


πŸ–₯ Example JavaScript Code

document.getElementById("btn").addEventListener("click", () => {
  alert("Button clicked!");
});

This code runs when a user clicks a button.


🌍 What can you build with JavaScript?

βœ” Websites

βœ” Mobile apps (React Native)

βœ” Desktop apps (Electron)

βœ” Server APIs (Node.js + Express)

βœ” Games (Phaser.js, Three.js)

βœ” Machine Learning models (TensorFlow.js)


🀝 How to setup Javascript locally

Option 1: Html + CSS + Javascript (Eventually you will use this also later)

https://www.youtube.com/watch?v=xkMfMJn5Smg

Option 2: Only JavaScript (Preferred for this Course)

https://www.youtube.com/watch?v=0CkeMXkEOrc


🏁 In short

JavaScript is the brain of the web, allowing developers to build interactive, responsive, real-time, and modern applications.

It transforms static pages into dynamic experiences users actually enjoy.