JavaScript Getters and Setters Explained

  Рет қаралды 21,883

Colt Steele

Colt Steele

Күн бұрын

Пікірлер: 54
@tresschess6591
@tresschess6591 2 жыл бұрын
Colt Steele: "Always calling it like it is." I'm glad you do because you've helped me learn so much!
@devnullsrevenge
@devnullsrevenge 2 жыл бұрын
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.
@swagathshetty
@swagathshetty 2 жыл бұрын
But we can already send a copy of array without using getter right?
@devnullsrevenge
@devnullsrevenge 2 жыл бұрын
@@swagathshetty The getter would return a reference to the original mutable array, unless you purposefully write logic to ensure it's a copy. This is why tricks like returning the array.slice() with no arguments are popular.
@hassansyed6087
@hassansyed6087 Жыл бұрын
Wonderfully said. I understood bits and pieces of it but i could put it all together eventually
@eliud_karuga
@eliud_karuga Жыл бұрын
concise, clear, direct and easy to understand. thanks a lot. I was struggling with this before
@motostreat9764
@motostreat9764 2 жыл бұрын
i still watching your web developer classes from the start it really helps me a lot colt!God bless you.
@chaswards
@chaswards 2 жыл бұрын
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!
@erickchavez4551
@erickchavez4551 5 ай бұрын
Nicely explained. Had no idea why there was a get in a class I was studying and now I get it. Thanks!
@SidKnight
@SidKnight Жыл бұрын
Thanks. I'm new to coding and I was trying to figure out what was the point of getters. Cleared it up.
@hipnomedia4504
@hipnomedia4504 2 жыл бұрын
stayed till the end and I gotta say I FINALLY GET IT!!
@johntheawsomeful
@johntheawsomeful Жыл бұрын
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
@theHarbingerOfDoom
@theHarbingerOfDoom Жыл бұрын
Thanks, I finally understood this thanks to your explanation, well done
@wickywuth6976
@wickywuth6976 5 ай бұрын
Great video, thank you for this beautiful explanation
@RobbSnor
@RobbSnor 2 жыл бұрын
Really well explained, now I understand them!
@EnjoyYourLif3
@EnjoyYourLif3 2 жыл бұрын
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()
@_betheducky
@_betheducky 5 ай бұрын
Super simple and helpful. Thanks man!
@jiix4723
@jiix4723 2 жыл бұрын
Love you colt, you dropped this right as I got to OOP in your bootcamp course. Hope you're doing well
@abtinjalali6191
@abtinjalali6191 2 жыл бұрын
Great Video Colt! Thank you.🙂👍
@sobeyyy
@sobeyyy 2 жыл бұрын
Awesome video thank you Colt!
@sob3ygrime
@sob3ygrime 2 жыл бұрын
Hey tyler what's UP?
@vanta6lack
@vanta6lack 8 ай бұрын
Thanks for the video, Colt!
@NiksWP
@NiksWP 7 ай бұрын
Thanks for the explanation
@BlaBlaBlaInDaHouse
@BlaBlaBlaInDaHouse 2 жыл бұрын
Thank you for your explanation!
@stephenohaeri2472
@stephenohaeri2472 2 жыл бұрын
Still looking to get your JavaScript updated course, Colt
@GoodCodeArabic
@GoodCodeArabic 2 жыл бұрын
Colt already updated his course on Udemy Web development bootcamp and also the course he made with Stephen grider
@stephenohaeri2472
@stephenohaeri2472 2 жыл бұрын
@@GoodCodeArabic yeah that's the one I'm looking to get
@outlawpl
@outlawpl 2 жыл бұрын
Nice explanation.
@Retrofire-47
@Retrofire-47 5 ай бұрын
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?
@junsgk
@junsgk 2 жыл бұрын
Colt you're the best
@andrejscupecs5091
@andrejscupecs5091 2 жыл бұрын
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?
@shawn.builds
@shawn.builds Жыл бұрын
thanks colt!
@luisalbertogarciaibarra9852
@luisalbertogarciaibarra9852 2 жыл бұрын
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.
@leonardrichter2661
@leonardrichter2661 2 жыл бұрын
Thanks for the video! I would love if you would update your The Modern Javascript Bootcamp Course on Udemy. It really needs a big update like the one you did with the Web Developer Bootcamp at this point, due to all the changes that made a lot of the code to stop working.
@Jake-zx9mp
@Jake-zx9mp Жыл бұрын
Thank you
@ianl5753
@ianl5753 2 жыл бұрын
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 👍
@khoushiekram5287
@khoushiekram5287 2 жыл бұрын
Thanks bud ❤️
@BigSmoke-r9w
@BigSmoke-r9w 9 ай бұрын
Timothee chalamander
@gerkim62
@gerkim62 2 жыл бұрын
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
@user-xf7wx3zk8j
@user-xf7wx3zk8j Жыл бұрын
thank you!
@phileze_
@phileze_ Жыл бұрын
How did you assign first and last in the constructor when there is no property for that in the class please?
@lizavetakanapatskaya6963
@lizavetakanapatskaya6963 Жыл бұрын
If I get you right, the answer is - the constructor of the Person class is accepting 2 values (on the very top - line #2): 'first' and 'last' and then we assign them like - this.first = first. and this.last = last (line #3 and #4). That means when we'll create new object (line #11) - everything we pass into brackets of "new Person()" will assign the first argument as our first name and the second argument - as the second name.
@whitebeardpirates7551
@whitebeardpirates7551 2 жыл бұрын
thx♥♥
@tenzinwoeser6842
@tenzinwoeser6842 Жыл бұрын
Shessssshh. Just like that. Thanks
@mrwho.7163
@mrwho.7163 2 жыл бұрын
looks like arrow function & couple of variables do the job , better
@darwish-mammo
@darwish-mammo 2 жыл бұрын
😘
@frosttx2
@frosttx2 7 ай бұрын
and why should i use this instead of a function
@luciusrex
@luciusrex 11 ай бұрын
i watched this to the end in 3-4min bc x2 speed lol
@justinmiller3349
@justinmiller3349 2 жыл бұрын
Regarding thumbnails, I hate that creators are essentially forced to play the game or be punished by the algorithm. I usually avoid watching if its too egregious in a futile and miniscule attempt to not reward the system.
@jorims8537
@jorims8537 Жыл бұрын
Great video but I still don’t really understand a clear usecase
@johnm8358
@johnm8358 2 жыл бұрын
It's pronounced sur-sha
@corajohnson2219
@corajohnson2219 Жыл бұрын
Nice video. But why pick names you don’t know how to spell 😂?
@jsbr
@jsbr 2 жыл бұрын
Seems kind of useless thing compared to Java
JavaScript GETTERS & SETTERS are awesome!!! 📐
13:14
Bro Code
Рет қаралды 20 М.
Getter and setter properties in JavaScript
17:18
procademy
Рет қаралды 7 М.
How many people are in the changing room? #devil #lilith #funny #shorts
00:39
BAYGUYSTAN | 1 СЕРИЯ | bayGUYS
37:51
bayGUYS
Рет қаралды 859 М.
JS Spread Operator: How It Works & Why I Love It
16:31
Colt Steele
Рет қаралды 76 М.
STOP Using Classes In JavaScript | Prime Reacts
14:02
ThePrimeTime
Рет қаралды 253 М.
The Complete Guide to JS Symbols ES6
12:18
Colt Steele
Рет қаралды 54 М.
Dependency Injection, The Best Pattern
13:16
CodeAesthetic
Рет қаралды 896 М.
JS Arrow Functions: Everything You Need to Know
20:23
Colt Steele
Рет қаралды 31 М.
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 751 М.
Complete Guide to JS Sets: How They Work & When To Use Them
18:38
How many people are in the changing room? #devil #lilith #funny #shorts
00:39