FED18. 寄生组合式继承
描述
请补全JavaScript代码,要求通过寄生组合式继承使"Chinese"构造函数继承于"Human"构造函数。要求如下:HTML/CSS/JavaScript 解法, 执行用时: 1696ms, 内存消耗: 77772KB, 提交时间: 2022-02-09
{"css":"","js":"","html":"<!DOCTYPE html>\n<html>\n <head>\n <meta charset=utf-8>\n </head>\n <body>\n \t\n <script type=\"text/javascript\">\n // 补全代码\n class Human {\n constructor(name){\n this.name = name\n this.kingdom = 'animal'\n this.color = ['yellow', 'white', 'brown', 'black']\n }\n \n getName(){\n return this.name\n }\n }\n\n class Chinese extends Human{\n constructor(name,age){\n super(name)\n this.age = age\n this.color = 'yellow'\n }\n \n getAge(){\n return this.age\n }\n }\n \n </script>\n </body>\n</html>","libs":[]}
HTML/CSS/JavaScript 解法, 执行用时: 1743ms, 内存消耗: 77864KB, 提交时间: 2022-01-25
{"css":"","js":"","html":"<!DOCTYPE html>\n<html>\n <head>\n <meta charset=utf-8>\n </head>\n <body>\n \t\n <script type=\"text/javascript\">\n // 补全代码\n \n function Human(name) {\n this.name = name\n this.kingdom = 'animal'\n this.color = ['yellow', 'white', 'brown', 'black']\n}\nHuman.prototype.getName = function() {\n return this.name\n}\nfunction Chinese(name,age) {\n Human.call(this,name)\n this.age = age\n this.color = 'yellow'\n}\nChinese.prototype = Object.create(Human.prototype)\nChinese.prototype.constructor = Chinese\nChinese.prototype.getAge = function() {\n return this.age\n}\n </script>\n </body>\n</html>","libs":[]}
HTML/CSS/JavaScript 解法, 执行用时: 1748ms, 内存消耗: 77772KB, 提交时间: 2022-01-01
{"css":"","js":"","html":"<!DOCTYPE html>\n<html>\n <head>\n <meta charset=utf-8>\n </head>\n <body>\n \t\n <script type=\"text/javascript\">\n // 补全代码\n function Human(name) {\n this.name = name\n this.kingdom = 'animal'\n this.color = ['yellow', 'white', 'brown', 'black']\n }\n Human.prototype.getName = function(){\n return this.name\n }\n function Chinese(name,age) {\n Human.call(this, name)\n this.color = 'yellow'\n this.age = age\n }\n Chinese.prototype = Object.create(Human.prototype)\n Chinese.prototype.constructor = Chinese\n Chinese.prototype.getAge = function(){\n return this.age\n }\n </script>\n </body>\n</html>","libs":[]}
HTML/CSS/JavaScript 解法, 执行用时: 1749ms, 内存消耗: 77760KB, 提交时间: 2021-12-07
{"css":"","js":"","html":"<!DOCTYPE html>\n<html>\n <head>\n <meta charset=utf-8>\n </head>\n <body>\n \t\n <script type=\"text/javascript\">\n // 补全代码\n function Human(name) {\n this.name = name\n this.kingdom = 'animal'\n this.color = ['yellow', 'white', 'brown', 'black']\n }\n \n Human.prototype.getName=function(){\n return this.name;\n }\n function Chinese(name,age) {\n Human.call(this,name);\n this.age=age;\n this.color = 'yellow'\n }\n Chinese.prototype=Object.create(Human.prototype);\n Chinese.prototype.constructor=Chinese;\n Chinese.prototype.getAge=function(){\n return this.age;\n }\n \n </script>\n </body>\n</html>","libs":[]}
HTML/CSS/JavaScript 解法, 执行用时: 1749ms, 内存消耗: 77772KB, 提交时间: 2021-12-17
{"css":"","js":"","html":"<!DOCTYPE html>\n<html>\n <head>\n <meta charset=utf-8>\n </head>\n <body>\n \t\n <script type=\"text/javascript\">\n // 补全代码\n function Human(name) {\n this.name = name\n this.kingdom = 'animal'\n this.color = ['yellow', 'white', 'brown', 'black']\n }\n\n Human.prototype.getName = function() {\n return this.name\n }\n function Chinese(name,age) {\n Human.call(this,name)\n this.age = age\n this.color = 'yellow'\n }\n Chinese.prototype = Object.create(Human.prototype)\n Chinese.prototype.constructor = Chinese\n Chinese.prototype.getAge = function() {\n return this.age\n }\n </script>\n </body>\n</html>","libs":[]}