⚠ यह कार्रवाई अनुमति नहीं है!
⚡ NIELIT O Level · M2-R5 Web Design · Hindi Notes

Chapter 6: JavaScript & AngularJS — पेज को Interactive बनाना

अब पेज में जान डालने की बारी! इस chapter में — Client-Side Scripting Intro, Variables (var/let/const), Operators, Conditional Statements, Popup Boxes, Events, Form Validation, और AngularJS — Expressions, Modules व Directives — 30+ examples के साथ, हर code में Copy button!

📑 9 Topics 💻 30+ Examples 📊 Diagrams ❓ 50 MCQs + Theory 🗓 Updated 2026
👉 सभी chapters देखने के लिए swipe करें
📑 Table of Contents — किसी भी topic पर सीधे जाएँ
6.0

Client-Side Scripting Introduction — Browser में चलने वाला Code

Client-Side Scripting Language browser में run होती है — इसे execute करने के लिए server की ज़रूरत नहीं होती। सबसे प्रसिद्ध उदाहरण JavaScript है।

जब कोई user webpage खोलता है, browser HTML, CSS व JavaScript download करके execute करता है। HTML structure देता है, CSS design देता है, JavaScript webpage में interactivity लाती है।

✨ Features of Client-Side Scripting

  • Runs on Browser: code user के browser पर चलता है, server पर नहीं।
  • Fast Execution: network communication की ज़रूरत नहीं, speed तेज़।
  • Interactive UI: animation, validation व user interaction जोड़ता है।
  • Lightweight: logic local browser में चलने से page size छोटा रहता है।
  • Limited Access: local files/system data directly access नहीं कर सकता — security बनी रहती है।
⚡ पहला JavaScript program
<button onclick="showMessage()">Click Me</button>

<script>
  function showMessage() {
    alert("Hello! This runs in your browser.");
  }
</script>

🔄 DOM Manipulation Example

JavaScript webpage के content को runtime पर बदल सकता है — इसे DOM Manipulation कहते हैं।

⚡ content dynamically बदलना
<p id="demo">Original text.</p>
<button onclick="changeText()">Change Text</button>

<script>
  function changeText() {
    document.getElementById("demo").innerHTML = "Content changed by script!";
  }
</script>

⚖️ Client-Side vs Server-Side

Client-Side ScriptingServer-Side Scripting
Browser पर run होती हैServer पर run होती है
Page interaction व validation के लिएDatabase व backend logic के लिए
Example: JavaScript, VBScriptExample: PHP, ASP, Node.js
तेज़ executionServer communication की वजह से धीमा
Exam Point: Client-side = browser पर चलती है, server की ज़रूरत नहीं (JavaScript)। Server-side = server पर चलती है, database access कर सकती है (PHP)। यह "difference" question बहुत common है।
6.1

Variables in JavaScript — Data रखने का Container

Variable एक नामित memory location है जहाँ data temporarily store किया जाता है ताकि बाद में उपयोग हो सके।

🧠 Declare करने के 3 तरीके

KeywordScopeReassignableDescription
varFunction ScopeYesपुराना तरीका (ES5 तक)
letBlock ScopeYesModern (ES6) — recommended
constBlock ScopeNoConstant — value बदली नहीं जा सकती
⚡ var, let, const का उपयोग
var name = "Rahul";
let age = 21;
const country = "India";

document.getElementById("output").innerHTML =
  "Name: " + name + "<br>Age: " + age + "<br>Country: " + country;

🔭 Variable Scope

Global Scope: variable पूरे script में accessible। Local (Block) Scope: केवल उस block/function के अंदर accessible।

⚡ global व local scope
let globalVar = "I am global!";

function testScope() {
  let localVar = "I am local!";
  console.log(globalVar + " " + localVar);
}

📋 Naming Rules

  • Letter, underscore (_) या $ से शुरू होता है।
  • बीच/अंत में numbers आ सकते हैं, शुरुआत में नहीं।
  • Case-sensitive होते हैं (nameName)।
  • Reserved keywords (var, if, function) नाम नहीं बन सकते।
⚡ valid vs invalid names
// ✅ Valid
let firstName = "Aman";
let _count = 10;

// ❌ Invalid
let 1name = "Ravi";     // digit से शुरू नहीं हो सकता
let var = "Hello";      // reserved keyword
Exam Point: var=function scope+hoisted; let=block scope+not hoisted; const=block scope+reassign नहीं हो सकता। "var vs let vs const" NIELIT का बहुत common question है।
6.2

Operators in JavaScript — गणना, तुलना व निर्णय

Operators ऐसे symbols हैं जिनसे values/variables पर operations perform होते हैं — जोड़, घटाना, तुलना, logical decisions आदि।

1️⃣ Arithmetic Operators

OperatorकामExample
+Addition10+5=15
-Subtraction10-5=5
*Multiplication10*5=50
/Division10/2=5
%Modulus (शेष)10%3=1
++/--Increment/Decrementx++ / x--
⚡ arithmetic operators demo
let a = 10, b = 5;
console.log(a + b);  // 15
console.log(a % b);  // 0

2️⃣ Assignment Operators

⚡ shorthand assignment
let x = 10;
x += 5;   // x = x + 5 → 15
x -= 3;   // x = x - 3 → 12

3️⃣ Comparison Operators

OperatorकामExample
==Equal value (type check नहीं)5=="5" → true
===Equal value व type दोनों5==="5" → false
!=Not equal5!=10 → true
> / <Greater/Less than10>5 → true
⚠️ ध्यान दें: == सिर्फ value compare करता है (type conversion करता है), === value व type दोनों check करता है — यह बहुत common exam question है।

4️⃣ Logical Operators

⚡ AND, OR, NOT
let x = 10, y = 3;
console.log(x > 5 && y < 10);  // AND — true
console.log(x > 5 || y > 10);  // OR — true
console.log(!(x > 5));         // NOT — false

5️⃣ Conditional (Ternary) Operator

if-else का short form: condition ? value_if_true : value_if_false

⚡ ternary operator
let age = 18;
let result = (age >= 18) ? "Eligible to Vote" : "Not Eligible";
Exam Point: == vs === (loose vs strict equality); ternary operator if-else का shorthand है; % modulus शेष (remainder) देता है, division नहीं।
6.3

Conditional Statements — शर्तों के अनुसार निर्णय

Conditional statements से program अलग-अलग conditions के अनुसार अलग-अलग tasks perform करता है — if, else if, else, switch

1️⃣ if Statement

⚡ basic if
let age = 20;
if (age >= 18) {
  console.log("You are eligible to vote.");
}

2️⃣ if...else Statement

⚡ if-else दो अलग outputs
let marks = 40;
if (marks >= 50) {
  console.log("You Passed!");
} else {
  console.log("You Failed!");
}

3️⃣ if...else if...else Ladder

⚡ grade calculator
let percentage = 75, grade;
if (percentage >= 90) { grade = "A+"; }
else if (percentage >= 75) { grade = "A"; }
else if (percentage >= 60) { grade = "B"; }
else { grade = "Fail"; }

4️⃣ switch Statement

जब एक variable की कई values के अनुसार अलग-अलग code चलाना हो — if...else if का विकल्प।

⚡ switch — day of week
let day = 3, dayName;
switch(day) {
  case 1: dayName = "Monday"; break;
  case 2: dayName = "Tuesday"; break;
  case 3: dayName = "Wednesday"; break;
  default: dayName = "Invalid Day";
}
Statementउपयोग
ifSingle condition check
if...elseTrue/False दोनों में अलग output
if...else if...elseMultiple conditions
switchकई fixed values के अनुसार code चलाना
Exam Point: switch केवल equality (==) check करता है; if complex logical expressions handle कर सकता है। हर case के बाद break ज़रूरी है, वरना अगला case भी चल जाता है (fall-through)।
6.4

JavaScript Popup Boxes — User से सीधा Interaction

Popup boxes छोटे dialog boxes हैं जो message दिखाने, confirmation लेने या input लेने के लिए उपयोग होते हैं — alert(), confirm(), prompt()

1️⃣ alert() Box

Simple message दिखाने के लिए।

⚡ alert box
function showAlert() {
  alert("Welcome to JavaScript!");
}

2️⃣ confirm() Box

OK व Cancel दो buttons होते हैं। OK पर true, Cancel पर false return होता है।

⚡ confirm box — delete action
function deleteItem() {
  let result = confirm("Are you sure you want to delete this?");
  if (result == true) {
    console.log("Item deleted!");
  } else {
    console.log("Action cancelled.");
  }
}

3️⃣ prompt() Box

User से text input लेने के लिए। User जो type करता है वह return value के रूप में मिलता है।

⚡ prompt box — नाम पूछना
let name = prompt("Please enter your name:");
if (name != null && name != "") {
  console.log("Hello " + name + "!");
}
Popupकामउपयोग
alert()Information दिखानाWarning/notification
confirm()OK/Cancel confirmationDelete/submit confirm
prompt()User input लेनाName/email पूछना
Exam Point: confirm() true/false return करता है; prompt() user का typed text (या null अगर cancel) return करता है; alert() कुछ return नहीं करता (सिर्फ दिखाता है)।
6.5

JavaScript Events — User की हरकतों पर Reaction

Events ऐसे actions हैं जो user interaction या browser action से होते हैं — click, mouse move, key press आदि। Event होने पर JavaScript function run होता है।

Event Flow — Action से Response तक

User Action Event Fires Function Runs

🔹 Common Event Types

Eventकब trigger होता है
onclickElement पर click होने पर
ondblclickDouble-click होने पर
onmouseoverMouse element के ऊपर आने पर
onmouseoutMouse element से हटने पर
onkeyup / onkeydownKey release/press होने पर
onloadपूरा page load होने पर
onchangeInput value बदलने पर
onsubmitForm submit होने पर

🖱️ onClick Example

⚡ click event
<button onclick="showMessage()">Click Me</button>
<p id="msg"></p>

<script>
  function showMessage() {
    document.getElementById("msg").innerHTML = "You clicked the button!";
  }
</script>

🖱️ Mouse Hover Events

⚡ mouseover/mouseout
<div onmouseover="hoverIn()" onmouseout="hoverOut()">Hover Here</div>

<script>
  function hoverIn() { document.querySelector('div').style.background = "lightgreen"; }
  function hoverOut() { document.querySelector('div').style.background = "lightgray"; }
</script>

⌨️ Keyboard Event

⚡ onkeyup — typing detect करना
<input type="text" onkeyup="showKey(event)">

<script>
  function showKey(event) {
    console.log("You pressed: " + event.key);
  }
</script>
Exam Point: onclick/ondblclick = mouse events; onkeyup/onkeydown = keyboard events; onload = पूरे page load होने पर; onsubmit = form submit पर। Event handler HTML attribute (जैसे onclick="fn()") में लगता है।
6.6

Basic Form Validation — Input की जाँच

Form validation user द्वारा दिए input की सही/गलत जाँच है — required fields, email format, password strength आदि JavaScript से check होते हैं।

🔹 Types of Validation

  • Required Field: field खाली न हो।
  • Email Validation: सही format हो (example@gmail.com)।
  • Password Validation: पर्याप्त लंबा/secure हो।
  • Number Validation: केवल numbers allow हों।
⚠️ Remember: JavaScript validation client-side है; server-side validation भी हमेशा साथ में होनी चाहिए (security के लिए)।

📋 Registration Form Validation Example

⚡ name, email, password validate करना
function validateForm() {
  let name = document.forms["myForm"]["username"].value;
  let email = document.forms["myForm"]["email"].value;
  let password = document.forms["myForm"]["password"].value;
  let emailPattern = /^[^ ]+@[^ ]+\.[a-z]{2,3}$/;

  if (name == "") {
    alert("Name must be filled out!");
    return false;
  }
  if (!email.match(emailPattern)) {
    alert("Please enter a valid email address!");
    return false;
  }
  if (password.length < 6) {
    alert("Password must be at least 6 characters!");
    return false;
  }
  return true;
}

🔢 Number Validation

⚡ isNaN() से number check
function checkNumber() {
  let num = document.getElementById("num").value;
  if (isNaN(num) || num == "") {
    alert("Please enter a valid number!");
  } else {
    alert("Valid Number: " + num);
  }
}
ValidationMethod
Empty Fieldif (x == "")
Email Format.match(regex)
Number CheckisNaN()
Password Length.length
Exam Point: isNaN() = "is Not a Number" check करता है। .match(regex) से email/pattern validate होता है। form onsubmit="return validateForm()" से validation function call होता है — false return पर form submit नहीं होता।
6.7

AngularJS: Expressions, Modules & Directives — Dynamic Web Apps

AngularJS Google द्वारा 2010 में बनाया गया open-source JavaScript framework है, जो single-page web applications को two-way data binding व MVC architecture के साथ बनाने के लिए उपयोग होता है।

✨ Key Features

  • Two-Way Data Binding
  • MVC (Model-View-Controller) Architecture
  • Reusable Components
  • Dependency Injection
  • Directives & Expressions

📍 AngularJS को Project में जोड़ना

🅰️ CDN से AngularJS शामिल करना
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></script>

1️⃣ AngularJS Expressions

Data को HTML में display करने के लिए — curly braces {{ }} के अंदर लिखा जाता है।

🅰️ expressions {{ }}
<html ng-app>
<body>
  <p>Addition: {{ 5 + 5 }}</p>
  <p>Text: {{ 'Boosting' + 'Skills' }}</p>
</body>
</html>

2️⃣ AngularJS Modules

Module AngularJS application का container है — इसमें controllers, directives व services define होते हैं।

🅰️ module + controller
<html ng-app="myApp">
<body ng-controller="myCtrl">
  <p>Hello {{ name }}!</p>

  <script>
    var app = angular.module("myApp", []);
    app.controller("myCtrl", function($scope) {
      $scope.name = "BoostingSkills Student";
    });
  </script>
</body>
</html>

3️⃣ AngularJS Directives

Directives HTML elements को नया behaviour देने वाले special attributes हैं।

Directiveकाम
ng-appApplication define करता है
ng-modelInput field को data से bind करता है
ng-bindData को HTML elements में display करता है
ng-repeatArrays/lists को repeat करता है
ng-show / ng-hideCondition के अनुसार element दिखाना/छुपाना
🅰️ ng-model + ng-bind + ng-repeat
<body ng-controller="demoCtrl">
  <input type="text" ng-model="userName">
  <p>Welcome, <span ng-bind="userName"></span>!</p>

  <ul>
    <li ng-repeat="course in courses">{{ course }}</li>
  </ul>

  <script>
    var app = angular.module("demoApp", []);
    app.controller("demoCtrl", function($scope) {
      $scope.userName = "Student";
      $scope.courses = ["HTML", "CSS", "JavaScript", "AngularJS"];
    });
  </script>
</body>

AngularJS MVC Architecture

Model$scope data ControllerLogic handle ViewHTML display
Exam Point: AngularJS = Google, 2010; MVC — Model(data), View(display), Controller(logic)। Expressions {{ }} में लिखे जाते हैं; ng-model two-way binding देता है; ng-repeat arrays loop करता है।
6.8

Summary — Quick Revision (Exam से पहले पढ़ें)

  • Client-side scripting = browser में चलती है (JavaScript); server-side (PHP) server पर चलती है।
  • Variables: var (function scope), let/const (block scope); const reassign नहीं हो सकता।
  • Operators: Arithmetic (+,-,*,/,%), Comparison (==, ===), Logical (&&,||,!), Ternary (? :)।
  • Conditional: if/if-else/if-else-if/switch — switch सिर्फ equality check करता है।
  • Popup boxes: alert() (message), confirm() (true/false), prompt() (input value)।
  • Events: onclick, onmouseover/out, onkeyup/down, onload, onsubmit।
  • Form Validation: required field check, email regex, isNaN() number check, password length।
  • AngularJS: Google (2010); MVC architecture; Expressions {{ }}; Modules (angular.module); Directives (ng-app, ng-model, ng-repeat, ng-bind)।
6.9

Model Questions — 50 MCQs + 15 Theory Questions

❓ A. Multiple Choice Questions (50)

1

JavaScript कहाँ run होती है?

(a) Server पर(b) Browser पर(c) Database पर(d) Compiler पर
✔ सही उत्तर: (b) Browser पर
2

इनमें से server-side language है —

(a) JavaScript(b) PHP(c) VBScript(d) TypeScript
✔ सही उत्तर: (b) PHP
3

DOM manipulation का मतलब है —

(a) database बदलना(b) runtime पर content बदलना(c) server restart करना(d) फाइल delete करना
✔ सही उत्तर: (b) runtime पर content बदलना
4

Variable बनाने का modern तरीका है —

(a) var(b) let(c) variable(d) declare
✔ सही उत्तर: (b) let
5

Reassign न होने वाला variable बनता है —

(a) var(b) let(c) const(d) static
✔ सही उत्तर: (c) const
6

var किस scope का variable बनाता है?

(a) Block scope(b) Function scope(c) Global only(d) कोई scope नहीं
✔ सही उत्तर: (b) Function scope
7

इनमें से invalid variable name है —

(a) firstName(b) _count(c) 1name(d) $price
✔ सही उत्तर: (c) 1namedigit से शुरू नहीं हो सकता।
8

JavaScript variables होते हैं —

(a) case-insensitive(b) case-sensitive(c) numbers only(d) symbols only
✔ सही उत्तर: (b) case-sensitive
9

Modulus operator है —

(a) /(b) %(c) *(d) ^
✔ सही उत्तर: (b) %
10

value व type दोनों check करने वाला operator —

(a) ==(b) ===(c) =(d) !=
✔ सही उत्तर: (b) ===
11

5 == "5" का result है —

(a) true(b) false(c) undefined(d) error
✔ सही उत्तर: (a) true
12

5 === "5" का result है —

(a) true(b) false(c) undefined(d) error
✔ सही उत्तर: (b) false
13

Logical AND operator है —

(a) ||(b) &&(c) !(d) ??
✔ सही उत्तर: (b) &&
14

Ternary operator if-else का क्या है?

(a) replacement(b) shorthand(c) opposite(d) कोई संबंध नहीं
✔ सही उत्तर: (b) shorthand
15

कई conditions check करने के लिए उपयोग होता है —

(a) if केवल(b) if...else if...else(c) alert()(d) var
✔ सही उत्तर: (b) if...else if...else
16

switch statement केवल क्या check करता है?

(a) equality(b) range(c) type(d) function
✔ सही उत्तर: (a) equality
17

switch में हर case के बाद क्या ज़रूरी है?

(a) return(b) break(c) continue(d) end
✔ सही उत्तर: (b) break
18

कोई value match न होने पर switch में चलता है —

(a) default(b) else(c) case 0(d) null
✔ सही उत्तर: (a) default
19

सिर्फ message दिखाने वाला popup —

(a) confirm()(b) prompt()(c) alert()(d) popup()
✔ सही उत्तर: (c) alert()
20

OK/Cancel confirmation देने वाला popup —

(a) alert()(b) confirm()(c) prompt()(d) message()
✔ सही उत्तर: (b) confirm()
21

User input लेने वाला popup —

(a) alert()(b) confirm()(c) prompt()(d) input()
✔ सही उत्तर: (c) prompt()
22

confirm() में Cancel दबाने पर return होता है —

(a) true(b) false(c) null(d) undefined
✔ सही उत्तर: (b) false
23

Click event के लिए attribute है —

(a) onmouseover(b) onclick(c) onload(d) onchange
✔ सही उत्तर: (b) onclick
24

Mouse element के ऊपर आने पर trigger होता है —

(a) onmouseout(b) onmouseover(c) onclick(d) onload
✔ सही उत्तर: (b) onmouseover
25

Key release पर trigger होने वाला event —

(a) onkeydown(b) onkeyup(c) onkeypress(d) onload
✔ सही उत्तर: (b) onkeyup
26

पूरा page load होने पर trigger होता है —

(a) onclick(b) onload(c) onchange(d) onsubmit
✔ सही उत्तर: (b) onload
27

Form submit होने पर trigger होता है —

(a) onsubmit(b) onload(c) onchange(d) onfocus
✔ सही उत्तर: (a) onsubmit
28

Input value बदलने पर trigger होता है —

(a) onchange(b) onclick(c) onload(d) onmouseover
✔ सही उत्तर: (a) onchange
29

Form validation किस लिए होती है?

(a) design के लिए(b) input की सही जाँच के लिए(c) database के लिए(d) hosting के लिए
✔ सही उत्तर: (b) input की सही जाँच के लिए
30

Number check करने के लिए function —

(a) isNaN()(b) isNumber()(c) checkNum()(d) typeOf()
✔ सही उत्तर: (a) isNaN()
31

Email format check करने के लिए उपयोग होता है —

(a) isNaN()(b) .match(regex)(c) .length(d) alert()
✔ सही उत्तर: (b) .match(regex)
32

Password की length check करने के लिए —

(a) .size(b) .length(c) .count(d) .len
✔ सही उत्तर: (b) .length
33

JavaScript validation किस side पर होती है?

(a) Server-side(b) Client-side(c) Database-side(d) Network-side
✔ सही उत्तर: (b) Client-side
34

AngularJS किसने बनाया?

(a) Microsoft(b) Google(c) Facebook(d) Apple
✔ सही उत्तर: (b) Google
35

AngularJS कब आया?

(a) 2005(b) 2010(c) 2015(d) 2020
✔ सही उत्तर: (b) 2010
36

AngularJS किस architecture पर आधारित है?

(a) MVC(b) MVP(c) MVVM only(d) कोई नहीं
✔ सही उत्तर: (a) MVC
37

AngularJS expressions कहाँ लिखी जाती हैं?

(a) [ ](b) { }(c) {{ }}(d) ( )
✔ सही उत्तर: (c) {{ }}
38

Application define करने वाली directive —

(a) ng-model(b) ng-app(c) ng-bind(d) ng-repeat
✔ सही उत्तर: (b) ng-app
39

Input field को data से bind करने वाली directive —

(a) ng-app(b) ng-model(c) ng-show(d) ng-repeat
✔ सही उत्तर: (b) ng-model
40

Arrays को repeat करने वाली directive —

(a) ng-repeat(b) ng-model(c) ng-bind(d) ng-app
✔ सही उत्तर: (a) ng-repeat
41

Data को HTML में display करने वाली directive —

(a) ng-bind(b) ng-app(c) ng-hide(d) ng-repeat
✔ सही उत्तर: (a) ng-bind
42

AngularJS Module बनाने के लिए —

(a) angular.app()(b) angular.module()(c) angular.controller()(d) angular.init()
✔ सही उत्तर: (b) angular.module()
43

MVC में "M" का मतलब है —

(a) Method(b) Model(c) Menu(d) Module
✔ सही उत्तर: (b) Model
44

MVC में Controller क्या करता है?

(a) data represent(b) display करता है(c) logic handle करता है(d) styling करता है
✔ सही उत्तर: (c) logic handle करता है
45

Controller में data रखने के लिए उपयोग होता है —

(a) $scope(b) $data(c) $model(d) $store
✔ सही उत्तर: (a) $scope
46

AngularJS की सबसे बड़ी विशेषता है —

(a) one-way binding only(b) two-way data binding(c) कोई binding नहीं(d) सिर्फ styling
✔ सही उत्तर: (b) two-way data binding
47

Directives वे क्या हैं?

(a) CSS properties(b) special HTML attributes(c) database tables(d) server files
✔ सही उत्तर: (b) special HTML attributes
48

Condition के अनुसार element छुपाने वाली directive —

(a) ng-hide(b) ng-model(c) ng-app(d) ng-repeat
✔ सही उत्तर: (a) ng-hide
49

AngularJS को project में जोड़ने के लिए —

(a) <style> tag(b) <script> tag (CDN)(c) <link> tag(d) <meta> tag
✔ सही उत्तर: (b) <script> tag (CDN)
50

"Client-Side Scripting Language" का सबसे प्रसिद्ध उदाहरण —

(a) PHP(b) JavaScript(c) MySQL(d) Python
✔ सही उत्तर: (b) JavaScript

📝 B. 15 Theory Questions (Short Answers)

  1. Client-Side Scripting Language क्या है? उदाहरण दीजिए।Client-Side Scripting Language browser में run होती है, server की ज़रूरत नहीं होती। उदाहरण — JavaScript, VBScript। यह webpage को interactive बनाती है।
  2. Client-Side और Server-Side scripting में अंतर लिखिए।Client-side browser पर चलती है (JavaScript), page interaction/validation के लिए। Server-side server पर चलती है (PHP), database व backend logic के लिए। Client-side तेज़ होती है।
  3. var, let व const में अंतर बताइए।var — function scope, reassign हो सकता है, hoisted होता है (पुराना)। let — block scope, reassign हो सकता है (modern)। const — block scope, reassign नहीं हो सकता (constant values के लिए)।
  4. == और === में अंतर लिखिए उदाहरण सहित।== सिर्फ value compare करता है, type conversion कर लेता है (5=="5" → true)। === value व type दोनों check करता है (5==="5" → false)। एग्ज़ैक्ट comparison के लिए === बेहतर है।
  5. Ternary operator क्या है? Syntax व example दीजिए।यह if-else का shorthand है। Syntax: condition ? value_if_true : value_if_false। उदाहरण: let result = (age>=18) ? "Eligible" : "Not Eligible";
  6. switch statement कैसे काम करता है?switch किसी variable की value को अलग-अलग case values से match करता है। Match होने पर वह block चलता है (break तक)। कोई match न हो तो default block चलता है। यह केवल equality check करता है।
  7. alert(), confirm() व prompt() में अंतर लिखिए।alert() सिर्फ message दिखाता है, कोई return value नहीं। confirm() OK/Cancel देता है, true/false return करता है। prompt() input field देता है, user का typed text (या null) return करता है।
  8. JavaScript में कोई 4 events के नाम व उनका काम लिखिए।onclick (क्लिक होने पर), onmouseover (mouse ऊपर आने पर), onkeyup (key release पर), onload (page load होने पर)।
  9. Form validation क्यों ज़रूरी है? कोई 2 validation types लिखिए।Form validation से गलत/अधूरा data server तक जाने से पहले रुक जाता है, जिससे errors व security issues कम होते हैं। Types — required field validation (खाली न हो), email validation (सही format हो)।
  10. isNaN() function का उपयोग समझाइए।isNaN() check करता है कि value एक valid number है या नहीं — अगर value number नहीं है तो true return करता है। Number input validation में उपयोगी है।
  11. AngularJS क्या है? इसे किसने बनाया?AngularJS एक open-source JavaScript framework है जो dynamic single-page web applications बनाने के लिए उपयोग होता है — Google द्वारा 2010 में develop किया गया। यह MVC architecture व two-way data binding देता है।
  12. AngularJS Expressions क्या हैं? उदाहरण दीजिए।Expressions data को HTML में display करने के लिए curly braces {{ }} में लिखी जाती हैं। उदाहरण: {{ 5+5 }} output में 10 दिखाएगा।
  13. AngularJS Module क्या है?Module AngularJS application का मुख्य container है जिसमें controllers, directives व services define होते हैं। इसे angular.module("appName", []) से बनाया जाता है।
  14. AngularJS Directives क्या हैं? कोई 4 directives लिखिए।Directives special HTML attributes हैं जो elements को नया behaviour देते हैं। उदाहरण — ng-app (application define), ng-model (data binding), ng-repeat (list repeat), ng-bind (data display)।
  15. AngularJS में MVC architecture समझाइए।Model data represent करता है ($scope से), View HTML में display करता है, Controller business logic handle करता है और Model व View के बीच connection बनाता है — इससे code clean व structured रहता है।
Revision Tip: var/let/const का फर्क, == vs ===, alert/confirm/prompt के return values, common events (onclick/onload/onchange), व AngularJS directives (ng-app/ng-model/ng-repeat) — ये facts इस chapter के आधे MCQs cover कर देते हैं।
FAQ

अक्सर पूछे जाने वाले प्रश्न

JavaScript क्या है?
JavaScript एक client-side scripting language है जिसका उपयोग web pages में interactivity, validation, events, animations व dynamic behaviour जोड़ने के लिए किया जाता है। यह browser में ही run होती है, server पर नहीं।
JavaScript में Variables क्या होते हैं?
Variables memory location का नाम होते हैं जिसमें data store किया जाता है। JavaScript में var, let व const keywords से variables बनाए जाते हैं — let व const modern व block-scoped हैं।
JavaScript Events क्या हैं?
Events वह actions हैं जिन पर JavaScript code चलता है जैसे click, mouseover, keypress, load, change आदि। इन्हें event handlers (जैसे onclick) से manage किया जाता है।
AngularJS क्या है?
AngularJS Google द्वारा 2010 में बनाया गया JavaScript framework है जो dynamic web apps बनाने के लिए उपयोग होता है। यह two-way data binding, MVC architecture व directives support करता है।
AngularJS Directives क्या होते हैं?
Directives वे special HTML attributes हैं जो elements को नया behaviour देते हैं — जैसे ng-app, ng-model, ng-repeat, ng-bind। ये data binding व UI control में उपयोग होते हैं।

🎯 Chapter 6 पूरा हुआ! अब आगे बढ़ें

Chapter 7 में Photo Editor tools — images edit करने के लिए ज़रूरी software व techniques।

Chapter 7 पढ़ें ➜