前端面试题 文章目录 前端面试题一、计算数组最大深度 一、计算数组最大深度 function countDeep(arr) { const n = arr.length; // 递归出口 if (n < 1) return 0; let max = 1; for (let i = 0; i < n; i++) { let count = 1; if (Array.isArray(arr[i])) { count += countDeep(arr[i]); } max = Math.max(max, count); } return max; }