Had something like this in a mock. A is the only one using setItem with JSON.stringify, which you need to turn the JS object into a string for localStorage. The rest either use wrong methods or miss parameters. Pretty sure A is correct here.
I don’t think D is right here. The curly brace after the method name in D isn’t valid JavaScript for defining prototype methods, that’s more like class syntax. B overrides the load method on the prototype properly, so all Console16bit instances pick up the change. Pretty sure B is what they want, unless I’m missing a subtlety.
prototype.load = function() directly overrides for all instances. D just isn't valid JS syntax for prototype methods, as others mentioned. I think B is correct but curious if I'm overlooking something small.I don’t think it’s B, I’d go with D. The way D is written looks like just defining the function directly fits the pattern here, even if the prototype assignment isn’t explicit. Unless I’m missing a syntax trap?
C is correct for this, since objA and objB reference the same object. But if the question had asked for what would happen if objB = {...objA} was used instead, then result would stay 10. Are we supposed to assume no shallow copy here?
I don't think it's B. C should work since calling server() would start the server directly, especially if the library's main export is a function. The event/callback thing in B seems a bit much for just booting up. Maybe I'm missing something subtle?
server.on() does. C looks tempting but skips the event-driven part.Object.freeze() makes the object immutable so properties can't be added or changed, which matches exactly what’s asked. Nice clear question-see this kind pop up a lot in practice sets.Not C, pretty sure D is the only real method in JavaScript for making an object truly immutable. The other options aren't valid methods, so D stands out. C is a trap, but doesn't exist in JS as an object method. Disagree?
display only accepts 'block' or 'none' to actually show or hide. Using 'visible' or 'hidden' isn't valid for display property, that's for visibility. Pretty sure it's B but open to correction.'visible' and 'hidden' for the display property, that technically might still hide or show something in older browsers or with some odd engine, right? Not super common but maybe possible.