-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3_object.js
More file actions
40 lines (34 loc) · 879 Bytes
/
3_object.js
File metadata and controls
40 lines (34 loc) · 879 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
34
35
36
37
38
39
40
let person={
name:'akhir',
age:25,
phone :123456789
}
//access all elements
console.log(person)
//access particular element
//using dot operator
console.log(person.name)
//qusing bracket notation
console.log(person['phone'])
let capitanAmerica={
firstName:"steve",
lastName:'rogers',
isAvenger:true,
friends:['thor','toney stark','buckey barners'],//array
age:102,
address:{
state:"new york", //object
city:"Brroklyn"
}
// even we can define function also but later we will see
}
console.log(capitanAmerica.friends[1])// output toney stark
//add property(array) in object
capitanAmerica.movie=['civil war','end game']
console.log(capitanAmerica)
//delete properties from object
delete capitanAmerica.age;
console.log(capitanAmerica)
//update properties
capitanAmerica.isAvenger=true;
console.log(capitanAmerica)