-
Notifications
You must be signed in to change notification settings - Fork 0
/
oop.js
35 lines (28 loc) · 898 Bytes
/
oop.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
// const user = {
// username:"Gauri",
// loginCount:8,
// signedIn:true,
// getUserDetails: function(){
// //console.log("Got user details from database");
// //console.log(`username ${this.username}`);
// }
// }
//console.log(user.username);
//console.log(user.getUserDetails());
//const promise = new Promise()
//const date = new Date()
function User(username,loginCount,isLoggedIn){
this.username = username;
this.loginCount = loginCount;
this.isLoggedIn = isLoggedIn;
this.greeting = function(){
console.log(`welcome ${this.username}`);
}
//return this
}
const userOne = new User("Gauri",12,true)
const userTwo = new User("Js",20,true)
console.log(userOne);
//new keyword creates an new object
//after new keyword a constructor function is called
//arguments inject in this keyword