Clean Code: Objects - Beau teaches JavaScript

preview_player
Показать описание
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.

Code:
Ryan McDermott’s original article:

⭐JavaScript Playlists⭐

-
We're busy people who learn to code, then practice by building projects for nonprofits. Learn Full-stack JavaScript, build a portfolio, and get great references with our open source community.

Рекомендации по теме
Комментарии
Автор

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.

MakeMultiplayerGames
Автор

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.

ohisaac
Автор

Treehouse and Code School Js courses are awesome, but this youtube series is actually better and more thorough in my opinion.

trappedcat
Автор

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?

keithcorona
welcome to shbcf.ru