- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
constructors in javaSCript
How Inheritance Worked Before ES6:
Constructor Functions: Functions were used to create objects and initialize properties. Each constructor function could define properties and methods for the object it created.
call() Method: The call() method was used to invoke a constructor function in the context of another object, essentially "inheriting" properties from the parent object. This allowed a child constructor to initialize properties from a parent constructor.
Prototypes: Prototypes were used to share methods between instances of the same constructor. For inheritance, the child's prototype was set to be an instance of the parent constructor's prototype, ensuring that the child could inherit methods from the parent.
Before ES6, JavaScript developers used constructor functions and prototypes along with call() (and sometimes apply()) to implement inheritance. This approach was more flexible but also more complex and error-prone. With the introduction of ES6 classes, JavaScript simplified inheritance, making it easier to write and manage object-oriented code. The new class and extends syntax provides a clearer, more structured way of implementing inheritance, without the need for manual prototype manipulation or using call() and apply().
While the older approach is still valid and can be used in legacy code, ES6 classes have become the standard practice for object-oriented programming in modern JavaScript.
Видео constructors in javaSCript канала Profu' de geogra'
Constructor Functions: Functions were used to create objects and initialize properties. Each constructor function could define properties and methods for the object it created.
call() Method: The call() method was used to invoke a constructor function in the context of another object, essentially "inheriting" properties from the parent object. This allowed a child constructor to initialize properties from a parent constructor.
Prototypes: Prototypes were used to share methods between instances of the same constructor. For inheritance, the child's prototype was set to be an instance of the parent constructor's prototype, ensuring that the child could inherit methods from the parent.
Before ES6, JavaScript developers used constructor functions and prototypes along with call() (and sometimes apply()) to implement inheritance. This approach was more flexible but also more complex and error-prone. With the introduction of ES6 classes, JavaScript simplified inheritance, making it easier to write and manage object-oriented code. The new class and extends syntax provides a clearer, more structured way of implementing inheritance, without the need for manual prototype manipulation or using call() and apply().
While the older approach is still valid and can be used in legacy code, ES6 classes have become the standard practice for object-oriented programming in modern JavaScript.
Видео constructors in javaSCript канала Profu' de geogra'
Комментарии отсутствуют
Информация о видео
18 марта 2025 г. 18:55:48
00:13:35
Другие видео канала





















