You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 100Questions/100_JS_Que
+80Lines changed: 80 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -4,3 +4,83 @@ console.log(a==b); //false
4
4
console.log(a===b); //false
5
5
//Explaination : Here we are comparing memory location, not an array. Memory location of 2 arrays are not same.
6
6
--------------------------
7
+
let a = [];
8
+
let b = a;
9
+
console.log(a==b); //true
10
+
console.log(a===b); //true
11
+
//Explaination : Here we are assigning a to b, where memory location is now same.
12
+
---------------------------
13
+
let a = [1];
14
+
let b = [1];
15
+
console.log(a[0]==b[0]); //true
16
+
console.log(a[0]===b[0]); //true
17
+
//Explaination : Here we are comparing elements inside an array, not a memory location. We specify the index so that's why element get compared.
18
+
-----------------------------
19
+
let z= [1,2,3]
20
+
let a ={name: "priya"}
21
+
console.log(...z); // 1 2 3
22
+
//Explaination : ...z means destructing happened i.e, all the elements are come out from an array/object.
23
+
------------------------------
24
+
console.log(typeof NaN); //number
25
+
//Explaination : If we divide "priya"/2 then it will give NaN.
26
+
--------------------------------
27
+
let data = 10 - -10;
28
+
console.log(data); //20
29
+
//Explaination : Minus minus will become plus so 10+10=20
30
+
---------------------------------
31
+
const set = new Set([1,1,2,2,3,4,5])
32
+
console.log(set) //{1,2,3,4,5}
33
+
//Explaination : It will remove duplicate values.
34
+
---------------------------------
35
+
let data ={name: "priya"}
36
+
console.log(delete data.name); //true
37
+
console.log(data)//{}
38
+
//Explaination : delete will return either true or false.
39
+
-----------------------------------
40
+
let data ={name: "priya"}
41
+
console.log(delete data); //false
42
+
//Explaination : We can delete the object property only. We can't able to delete the object(i.e, data).
43
+
------------------------------------
44
+
const data = ["piya", "priya", "supriya"];
45
+
const [y] = data;
46
+
console.log(y); //"priya"
47
+
//Explaination : We are doing destructuring here. y is representing the first index only
48
+
-------------------------------------
49
+
const data = ["piya", "priya", "supriya"];
50
+
const [y,z] = data;
51
+
console.log(y,z); //"priya", "priya"
52
+
//Explaination : We are doing destructuring here. y is representing the first index only and z representing the second index.
53
+
--------------------------------------
54
+
const data = ["piya", "priya", "supriya"];
55
+
const [,m] = data; // way to access any specific element here at second position
56
+
console.log(m); //"priya"
57
+
//Explaination : To access any element without taking previous values, we can do just write comma.
58
+
--------------------------------------
59
+
const data ={name:"priya"}
60
+
const {name} = data; //how to get the name property without . dot operator
61
+
console.log(name);//priya
62
+
//Explaination : Here we did object destructuring.It's not store in continuos memory location but array store in continuoes memory location so that's why we used comma in an array.
63
+
--------------------------------------
64
+
let data ={name:"priya"}
65
+
let data1={city:"ABC"}
66
+
data = {...data, ...data1} //merge 2 objects
67
+
console.log(data); // {name:"priya", age:"ABC"}
68
+
//Explaination : using spread operator we use to merge the 2 objects. Three dots will pop out the property from an object and assign inside curly brackets.
//Explaination :Three dots will pop out the property from an object and assign inside curly brackets. If we didn't do destructing or spread operator then key will be object name(i.e, data) and assign the value as whole object into it.
//Explaination : If we have same keys while merging then the position of the property will remain same but the value get updated with new value. Because in an objects Keys hould be unique.
81
+
-------------------------------------------
82
+
const name = "priya"
83
+
console.log(name()); //Error: name is not a function
84
+
//Explaination : Function we are calling but it's not present so it will an error.
0 commit comments