Please tell me how to loop and recursively put all the id of an array in an array into another array.

Thank you. I thought of it as soon as it was released.
data: [

]
{
    value: ""
    children: [
        {
            value:"",
                children: [
                    {value: ""}
                ]
        },
        {
            value:"",
                children: [
                    {value: ""}
                ]
        },
    ]
}

]
how to determine whether there is a children array under the array, and then put the value in it into a new array?

Mar.10,2021

let data = {
    value: '',
    children: [{
            value: '',
            children: [
                { value: '' }
            ]
        },
        {
            value: '',
            children: [
                { value: '' }
            ]
        },
    ]
}


function f({ value, children }, array = []) {
    array.push(value)
    if (children && children.length > 0) {
        for (let child of children) {
            f(child, array)
        }
    }
    return array;
}

console.log(f(data))//[ '', '', '', '', '' ]

var data = [

  {
    value: '',
    children: [
      {
        value: '',
        children: [
          { value: '' }
        ]
      },
      {
        value: '',
        children: [
          { value: '' }
        ]
      },
    ]
  }
]
var arr = []
function f(items) {
  items.forEach(item => {
    arr.push(item.value)
    if (item.children) {
      f(item.children)
    }
  })
}
f(data)
console.log(arr)

var m = [];
function test(arr){
    arr.forEach(v=>{
        m.push(v.value);
        f(v.children)test(v.children)
    })
}
Menu