JavaScript Getters and Setters Explained

preview_player
Показать описание
Let's learn the Javascript get and set keywords
Рекомендации по теме
Комментарии
Автор

Colt Steele: "Always calling it like it is." I'm glad you do because you've helped me learn so much!

tresschess
Автор

Nicely explained. Had no idea why there was a get in a class I was studying and now I get it. Thanks!

erickchavez
Автор

Good stuff. You didn't mention immutability and encapsulation design principles. If for example you have a class with private fields, you can use getters to expose their values as copies to the public without the program being able to change the private field's value. Some datatypes are immutable, but others aren't like arrays, so this is a great use case of a getter to send a copy of an array (e.g using .slice() ) while protecting the real private array.

devnullsrevenge
Автор

Awesome video Colt! I've come across getters and setters a few times at work but never really worked with them. It's good to actually see what they do! Thanks!

chaswards
Автор

Great video, thank you for this beautiful explanation

wickywuth
Автор

i still watching your web developer classes from the start it really helps me a lot colt!God bless you.

motostreat
Автор

concise, clear, direct and easy to understand. thanks a lot. I was struggling with this before

eliud_karuga
Автор

Thanks. I'm new to coding and I was trying to figure out what was the point of getters. Cleared it up.

SidKnight
Автор

stayed till the end and I gotta say I FINALLY GET IT!!

hipnomedia
Автор

Thank you for this man. I was confused for no reason lol
I had some weird idea for what getters and setters were and now I understand it's basically using a method as an object's property

johntheawsomeful
Автор

Thanks, I finally understood this thanks to your explanation, well done

theHarbingerOfDoom
Автор

Really well explained, now I understand them!

RobbSnor
Автор

Love you colt, you dropped this right as I got to OOP in your bootcamp course. Hope you're doing well

jiix
Автор

The real MVP!! I was getting confuse on creating a setter and getter until I found this video. Thank you once again.
I know this is not like c++ but I was wondering if we can also named the method set setFullName(newName) and get getFullName or it is better just a set fullname(newName) and get fullName()

EnjoyYourLif
Автор

Question!

what about more _simple_ mutations of an object? Maybe i just want to decrement a property, why do i require an argument when using the setter in that case?

Retrofire-
Автор

Great video. Very useful.
I'd love to see how you'd tackle a complex form. Something with lots of conditional logic that saves different field values based on those conditions into a database. Also how you'd deal with retrieving the values back into the form to edit and resave them.
I can all but hope 👍

ianl
Автор

Great video! You are very talented teacher @ColtSteele!
Short question: is there a way to make 'first' and 'last' as private properties in JS? Or in TS, maybe?

andrejscupecs
Автор

Still looking to get your JavaScript updated course, Colt

stephenohaeri
Автор

I have a question, isn't it a performance issue when a getter is called multiple times instead of only once and returning that value instead of recomputing it every time

gerkim
Автор

Hey man, at 7:50 your image covers the result of count and it can't be seen, you say it out loud and I think we all understood, just something to consider for your future videos.

luisalbertogarciaibarra