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.
You might also want to check out the video on the JavaScript 'this' keyword to see how that works: https://youtu.be/apE-9SEKxzE
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
07:24 Using Object.defineProperty
— Follow Me —
Twitter: https://www.twitter.com/codebubb
Facebook: https://www.facebook.com/juniordevelopercentral/
Blog: https://www.juniordevelopercentral.com/
— 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.
Видео JavaScript Getters and Setters Explained канала Junior Developer Central
You might also want to check out the video on the JavaScript 'this' keyword to see how that works: https://youtu.be/apE-9SEKxzE
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
07:24 Using Object.defineProperty
— Follow Me —
Twitter: https://www.twitter.com/codebubb
Facebook: https://www.facebook.com/juniordevelopercentral/
Blog: https://www.juniordevelopercentral.com/
— 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.
Видео JavaScript Getters and Setters Explained канала Junior Developer Central
Показать
Комментарии отсутствуют
Информация о видео
6 сентября 2020 г. 21:00:01
00:09:59
Другие видео канала
![JavaScript Getters and Setters | Mosh](https://i.ytimg.com/vi/bl98dm7vJt0/default.jpg)
![Python OOP Tutorial 6: Property Decorators - Getters, Setters, and Deleters](https://i.ytimg.com/vi/jCzT9XFZ5bw/default.jpg)
![JavaScript Classes Tutorial](https://i.ytimg.com/vi/2ZphE5HcQPQ/default.jpg)
![Understanding JavaScript Callbacks](https://i.ytimg.com/vi/Nau-iEEgEoM/default.jpg)
![JavaScript OOP Crash Course (ES5 & ES6)](https://i.ytimg.com/vi/vDJpGenyHaA/default.jpg)
![JavaScript ES6 / ES2015 - [04] Classes and Inheritance](https://i.ytimg.com/vi/RBLIm5LMrmc/default.jpg)
![Getters & Setters | Java | Tutorial 31](https://i.ytimg.com/vi/UoM7SqWIrtA/default.jpg)
![Learn DOM Manipulation In 18 Minutes](https://i.ytimg.com/vi/y17RuWkWdn8/default.jpg)
![Private props getters and setters in javascript](https://i.ytimg.com/vi/mGR2nH1HIR4/default.jpg)
![Why Is Array/Object Destructuring So Useful And How To Use It](https://i.ytimg.com/vi/NIq3qLaHCIs/default.jpg)
![](https://i.ytimg.com/vi/eLDi16xk3dQ/default.jpg)
![Introduction to Classes and Objects - Part 1 (Data Structures & Algorithms #3)](https://i.ytimg.com/vi/8yjkWGRlUmY/default.jpg)
![JavaScript Higher Order Functions & Arrays](https://i.ytimg.com/vi/rRgD1yVwIvE/default.jpg)
![JavaScript Map and Set Explained](https://i.ytimg.com/vi/hLgUTM3FOII/default.jpg)
![9.19: Prototypes in Javascript - p5.js Tutorial](https://i.ytimg.com/vi/hS_WqkyUah8/default.jpg)
![C# Properties: Why use "get" and "set"](https://i.ytimg.com/vi/I5d5pfkHXCs/default.jpg)
![Iterating Over a JavaScript Object](https://i.ytimg.com/vi/SFHmEYiW0qU/default.jpg)
![JavaScript Promises In 10 Minutes](https://i.ytimg.com/vi/DHvZLI7Db8E/default.jpg)
![Getters and Setters - Learn Getters and Setters in Java](https://i.ytimg.com/vi/6wVmqY-CrGM/default.jpg)
![Prototype and Prototypal Inheritance in Javascript | Frontend Interview Question](https://i.ytimg.com/vi/wstwjQ1yqWQ/default.jpg)