当前位置:网站首页>JS uses the for loop in the function to insert and delete the array at the specified position
JS uses the for loop in the function to insert and delete the array at the specified position
2022-06-25 12:41:00 【Fall in love with*】
var arr = [10, 20, 30, 40, 50, 60, 70, 80];
function del(arr,para){
for (var i = 0; i < arr.length; i++) {
if(arr[i]==para){
break;
}
}
console.log(i);
for (var j = i; j < arr.length; j++) {
arr[j]=arr[j+1];
}
arr.length--;
console.log(arr);
}
del(arr,50); var arr = [10, 20, 30, 40, 50, 60, 70, 80];
function inser(arr, para1) {
for (var i = 0; i < arr.length; i++) {
if (arr[i] == para1) {
break;
}
}
console.log(i);
for (var j = arr.length - 1; j > i; j--) {
arr[j + 1] = arr[j];
}
arr[j + 1] = "666";
console.log(arr);
}
inser(arr, 60);边栏推荐
- Windows下MySQL的安装和删除
- Upgrade opsenssh to 8.8p1
- Go novice exploration road 2
- Ten commandments of self-learning in machine learning
- ECSHOP video list_ ECSHOP uploading video, video classification, video list playing video function
- Circular exercises of JS
- Laravel echart statistical chart line chart
- visual studio2019链接opencv
- Controllable character image synthesis based on attribute decomposition and Gan reproduction
- Shell learning notes (latest update: 2022-02-18)
猜你喜欢

K8s, docker compose install MySQL 8.0.18

Total number of MySQL statistics, used and unused
![Select randomly by weight [prefix and + dichotomy + random target]](/img/84/7f930f55f8006a4bf6e23ef05676ac.png)
Select randomly by weight [prefix and + dichotomy + random target]

Windows下MySQL的安装和删除

冷启动的最优解决方案

SDN system method | 9 Access network

一篇文章讲清楚MySQL的聚簇/联合/覆盖索引、回表、索引下推

Shell learning notes (latest update: 2022-02-18)

Embedded software development written examination and interview notes (latest update: February 17, 2022)

(6) Pyqt5--- > window jump (registration login function)
随机推荐
Is it safe to open an account and buy stocks on the Internet?
JS enter three integers a, B and C, and sort them from large to small (two methods)
微信全文搜索技术优化
Go defer little knowledge
Write regular isosceles triangle and inverse isosceles triangle with for loop in JS
为何数据库也云原生了?
Shell learning notes (latest update: 2022-02-18)
2022 meisai D topic ideas sharing + translation
GNSS receiver technology and application review
Thinkphp3 reinforcement i() function filter single quotation marks
Learning notes 2022 overview | automatic graph machine learning, describing AGML methods, libraries and directions
ECSHOP commodity wholesale multi attribute multi specification multi inventory batch purchase ECSHOP wholesale plug-in ECSHOP multi attribute order
(4) Pyqt5 tutorial -- > Custom signal and slot (super winding...)
Image tagging to obtain the coordinates of the image in the ImageView
Matlab simulation of m-sequence
Does sklearex make your sklearn machine learning model training fly fast?
Tidb common commands
The difference between this and super and their respective functions
Go novice exploration road 2
C program linking SQLSERVER database: instance failed