Trang 11 JavaScript rests in the Bodydocument.getElementById"demo12".innerHTML = "This is your FirstJavaScript"; JavaScript Rests in the Body Trang 12 4 BÀI 1: You have seen the JavaSc
Trang 1Biên
www.hutech.edu.vn
Trang 2*1.2021.CAP126*
tailieuhoctap@hutech.edu.vn
Trang 3I V
1
1
1
2
5
8
8
1.1.6 Tính toán 9
9
10
11
13
14
15
15
16
17
18
19
23
24
25
27
N 28
28
29
31
35
37
37
38
39
43
44
44
1.5.8 46
Trang 449
1.5.10 JavaScript Iteration 51
52
54
55
56
57
59
63
65
67
1.6.4 70
1.6.5 70
71
73
76
78
80
1 81
1.7.4 Arrow Functions 82
83
85
86
88
BÀI 2: JAVASCRIPT NÂNG CAO 95
95
95
96
98
98
2.1 99
2.1.1 100
103
105
105
106
108
109
113
115
117
Trang 52.3.1 Requesting Remote Data with Fetch 117
121
2.1.2 123
124
125
125
ent-Side Storage 129
-Side Data Storage Item 129
BÀI 3: NODE.JS 131
131
3.2 CÁC MODULE TRONG NODE.JS 133
3.3 REPL TERMINAL TRONG NODE.JS 135
3.4 NODE.JS NPM 138
138
140
142
142
3.5 EVENT LOOP VÀ EVENTEMITTER 143
143
145
146
146
3.5.5 Buffer và Stream 148
148
149
3.6 FILESTREAM TRONG NODE.JS 150
151
152
152
3.7.2 Dùng MongoDB và Node.js 153
156
3.8.1 filename trong Node.js 156
3.8.2 dirname trong Node.js 157
3.8.3 Hàm setTimeout(cb, ms) trong Node.js 158
3.8.4 Hàm clearTimeout(t) trong Node.js 158
3.8.5 Hàm setInterval(cb, ms) trong Node.js 159
160
3.9.1 Express.js là gì 160
161
3.9.3 Các Route là gì 162
3.10 API SERVER TRONG NODE.JS 165
Trang 6BÀI 4: ANGULAR 168
168
169
174
174
4.3.2 Lazy loading with Angular 12 182
gular 12 191
201
4.3.5 HttpClient with Angular 12 215
ANGULAR 12 226
BÀI 5: REACT 233
233
242
244
245
- REACTJS VÀ ANGULARJS 245
Trang 835%
Trang 11JavaScript Rests in the Body
This is your First JavaScript
Trang 12This is A Web Page
I have changed the Paragraph
Click Me
Trang 13<p>This is going to be my First Web Page</p>
<p>This will be the First Paragraph.</p>
This is going to be my First Web Page
This will be the First Paragraph
<p>This is going to be my First Web Page</p>
<p>This will be the First Paragraph.</p>
<p id="demo1234"></p>
<script>
document.write (4567 + 36);
</script>
Trang 146 BÀI 1:
</body>
</html
This is going to be my First Web Page
This will be the First Paragraph
4603
<!DOCTYPE html>
<html>
<body>
<p>This is going to be my First Web Page</p>
<p>This will be the First Paragraph.</p>
<button type="button" onclick="document.write(335 + 6)">Click me</button>
</body>
</html>
This is going to be my First Web Page
This will be the First Paragraph
<p>This is going to be my First Web Page</p>
<p>This will be the First Paragraph.</p>
<p id="demo1234"></p>
<script>
window.alert (4567 + 36);
Trang 15</body>
</html>
This is going to be my First Web Page
This will be the First Paragraph
<!DOCTYPE html>
<html>
<body>
<p>This is going to be my First Web Page</p>
<p>This will be the First Paragraph.</p>
<p>This is going to be my First Web Page</p>
<p>This will be the First Paragraph.</p>
<p id="demo1234"></p>
<script>
console.log (4567 + 36);
Trang 19<!DOCTYPE html>
<html>
<body>
<p>Learn JavaScript Arrays</p>
<p>The indices of JavaScript Arrays are zero-based It means the first item
Learn JavaScript Arrays
The indices of JavaScript Arrays are zero-based It means the first item in an array is [0]
Volkswag
1.2 BI N TRONG JAVASCRIPTS
-
-
Trang 20<p>These are JavaScript Variables</p>
<p>In the following example, a, b, and c are JavaScript variables.</p>
These are JavaScript Variables
In the following example, a, b and c are JavaScript variables
The value of c is: 66
Trang 21<!DOCTYPE html>
<html>
<body>
<p>You are studying JavaScript Variables</p>
<p>In the following example, the variables will have full-word names.</p>
You are studying JavaScript Variables
In the following example, the variables will have full-word
names
The value of totalprice is: 310
-
Trang 22<p>You are studying JavaScript Variables</p>
<p>I am defining JavaScript datatypes.</p>
<p id="variable-demo"></p>
<script>
var num = 5555555.889;
var novelist = "Charles Dickens";
var introduction = 'Charles Dickens wrote melodramatic novels!'; document.getElementById("variable-demo").innerHTML =
num + "<br>" + novelist + "<br>" + introduction;
</script>
</body>
</html>
Trang 23You are studying JavaScript Variables
I am defining JavaScript datatypes
<!DOCTYPE html>
<html>
<body>
<p>You are studying JavaScript Variables</p>
<p>I am defining JavaScript's undefined variables.</p>
Trang 2416 BÀI 1:
</body>
</html>
You are studying JavaScript Variables
I am defining JavaScript's undefined variables
1.2.5 Khai báo l i m t bi n
<!DOCTYPE html>
<html>
<body>
<p>You are learning JavaScript Variables</p>
<p>This is JavaScript's undeclared variables.</p>
<p id="variable-demo"></p>
<script>
var num = 5555.444;
var novelist = "Charles Lamb";
var introduction = "Charles Lamb wrote beautiful humor.";
You are learning JavaScript Variables
This is JavaScript's undeclared variables
Trang 27<p>JavaScript Let Keyword</p>
<p>You can access a GLOBAL variable working from any script or any function.</p>
Trang 2820 BÀI 1:
</body>
</html>
JavaScript Let Keyword
You can access a GLOBAL variable working from any script or any
<p>These are JavaScript Scopes</p>
<p>I will define and declare a variable outside of Function2().</p>
Trang 29I will define and declare a variable outside of Function2()
Trang 32These are JavaScript constants
Let try if we can change primitive value
TypeError: Assignment to constant variable
// I am going to create an object:
const mycar = {name:"Honda", model:"Vezel", make:"Japan",
color:"Grey"};
// Let us Change the property:
mycar.model = "Civic";
Trang 33<p>In this example, I will be declaring a Variable by Using the const
<p>These are JavaScript constants</p>
<p>Let try if we can change primitive value.</p>
<p id="const-demo"></p>
<script>
try {
Trang 34These are JavaScript constants
Let try if we can change primitive value
TypeError: Assignment to constant variable
// I am going to create an object:
const mycar = {name:"Honda", model:"Vezel", make:"Japan",
color:"Grey"};
// Let us Change the property:
mycar.model = "Civic";
Trang 35// You also can add a new property:
mycar.transmission = "Automatic";
// It is time to display your properties:
document.getElementById("const-demo").innerHTML = "I have a " + mycar.name + "." + " It is of " + mycar.color + " color and its model label is
" + mycar.model + " " + "This car has " + mycar.transmission +
<p>Learning JavaScript constants</p>
<p>Prohibited: You cannot reassign a different object to the same constant:
Trang 36Learning JavaScript constants
Prohibited: You cannot reassign a different object to the same constant:
Trang 37per the current time:</p>
<button onclick="FunctionX()">Please hit me to display the
greetings</button>
<p id="ifelse-demo"></p>
<script>
Trang 38the current time:
Please hit me to display the greetings
Have a Great Day
per the current time:</p>
<button onclick="FunctionX()">Please hit me to display the
Trang 39var mytime = new Date().getHours();
the current time:
Please hit me to display the greetings
Have a Great Day Don't forget to eat your lunch
Trang 42BÀI 1: 37
lastIndexOf() New York
<!DOCTYPE html>
<html>
<body>
<p>Learning Properties of JavaScript Strings</p>
<p>This String property will answer the question about the inner string of
Trang 43<p>Learning Properties of JavaScript Strings</p>
<p>This String property will answer the question about the length
Trang 44<p>Learning Properties of JavaScript Strings</p>
<p>This String property will answer the question about the inner string of
Trang 451.5.1 c lastIndexOf()
lastIndexOf() New York
<!DOCTYPE html>
<html>
<body>
<p>Learning Properties of JavaScript Strings</p>
<p>This String property will answer the question about the inner string of
Trang 46<p>Learning Properties of JavaScript Strings</p>
<p>This String property will answer the question about the inner string of
Trang 47var msgY = msgX.search("New York");
<p>Learning Properties of JavaScript Strings</p>
<p>This String property will answer the question about the inner string of
Trang 48<p>Learning Properties of JavaScript Strings</p>
<p>This String property will answer the question about the inner string of
Trang 49<p>This String property will answer the question about the inner
<p>Learning Properties of JavaScript Strings</p>
<p>This String property will answer the question about the inner
Trang 50Learning Properties of JavaScript Strings
I am about to leave for 'Las Vegas' to start my own business
Trang 51Learning Properties of JavaScript Strings
I am about to leave for 'Las Vegas' to start my own business
Learning JavaScript Strings
I have been promoted as Chief Executive Officer of Skyfall I will call a board meeting next week.!
Trang 52<p>Please click "Click me" to produce the first array element.</p>
<button onclick="FunctionX()">Click This Button</button>
Please click "Click me" to produce the first array element
Click This Button
Texas
1.5.7 M ng trong JavaScript
var,
Trang 54<!DOCTYPE html>
<html>
<body>
<p>Learning JavaScript Arrays</p>
<p>I will use the push method to append new elements to existing arrays
Trang 55Learning JavaScript Arrays
I will use the push method to append new elements to existing arrays
Please click this Button
Pumpkin, Tomato, Ginger, Potato
Please click this Button
Pumpkin, Tomato, Ginger, Potato,Spinach
<!DOCTYPE html>
<html>
<body>
<p>Learning JavaScript Arrays</p>
<p>I will use the push method to append new elements to existing arrays
Trang 56Learning JavaScript Arrays
I will use the push method to append new elements to existing arrays
Please click this Button
Pumpkin, Tomato, Ginger, Potato, Spinach
<!DOCTYPE html>
<html>
<body>
<p>Learning JavaScript Arrays</p>
<p>I will add elements that have high indices The result will be undefined
"holes" in the array.</p>
<p id="undefinedarray-demo"></p>
<script>
Trang 57Learning JavaScript Arrays
I will add elements that have high indices The result will be undefined "holes" in the array
Trang 5850 BÀI 1:
<html>
<body>
<p>JavaScript Array concat()</p>
<p>The concat() method follows the merging pattern:</p>
JavaScript Array concat()
The concat() method follows the merging pattern:
Tomato, Potato, Cauliflower, Cabbage, Orange, Fig, Guava, Date
concat()
<!DOCTYPE html>
<html>
<body>
<p>JavaScript Array concat()</p>
<p>The concat() method follows the merging pattern:</p>
<p id="array-demo"></p>
<script>
var veggies = ["Tomato ", "Potato ", "Cauliflower ", "Cabbage "]; var frutoos = ["Orange ", "Fig ", "Guava ", "Date "];
var summerfrutoos = ["Watermelon ", "Melon ", "Mango "]
var fruitbasket = veggies.concat(frutoos, summerfrutoos);
document.getElementById("array-demo").innerHTML = fruitbasket;
</script>
Trang 59</html>
JavaScript Array concat()
The concat() method follows the merging pattern:
Tomato ,Potato ,Cauliflower ,Cabbage ,Orange ,Fig ,Guava ,Date
,Watermelon ,Melon ,Mango
1.5.10 JavaScript Iteration
forEach()
<!DOCTYPE html>
<html>
<body>
<p>This is JavaScript Array.forEach()</p>
<p>This method makes a function call at least once for all individual array
Trang 60<p>This is JavaScript Array.filter()</p>
<p>The following program will create a new array by filtering all array
elements that tend to pass the test.</p>
Trang 61This is JavaScript Array.map()
I will create a new array by applying the function on all array elements
var nums2 = nums1.map (FunctionM);
document.getElementById ("demo90") innerHTML = nums2;
} </script>
</body>
</html>
Trang 62<p>This is JavaScript Array.filter()</p>
<p>The following program will create a new array by filtering all array
elements that tend to pass the test.</p>
Trang 63The following program will create a new array by filtering all array elements that tend to pass the test
<p>This is JavaScript Array.reduce()</p>
<p>The following program will create a new array by reducing all array
elements that tend to pass the test.</p>
function FunctionZ(Total, valueF) {
return Total + valueF;
}
</script>
</body>
</html>
This is JavaScript Array.reduce()
The following program will create a new array by filtering all array elements that tend to pass the test
160433
Trang 64<p>This is JavaScript Array.filter()</p>
<p>The following program will create a new array by filtering all array
elements that tend to pass the test.</p>
function FunctionZ(Total, valueF) {
return Total + valueF;
}
</script>
</body>
</html>
This is JavaScript Array.filter()
The following program will create a new array by filtering all array
elements that tend to pass the test
5000160433
every() không
<!DOCTYPE html>
Trang 65<body>
<p>This is JavaScript Array.every()</p>
<p>The following program will display the results of the test.</p>
<p id="demo789"></p>
<script>
var nums = [45890, 17, 3459, 18, 2, 6, 23416, 87625900000];
var Over500 = nums.every(FunctionZ);
document.getElementById("demo789").innerHTML = "Are all values bigger than 500: " + Over500;
This is JavaScript Array.every()
The following program will display the results of the test
Are all values bigger than 500: false