I have an array something like this, I would like to iterate each element until they not have property "sub". How can I make it with javascript??? I don't know what number of "sub" they have.
var items = [
{ title: 'a' },
{ title: 'b', sub: [
{ title: 'ba' },
{ title: 'bb' }
] },
{ title: 'c', sub: [
{ title: 'ca', sub: [
{ title: 'caa' },
{ title: 'cba' }
] }
] }
];