📄 4.02 - the prototype chain.js
字号:
/* Class Author. */function Author(name, books) { Person.call(this, name); // Call the superclass' constructor in the scope of this. this.books = books; // Add an attribute to Author.}Author.prototype = new Person(); // Set up the prototype chain.Author.prototype.constructor = Author; // Set the constructor attribute to Author.Author.prototype.getBooks = function() { // Add a method to Author. return this.books;};var author = [];author[0] = new Author('Dustin Diaz', ['JavaScript Design Patterns']);author[1] = new Author('Ross Harmes', ['JavaScript Design Patterns']);author[1].getName();author[1].getBooks();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -