JSFiddle - React, Tailwind, and code Playground
JavaScript
const ThisWindow = window;
const ThisObj = ThisWindow.history;
const OtherWindow = window.open();
const OtherObj = OtherWindow.history;
console.log(ThisObj instanceof Object); //true
console.log(OtherObj instanceof Object); //false
console.log(OtherObj instanceof OtherWindow.Object); // true
const getFunction = (ObjectIn) => {
// Get the prototype of ObjectIn
const ObjectInPrototype = Object.getPrototypeOf(ObjectIn);
// Get ObjectIn's constructor
const ObjectInConstructor = ObjectIn.constructor;
return ObjectInConstructor.constructor;
};
const getObject = (ObjectIn) => {
const Function = getFunction(ObjectIn);
return Function('return Object')();
};
console.log(OtherObj instanceof getObject(OtherObj)); // true
const OtherFunction = getFunction(OtherObj);
console.log(OtherFunction('return window')() === OtherWindow);
OtherWindow.close(); // cleanup