Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

YouTube

Javascript Classes Explained - Javascript Factory Functions - ES6 Private Variables Properties

Dave Gray via YouTube

Overview

Coursera Flash Sale
40% Off Coursera Plus for 3 Months!
Grab it
Explore JavaScript classes, factory functions, and ES6 private variables in this comprehensive 31-minute tutorial. Learn to create classes with constructors, add methods, use the 'this' keyword, and implement getters and setters. Discover how to work with parent and child classes using 'extends' and 'super' keywords. Dive into factory functions to solve private property challenges, and examine the latest additions to JavaScript for public and private class fields. Gain insights into naming conventions, object instantiation, and browser support for these features.

Syllabus

Classes are "syntactic sugar" in JS
Creating a simple class with a constructor
Using the keyword this
Adding a method to the class
Classes are templates / blueprints for objects
Using the new keyword to create the object
Calling the object's method
Adding parameters to the constructor
Passing multiple parameters to the constructor
Accessing properties with dot notation
getters and setters
A more readable getter and setter method
An array property with a getter and setter
A parent "super" class
Creating a child class with extends
The super keyword
No need to create a parent object in order to create a child object from the classes
A naming convention for private properties
Good intentions but not enforced by the code
Factory Functions
Instantiating a pizza factory object
Factory Functions solve the private properties problem
New additions to JS allow public and private class fields
How much support for public and private class fields?

Taught by

Dave Gray

Reviews

Start your review of Javascript Classes Explained - Javascript Factory Functions - ES6 Private Variables Properties

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.