ES6语法中关于flat()的基本用法介绍,下面web建站小编给大家简单介绍一下各种用法介绍!
各种代码如下:
//默认数组 var arr = [1, 2, [ 3, [ 4, 5 ], 6 ], 7, 8] // 不传参 flat() const array3 = arr.flat(); console.log(array3); // [1, 2, [ 3, [ 4, 5 ], 6 ], 7, 8] // 如果不传参 则是从外到里 降一维 // flat(0) const array4 = arr.flat(0); console.log(array4); // [1, [2, [3, [4, 5], 6,], 7], 8] // 传参为 0 数组没有变化 // flat(1) const array3 = arr.flat(1); console.log(array3); // [1, 2, [ 3, [ 4, 5 ], 6 ], 7, 8] // 传参为 1 则是从外到里 降一维, 和不传参一样 // flat(2) const array4 = arr.flat(2); console.log(array4); // [1, 2, 3, [4, 5], 6, 7, 8] // flat(0) const array5 = arr.flat(-1); console.log(array5); // [1, [2, [3, [4, 5], 6,], 7], 8] // 传参为 0 数组没有变化
上面是“ES6语法中关于flat()的基本用法”的全面内容,想了解更多关于 js 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_2927.html
workflows工作流
一位老人安详地坐在云层中钓鱼
树上挂着一只快乐的小樱桃
文生图工作流:树枝上站着一只鸟
一头巨大的古代大象背后建着一座城市
树上一个快乐的猕猴桃ComfyUI工作流
一架受损严重的宇宙飞船内有一只猫
森林里一只空灵的犀鸟ComfyUI工作流
一个纸杯蛋糕ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!