-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile71.js
36 lines (32 loc) · 925 Bytes
/
file71.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
35
36
"use strict";
// methods
// functions inside object
// this keyword -> this keyword exects the value in whole object
function aboutInfo(){
console.log(`the value of firstName is = "${this.firstName}" and their age is = " ${this.age} "`);
}
const person = {
firstName : "jitendra",
age : 24,
about: aboutInfo
}
// here about checks the value of aboutinfo, aboutinfo is the function already declared when it checks about info then it find "this" keyword and "this" means what object we are working on and from using this keyword we can access all this data from that perticluar object
const person2 = {
firstName : "punit",
age : 18,
about: aboutInfo
}
const person3 = {
firstName : "ankit",
age : 14,
about: aboutInfo
}
const person4 = {
firstName : "rishi",
age : 44,
about: aboutInfo
}
console.log(person.firstName);
person.about();
person2.about();
person3.about();