/*** @param {number[][]} matrix* @return {number[]}*/varspiralOrder=function(matrix){let left =0;//四个边界let right = matrix[0].length -1;let top =0;let bottom = matrix.length -1;let res =[];//存储结果while(true){for(let i = left; i <= right; i++){res.push(matrix[top][i]);}top++;if(top > bottom)break;// 四个边,每个边结束都判断是否终止for(let i = top; i <= bottom; i++){res.push(matrix[i][right]);}right--;if(right < left)break;for(let i = right; i >= left; i--){res.push(matrix[bottom][i]);}bottom--;if(bottom < top)break;for(let i = bottom; i >= top;i--){res.push(matrix[i][left]);}left++;if(left > right)break;}return res;};