I'm trying to check if document has 'hidden' property using document.hasOwnProperty but it always returns false in Chrome (74).
I've tried Object.prototype.hasOwnProperty but that too returns false. When I tried to stringify and parse back document I got back Location object as a property.
console.log(document.hasOwnProperty("hidden"));
console.log(Object.prototype.hasOwnProperty.call(document, "false"));
console.log(JSON.parse(JSON.stringify(document)));
console.log(typeof document.hidden !== "undefined");
console.log(document.hidden);
console.log(Document.prototype.hasOwnProperty.call(document, "hidden"));
console.log(Document.prototype.hasOwnProperty.call(document, "location"));
Shouldn't hasOwnProperty
check if an object has a property irrespective of the object type? I apologize if the question has already been answered.