Valid JS-Dev-101 Dumps shared by EduDump.com for Helping Passing JS-Dev-101 Exam! EduDump.com now offer the newest JS-Dev-101 exam dumps, the EduDump.com JS-Dev-101 exam questions have been updated and answers have been corrected get the newest EduDump.com JS-Dev-101 dumps with Test Engine here:
Given the code: 01 function GameConsole(name) { 02 this.name = name; 03 } 04 05 GameConsole.prototype.load = function(gamename) { 06 console.log('${this.name} is loading a game: ${gamename}....'); 07 } 08 09 function Console16bit(name) { 10 GameConsole.call(this, name); 11 } 12 13 Console16bit.prototype = Object.create(GameConsole.prototype); 14 15 // insert code here 16 console.log('${this.name} is loading a cartridge game: ${gamename}....'); 17 } 18 19 const console16bit = new Console16bit('SNEGeneziz'); 20 console16bit.load('Super Monic 3x Force'); What should a developer insert at line 15?
Correct Answer: D
A subclass created by: Console16bit.prototype = Object.create(GameConsole.prototype); inherits all prototype methods from GameConsole, including load. To override the inherited method, the correct syntax is to assign a new function to the method name on the prototype: Console16bit.prototype.load = function(gamename) { console.log(`${this.name} is loading a cartridge game: ${gamename}....`); }; Why the other options are wrong: A assigns something to the constructor function itself, not to the prototype method. Invalid. B attempts to call a function in the left-hand side of an assignment; invalid syntax. C also uses invalid syntax-prototype methods cannot be defined this way. D is the correct definition of a prototype method override. JavaScript Knowledge Reference (text-only) Methods are overridden by assigning functions to Subclass.prototype.methodName. Object.create() establishes prototype inheritance. Constructor functions require prototype method attachment using assignment syntax.