![Javascript Question of the Day #20 [Talk::Overflow]](/_next/image?url=https%3A%2F%2Fmedia2.dev.to%2Fdynamic%2Fimage%2Fwidth%3D1000%2Cheight%3D500%2Cfit%3Dcover%2Cgravity%3Dauto%2Cformat%3Dauto%2Fhttps%253A%252F%252Fdev-to-uploads.s3.amazonaws.com%252Fuploads%252Farticles%252Fdzrbj4zywmxf04wiz8da.png&w=1200&q=75)
Javascript Question of the Day #20 [Talk::Overflow]
This post explains a quiz originally shared as a LinkedIn poll . 🔹 The Question function User ( name ) { this . name = name ; } User . prototype . settings = { theme : ' light ' , notifications : true }; const alice = new User ( ' Alice ' ); const bob = new User ( ' Bob ' ); alice . settings . theme = ' dark ' ; console . log ( bob . settings . theme ); console . log ( alice . hasOwnProperty ( ' settings ' )); console . log ( alice . settings === bob . settings ); Hint: When you write alice.settings.theme = 'dark' , ask yourself: are you creating a new property on alice , or reaching through the prototype chain to mutate something shared? Follow me for JavaScript puzzles and weekly curations of developer talks & insights at Talk::Overflow: https://talkoverflow.substack.com/ 🔹 Solution Correct answer: A) dark, false, true The output is: dark false true 🧠How this works JavaScript's prototype chain has an asymmetry that trips up even experienced developers: reading a property walks up th
Continue reading on Dev.to JavaScript
Opens in a new tab



