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:
JavaScript: 01 function Tiger() { 02 this.type = 'Cat'; 03 this.size = 'large'; 04 } 05 06 let tony = new Tiger(); 07 tony.roar = () => { 08 console.log('They\'re great!'); 09 }; 10 11 function Lion() { 12 this.type = 'Cat'; 13 this.size = 'large'; 14 } 15 16 let leo = new Lion(); 17 // Insert code here 18 leo.roar(); Which two statements could be inserted at line 17 to enable line 18?
Correct Answer: A,B
________________________________________ Comprehensive and Detailed Explanation From Exact Extract JavaScript Knowledge There are two valid ways to ensure leo.roar() exists: Directly assign a roar function to leo (Option A). Assigning a property to an instance object creates a new method on that instance. leo.roar = () => { console.log('They\'re pretty good!'); }; After this, calling leo.roar() is valid. Copy tony's properties into leo using Object.assign (Option B). Object.assign(target, source) copies enumerable own properties from the source object into the target object. Since tony.roar exists, executing: Object.assign(leo, tony); copies roar into leo, making leo.roar() valid. Why the other answers are incorrect: Option C: Object.assign(leo, Tiger) copies properties from the function object Tiger, not from Tiger.prototype and not from a Tiger instance. Tiger (the function) has no roar property, so nothing useful is copied. Option D: leo.prototype is undefined because leo is an instance, not a constructor function. Only constructor functions have a .prototype property. This line would cause an error. ________________________________________ JavaScript Knowledge Reference (text-only) Instances have their own properties and do not contain a .prototype property. Object.assign(target, source) copies own enumerable properties of the source object. Assigning a function as a property of an object creates a callable method.