-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoops.js
More file actions
41 lines (30 loc) · 982 Bytes
/
oops.js
File metadata and controls
41 lines (30 loc) · 982 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const user = {
username: "sandeep",
loginCount: 8,
signedIn: true,
getUserDetails: function(){
console.log("Got user datails from database")
// console.log(this.username)
console.log(this)
}
}
console.log(user.username)
// console.log(user.getUserDetails());
//console.log(this)
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("sandeep", 4, true)
const userTwo = new User("chaiaurcode", 8, false)
console.log(userOne.constructor);
//console.log(userTwo);
// 1. when new key word used an a empty object created which we called instance
// 2. construction function called becouse of new key word it pack all the arguments in it
// 3. this key are injected
// 4. executed