# javs script

## 🌐 What is JavaScript (JS)?

* **JavaScript (JS)** is a **programming language** mainly used for building **dynamic and interactive web pages**.
    
* It is often called the **language of the web** because almost every website uses it.
    

---

## 🖥️ Where does JavaScript run?

* JavaScript **runs inside browsers** (like Chrome, Firefox, Safari).  
    Example: when you click a button, a popup shows → that’s JavaScript.
    
* With **Node.js**, JavaScript can also run **outside browsers** (on servers, computers, etc.).
    

---

## ⚡ Why do we need JavaScript?

* Without JS → websites are just static (plain text + images).
    
* With JS → websites become **interactive**.
    

Examples of JS in action:

1. Clicking a button → opens a menu.
    
2. Form validation → shows “Please enter email” before submitting.
    
3. Animations → sliders, fading effects.
    
4. Online games → built with JS.
    
5. Apps like Gmail, Facebook, Instagram → heavily powered by JS.
    

---

## 🧩 How JavaScript works in a web page?

A webpage uses **3 main technologies**:

1. **HTML** → structure (skeleton).
    
2. **CSS** → styling (clothes/looks).
    
3. **JavaScript** → behavior (brain/movement).
    

👉 Example:

```javascript
<!DOCTYPE html>
<html>
<head>
  <title>JS Example</title>
</head>
<body>
  <h1>Hello!</h1>
  <button onclick="sayHello()">Click Me</button>

  <script>
    function sayHello() {
      alert("Hello, Welcome to JavaScript!");
    }
  </script>
</body>
</html>
```

Here:

* HTML = button
    
* JS = shows popup when you click
    

---

## 🔑 Features of JavaScript

1. **Lightweight** – easy to learn.
    
2. **Interpreted** – runs directly in browser (no need to compile).
    
3. **Event-driven** – reacts to user actions (click, type, scroll).
    
4. **Versatile** – can be used for frontend, backend, mobile apps, even AI.
    

---

## 🚀 What can you build with JavaScript?

* **Frontend websites** → interactive UI
    
* **Backend servers** → Node.js, Express
    
* **Mobile apps** → React Native, Ionic
    
* **Desktop apps** → Electron.js (e.g., VS Code built with JS)
    
* **Games & AI projects**
