前端开发这些年碰到不常见的api(不论新旧 持续更新)
# HTML
# JavaScript
# 数组
# splice 方法-添加元素到数组的任何位置
splice()
方法通过删除或替换现有元素或者原地添加新的元素来修改数组,并以数组形式返回被修改的内容。此方法会改变原数组。
array.splice(start[, deleteCount[, item1[, item2[, ...]]]])
const months = ['Jan', 'March', 'April', 'June'];
months.splice(1, 0, 'Feb');
// inserts at index 1
console.log(months);
// expected output: Array ["Jan", "Feb", "March", "April", "June"]
months.splice(4, 1, 'May');
// replaces 1 element at index 4
console.log(months);
// expected output: Array ["Jan", "Feb", "March", "April", "May"]
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
# CSS
上次更新: 2023/09/17, 20:06:58