JavaScript - passing string as an object property
<p>Just FYI this code is part of ExtJS 4 script. I have a global setting which I use to show the path to the dir where my icons are. I'm making some modifications so before was:</p>

<blockquote>
  <p>g_settings.iconUrl</p>
</blockquote>

<p>but now I need to pass a third argument property like this:</p>

<blockquote>
  <p>g_settings.iconUrl.docIcon</p>
</blockquote>

<p>The problem I met is where I have an <code>if</code> statement where I check for different values:</p>

<blockquote>
  <p>if (extensions == 'doc'||extensions == 'docx'||extensions == 'xlsx'||extensions == 'xls)</p>
</blockquote>

<p>and then I do:</p>

<blockquote>
  <p>extensions += 'Icon';</p>
</blockquote>

<p>and I need to use:</p>

<blockquote>
  <p>g_settings.iconUrl.extension</p>
</blockquote>

<p>when I use <code>console.log(extensions)</code> it's value is as expected (for example <code>docIcon</code>) but when I try to use it as a property it doesn't work. If I use console.log on:</p>

<blockquote>
  <p>console.log(g_settings.iconUrl+ '.' +extensions)</p>
</blockquote>

<p>the output is <code>[object Object].docIcon</code> so I think I have to convert somehow <code>extensions</code> to object too.
I'm not sure that this will solve the problem but that's what I have for now.</p>

<p>Any suggestions?</p>

<p>Thanks</p>

<p>Leron</p>
