Skip to content

Commit 79e3906

Browse files
some js concepts
1 parent c01e6a3 commit 79e3906

File tree

1 file changed

+141
-0
lines changed

1 file changed

+141
-0
lines changed

JavaScript Refresher/index.html

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,148 @@
88
</head>
99
<body>
1010
<script>
11+
12+
/*
13+
There are two types variables in the javascript
14+
1] local
15+
2] global
16+
17+
How we can make the variables?
18+
we can use var , let , const for making the variables
19+
20+
* var - It's globally declare
21+
* let - The lets keyword use in locally (e.g you can meke one let variable in function and with same name
22+
you can also create the another let variavle in onther function so you can do this , But you cannot do
23+
this with var function)
24+
* const - Its always constant variavle you can not chnage this in whole program.
25+
26+
27+
There two types of data types in the javascript
28+
1] primitive
29+
2] non-primitive
30+
31+
The basic differnece between the primitive and non-primitive are the
32+
primitive are immutable
33+
non-primitive are mutable
34+
35+
immutable means those value cannot change after the creation
36+
mutable means those value which can be change after the creation
37+
38+
39+
1] primitive data types are
40+
string - represents the string
41+
number - numeric value
42+
boolean - its use for only true or false
43+
undefined - represents the undefined value
44+
null - no value at all
45+
46+
2] non-primitive data types are
47+
object
48+
array
49+
RegExp
50+
*/
51+
52+
// string e.g
53+
let str = "Rohit";
54+
console.log(str);
55+
56+
// number e.g
57+
let num = 34;
58+
console.log(num);
59+
60+
// boolean e.g
61+
let bool = true;
62+
console.log(bool);
63+
64+
// null e.g
65+
let nu = null;
66+
console.log(nu);
67+
68+
// undefined e.g
69+
console.log(undefined);
70+
71+
72+
// object e.g
73+
const person = {
74+
firstName: "Rohit",
75+
lastName: "Bhadane",
76+
interest: "web dev",
77+
age: 19
78+
}
79+
console.log(person);
80+
81+
// array e.g
82+
const friends = ["Rohit" , "Sumit" , "Sahil" , "Raj"];
83+
console.log(friends);
84+
85+
const points = new Array(50 , 100 , 1);
86+
console.log(points);
87+
88+
89+
90+
/*
91+
There are 3 ways of writing function in javascript
92+
1] function declaration
93+
2] function expression
94+
3] arrow function
95+
*/
96+
97+
// function declaration
98+
function add1(a , b){
99+
console.log(a+b);
100+
}
101+
102+
add1(3 , 5);
103+
104+
// function expression
105+
const add2 = function (a , b){
106+
console.log(a+b);
107+
}
108+
109+
add2(5 , 6);
110+
11111

112+
// arrow function
113+
const add3 = (a , b) => a + b;
114+
console.log(add3(9 , 7));
115+
116+
const check = (r , j) =>{
117+
118+
if(r > j)
119+
return "r is greater";
120+
else
121+
return "j is greater";
122+
}
123+
124+
console.log(check( 4 , 1));
125+
126+
127+
128+
/*
129+
Events in the javascript
130+
what is the event - The event means the javascript interaction with the html, we can handle the
131+
html using javascript with the help of events.
132+
*/
133+
134+
document.addEventListener("click" , function click(){
135+
console.log("clicked");
136+
alert("you now click the header");
137+
})
138+
139+
document.addEventListener("click" , function click(){
140+
console.log("clicked");
141+
142+
let conf = confirm ("are you sure");
143+
console.log(conf);
144+
})
145+
146+
setTimeout(() => {
147+
console.log("This is me");
148+
}, 3000);
149+
console.log("This is the after the me");
150+
12151
</script>
152+
153+
<h1>This is the heading</h1>
13154
</body>
14155
</html>

0 commit comments

Comments
 (0)