Getter & Setter in JavaScript / ES6

  Рет қаралды 5,316

JavaScript Talks

JavaScript Talks

2 жыл бұрын

ES6 allows us to write custom getter setter functions for any object properties. It is very convenient to write a getter function for a computed value. And if you need to validate the property value, you can easily add validation in setter functions.
For more JavaScript news, tips and tutorials, don't forget to subscribe to JavaScriptTalks :)

Пікірлер: 11
@gabrielska7733
@gabrielska7733 Жыл бұрын
i will build you a monument!!! Thank you so much. i finally got the point of getters and setters after so much struggle haha
@javascripttalks
@javascripttalks Жыл бұрын
Thanks for watching! I am so happy that you have learnt something from my videos
@visheshgupta4990
@visheshgupta4990 Жыл бұрын
simple and useful , Nice explanation 🔥
@dtawantawng5131
@dtawantawng5131 2 жыл бұрын
Nice explanation - really helpful!
@javascripttalks
@javascripttalks 2 жыл бұрын
Thanks. I am glad you liked it.
@goodpanda4082
@goodpanda4082 2 жыл бұрын
awesome
@aleksazlatkovic4663
@aleksazlatkovic4663 Жыл бұрын
I''ve never watched this much easy-to-understand video. :D Absolutely AMAZING!!!! Ty sir :) Btw, are getters and setters commonly used nowadays?
@javascripttalks
@javascripttalks Жыл бұрын
I am glad you liked it. Of course getter setters are used. Have you heard of react state management library "MobX"? It is built around getter setters.
@aleksazlatkovic4663
@aleksazlatkovic4663 Жыл бұрын
@@javascripttalks Thanks again. No, I've not. Is it commonly used for web development?
@DaviesMaina
@DaviesMaina 2 жыл бұрын
Thank you! how do we use arrow functions with get and set?
@javascripttalks
@javascripttalks 2 жыл бұрын
We can't. ES6 getter setter only provides two syntax " get prop(){ } " and " get [expression]() { } ". And you can notice the syntax is different from regular function syntax as there is no 'function' keyword. ES5 alternative of getter setter is Object.defineProperty where you can write arrow function Object.defineProperty(obj, 'prop', { get: ()=>123 });
JavaScript Optional Chaining ( ?. )
3:22
JavaScript Talks
Рет қаралды 776
Getter and setter properties in JavaScript
17:18
procademy
Рет қаралды 6 М.
I CAN’T BELIEVE I LOST 😱
00:46
Topper Guild
Рет қаралды 74 МЛН
Я нашел кто меня пранкует!
00:51
Аришнев
Рет қаралды 2 МЛН
JavaScript Getters and Setters Explained
9:11
Colt Steele
Рет қаралды 20 М.
JavaScript Getters and Setters | Mosh
6:37
Programming with Mosh
Рет қаралды 236 М.
JavaScript ES6 Arrow Functions Tutorial
9:32
Web Dev Simplified
Рет қаралды 818 М.
Getter Setter and Stack Overflow | chai aur #javascript
31:23
Chai aur Code
Рет қаралды 37 М.
Inheritance in JavaScript - Prototypal Inheritance tutorial
20:06
Урок 6. JavaScript. Объекты с Object.create. Что такое getters, setters
14:34
Getters and Setters in JavaScript
6:41
Sam Meech-Ward
Рет қаралды 4,3 М.
5 JavaScript Concepts You HAVE TO KNOW
9:38
James Q Quick
Рет қаралды 1,4 МЛН
Getters and Setters Java Tutorial #84
14:12
Alex Lee
Рет қаралды 490 М.
Lid hologram 3d
0:32
LEDG
Рет қаралды 10 МЛН