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:
Refer to the code below: 01 const objBook = { 02 title: 'JavaScript', 03 }; 04 Object.preventExtensions(objBook); 05 const newObjBook = objBook; 06 newObjBook.author = 'Robert'; What are the values of objBook and newObjBook respectively?
Correct Answer: A
________________________________________ Comprehensive and Detailed Explanation From Exact Extract JavaScript Knowledge Object.preventExtensions(obj) This built-in JavaScript method marks an object so that no new properties can be added to it. Existing properties can still be read and updated, but adding new ones is disallowed. const newObjBook = objBook; Both variables reference the same object in memory. JavaScript objects are assigned by reference, not copied. newObjBook.author = "Robert"; Because the object has been marked as non-extensible, JavaScript will not allow new properties to be added. The behavior depends on mode: In non-strict mode: the assignment silently fails and does nothing. In strict mode: this would throw a TypeError. Since nothing indicates strict mode, this is non-strict behavior, making the assignment fail silently. Therefore, the object remains: { title: "JavaScript" } Both objBook and newObjBook point to the same unchanged object. This matches option A. ________________________________________ JavaScript knowledge references (text-only) Object.preventExtensions() prevents adding new properties. Assigning an object to another variable copies the reference, not the object. Adding a property to a non-extensible object silently fails in non-strict mode.