js 数组随手记

本文深入讲解了JavaScript中的concat()和slice()方法。concat()方法用于连接两个或多个数组,返回新数组而不改变原有数组。slice()方法则从已有数组中返回选定元素的新数组,同样不改变原数组。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

1、JavaScript concat() 方法

concat() 方法用于连接两个或多个数组。该方法不会改变现有的数组,而仅仅会返回被连接数组的一个副本。

[1,2,3].concat(4);
arr.concat(arr2,arr3)

2、slice()方法

slice() 方法可从已有的数组中返回选定的元素。返回一个新的数组,包含从 start 到 end (不包括该元素)的 arrayObject 中的元素,该方法不会改变现有的数组。

我的代码是:Page({ data: { activeIndex: 0, activeStatus: 0, commonFunctions: [ { name: "排查录入", icon: "/images/icons/排查录入.png" }, { name: "排查分配", icon: "/images/icons/排查分配.png" }, { name: "排查记录", icon: "/images/icons/排查记录.png" }, { name: "待整改隐患", icon: "/images/icons/待整改隐患.png" } ], sections: [ // 1. 事故隐患 { title: "事故隐患", functions: [ { name: "排查录入", icon: "/images/icons/排查录入.png", type: "ai-detection" // 关键标识符 }, { name: "排查分配", icon: "/images/icons/排查分配.png", type: "ai-detection" // 关键标识符 }, { name: "排查记录", icon: "/images/icons/排查记录.png", type: "ai-detection" // 关键标识符 }, { name: "待整改隐患", icon: "/images/icons/待整改隐患.png", type: "ai-detection" // 关键标识符 }, { name: "超期未整改隐患", icon: "/images/icons/超期未整改隐患.png", type: "ai-detection" // 关键标识符 }, { name: "待复查隐患", icon: "/images/icons/待复查隐患.png", type: "ai-detection" // 关键标识符 }, { name: "复查不合格", icon: "/images/icons/复查不合格.png", type: "ai-detection" // 关键标识符 }, { name: "随手拍", icon: "/images/icons/随手拍.png", type: "ai-detection" // 关键标识符 }, { name: "制定排查任务", icon: "/images/icons/制定排查任务.png", type: "ai-detection" // 关键标识符 }, { name: "任务排查", icon: "/images/icons/任务排查.png", type: "ai-detection" // 关键标识符 }, { name: "AI识隐患", icon: "/images/icons/AI识隐患.png", type: "ai-detection" // 关键标识符 }, ] }, // 2. 风险管控 { title: "风险管控", functions: [ { name: "风险评估", icon: "/images/icons/待整改隐患.png" },
最新发布
03-14
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值