📑 Table of Contents — किसी भी topic पर सीधे जाएँ
Client-Side Scripting Introduction — Browser में चलने वाला Code
जब कोई 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 बनी रहती है।
<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 कहते हैं।
<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 Scripting | Server-Side Scripting |
|---|---|
| Browser पर run होती है | Server पर run होती है |
| Page interaction व validation के लिए | Database व backend logic के लिए |
| Example: JavaScript, VBScript | Example: PHP, ASP, Node.js |
| तेज़ execution | Server communication की वजह से धीमा |
Variables in JavaScript — Data रखने का Container
🧠 Declare करने के 3 तरीके
| Keyword | Scope | Reassignable | Description |
|---|---|---|---|
| var | Function Scope | Yes | पुराना तरीका (ES5 तक) |
| let | Block Scope | Yes | Modern (ES6) — recommended |
| const | Block Scope | No | Constant — value बदली नहीं जा सकती |
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।
let globalVar = "I am global!";
function testScope() {
let localVar = "I am local!";
console.log(globalVar + " " + localVar);
}📋 Naming Rules
- Letter, underscore (_) या $ से शुरू होता है।
- बीच/अंत में numbers आ सकते हैं, शुरुआत में नहीं।
- Case-sensitive होते हैं (
name≠Name)। - Reserved keywords (var, if, function) नाम नहीं बन सकते।
// ✅ Valid let firstName = "Aman"; let _count = 10; // ❌ Invalid let 1name = "Ravi"; // digit से शुरू नहीं हो सकता let var = "Hello"; // reserved keyword
Operators in JavaScript — गणना, तुलना व निर्णय
1️⃣ Arithmetic Operators
| Operator | काम | Example |
|---|---|---|
| + | Addition | 10+5=15 |
| - | Subtraction | 10-5=5 |
| * | Multiplication | 10*5=50 |
| / | Division | 10/2=5 |
| % | Modulus (शेष) | 10%3=1 |
| ++/-- | Increment/Decrement | x++ / x-- |
let a = 10, b = 5; console.log(a + b); // 15 console.log(a % b); // 0
2️⃣ Assignment Operators
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 equal | 5!=10 → true |
| > / < | Greater/Less than | 10>5 → true |
== सिर्फ value compare करता है (type conversion करता है), === value व type दोनों check करता है — यह बहुत common exam question है।4️⃣ Logical Operators
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
let age = 18; let result = (age >= 18) ? "Eligible to Vote" : "Not Eligible";
Conditional Statements — शर्तों के अनुसार निर्णय
1️⃣ if Statement
let age = 20;
if (age >= 18) {
console.log("You are eligible to vote.");
}2️⃣ if...else Statement
let marks = 40;
if (marks >= 50) {
console.log("You Passed!");
} else {
console.log("You Failed!");
}3️⃣ if...else if...else Ladder
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 का विकल्प।
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 | उपयोग |
|---|---|
| if | Single condition check |
| if...else | True/False दोनों में अलग output |
| if...else if...else | Multiple conditions |
| switch | कई fixed values के अनुसार code चलाना |
JavaScript Popup Boxes — User से सीधा Interaction
1️⃣ alert() Box
Simple message दिखाने के लिए।
function showAlert() {
alert("Welcome to JavaScript!");
}2️⃣ confirm() Box
OK व Cancel दो buttons होते हैं। OK पर true, Cancel पर false return होता है।
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 के रूप में मिलता है।
let name = prompt("Please enter your name:");
if (name != null && name != "") {
console.log("Hello " + name + "!");
}| Popup | काम | उपयोग |
|---|---|---|
| alert() | Information दिखाना | Warning/notification |
| confirm() | OK/Cancel confirmation | Delete/submit confirm |
| prompt() | User input लेना | Name/email पूछना |
JavaScript Events — User की हरकतों पर Reaction
Event Flow — Action से Response तक
🔹 Common Event Types
| Event | कब trigger होता है |
|---|---|
| onclick | Element पर click होने पर |
| ondblclick | Double-click होने पर |
| onmouseover | Mouse element के ऊपर आने पर |
| onmouseout | Mouse element से हटने पर |
| onkeyup / onkeydown | Key release/press होने पर |
| onload | पूरा page load होने पर |
| onchange | Input value बदलने पर |
| onsubmit | Form submit होने पर |
🖱️ onClick Example
<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
<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
<input type="text" onkeyup="showKey(event)">
<script>
function showKey(event) {
console.log("You pressed: " + event.key);
}
</script>Basic Form Validation — Input की जाँच
🔹 Types of Validation
- Required Field: field खाली न हो।
- Email Validation: सही format हो (example@gmail.com)।
- Password Validation: पर्याप्त लंबा/secure हो।
- Number Validation: केवल numbers allow हों।
📋 Registration Form Validation Example
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
function checkNumber() {
let num = document.getElementById("num").value;
if (isNaN(num) || num == "") {
alert("Please enter a valid number!");
} else {
alert("Valid Number: " + num);
}
}| Validation | Method |
|---|---|
| Empty Field | if (x == "") |
| Email Format | .match(regex) |
| Number Check | isNaN() |
| Password Length | .length |
AngularJS: Expressions, Modules & Directives — Dynamic Web Apps
✨ Key Features
- Two-Way Data Binding
- MVC (Model-View-Controller) Architecture
- Reusable Components
- Dependency Injection
- Directives & Expressions
📍 AngularJS को Project में जोड़ना
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></script>
1️⃣ AngularJS Expressions
Data को HTML में display करने के लिए — curly braces {{ }} के अंदर लिखा जाता है।
<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 होते हैं।
<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-app | Application define करता है |
| ng-model | Input field को data से bind करता है |
| ng-bind | Data को HTML elements में display करता है |
| ng-repeat | Arrays/lists को repeat करता है |
| ng-show / ng-hide | Condition के अनुसार element दिखाना/छुपाना |
<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
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)।
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)
- Client-Side Scripting Language क्या है? उदाहरण दीजिए।Client-Side Scripting Language browser में run होती है, server की ज़रूरत नहीं होती। उदाहरण — JavaScript, VBScript। यह webpage को interactive बनाती है।
- Client-Side और Server-Side scripting में अंतर लिखिए।Client-side browser पर चलती है (JavaScript), page interaction/validation के लिए। Server-side server पर चलती है (PHP), database व backend logic के लिए। Client-side तेज़ होती है।
- var, let व const में अंतर बताइए।var — function scope, reassign हो सकता है, hoisted होता है (पुराना)। let — block scope, reassign हो सकता है (modern)। const — block scope, reassign नहीं हो सकता (constant values के लिए)।
- == और === में अंतर लिखिए उदाहरण सहित।== सिर्फ value compare करता है, type conversion कर लेता है (5=="5" → true)। === value व type दोनों check करता है (5==="5" → false)। एग्ज़ैक्ट comparison के लिए === बेहतर है।
- Ternary operator क्या है? Syntax व example दीजिए।यह if-else का shorthand है। Syntax: condition ? value_if_true : value_if_false। उदाहरण: let result = (age>=18) ? "Eligible" : "Not Eligible";
- switch statement कैसे काम करता है?switch किसी variable की value को अलग-अलग case values से match करता है। Match होने पर वह block चलता है (break तक)। कोई match न हो तो default block चलता है। यह केवल equality check करता है।
- alert(), confirm() व prompt() में अंतर लिखिए।alert() सिर्फ message दिखाता है, कोई return value नहीं। confirm() OK/Cancel देता है, true/false return करता है। prompt() input field देता है, user का typed text (या null) return करता है।
- JavaScript में कोई 4 events के नाम व उनका काम लिखिए।onclick (क्लिक होने पर), onmouseover (mouse ऊपर आने पर), onkeyup (key release पर), onload (page load होने पर)।
- Form validation क्यों ज़रूरी है? कोई 2 validation types लिखिए।Form validation से गलत/अधूरा data server तक जाने से पहले रुक जाता है, जिससे errors व security issues कम होते हैं। Types — required field validation (खाली न हो), email validation (सही format हो)।
- isNaN() function का उपयोग समझाइए।isNaN() check करता है कि value एक valid number है या नहीं — अगर value number नहीं है तो true return करता है। Number input validation में उपयोगी है।
- AngularJS क्या है? इसे किसने बनाया?AngularJS एक open-source JavaScript framework है जो dynamic single-page web applications बनाने के लिए उपयोग होता है — Google द्वारा 2010 में develop किया गया। यह MVC architecture व two-way data binding देता है।
- AngularJS Expressions क्या हैं? उदाहरण दीजिए।Expressions data को HTML में display करने के लिए curly braces {{ }} में लिखी जाती हैं। उदाहरण: {{ 5+5 }} output में 10 दिखाएगा।
- AngularJS Module क्या है?Module AngularJS application का मुख्य container है जिसमें controllers, directives व services define होते हैं। इसे angular.module("appName", []) से बनाया जाता है।
- 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)।
- AngularJS में MVC architecture समझाइए।Model data represent करता है ($scope से), View HTML में display करता है, Controller business logic handle करता है और Model व View के बीच connection बनाता है — इससे code clean व structured रहता है।