Last active
August 5, 2019 04:17
-
-
Save AliN11/458f0c7ff42b03dcd6d937ba764fabd9 to your computer and use it in GitHub Desktop.
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
class User { | |
private rawUsername: string; | |
get userName(): string { | |
return "The fullname is: " + this.rawUsername; | |
} | |
set userName(newName: string) { | |
if (newName.length > 10) { | |
newName = newName.substr(0, 10); | |
} | |
this.rawUsername = newName; | |
} | |
} | |
let e = new User; | |
e.userName = 'abcdefghijklmnopq'; | |
console.log(e.userName); // abcdefghij |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment