<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>
<channel>
	<title>Comments on: Breaking instanceof in Javascript</title>
	<atom:link href="http://blog.brianhartsock.com/2007/03/08/breaking-instanceof-in-javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.brianhartsock.com/2007/03/08/breaking-instanceof-in-javascript/</link>
	<description>The exciting life of a software developer and nerd</description>
	<pubDate>Tue, 06 Jan 2009 04:54:56 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Jesper</title>
		<link>http://blog.brianhartsock.com/2007/03/08/breaking-instanceof-in-javascript/comment-page-1/#comment-472</link>
		<dc:creator>Jesper</dc:creator>
		<pubDate>Wed, 17 Sep 2008 14:18:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.brianhartsock.com/?p=13#comment-472</guid>
		<description>Here's another interesting thing with instanceof in JavaScript. Guess what the output of this is:

var s = "hello";
alert(s instanceof String);

Surprisingly, it is false! A srting literal isn't a string in JavaScript. The following shows true:

var s = new String("hello");
alert(s instanceof String);

Very annoying, especially if you're a Java programmer... :-(</description>
		<content:encoded><![CDATA[<p>Here&#8217;s another interesting thing with instanceof in JavaScript. Guess what the output of this is:</p>
<p>var s = &#8220;hello&#8221;;<br />
alert(s instanceof String);</p>
<p>Surprisingly, it is false! A srting literal isn&#8217;t a string in JavaScript. The following shows true:</p>
<p>var s = new String(&#8221;hello&#8221;);<br />
alert(s instanceof String);</p>
<p>Very annoying, especially if you&#8217;re a Java programmer&#8230; <img src='http://blog.brianhartsock.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Trenda</title>
		<link>http://blog.brianhartsock.com/2007/03/08/breaking-instanceof-in-javascript/comment-page-1/#comment-389</link>
		<dc:creator>Scott Trenda</dc:creator>
		<pubDate>Sat, 01 Dec 2007 00:57:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.brianhartsock.com/?p=13#comment-389</guid>
		<description>(This is way after the fact, I know, but whatever.)

You didn't really "break" instanceof here, you just didn't get the answer you were expecting. All instanceof really does is checks to see if the function on the right is equal to any of the the constructor functions in the prototype chain of the object on the left. That is to say, it asks "Was this constructor function over here used to create this object over here?" In the case of the first one, you were creating the new array within the child window and passing it to the parent window, where foobar() exists in the scope of the parent window. And so the first one is asking "Was this.Array() used to create value?" No, child_window.Array() was used to create it.

Now if only I could find a way to test if an object is an instanceof Window in IE... :)</description>
		<content:encoded><![CDATA[<p>(This is way after the fact, I know, but whatever.)</p>
<p>You didn&#8217;t really &#8220;break&#8221; instanceof here, you just didn&#8217;t get the answer you were expecting. All instanceof really does is checks to see if the function on the right is equal to any of the the constructor functions in the prototype chain of the object on the left. That is to say, it asks &#8220;Was this constructor function over here used to create this object over here?&#8221; In the case of the first one, you were creating the new array within the child window and passing it to the parent window, where foobar() exists in the scope of the parent window. And so the first one is asking &#8220;Was this.Array() used to create value?&#8221; No, child_window.Array() was used to create it.</p>
<p>Now if only I could find a way to test if an object is an instanceof Window in IE&#8230; <img src='http://blog.brianhartsock.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.467 seconds -->
