- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobject.js
More file actions
Latest commit
33 lines (27 loc) · 646 Bytes
/
Copy pathobject.js
File metadata and controls
33 lines (27 loc) · 646 Bytes
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
letplayers={
firstName : 'Joe',
lastName : "Root",
country : "England"
}
console.log(players);
//add an element from outside
players.gender="Male";
console.log(players)
players.ranking=2
console.log(players)
//delete an element from outside
deleteplayers.ranking;
console.log(players)
//another object
varcar={
brand : "Toyota",
model : 2023,
make : 'Rav4',
color : ["White","red","silver"]
}
//accessing single element from the object
console.log(car['make']);
console.log(car['color'])
console.log(car)
//accessing multiple elements from the object
console.log(car['brand']+" "+car['model']);