-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode.js
116 lines (95 loc) · 1.47 KB
/
code.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
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
/*if (true) {
var name = '123';
}
console.log(name);
*/
/*
if (true) {
let name = '123';
}
console.log(name);
*/
/*
for (var i=0; i<3; i++) {
console.log(i);
}
console.log(i);
*/
/*
if (5<3) {
console.log('this is impossible');
} else{
console.log('really 5 is not less than 3' );
}
*/
/*
let i=0;
while (i < 4) {
console.log(2);
}
*/
/*array basic example
let students = ['student1','student2','student3']
console.log(students[1]);
*/
/* not an error, but undefined
let students = ['student1','student2','student3']
console.log(students[40]);
*/
/* container
const friends = {friend1: '123456' , friend2: '789456'};
console.log(friends.friend1);
console.log(friends['friend2']);
*/
/*
function fac( n ) {
if ( n == 0 )
return 1;
else
return fac( n - 1 ) * n;
}
console.log(fac(8));
*/
/*
if (0 / 0 > 5 ) {
console.log('you are an idiot');
} else {
console.log('fuckin idiot');
}
*/
/* -Infinity
console.log( -3 / 0 );
*/
/* NaN
console.log( 0 / 0 );
*/
/*Boolean simplest
console.log( 3 < 2 );
*/
/* Logical operators
console.log(5<4 && 12>4);
console.log(5<4 || 12>4);
console.log(!5<4);
*/
/* ternary operator
console.log ( true ? 1 : 2) ;
console.log ( false ? 1 : 2) ;
*/
/*automatic type conversion
console.log (8 * null )
// ! 0
console.log ("5" - 1)
// ! 4
console.log ("5" + 1)
// ! 51
console.log (" five " * 2)
// ! NaN
console.log ( false == 0)
// ! true
*/
/*
console.log ( null == undefined) ;
// ! true
console.log( null == 0) ;
// ! false
*/