-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathBasic.js
More file actions
223 lines (117 loc) · 3.65 KB
/
Basic.js
File metadata and controls
223 lines (117 loc) · 3.65 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
// First Line Code
console.log("My Firs Code in Javascript");
// My First Variable (Container)
// there is only three keyword for declaring any variable
// let var const
// Variable decalragtion using Var
var myName = "Vishal Sharma";
var myNumber = 9915378881;
var myTechStack = [
"ReactJs",
"JavaScript",
"NextJs",
"VueJs",
"Angular",
"NodeJs",
"React Native",
];
var myDetails = {
name: "Vishal",
lastName: "Sharma",
};
console.log(myName, myNumber);
console.log(myTechStack);
console.log(myDetails);
// Variable declaration using let
let collegeName = "LPU";
let homeTown = "Zepto";
let pincode = 208002;
console.log("Here varibales with let:: ", collegeName, homeTown, pincode);
// dynamically type conversion
var mobile = 9915378881;
// typeof will give you the type of variable
console.log("First:: ", typeof mobile);
mobile = "9915378881";
console.log("Second:: ", typeof mobile);
mobile = {
phone: "9915378881",
};
console.log("Third:: ", typeof mobile);
// convert number into string
console.log("toString Method::: ==========");
var myPhone = 9915378881;
console.log(typeof myPhone);
myPhone = myPhone.toString();
console.log(typeof myPhone);
// convert string to number
console.log("parseInt Method::: ==========");
var pincode1 = "208002";
console.log(typeof pincode1);
pincode1 = parseInt(pincode1);
console.log(typeof pincode1);
// convert decimal into the integer or number
console.log(parseInt(1234.555));
// constant in javascript
// If you want to declare any variable as constant there is keyword called const for declaring the varaible
const name1 = "Vishal";
name1 = "Vishal"; // this will throw error because you cannot reaasign the const variable
// New Code
console.log("Hey will do later...");
console.log("Hey I am learning Js");
console.log("Requesting evryone to code parallel")
var abc = 'CHIM CHOM';
var abc1 = 'Chim Chom2';
console.log(abc);
console.log(abc1);
var mult1= 'maze me';
var multi2 = "funny ha ";
console.log(mult1 , multi2);
// console value and variable sath me
console.log("Hey your name is ::" , abc , "," , 'Hey updated name is::' , abc1);
// typeof
console.log( "Data type of multi2 is::" ,typeof multi2 , 'data type of multi1::' , typeof mult1) // string
var a = 20;
var b= 30;
console.log(40)
console.log(a , b)
console.log(typeof a , typeof b)
console.log(typeof -1)
var c = a+b;
console.log(typeof c)
console.log(1/0); // Infinity => NaN isNaN();
console.log(typeof 1/0); // => NAN
console.log(typeof Infinity , 'hey') //number
// Primitive Datatype
// string , number , boolean , undefined , null , , =>>> Symbol ,BigInt ()
console.log(typeof Boolean); // Function
console.log(typeof Number); // // Function
console.log(typeof String); //// Function
var dataType = typeof 'hello'; // string
console.log(typeof dataType)
console.log(typeof undefined) // undefined
console.log(typeof null)
var checked = true; // booolean
console.log( typeof typeof checked)
checked = "Hey I am converted"; // strinf
console.log('newtype' ,typeof checked)
checked = 1234;
console.log(typeof checked);
checked = ()=> {
console.log("yeee");
}
console.log(typeof checked);
lastName = "Hello";
console.log(lastName)
// isNaN() => THIS FUNCTION
var p = "1234"; // typeof p => string;
var pp = 'hey'
var t = Number('p');
var tt = Number(pp)
console.log(t ,'hey');
console.log(typeof NaN)
console.log(typeof tt);
console.log(typeof +'12345') ; // shorthan way to convert number string to number
var isNumber = isNaN('123456'); // FALSE
var isNumber2 = isNaN('hello'); // TRUE
console.log(isNumber)
console.log(isNumber2)