-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
304 lines (231 loc) · 7.34 KB
/
Copy pathscript.js
File metadata and controls
304 lines (231 loc) · 7.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
//! JavaScrirpt Variables
//* var, let, const
// ^^^^^^^^^^^^^^^^^^^^^
//! First "var"
// var a; //* Delcare karna
// var b = 10; //* Delcare and intialize
// var //* Function scoped hota hai
// var //* You can redelcare and reintialize
// var //* window object ke sath attach hota hai
// var //* hoisting hota hai
//! Second "let"
// let c; //* Delcare karna
// let d = 10; //* Delcare and intialize
// let //* block scope hota hai
// let //* You can just reintialize
// let //* hoisting hota hai but you can not access it before initialization
//! third "const"
// const a; //* Esa declare karna allowed nahi hai
// const b = 10; //* Delcare and intialize
// const //* block scope hota hai
// const //* You can not reintialize and redeclare
// const //* hoisting hota hai but you can not access it before initialization
// ==>---------------------------------------------------------------------------------------------<== //
//! JavaScript Data Types
// Primitives: string, number, boolean, null, undefined, symbol, bigint
// reference: object, array, function
// Non-Primitive / Reference Data Types: object, array, function
//! ==> Primitive Data Types <== //
//! 1. ( String )
//* String text/data ko represent karta hai
// let a = "Rafay";
// let b = 'Karachi';
// let c = `Pakistan`;
//! 2. ( Number )
//* Number integer aur decimal dono values ko represent karta hai
// let age = 18;
// let price = 99.99;
//! 3. ( Boolean )
//* Boolean ki sirf 2 values hoti hain: true aur false
// let isLoggedIn = true;
// let isAdmin = false;
//! 4. ( Undefined )
//* Variable declare ho lekin usko koi value assign na ki gayi ho
// let username;
// console.log(username); // undefined
//! 5. ( Null )
//* Intentionally empty ya no value ko represent karta hai
// let selectedUser = null;
//! 6. ( Symbol )
// Unique value/identifier create karne ke liye use hota hai
// let id = Symbol("id");
//! 7. ( BigInt )
// Bohat bade integers ko store karne ke liye use hota hai
// let bigNumber = 123456789012345678901234567890n;
//! ==> Non-Primitive / Reference Data Type <== //
//! 8. ( Object )
//* Key-value pairs mein data store karta hai
// let user = {
// name: "Rafay",
// age: 18
// };
//! ( Array )
//* Multiple values ko ek variable mein store karta hai
// let fruits = ["Apple", "Mango", "Banana"];
//! ( Function )
//* Function bhi JavaScript mein ek Object hota hai
// function greet() {
// console.log("Hello");
// }
//! ==> Important Point <== //
// Primitive:
// string
// number
// boolean
// undefined
// null
// symbol
// bigint
// Non-Primitive / Reference:
// object
// array
// function
//! ==> typeof Operator <== //
// typeof se hum kisi value ka data type check kar sakte hain
//* console.log(typeof "Rafay"); // string
//* console.log(typeof 100); // number
//* console.log(typeof true); // boolean
//* console.log(typeof undefined); // undefined
//* console.log(typeof 123n); // bigint
//* console.log(typeof Symbol("id")); // symbol
//* console.log(typeof {}); // object
//* console.log(typeof []); // object
//* console.log(typeof function(){}); // function
//! ==> Important JavaScript Weirdness <== //
// typeof null "object" return karta hai
// console.log(typeof null); // object
// Array technically Object hota hai
// console.log(typeof []); // object
// Array check karne ka correct method:
// console.log(Array.isArray([])); // true
//! ==> JavaScript operators <== //
//* Arithmetic Operators: ( +, -, *, **, /, %, ++, -- )
//* Comparison Operators: ( =, ==, ===, !=, !==, >, <, >=, <= )
//* Assignment Operators: ( =, +=, -=, *=, /=, %= )
//* Logical Operators: ( &&, ||, ! )
//* unary Operators: ( typeof, void, delete )
//* ternary Operators: ( condition ? expr1 : expr2 )
//!Arithmetic Operators
//* +, -, *, **, /, %, ++, --
// ( + ) adition karta hai or concatenate bhi karta hai
// ( - ) subtraction karta hai
// ( * ) multiplication karta hai
// ( ** ) exponentiation karta hai
// ( / ) division karta hai
// ( % ) modules, modulo karta hai
// ( ++ ) increment karta hai
// ( -- ) decrement karta hai
// console.log(10 + "11"); // "1011"
// console.log(20 - 11); // 9
// console.log(10 * 2); // 20
// console.log(2 ** 3); // 8
// console.log(10 / 2); // 5
// console.log(10 % 3); // 1
// console.log(10++); // 11
// console.log(10--); // 9
// console.log(++10); // 11
// console.log(--10); // 9
//! Comparison Operators
//* ==, ===, !=, !==, >, <, >=, <=
// ( = ) assignment operator hai, variable ko value assign karta hai value dal ta hai
// ( == ) values ko compare karta hai, type coercion ke saath
// ( === ) values ko compare karta hai, type coercion ke bina
// ( != ) not equal to hota hai, type coercion ke saath
// ( !== ) strict not equal to hota hai, type coercion ke bina
// ( > ) greater than hota hai
// ( < ) less than hota hai
// ( >= ) greater than or equal to hota hai
// ( <= ) less than or equal to hota hai
// console.log(10 == "11"); // true
// console.log(10 === 10); // true
// console.log(10 != 10); // false
// console.log(10 !== 10); // false
// console.log(10 > 5); // true
// console.log(10 < 5); // false
// console.log(10 >= 5); // true
// console.log(10 <= 5); // false
// let x = 10;
// let y = 20;
// if (x > 5 && y < 30) {
// console.log("A");
// } else{
// console.log("B");
// }
// let temp = 35;
// if (!(temp < 30)) {
// console.log("Hot outside.");
// } else {
// console.log("pleasant outside.");
// }
// let marks = 78;
// let result =
// marks
// >= 80
// ? "A+"
// : marks >= 70
// ? "A"
// : marks >= 60
// ? "B"
// : "Fail";
// console.log(result);
// let num = -8;
// let result = num > 0
// ? (num % 2 === 0 ? "Positive Even" : "Positive Odd")
// : "Not Positive";
// console.log(result);
// let age = 17;
// let status = age >= 18
// ? "Adult"
// : age >= 13
// ? "Teenager"
// : "Child";
// console.log(status);
// let marks = 75;
// let attendance = 80;
// let result = marks >= 75 && attendance >= 80 ? "Pass" : "Fail";
// console.log(result);
// let rafayAge = 10;
// let aliAge = 20;
// let result = rafayAge > aliAge ? rafayAge : aliAge;
// console.log(result);
// let temperature = 35;
// let result = temperature >= 40
// ? "Very Hot"
// : temperature >= 30
// ? "Hot"
// : temperature >= 20
// ? "Normal"
// : "Cold";
// console.log(result);
// let a = 15;
// let b = 4;
// let result = a % b === 0
// ? "Divisible"
// : "Not Divisible";
// console.log(result);
// let num = 12;
// let result = num > 10
// ? num % 2 === 0
// ? "Greater than 10 and Even"
// : "Greater than 10 and Odd"
// : "10 or Less";
// console.log(result);
// function getGrade(score) {
// if (score >= 90 && score <= 100) {
// return "A+"
// } else if (score >= 80 && score <= 89) {
// return "A"
// }
// else if (score >= 70 && score <= 79) {
// return "B"
// }
// else if (score >= 60 && score <= 69) {
// return "C"
// }
// else if (score >= 33 && score <= 59) {
// return "D"
// }
// else if (score >= 0 && score <= z) {
// return "Fail"
// }
// }