Javascript: Loop through unknown number of object literals
<p>I have a list of objects all named in this fashion:</p>

<pre><code>var p1 = {};
var p2 = {};
p1.name = "john";
p1.hobby = "collects stamps";
p2.name = "jane";
p2.hobby = "collects antiques";
</code></pre>

<p>I know how to loop through p1 and p2 to collect the properties, provided I know how many of these p object literals there are. Here's my problem, I don't always know how many of these p object literals there will be. Sometimes it goes up to p2, sometimes it goes up to p20. </p>

<p>Is there a way to loop through objects if I know they all share the same prefix?</p>

<p>Edit: I can't change how I'm getting the list of objects. It's given to me in that format...</p>
