⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 4.02 - the prototype chain.js

📁 JS设计模式源代码
💻 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 + -