Select photo while keep the order
<p>I have a list of photo on the page, each have an unique id, user can click on them to toggle select the photo, when they click the submit button, I need to send the array of selected photo ids to the back end, in the order that the photo was selected.</p>

<p>I think that the fastest way to track if a photo is selected is to use an object that use photo id as key, like:</p>

<pre><code>var selected = {
    "6272861": true,
    "6272888": true
}
</code></pre>

<p>when the user unselect a photo, I just need to <code>delete selected["6272861"]</code>.</p>

<p>But this will ignore the order, if I use an array to keep the selected photos:</p>

<pre><code>var selected = ["6272861", "6272888"];
</code></pre>

<p>then when I need to unselect a photo, I have to loop through the array and delete the item.</p>

<p>Is there better ways? thanks.</p>
