We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7922aa4 commit c8f03daCopy full SHA for c8f03da
11_Classes_and_Oop/properties_get_set.js
@@ -0,0 +1,25 @@
1
+function User(email, password){
2
+ this._email = email
3
+ this._password = password
4
+
5
+ Object.defineProperty(this, "email", {
6
+ get: function(){
7
+ return this._email.toUpperCase()
8
+ },
9
+ set: function(value){
10
+ this._email = value
11
+ }
12
+ })
13
+ Object.defineProperty(this, "password", {
14
15
+ return this._password.toUpperCase()
16
17
18
+ this._password = value
19
20
21
+}
22
23
+const user = new User("ayush@mail.com", "abc")
24
+console.log(user.email) // AYUSH@MAIL.COM
25
+console.log(user.password); // ABC
0 commit comments