<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Check if array key exists via the in operator]]></title><description><![CDATA[<p dir="auto">The in operator doesn't seem to be acting like I would expect. In this snippet of code it should be printing 0 but it always prints 1.</p>
<pre><code>var myObj = {pie:"apple", cake:"chocolate", sausage:"dog"};

if ("fish" in myObj)
{
	Console.print(1);
}
else 
{
	Console.print(0);
}</code></pre>
]]></description><link>https://forum.hise.audio/topic/57/check-if-array-key-exists-via-the-in-operator</link><generator>RSS for Node</generator><lastBuildDate>Mon, 12 Oct 2026 13:20:59 GMT</lastBuildDate><atom:link href="https://forum.hise.audio/topic/57.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 14 Oct 2016 16:42:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Check if array key exists via the in operator on Fri, 14 Oct 2016 23:09:51 GMT]]></title><description><![CDATA[<p dir="auto">Thank you :)</p>
]]></description><link>https://forum.hise.audio/post/279</link><guid isPermaLink="true">https://forum.hise.audio/post/279</guid><dc:creator><![CDATA[David Healey]]></dc:creator><pubDate>Fri, 14 Oct 2016 23:09:51 GMT</pubDate></item><item><title><![CDATA[Reply to Check if array key exists via the in operator on Fri, 14 Oct 2016 22:53:04 GMT]]></title><description><![CDATA[<p dir="auto">Yeah, the <code>in</code> operator is only used for the iterator loop.</p>
<p dir="auto">But you can test if the key exists like this:</p>
<pre><code>var myObj = {"pie":"apple", "cake":"chocolate", "sausage":"dog"};

inline function keyExists(obj, key)
{
	return !(obj[key] == void); // Important: not undefined!
}

if (keyExists(myObj, "fish"))
{
	Console.print(1);
}
else 
{
	Console.print(0);
}
</code></pre>
]]></description><link>https://forum.hise.audio/post/274</link><guid isPermaLink="true">https://forum.hise.audio/post/274</guid><dc:creator><![CDATA[Christoph Hart]]></dc:creator><pubDate>Fri, 14 Oct 2016 22:53:04 GMT</pubDate></item></channel></rss>