Here's my code's jsfiddle. t
function test(i)
{
if(i==2)
return {title:"finished at 2", data:"empty"}
else
{
a=[]
a.push(test(i+1))
a.push(test(i+1))
return {title:"number "+i, data:a}
}
}
alert(JSON.stringify(test(0)))
Here, test(0) should be
{
title: "number 0",
data: [{
title: "number 1",
data: [{
title: "finished at 2",
data: "Empty"
}, {
title: "finished at 2",
data: "Empty"
}]
}, {
title: "number 1",
data: [{
title: "finished at 2",
data: "Empty"
}, {
title: "finished at 2",
data: "Empty"
}]
}]
while you can see it is different in the code's result. How and Why? What do I do to make it right?
console.log()in the future instead ofalert(). Not an answer though.