gazman,
function listToArray(obj) {
if (obj.rest != null) {
console.log(obj.value)
rez.push(obj.value);
obj = obj.rest;
listToArray(obj);
}
else {
rez.push(obj.value);
}
}
var rez = new Array;
a = { value: 5, rest: { value: 10, rest: { value: 15, rest: { value: 30, rest: null } } } };
listToArray(a);
alert(rez);
document.write(rez.join("<br>")); //
|