while( var row = fn() );
<p>Is there any equivalent metod to make like an php mysql_fetch_array while loop in js?</p>

<p>in php you can do:
</p>

<pre><code>&lt;?php
while ($row = mysql_fetch_array($result)) {
    echo "my name is " . $row['name'] . " and i'm " . $row['age'] . " yeas old";
}
?&gt;
</code></pre>

<p>i have this object/array:</p>

<pre><code>function fetch_array(arr) {
    // My magic fn that dose not work well, b/c it change the orginal refence
    return arr.shift();
}
var result = [{
    name: "Bob",
    age: 12
}, {
    name: "Jim",
    age: 18
}]

// And want to do:


while (row = fetch_array(result)) {
     alert("my name is " + row["name"] + " And I'm " + row['age'] + " years old");
 }

// returns zero :(​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​ dont want that
console.log(result.length);
</code></pre>
