-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy path83.js
More file actions
26 lines (24 loc) · 819 Bytes
/
83.js
File metadata and controls
26 lines (24 loc) · 819 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
// new keyword
// constructor function
function CreateUser(firstName, lastName, email, age, address){
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
this.age = age;
this.address = address;
return this;
}
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('harshit', 'vashsith', 'harshit@gmail.com', 18, "my address");
const user2 = new CreateUser('harsh', 'vashsith', 'harshit@gmail.com', 19, "my address");
const user3 = new CreateUser('mohit', 'vashsitha', 'harshit@gmail.com', 17, "my address");
console.log(user1);
console.log(user1.is18());