title: ColdFusion: how to check if array element exists?
body: <p>I have to loop over the array of street addresses and insert the data into database. User always provide one line of address and <strong>some times</strong> two.
  I am trying to loop the array and dynamically set address_1 and address_2(if exists or NULL if not), but  it does not work for me.</p>
  
  <p><a href="https://i.stack.imgur.com/2goyi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2goyi.png" alt="Image of array dump"></a></p>
  
  <p>Here is what I have:</p>
  
  <pre><code>&lt;cfset address_1 = #jsonData.addresses.customer.street[1]#&gt;
  &lt;cfif isDefined(jsonData.addresses.customer.street[2])&gt;
      &lt;cfset address_2 = #jsonData.addresses.customer.street[2]#&gt; 
  &lt;cfelse&gt;    
      &lt;cfset address_2 = ""&gt;
  &lt;/cfif&gt;
  </code></pre>
  
  <p>When I run it, I get this:
  <em>Parameter 1 of function IsDefined, which is now Suite 300, must be a syntactically valid variable name.</em> </p>