Skip to content

Commit bb08227

Browse files
committed
day 3 javascripts interview
1 parent b7f2860 commit bb08227

1 file changed

Lines changed: 87 additions & 0 deletions

File tree

  • JavaScript Interview/Day 3

JavaScript Interview/Day 3/fun.js

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
2+
/*
3+
event propagession
4+
5+
Capturing Phase: document → grandparent → parent → child.
6+
Target Phase: The event is processed at the child element.
7+
Bubbling Phase: child → parent → grandparent → document.
8+
9+
10+
11+
12+
1. function abc() {
13+
console.log(abc.xyz);
14+
}
15+
16+
abc()//undefine
17+
abc.xyz = 400
18+
abc.xyz = 200
19+
abc()//200
20+
21+
output
22+
undefined
23+
200
24+
25+
2. const numbers = [1, 2, 3, 4]
26+
numbers[100] = 500
27+
console.log(numbers)
28+
output
29+
[ 1, 2, 3, 4, <96 empty items>, 500 ]
30+
31+
3. console.log(typeof 10)//number
32+
console.log( typeof typeof 10)//String
33+
34+
35+
4. Spread operator (...)
36+
37+
The spread operator expands an iterable (like a string, array, or object) into individual elements.
38+
const arr=[..."nilaj"];
39+
console.log(arr)
40+
41+
output
42+
43+
[ 'n', 'i', 'l', 'a', 'j' ]
44+
45+
46+
5. parseInt converts string into Number
47+
48+
console.log(parseInt("10"))//10
49+
console.log(parseInt("N"))//Nan
50+
console.log(parseInt("Nil"))//NaN
51+
console.log(parseInt('10+2'))//10
52+
console.log(parseInt('7FM'))//7
53+
console.log(parseInt('M7F'))//NaN
54+
55+
console.log(isNaN("nilaj"))//true
56+
console.log(NaN("nil"))//error
57+
58+
59+
60+
61+
6. console.log([1,2].map(num=>{
62+
if(num>0) return ;
63+
return num * 2
64+
}))
65+
66+
output
67+
undefined
68+
undefined
69+
70+
71+
7. {
72+
function abc(){
73+
console.log("hii")
74+
}
75+
76+
77+
}
78+
79+
abc()
80+
81+
82+
ouput
83+
hii
84+
*/
85+
86+
87+

0 commit comments

Comments
 (0)