Gets are a way to have a more complex property that does some logic when being retrieved.
- [Instructor] Getters and setters … in object oriented programming and TypeScript … are one of the more powerful items that you can utilize. … It's also one of the most underused items … when it comes to getting data from the backend, … often times you're not mapping to your classes, … so you're losing out on some of these helper methods … and helper functions that getters and setters provide. … So, a get, which we'll talk about right now, … and we'll come back to set in future lectures, … is simply a property that does some logic to return a value. … You can denote that with the get keyword, … and let's say we wanted to return our message, … concatenated with whether it has been sent or not. … So, we'll have a property called messageStatus, … which we'll invoke like a function. … And we'll here have a return, … every get needs to have a return. … And all we want to do … is we'll just have a little bit of logic, … and we'll call this sentMessage, … and we'll set this equal to a ternary. …
Skill Level Intermediate
TypeScript: Upgrades and Featureswith Emmanuel Henri1h 15m Advanced
TypeScript for Node.js Developerswith Emmanuel Henri1h 2m Intermediate
1. Classes in TypeScript
2. Inheritance in TypeScript
3. Access Modifiers in TypeScript
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.