Spot the bug in hasOwnProperty

from Object static methods
Node 24 intermediate 4 min 1 issue to find

Find why this helper fails for a valid null-prototype settings object.

JavaScript
function owns(settings, key) {
  return settings.hasOwnProperty(key);
}

const settings = Object.create(null);
settings.mode = 'dark';
console.log(owns(settings, 'mode'));
Open in playground
Report an error