-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ad503dd
commit 9342c22
Showing
4 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class User { | ||
constructor(email, password){ | ||
this.email = email; | ||
this.password = password | ||
} | ||
|
||
get email(){ | ||
return this._email.toUpperCase() | ||
} | ||
set email(value){ | ||
this._email = value | ||
} | ||
|
||
get password(){ | ||
return `${this._password}hitesh` | ||
} | ||
|
||
set password(value){ | ||
this._password = value | ||
} | ||
} | ||
|
||
const hitesh = new User("[email protected]", "abc") | ||
console.log(hitesh.email); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const descripter = Object.getOwnPropertyDescriptor(Math, "PI") | ||
|
||
// console.log(descripter); | ||
|
||
// console.log(Math.PI); | ||
// Math.PI = 5 | ||
// console.log(Math.PI); | ||
|
||
const chai = { | ||
name: 'ginger chai', | ||
price: 250, | ||
isAvailable: true, | ||
|
||
orderChai: function(){ | ||
console.log("chai nhi bni"); | ||
} | ||
} | ||
|
||
console.log(Object.getOwnPropertyDescriptor(chai, "name")); | ||
|
||
Object.defineProperty(chai, 'name', { | ||
//writable: false, | ||
enumerable: true, | ||
|
||
}) | ||
|
||
console.log(Object.getOwnPropertyDescriptor(chai, "name")); | ||
|
||
for (let [key, value] of Object.entries(chai)) { | ||
if (typeof value !== 'function') { | ||
|
||
console.log(`${key} : ${value}`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const User = { | ||
_email: '[email protected]', | ||
_password: "abc", | ||
|
||
|
||
get email(){ | ||
return this._email.toUpperCase() | ||
}, | ||
|
||
set email(value){ | ||
this._email = value | ||
} | ||
} | ||
|
||
const tea = Object.create(User) | ||
console.log(tea.email); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
function User(email, password){ | ||
this._email = email; | ||
this._password = password | ||
|
||
Object.defineProperty(this, 'email', { | ||
get: function(){ | ||
return this._email.toUpperCase() | ||
}, | ||
set: function(value){ | ||
this._email = value | ||
} | ||
}) | ||
Object.defineProperty(this, 'password', { | ||
get: function(){ | ||
return this._password.toUpperCase() | ||
}, | ||
set: function(value){ | ||
this._password = value | ||
} | ||
}) | ||
|
||
} | ||
|
||
const chai = new User("[email protected]", "chai") | ||
|
||
console.log(chai.email); |