
Clean Code: Objects - Beau teaches JavaScript
video description
Date: 2022-03-14
Related videos
Comments and reviews: 5
Aditya
We can't delete employee.name because now it is put inside the closure of an anonymous object (which is being returned by the Employee constructor).
Just a silly question, if i end up with an object with several functions having values in their closures, will it be a bad practice? I mean performance wise or something?
BTW, I just saw your entire clean code series and it is wonderful. It has really inspired me to go through your Beau teaches JavaScript series. Really excited to learn more cool stuff from that series.. Thank You very much for making awesome series. Cheers!
reply
We can't delete employee.name because now it is put inside the closure of an anonymous object (which is being returned by the Employee constructor).
Just a silly question, if i end up with an object with several functions having values in their closures, will it be a bad practice? I mean performance wise or something?
BTW, I just saw your entire clean code series and it is wonderful. It has really inspired me to go through your Beau teaches JavaScript series. Really excited to learn more cool stuff from that series.. Thank You very much for making awesome series. Cheers!
reply
David
This is the -GOOD- way to create and store in memory a function for each public method for each instance. So if you have 1000 instances of Employee, and you want Employee to have 6 public methods, you are creating 6000 functions and storing them in memory. Instead of just using the same 6 functions stored in a prototype.
And it doesn't forbid you from doing -employee.getName = () => undefined-. In JavaScript, if you don't use a 'class' as you should, you are going to get 'unexpected' behaviour.
reply
This is the -GOOD- way to create and store in memory a function for each public method for each instance. So if you have 1000 instances of Employee, and you want Employee to have 6 public methods, you are creating 6000 functions and storing them in memory. Instead of just using the same 6 functions stored in a prototype.
And it doesn't forbid you from doing -employee.getName = () => undefined-. In JavaScript, if you don't use a 'class' as you should, you are going to get 'unexpected' behaviour.
reply
Keith
when getName() is used in the good way as return -getName()-return name;--; -- I am not sure where the function getName was declared; is it declared in in the return object without the function keyword? I see where it is being called in the return obj., but is this it being declared as well?
reply
when getName() is used in the good way as return -getName()-return name;--; -- I am not sure where the function getName was declared; is it declared in in the return object without the function keyword? I see where it is being called in the return obj., but is this it being declared as well?
reply
Isaac
Why using Getters and Setters are the right way of doing it?
Of course I can imagine the reason, but I would love to get an elaboration on it by someone more pro.
reply
Why using Getters and Setters are the right way of doing it?
Of course I can imagine the reason, but I would love to get an elaboration on it by someone more pro.
reply
trapped
Treehouse and Code School Js courses are awesome, but this youtube series is actually better and more thorough in my opinion.
reply
Treehouse and Code School Js courses are awesome, but this youtube series is actually better and more thorough in my opinion.
reply
Add a review, comment
Other channel videos















