JavaScript Classes #2: Getters & Setters - JavaScript OOP Tutorial

Опубликовано: 31 Май 2018
на канале: dcode
40,647
752

In JavaScript, you can use "getters" and "setters" within your class definitions to bind a function to a property. Both "getters" and "setters" behave like regular properties so you are able to get and set instance properties but you are able to define your own function to modify the behaviour.

They can be useful when you have a class with multiple instance properties and you'd like to compute/set a value while still maintaining loose coupling.

In this video I show you a few simple examples of how you can implement your own "getters" and "setters" on your user-defined classes.

For your reference, check this out:
https://developer.mozilla.org/en-US/d...

Support me on Patreon:
  / dcode  

Follow me on Twitter @dcode!

If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!


На этой странице сайта вы можете посмотреть видео онлайн JavaScript Classes #2: Getters & Setters - JavaScript OOP Tutorial длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь dcode 31 Май 2018, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 40,647 раз и оно понравилось 752 зрителям. Приятного просмотра!