We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent dea86dd commit 9394dcfCopy full SHA for 9394dcf
1 file changed
10_oops/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 chai = new User("chai@chai.com", "chai")
24
+console.log(chai.email)//CHAI@CHAI.COM
25
+console.log(chai.password)//CHAI
0 commit comments