-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution
More file actions
61 lines (48 loc) · 1.05 KB
/
Solution
File metadata and controls
61 lines (48 loc) · 1.05 KB
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
JavaScript comparison between Arrays and Objects
// Arrays example
var cars = ["Ferrary", "Maserati", "BMW"]; // enter
undefined
cars // enter
["Ferrary", "Maserati", "BMW"]
cars[1]; // enter
"Maserati"
// to add new date we use push metod
cars.push("MERCEDES") // enter
4
cars // enter
["Ferrary", "Maserati", "BMW", "MERCEDES"]
// or another metod to add new date
cars[1] = "MERCEDES" // enter
"MERCEDES"
// to resign value in Array
cars[1] // enter
"Maserati"
cars[1] = "AUDI" // enter
"AUDI"
cars // enter
["Ferrary", "AUDI", "BMW", "MERCEDES"]
// Objects example
var cars = {
name: "AUDI",
model: "A7"
} // enter
undefined
cars // enter
Objects {name: "AUDI", model: "A7"}
cars["name"] // enter
"AUDI"
cars.name // enter
"AUDI"
// to add in objects new date we use .(dot) function
cars.age = 5 // enter
5
cars // enter
Objects {name: "AUDI", model: "A7", age: 5}
// or another metod to add new date
cars["age"] = 5; // enter
5
// to resign value in Objects
cars.model = "A5" // enter
"A5"
cars // enter
Objects {name: "AUDI", model: "A5", age: 5}