Прототипы - GitHub Pages...Объекты разны х типов const student = { name:...

85
Прототипы 1

Transcript of Прототипы - GitHub Pages...Объекты разны х типов const student = { name:...

Page 1: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Прототипы

1

Page 2: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Объекты разных типов

const student = { name: 'Billy', getName() {

return this.name; }, sleep() {} };

const lecturer = { name: 'Sergey', getName() {

return this.name; }, talk() {} };

2

Page 3: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Объекты разных типов

const student = { name: 'Billy', getName() {

return this.name; }, sleep() {} };

const lecturer = { name: 'Sergey', getName() {

return this.name; }, talk() {} };

const person = { getName() { return this.name; } };

3

Page 4: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Прототип

const person = { getName() { return this.name;

} }; const student = { name: 'Billy' }; const lecturer = { name: 'Sergey' }; Object.setPrototypeOf(student, person); Object.setPrototypeOf(lecturer, person); student.getName(); // Billy lecturer.getName(); // Sergey

4

Page 5: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

create

const person = { getName() { return this.name;

} }; const student = Object.create(person, { name: { value: 'Billy' } });

5

Page 6: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

super

const person = { getName() { return this.name;

} }; const student = { name: 'Billy', getName() { return 'Student ' + super.getName(); } }; Object.setPrototypeOf(student, person); student.getName(); // Student Billy 6

Page 7: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Объекты одного типа

const billy = { name: 'Billy', getName() {

return this.name; } };

const willy = { name: 'Willy', getName() {

return this.name; } };

7

Page 8: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Конструированиеобъектов

8

Page 9: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Фабрика

function createStudent(name) { return { name,

getName() { return this.name; } }; } const billy = createStudent('Billy');

9

Page 10: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Фабрика

const studentProto = { getName() { return this.name;

} }; function createStudent(name) { const student = { name }; Object.setPrototypeOf(student, studentProto); return student; }

10

Page 11: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Фабрика

const studentProto = { getName() {} };

function createStudent(name) { return Object.create(studentProto, { name: { value: name } }); }

11

Page 12: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Фабрика

const studentProto = { getName() {} };

function createStudent(name) { return Object.create(studentProto, { name: { value: name, enumerable: true, writable: true } }); }

12

Page 13: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Фабрика

const studentProto = { getName() {} };

function createStudent(name) { const student = Object.create(studentProto); student.name = name; return student; }

13

Page 14: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Фабрика

const studentProto = { getName() {} };

function createStudent(name) { const student = Object.create(studentProto); return Object.assign(student, { name }); }

14

Page 15: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Фабрика

const personProto = { getName() {} };

const studentProto = Object.create(personProto); function createStudent(name) { const student = Object.create(studentProto); return Object.assign(student, { name }); }

15

Page 16: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Фабрика

const personProto = { getName() {} };

const studentProto = Object.create(personProto); studentProto.getName = function () { return 'Student ' + this.name; } function createStudent(name) { const student = Object.create(studentProto); return Object.assign(student, { name }); } 16

Page 17: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Фабрика

const personProto = { getName() {} };

const studentProto = Object.create(personProto); studentProto.getName = function () { return 'Student ' + super.getName(); Error } function createStudent(name) { const student = Object.create(studentProto); return Object.assign(student, { name }); } 17

Page 18: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Фабрика

const personProto = { getName() {} };

const studentProto = { getName() { return 'Student ' + super.getName(); } }; Object.setPrototypeOf(studentProto, personProto); function createStudent(name) { // ... } 18

Page 19: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Фабрика

const { createServer } = require('http'); const server = createServer((req, res) => {

res.end('Hello, World!'); }) server.listen(8080);

19

Page 20: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Person

LecturerStudent

20

Page 21: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Person

LecturerStudent

DesignerDeveloperDesignerDeveloper

21

Page 22: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Person

LecturerStudent

Employee

DeveloperDesigner

22

Page 23: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Student Designer

Lecturer Designer

Student Developer

Lecturer Developer

23

Page 24: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Favor object composition over classinheritance

24

Page 25: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Миксины

const studentProto = { getName() {} };

const developerProto = { getSalary() {} }; const proto = Object.assign({}, studentProto, developerProto); function create({ name, salary }) { const instance = Object.create(proto); return Object.assign(instance, { name, salary }); } 25

Page 26: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Object.assign не переносит свойстваполей, неперечисляемые поля, а также

set/get

26

Page 27: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Копирование полей со свойствами

const objTo = {}; const properties = Object.getOwnPropertyNames(objFrom);

for (const property of properties) { Object.defineProperty( objTo, property, Object.getOwnPropertyDescriptor(objFrom, property); ); }

27

Page 28: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Конструкторы

function createStudent(name) { this.name = name; }

const billy = new createStudent('Billy');

28

Page 29: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Функция, вызванная оператором new,работает как конструктор объектов

29

Page 30: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

this внутри конструкторов ссылается насоздаваемый объект

30

Page 31: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Конструкторы

function createStudent(name) { // const this = {}; this.name = name;

// return this; } const billy = new createStudent('Billy');

31

Page 32: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Конструкторы

function Student(name) { // const this = {}; this.name = name;

// return this; } const billy = new Student('Billy');

32

Page 33: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Чтобы отличить функции-конструкторы отпростых функций принято именовать их с

заглавной буквы

33

Page 34: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Конструкторы

function Student(name) { this.name = name; }

const billy = Student('Billy');

34

Page 35: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Конструкторы

'use strict'; function Student(name) {

this.name = name; } const billy = Student('Billy');

35

Page 36: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Конструкторы

function Student(name) { this.name = name;

return { name: 'Willy' }; } const billy = new Student('Billy');

console.info(billy.name); // Willy

36

Page 37: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Конструкторы

function Student(name) { this.name = name;

return 1703; } const billy = new Student('Billy');

console.info(billy.name); // Billy

37

Page 38: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

.prototype

function Student(name) { this.name = name; }

Student.prototype = { getName() {} } const billy = new Student('Billy'); billy.getName(); // Billy

38

Page 39: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

.prototype

function Student(name) { // const this = {}; // Object.setPrototypeOf(this, Student.prototype);

this.name = name; // return this; } Student.prototype = { getName() {} } const billy = new Student('Billy'); billy.getName(); // Billy

39

Page 40: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

.constructor

function Student(name) { this.name = name; }

Student.prototype.constructor === Student; // true

40

Page 41: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

.prototype

function Student(name) { // const this = {}; // Object.setPrototypeOf(this, Student.prototype);

this.name = name; // return this; } Object.assign(Student.prototype, { getName() {} }); const billy = new Student('Billy'); billy.getName(); // Billy

41

Page 42: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

.prototype

function Student(name) { // const this = {}; // Object.setPrototypeOf(this, Student.prototype);

this.name = name; // return this; } Student.prototype = { constructor: Student, getName() {} }; const billy = new Student('Billy'); billy.getName(); // Billy 42

Page 43: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Object.prototype

const obj = {};

43

Page 44: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Object.prototype

const obj = new Object(); function Object() {}

Object.prototype = { constructor: Object, hasOwnProperty() {}, toString() {} };

44

Page 45: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Конструкторы

function Person() {} Object.assign(Person.prototype, {

getName() {} }); function Student(name) { this.name = name; } Object.assign(Student.prototype, { getCourse() {} }); Object.setPrototypeOf(Student.prototype, Person.prototype); 45

Page 46: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

«Классы»

class Student { constructor(name) { this.name = name;

} getName() { return this.name; } }

typeof Student; // function Student.prototype.hasOwnProperty('getName'); // true

46

Page 47: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

«Классы» нельзя использовать без new

47

Page 48: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

«Классы» не всплывают

48

Page 49: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

«Классы» не всплывают

const student = new Student(); function Student() {}

const lecturer = new Lecturer(); Error class Lecturer {}

ReferenceError: Lecturer is not defined

49

Page 50: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

get/set

class Student { constructor(firstName, lastName) { this.firstName = firstName;

this.lastName = lastName; } get fullName() { return this.firstName + ' ' + this.lastName; } }

50

Page 51: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Статичный метод

class User { constructor(role, name) { this.name = name;

this.role = role; } static createAdmin(name) { return new User('admin', name); } static createGuest(name) { return new User('guest', name); } } User.createAdmin('Billy'); 51

Page 52: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Все методы не перечислимы

52

Page 53: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Все методы поддерживают super

53

Page 54: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Все методы работают в строгом режиме

54

Page 55: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

extends

class Person { constructor(name) { this.name = name;

} } class Student extends Person { constructor(name, course) { super(name); this.course = course; } } const billy = new Student('Billy', 4);

55

Page 56: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

extends

class Student extends Person { constructor(name, course) { this.course = course;

super(name); } } const billy = new Student('Billy', 4); Error

ReferenceError: Must call super constructor inderived class before accessing or returning

from derived constructor56

Page 57: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Objectbilly

name

[[Prototype]]course

FunctionStudent

prototype

[[Prototype]]

constructor

FunctionPerson

prototype

[[Prototype]]

constructor

FunctionObject

prototypeconstructor

getCourse getName hasOwnProperty[[Prototype]]

null

57

Page 58: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Наследоваться можно либо от другогоконструктора («класса»), либо от null

58

Page 59: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

extends

class Student extends null {}

59

Page 60: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

isPrototypeOf

class Student {} const billy = new Student();

Student.prototype.isPrototypeOf(billy); // true

60

Page 61: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

instanceof

class Student {} const billy = new Student();

billy instanceof Student; // true

61

Page 62: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

instanceof

class Student extends Person {} const billy = new Student();

billy instanceof Student; // true billy instanceof Person; // true

62

Page 63: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

billy instanceof Person

billy.[[Prototype]] === Person.prototype; // false // Может, там null?

billy.[[Prototype]] === null; // false // Идём дальше по цепочке billy.[[Prototype]].[[Prototype]] === Person.prototype; // true // Возвращаем true

63

Page 64: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Развитие JavaScript

64

Page 65: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

TC39 (Technical Committee 39)

65

Page 66: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Microso�, Google, IBM, Intel, Yahoo,Facebook, Airbnb, Netflix, PayPal, Hewlett

Packard

66

Page 67: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

встречаются ирассматривают (proposals)

Переодическипредложения

67

Page 68: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Заметки со встреч ,а решения принимаются большинством

голосов

размещаются на Github

68

Page 69: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

0. Идея (Strawman)

Идея может быть предложена командойTC39 или любым человеком

как контрибуторзарегистрированным

69

Page 70: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

1. Предложение (Proposal)

Выбирается ответственный запредложение из TC39. Подготавливается

подробное описание с примерами.Пишутся полифилы.

70

Page 71: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

2. Черновик (Dra�)

Подготавливается описание на языкеспецификации ECMAScript. Пишутся две

реализации (одна из них длятранспилера).

71

Page 72: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

3. Кандидат (Candidate)

Описание финализируется и проходитревью других членов TC39. Пишутся две

полноценные реализации.

72

Page 73: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

4. Спецификация (Finished)

Пишутся тесты . Реализациипроходят все тесты. Редакторы ECMAScript

подписыват спецификацию.

Test262

73

Page 74: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Стандарт

Раз в год в июле обновлённаяспецификация становится новым

стандартом

74

Page 75: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

+ (Candidate)

class Student { #name = null;

constructor(value) { this.#name = value; } getName() { return 'Student ' + this.#name; } }

Class fields Private methods

75

Page 76: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

(Dra�)

class Student { @enumerable(true) getName() {

return this.name; } } function enumerable(value) { return (target, propertyName, descriptors) => { // target === Student.prototype descriptors.enumerable = value; }; }

Декораторы методов

76

Page 77: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

(Dra�)

@debug class Student {}

function debug(Class) { return (...args) => { console.trace(Class.name, args); return new Class(...args); }; }

Декораторы классов

77

Page 78: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

npm install -g babel-cli babel-node --plugins transform-decorators script.js

Babel

78

Page 79: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

(Proposal)

class C { static f() { ... } g() { C.f(); } }

Доступ к статичным полям через class

79

Page 80: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

(Proposal)

class C { static f() { ... } g() { class.f(); } }

Доступ к статичным полям через class

80

Page 81: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

(Proposal)

module.exports = class { static f() { ... } g() { class.f(); } }

Доступ к статичным полям через class

81

Page 82: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Почитать

Speaking JavaScript Chapter 17. Objects and Inheritance.

Speaking JavaScript Chapter 17. Objects and Inheritance

Exploring ES6

Layer 3: Constructors—Factories for Instances

Layer 4: Inheritance Between Constructors

15. Classes82

Page 83: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Почитать

Eric Elliott

Лекции 2015 года

Common Misconceptions About Inheritancein JavaScript

Про this

83

Page 84: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Почитать

Современный учебник Javascript

Современный учебник Javascript Современные возможности ES-2015

ООП в прототипном стиле

Классы

84

Page 85: Прототипы - GitHub Pages...Объекты разны х типов const student = { name: 'Billy', getName() { return this.name; }, sleep() {} }; const lecturer = { name:

Почитать

Dr. Axel Rauschmayer The TC39 process for ECMAScript features

85