VehiclesFashionRecipesBlogsHuntTravelsSportFunHandmadeITEducation
Mini-Games
x

x
zakruti.com » IT - Software » freeCodeCamp.org
Clean Code: Objects - Beau teaches JavaScript

Clean Code: Objects - Beau teaches JavaScript

FBTwitterReddit

video description

Rating: 4.0; Vote: 1
Learn the best practices of how to write clean objects in JS. This video tutorial shows you how easy is to make Javascript objects that are readable, reusable, and refactorable. - http://codepen.io/beaucarnes/pen/BpPevo?editors=0012 Ryan McDermott-s original article: - https://github.com/ryanmcdermott/clean-code-javascript Beau Carnes on
Date: 2022-03-14

Comments and reviews: 5


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

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

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

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

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