-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path04-Type-conversion.js
More file actions
37 lines (32 loc) · 825 Bytes
/
Copy path04-Type-conversion.js
File metadata and controls
37 lines (32 loc) · 825 Bytes
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
// Datatypes in javaScript
/*
String
Number
Booleans
Undefined
null
BigInt
Symbol
*/
// typeof oferator -> gives the datatype of variable
// let age = 22;
// console.log(typeof age);
// Some Important thing
// age = age + "";
// console.log(typeof age);
// This will give the output as string because adding a string to number changes it to string
// converting number to string
// Just adding string to number will change the number to string.
// Second method
// let age = 18;
// age = String(age); //using String method
// console.log(typeof age);
//converting string to number
//use + operator at the beginning of the string.
// let age = +"22";
// console.log(typeof age);
//It will give output as number
//SECOND METHOD
// let age = "22";
// age = Number(age); //using Number method.
// console.log(typeof age);