Re: Determining what prototype should be used for an object

On Fri, Nov 14, 2014 at 12:31 PM, Domenic Denicola <d@domenic.me> wrote:
> Just to sharpen the discussion, it would help to give one example of each...

<!DOCTYPE html>
<iframe></iframe>
<script>
 function isObjectFromGlobal(object, global) { return object
instanceof global.Object }
 onload = function() {
   var x = new self[0].Array()
   w(isObjectFromGlobal(x, self[0]))
   x = Array.prototype.constructor.call(self[0])
   w(isObjectFromGlobal(x, self[0]))
   x = self[0].document.createElement("x")
   w(isObjectFromGlobal(x, self[0]))
   x = Document.prototype.createElement.call(self[0].document, "x")
   w(isObjectFromGlobal(x, self[0]))
 }
</script>

http://software.hixie.ch/utilities/js/live-dom-viewer/saved/3302

yields true, false, true, true.


-- 
https://annevankesteren.nl/

Received on Friday, 14 November 2014 11:39:50 UTC