Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 4th, 2012  |  syntax: None  |  size: 0.28 KB  |  hits: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to get the index of an object inside an array of objects?
  2. box[0] = {...}
  3. box[1] = {...}
  4. box[2] = {...}
  5. ...
  6. box[499] = {...}
  7.        
  8. box[i].id = i;
  9.        
  10. theArr.indexOf( this ); // assuming the function was called from the context
  11.                         //   of the object in question