Javascript Classes Explained | Javascript Factory Functions | es6 private variables properties
Dave Gray
@davegrayteachescodeAbout
Web Development tutorials with full courses on HTML, CSS, JavaScript, React, Node.js and more! My goal is to help you learn how to build the web. Teaching helps me learn, too. I work full-time as a Solutions Architect / Developer and part-time as a university web dev instructor. Thank you for subscribing, supporting my channel and sharing the videos you think may help others. Keep striving for progress over perfection. And a little progress every day goes a very long way. Milestones: July 20, 2020 - 1st video Jan 1, 2021 - 1k subs April 2021 - 4k watch hours Nov 2021 - 10k subs Jan 21, 2022 - Video at 100k views Feb 16, 2022 - 100k watch hours Feb 19, 2022 - 1m views Dec 13, 2022 - 100k subs Dec 2022 - Over 1m views in 1 month April 7, 2023 - 10m views May 26, 2023 - 1m watch hours Sept 22, 2023 - Video at 1m views Dec 25, 2023 - 250k subs
Latest Posts
Video Description
Web Dev Roadmap for Beginners (Free!): https://bit.ly/DaveGrayWebDevRoadmap In this video we explore the Javascript Class syntax introduced in ES6. We look at adding parameters, getters, setters, child classes with extends, the super keyword, public properties and private fields. We also look at how Factory Functions help us create private variables when we create objects. ▶ This video is part of the JavaScript Tutorials for Beginners Playlist found here: https://www.youtube.com/playlist?list=PL0Zuz27SZ-6Oi6xNtL_fwCrwpuqylMsgT ✅ Quick Concepts outline: Javascript Classes: (00:00) Intro (0:11) Classes are "syntactic sugar" in JS (0:45) Creating a simple class with a constructor (0:50) Using the keyword this (1:05) Adding a method to the class (1:35) Classes are templates / blueprints for objects (1:40) Using the new keyword to create the object (1:55) Calling the object's method (2:00) Adding parameters to the constructor (3:20) Passing multiple parameters to the constructor (4:35) Accessing properties with dot notation (5:15) getters and setters (6:52) A more readable getter and setter method (8:15) An array property with a getter and setter (10:20) A parent "super" class (11:15) Creating a child class with extends (11:35) The super keyword (13:45) No need to create a parent object in order to create a child object from the classes (16:15) A naming convention for private properties (17:15) Good intentions but not enforced by the code (17:45) Factory Functions (19:50) Instantiating a pizza factory object (20:20) Factory Functions solve the private properties problem (22:00) New additions to JS allow public and private class fields (28:40) How much support for public and private class fields? 📚 Further Reading: MDN Web Docs: Classes: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes Eloquent JavaScript Chapter 6: https://eloquentjavascript.net/06_object.html 📺 More Beginner JS Videos: freeCodeCamp: https://youtu.be/PkZNo7MFNFg Traversy Media: https://youtu.be/hdI2bqOjy3c The Net Ninja: https://youtu.be/iWOYAxlnaww ✅ Follow Me: Twitter: https://twitter.com/yesdavidgray Reddit: https://www.reddit.com/user/DaveOnEleven Medium: https://medium.com/@davegray_86804 #javascript #classes #explained
Essential Drone Accessories
AI-recommended products based on this video

DJI Mic Mini (2 TX + 1 RX), Detail-Rich Audio, Wireless Lavalier Microphone for Camera/Android, 2-Person Vlog, Team Production

DJI Mic Mini (2 TX + 1 RX), Detail-Rich Audio, Wireless Lavalier Microphone for Camera/Android, 2-Person Vlog, Team Production

DJI Mic Mini (2 TX + 1 RX), Detail-Rich Audio, Wireless Lavalier Microphone for Camera/Android, 2-Person Vlog, Team Production

SanDisk 128GB Extreme PRO SDXC UHS-I Memory Card - C10, U3, V30, 4K UHD, SD Card - SDSDXXD-128G-GN4IN

Anker USB C Charger Cable (6ft 100W, 2Pack), USB 2.0 Type C Fast Charging Cable for iPhone 15 / 15Pro / 15Plus / 15ProMax MacBook Pro 2020, iPad Pro 2020, iPad Air 4, Samsung Galaxy S23+/S23 Ultra ClimatePartner certified
![Anker USB C Cable, [2-Pack, 6 ft] Type C Charger Premium Nylon USB Cable, USB A to Type C Charging Cable Fast Charge for Samsung Galaxy S10 S10+ / Note 8, LG V20 and Other USB C Charger (Black)](https://m.media-amazon.com/images/I/71N7xhCJnoL._AC_UL960_FMwebp_QL65_.jpg)
Anker USB C Cable, [2-Pack, 6 ft] Type C Charger Premium Nylon USB Cable, USB A to Type C Charging Cable Fast Charge for Samsung Galaxy S10 S10+ / Note 8, LG V20 and Other USB C Charger (Black)

Anker Nano USB C Wall Charger,45W Fast Charging Smart Display Charger,with 180°Foldable Plug,Smart Recognition,Built-in Care Mode,for iPhone17/16/15 (Non-Battery,One USB-C Port,No Cable Included) ClimatePartner certified

Skytech Archangel Gaming PC Desktop – AMD Ryzen 5 3600 3.6 GHz, NVIDIA RTX 3060, 1TB NVME SSD, 16GB DDR4 RAM 3200, 600W Gold PSU, 11AC Wi-Fi, Windows 11 Home 64-bit

ANXRE 71" Phone Tripod, NT79 Extendable Selfie Stick for Cell Phone&Camera Photo Video Kits, Travel Tripod Stand with Remote for Video Recording, Phone Holder Tripod Compatible with Phone Camera Gopro

DJI Mic Mini (2 TX + 1 RX), Detail-Rich Audio, Wireless Lavalier Microphone for Camera/Android, 2-Person Vlog, Team Production

FERIETELF Drone with Camera - T26 RC Drones for Adults with 1080P HD Live Video, FPV Drone with 24mins Flight/Altitude Hold/Headless Mode/Gravity Sensor for Kids Beginners

DJI Mic Mini (2 TX + 1 RX), Detail-Rich Audio, Wireless Lavalier Microphone for Camera/Android, 2-Person Vlog, Team Production




















