filmov
tv
JavaScript Getters and Setters Explained
Показать описание
In this tutorial we'll take a look at JavaScript Getters and Setters and see how you can use them with both the ES6 Class syntax and also with the more traditional way to define JavaScript classes.
JavaScript Getters and Setters Explained
-----------------------------------------------------------------
00:00 Introduction
00:46 Creating a new Class
01:41 Adding a setter
03:09 Adding a getter
03:27 Adding value to Getters and setters
06:53 Non-ES6 getters and setters
— Follow Me —
— Thanks! —
So in this JavaScript tutorial we'll take a look at how, with a basic JavaScript class definition, you can create custom behaviour for when you assign properties to an object and also retrieve their values.
We'll start of the tutorial with a simple bit of code that demonstrates how classes can be used to create new JavaScript objects and assign properties to the new object that is created.
We'll then define custom behaviour for our object's properties, adding validation for when we assign a new value to a property and also returning a different value for a property that has already been assigned a value.
Once we've taken a look at the ES6 getters and setters on a class, we'll see how this works with the older, more traditional way of assigning new properties to a class with a function constructor in JavaScript.
Check out some more Junior Developer Central JavaScript tutorials on the rest of the channel. Channel Handle @codebubb
JavaScript Getters and Setters Explained
-----------------------------------------------------------------
00:00 Introduction
00:46 Creating a new Class
01:41 Adding a setter
03:09 Adding a getter
03:27 Adding value to Getters and setters
06:53 Non-ES6 getters and setters
— Follow Me —
— Thanks! —
So in this JavaScript tutorial we'll take a look at how, with a basic JavaScript class definition, you can create custom behaviour for when you assign properties to an object and also retrieve their values.
We'll start of the tutorial with a simple bit of code that demonstrates how classes can be used to create new JavaScript objects and assign properties to the new object that is created.
We'll then define custom behaviour for our object's properties, adding validation for when we assign a new value to a property and also returning a different value for a property that has already been assigned a value.
Once we've taken a look at the ES6 getters and setters on a class, we'll see how this works with the older, more traditional way of assigning new properties to a class with a function constructor in JavaScript.
Check out some more Junior Developer Central JavaScript tutorials on the rest of the channel. Channel Handle @codebubb
Комментарии