-
Notifications
You must be signed in to change notification settings - Fork 0
/
file36.js
34 lines (25 loc) · 822 Bytes
/
file36.js
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
"use strict";
// object
// Object are referce data type
// arrays are good but not sufficient for real world data
// objects store key value pairs
// objects don't have index
// how to create objects
// we create objects using {} littlrals
// const myFirstObject = {name:"jitendra",age:23};
const myFirstObject = {
name:"jitendra",
age:23,
hobbies:["playing cricket","coding","meditation"]
};
// how to access data from objects
// console.log(myFirstObject);
// console.log(myFirstObject.hobbies);
console.log(myFirstObject["hobbies"]);
// console.log(myFirstObject.name);
// how to add key value pair to objects
myFirstObject.gender = "male";
// console.log(myFirstObject);
// now trying to push inside the object of array
myFirstObject.hobbies.push("vollyball");
console.log(myFirstObject.hobbies);