-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path41_index41.js
30 lines (26 loc) · 932 Bytes
/
41_index41.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
//hasOwnProperty
function CreateUser(firstName , lastName , email, age , address){
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
this.age = age;
this.address = address;
}
CreateUser.prototype.about = function(){
return `${this.firstName} is ${this.age} years old.`;
};
CreateUser.prototype.is18 = function(){
return this.age >= 18;
}
CreateUser.prototype.sing = function(){
return "la la la la";
}
const user1 = new CreateUser('manish','Tomar','manishtomar00mt@gmail.com',23, "delhi");
const user2 = new CreateUser('Sonal','Mishra','manishtomar00mt@gmail.com',23, "delhi");
const user3 = new CreateUser('Varun','Tomar','varuntomar3233@gmail.com',18, "delhi");
for(let key in user1){
// console.log(key); (this will also show us prototype key in order to see only user1 property hasOwnPropery is used)
if (user1.hasOwnProperty(key)){
console.log(key)
}
}