Easy way (with out eval) to turn a passed string into an object refereance in JS?
<p>So let's say I have a in page function:</p>

<pre><code>&lt;img src="someImage.jpg" onclick="doSomething(this.id)" id="someVar" alt="blah" /&gt;
</code></pre>

<p>and I have a class set up:</p>

<pre><code>function anObject(someProp)
{
this.someProp=someProp;
}
someVar=anObject("prop");
</code></pre>

<p>Where I have trouble is in the doSomething function:</p>

<pre><code>function doSomething(theObject)
{
alert(theObject.someProp); //this is treated as "someVar".someProp as far as I can tell instead of someVar.someProp
}
</code></pre>

<p>Basically, I would like to be able to use that reference as an object reference instead of a string, is there an easy way to do this without eval?</p>

<p>Also is there some way to ensure the oppisite, that it is treated as a string instead of an object?</p>

<p><strong>EDIT: I am attempting to reference the object with the same name as the image's ID NOT the image itself.</strong></p>
