-
Notifications
You must be signed in to change notification settings - Fork 0
/
conversion.js
77 lines (57 loc) · 2.14 KB
/
conversion.js
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
let score=33
console.log(typeof score);
// let valuInnumber=number(score)
// console.log(typeof number);
//"33"=33
//"33abc"=nan not a number
//true=1 false=0
let isLogeedin=1
let booleanLoggedin=Boolean(isLogeedin)
console.log(typeof isLogeedin);
let someNumber=35
let StringNumber=String(someNumber)
console.log(typeof StringNumber);
let Truenumber=45
let symbolnumber=Symbol(Truenumber)
console.log( typeof symbolnumber);
//*******************************OPERATIONS*************************************\\
let negative=45
let isNegative=-(negative)
console.log(typeof isNegative);
console.log(isNegative);
//basic operations//
console.log(2*2)
console.log(2+2);
console.log(2-2);
console.log(4%2);
console.log(4/2)
//********************conceptual operations *//
console.log("2"+2) // output=22
console.log(2+"2") // output=22
console.log("2"+2+2) //output:-222
console.log("2"+"2") //output=22
console.log(2+2+"2") //output=42
//this comes under the type conversion if the first datatype is of string it will concatinate the rest if the first datatype is of number then it will
//it will do the first operation then it will prceed further//
//****************************************increment and decrement operator *****************************//
let gameCounter=100
gameCounter++
console.log(gameCounter);
let gameCounter1=101
++gameCounter1 // it will add one value to the gamecounter and then return the gamecounter value//
let gameCounter2=102
gameCounter2++ // it will first return the value of the gamecounter and then add one to it i.e it will first give 102 and then after gives 103//
console.log(gameCounter2);
//******************************************comparison operator *******************************//
console.log(2>1)//true
console.log(2<1)//false
console.log(2>=1)//true
console.log(2==1)//false
console.log(2!=1)//true
console.log(null==0)//false
console.log(null>0)//false
console.log(null>=0)//true
//comaprison operations converts null into number and then do the comaprison i.e null converted to 0 then it was compared to the 0>=0 as true//
console.log(undefined>0)//false
console.log(undefined<0)//false
console.log(undefined==0)//false