1
1
<a name =" basics.md " ></a >
2
+
2
3
# ** Module #1 - The Basics**
4
+
3
5
---
4
6
5
7
<a name =" loading " ></a >
8
+
6
9
## ** LOADING AND RUNNING JAVASCRIPT**
7
10
8
11
add ` <script> ` tag just before the ` </body> ` tag.
@@ -17,6 +20,7 @@ add `<script>` tag just before the `</body>` tag.
17
20
<br >
18
21
19
22
<a name =" variables " ></a >
23
+
20
24
## ** VARIABLES**
21
25
22
26
- ** var** (_ value can be updated_ )
@@ -30,11 +34,14 @@ const cool = true;
30
34
```
31
35
32
36
<a name =" typpeOfVariables " ></a >
37
+
33
38
## ** TYPE OF VARIABLES:**
34
39
35
40
<a name =" strings " ></a >
36
- - ### String:
37
- represent letter, pharagraphs, phases, etc. Can be declared with quotes, double-quotes or back ticks.
41
+
42
+ - ### String:
43
+
44
+ represent letter, paragraphs, phases, etc. Can be declared with quotes, double-quotes or back ticks.
38
45
39
46
``` js
40
47
const name = " Wes" ;
@@ -43,51 +50,60 @@ const cool = true;
43
50
```
44
51
45
52
sentence
46
- with "\ esc", quotes, single quotes and backtip option:
53
+ with "\ esc", quotes, single quotes and backtick option:
47
54
sentence = She´s so "cool"
48
55
49
56
``` js
50
57
const sentence = ' she´s so "cool"' ;
51
- const sentence = " she´s so \ " cool\" " ;
58
+ const sentence = ' she´s so "cool" ' ;
52
59
const sentence = ` She's so "cool"` ;
53
60
```
54
- contatenation & interpolation
61
+
62
+ concatenation & interpolation
63
+
55
64
``` js
56
- const hello = ` hello my name is ${ variable_name} nice yo meet you. I'm ${ 30 + 5 } years old`
65
+ const hello = ` hello my name is ${ variable_name} nice yo meet you. I'm ${
66
+ 30 + 5
67
+ } years old` ;
57
68
```
58
69
59
70
<a name =" numbers " ></a >
60
- - ### Numbers:
71
+
72
+ - ### Numbers:
73
+
61
74
Numbers on Javascript includes float, integers, etc ...
62
- there are all the basic operation (addition, substraction , multiplication and division).
75
+ there are all the basic operation (addition, subtraction , multiplication and division).
63
76
64
77
``` js
65
- let a = 10 + 10 // addition
66
- let b = 20 - 10 // subtraction
67
- let c = 10 * 10 // multiplication
68
- let d = 100 / 10 // division
69
- let e = 1000 % 3 // modulo
78
+ let a = 10 + 10 ; // addition
79
+ let b = 20 - 10 ; // subtraction
80
+ let c = 10 * 10 ; // multiplication
81
+ let d = 100 / 10 ; // division
82
+ let e = 1000 % 3 ; // modulo
70
83
```
71
- Javascript have helper methods like:
72
-
84
+
85
+ Javascript have helper methods like:
86
+
73
87
``` js
74
- Math .round (20.5 ) // result 21, round number up or down
75
- Math .floor (20.2 ) // result 20, will give you the lower
76
- Math .ciel (20.9 ) // result 21, will give you the upper
77
- Math .random () // gives random number between 0 and 1
88
+ Math .round (20.5 ); // result 21, round number up or down
89
+ Math .floor (20.2 ); // result 20, will give you the lower
90
+ Math .ceil (20.9 ); // result 21, will give you the upper
91
+ Math .random (); // gives random number between 0 and 1
78
92
```
79
93
80
94
NaN is an other number, that means _ Not a number_
81
-
95
+
82
96
``` js
83
- let a = 10 / ' dog' ;
84
- console .log (a)
97
+ let a = 10 / " dog" ;
98
+ console .log (a);
85
99
86
100
// result: NaN
87
101
```
88
102
89
- <a name =" objects " ></a >
90
- - ### Objects
103
+ <a name =" objects " ></a >
104
+
105
+ - ### Objects
106
+
91
107
Everything in javascript is an object, are use for collections of data or functionality.
92
108
93
109
``` js
@@ -97,32 +113,37 @@ const cool = true;
97
113
age = ' 35'
98
114
};
99
115
```
116
+
100
117
order doesn't matter in objects, we can access to the properties, the easiest way is:
101
118
102
119
``` js
103
- person .firstName // access to the first name properti
104
- person .lastName // access to the last name properti
105
- person .age // access to the age properti
120
+ person .firstName ; // access to the first name properties
121
+ person .lastName ; // access to the last name properties
122
+ person .age ; // access to the age properties
106
123
```
107
124
108
- <a name =" null_undefined " ></a >
109
- - ### Null and Undefined
125
+ <a name =" null_undefined " ></a >
126
+
127
+ - ### Null and Undefined
128
+
110
129
** Undefined:** comes when you try to access toa variable that has been created, but not set.
111
130
112
131
``` js
113
132
let dog;
114
- console .log (dog); // result should be undefined
133
+ console .log (dog); // result should be undefined
115
134
```
116
135
117
- ** Null:** is a value of nothing
136
+ ** Null:** is a value of nothing
118
137
119
138
``` js
120
- let somethingNull = null ;
139
+ let somethingNull = null ;
121
140
```
122
- <a name =" booleans " ></a >
123
- - ### Boolians and equiality
124
141
125
- ** Booleans:** is a value of true or false, can be manually set or calculate:
142
+ <a name =" booleans " ></a >
143
+
144
+ - ### Booleans and equality
145
+
146
+ ** Booleans:** is a value of true or false, can be manually set or calculate:
126
147
127
148
``` js
128
149
// manually set
@@ -134,24 +155,26 @@ const cool = true;
134
155
console .log (ofAge); // result should be false
135
156
```
136
157
137
- ** Equality:** we have:
158
+ ** Equality:** we have:
159
+
138
160
- = (setting or updating a variable)
139
161
- == (it compares the value but not the type of )
140
162
- === (compares the value and type of )
141
163
142
164
``` js
143
165
// =
144
- let dog = ' Sharon' ;
166
+ let dog = " Sharon" ;
145
167
146
168
// ==
147
- " 10" == 10 // result is true, it compares the value but not the type of (both values are 10)
169
+ " 10" == 10 ; // result is true, it compares the value but not the type of (both values are 10)
148
170
149
171
// ===
150
- " 10" === 10 // result is false, compares value and type of (first one is string, second one is number)
151
- ```
172
+ " 10" === 10 ; // result is false, compares value and type of (first one is string, second one is number)
173
+ ```
152
174
153
175
<br >
154
176
155
177
---
178
+
156
179
back to [ Table of Content] ( tableOfContent.md )
157
- next [ Functions] ( 02_functions.md )
180
+ next [ Functions] ( 02_functions.md )
0 commit comments