var arr=[
{title:"first",submenu:[{title:"ek"},{title:"do"},{title:"teen"}]},
{title:"second"},
{title:"third"}
];
var ul=document.createElement('ul');
document.body.appendChild(ul);
for(var i=0;i<arr.length;i++)
{var li=document.createElement('li');
li.innerHTML=arr[i].title;
ul.appendChild(li);
if (arr[i].submenu)
{
var ul2=document.createElement('ul');
//li[i].appendChild(ul2);
li.appendChild(ul2);
for(var j=0;j<arr[i].submenu.length;j++)
{
var li2=document.createElement('li');
//li2.innerHTML=arr[i].title;
li2.innerHTML=arr[j].title;
ul2.appendChild(li2);
}
}
}
dmFyIGFycj1bCnt0aXRsZToiZmlyc3QiLHN1Ym1lbnU6W3t0aXRsZToiZWsifSx7dGl0bGU6ImRvIn0se3RpdGxlOiJ0ZWVuIn1dfSwKe3RpdGxlOiJzZWNvbmQifSwKe3RpdGxlOiJ0aGlyZCJ9Cl07CnZhciB1bD1kb2N1bWVudC5jcmVhdGVFbGVtZW50KCd1bCcpOwpkb2N1bWVudC5ib2R5LmFwcGVuZENoaWxkKHVsKTsKZm9yKHZhciBpPTA7aTxhcnIubGVuZ3RoO2krKykKICB7dmFyIGxpPWRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ2xpJyk7CiAgbGkuaW5uZXJIVE1MPWFycltpXS50aXRsZTsKICB1bC5hcHBlbmRDaGlsZChsaSk7CiAgICAgCiAgICBpZiAoYXJyW2ldLnN1Ym1lbnUpCiAgICAgIHsKICAgICAgICB2YXIgdWwyPWRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ3VsJyk7CiAgICAgICAgLy9saVtpXS5hcHBlbmRDaGlsZCh1bDIpOwogICAgICAgIGxpLmFwcGVuZENoaWxkKHVsMik7CiAgICAgICAgZm9yKHZhciBqPTA7ajxhcnJbaV0uc3VibWVudS5sZW5ndGg7aisrKQogICAgIAogICAgICB7CiAgICAgICAgIHZhciBsaTI9ZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnbGknKTsKICAgICAgICAvL2xpMi5pbm5lckhUTUw9YXJyW2ldLnRpdGxlOwogICAgICAgICBsaTIuaW5uZXJIVE1MPWFycltqXS50aXRsZTsKICAgICAgICAgdWwyLmFwcGVuZENoaWxkKGxpMik7CiAgICAgICAgfQogICAgICAgCiAgICAgIH0KICB9