forked from jetbreed/ES6_Basics_JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSpreadOperator.html
44 lines (33 loc) · 855 Bytes
/
SpreadOperator.html
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
<!DOCTYPE html>
<html>
<body>
<script>
//object variable
//in java is HashMap
//in java is HashSet
//A key-value map representation
const myVehicle = {
brand: 'Ford',
model: 'Mustang',
color1: 'red'
}
//object variable
const updateMyVehicle = {
type: 'car',
year: 2021,
color2: 'yellow'
}
//Spread feature will help us to merge multiple arrays or objects
const arrayObject = ["Omiete", "Esther", "Waribi", "Sam", "Life"];
const myUpdatedVehicle = {...myVehicle, ...updateMyVehicle}
const variableObj_arrayObj = {...arrayObject, ...myVehicle}
//Check the result object in the console:
console.log(myVehicle);
console.log(updateMyVehicle);
console.log(myUpdatedVehicle);
console.log(arrayObject);
console.log(variableObj_arrayObj);
</script>
<p>Press F12 and see the result object in the console view.</p>
</body>
</html>