<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <script> let test = [ [ [{ code: 100, name: '100' },{ code: 101, name: '101' },{ code: 102, name: '102' }], [{ code: 200, name: '200' },{ code: 201, name: '201' },{ code: 202, name: '202' }] ] ] function arrList(arr,code) { arr.forEach(element => { if(element.code === code){ console.log('遍历到了',element.name); return element.name } if(element instanceof Array){ console.log('还有子元素'); arrList(element,code) } }); } let result = arrList(test,200) // 执行 console.log(result); /* 第二种方法 */ </script> </body> </html>