Note that there are some explanatory texts on larger screens.

plurals
  1. POI cannot access fields in my object directly or with a getter function
    primarykey
    data
    text
    <p>I've been banging my head against the wall on this trivial problem for hours. I'm simply trying to do what the code below shows and it doesn't work for me. It works fine in JSFiddle, but not in my environment. If you read this post earlier, I'm reposting because I'm desperate and everyone caught the typo that wasn't really the problem. Oops on my part.<br> If I define a toString method, that works for some reason. If I define a getMid() function, that doesn't work. If I use toString as a hacky getMid() function it works. I'm confused as heck. Could my doctype or any other html/js headings be affecting it? I'm just using <code>&lt;!DOCTYPE HTML&gt;</code>. This fails for me in all browsers and I've tried it on another computer. Thanks for helping me solve this mystery.</p> <pre><code>function Card (first , last , mid) { this.first = first ; this.last = last ; this.mid = mid ; } var testArray = [ new Card("A", "B", "C"), new Card("D", "E", "E") ]; alert(testArray[1].mid); </code></pre> <p>Thanks again, Dale</p> <p>Edited to add the "optional" semicolon after testArray assignment.</p> <p>I'm expecting anything but undefined. I think I've narrowed it down. testArray is being build like so: </p> <pre><code>alert(availableCardsForSet[0].cost); for (var int = 0; int &lt; 10 &amp;&amp; testArray.length &lt; 10; int++) { testArray.push(availableCardsForSet.splice(Math.floor(Math.random()*availableCardsForSet.length),1)); } alert(testArray[0].cost); alert(testArray[0].toString()); </code></pre> <p>The first alert gives me a valid result. The second alert gives me undefined. Strangely finalSet[0].toString gives me a valid result. So I think it may be down to, how am I breaking this thing in my for loop. I get the following error/warning when I run it through JSLint Problem at "line 15 character 14: Cannot set property 'first' of undefined" Line 15 is the guts of the for loop. I appreciate all of the responses. Hopefully this new info will help.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload