当前位置:网站首页>JS traversal array (using the foreach () method)
JS traversal array (using the foreach () method)
2022-06-23 15:11:00 【Liujiayi_】
forEach() Method You need a function as an argument
- Functions like this , Created by us but not called by us , We call it a callback function
- If there are several elements in the array, the function will execute several times , Every time it is executed , The browser will traverse the elements
Passed in as an argument , We can define formal parameters , Read this
- The browser will be in the callback function Pass three parameters :
The first parameter , Is the element currently being traversed
The second parameter , Is the index of the element currently being traversed
The third parameter , Is the array being traversed
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<script>
var arr = [" The Monkey King ", " Pig eight quit ", " The sand monk ", " Tang's monk ", " Bones jing "];
arr.forEach(function (value, index, obj) {
console.log(value);
});
</script>
</body>
</html>

边栏推荐
- Uniswap acquires genie, an NFT transaction aggregator. Will the NFT transaction market change?
- 2021-05-08
- Redis缓存三大异常的处理方案梳理总结
- Golang -- multiple processing scenarios for files
- Tencent ECS failed to send email
- [cloud based co creation] how manufacturing enterprises build "barcode factories"
- 5分钟快速上线Web应用和API(Vercel)
- 信贷产品额度定价场景下的回归模型效果评估
- 乐高宣布涨价,炒家更嗨皮了
- Raspberry PI installing the wiring pi
猜你喜欢

JSR303数据校验

2021-04-15

建議自查!MySQL驅動Bug引發的事務不回滾問題,也許你正面臨該風險!

useState vs useRef 和 useReducer:相同点、不同点和用例

SQL注入漏洞(原理篇)

Auto - vérification recommandée! Les bogues MySQL ne font pas reculer les transactions, peut - être êtes - vous à risque!

The well-known face search engine provokes public anger: just one photo will strip you of your pants in a few seconds

Effect evaluation of regression model under credit product quota pricing scenario

AXI_ Round_ Robin_ Arbiter design - aw and W channels

Moher College - manual SQL injection vulnerability test (MySQL database)
随机推荐
地平线开发板 调试
LEGO announces price increase, speculators are more excited
Introduction to the push function in JS
The new version of Alibaba Seata finally solves the idempotence, suspension and empty rollback problems of the TCC mode
Converging ecology, enabling safe operation, Huawei cloud security, cloud brain intelligent service security
中国矿大团队,开发集成多尺度深度学习模型,用于 RNA 甲基化位点预测
知名人脸搜索引擎惹众怒:仅需一张照片,几秒钟把你扒得底裤不剩
Pyqt5 工具盒使用
Logistics trade related
Mysql数据库---日志管理、备份与恢复
How is it safe to open an account for futures? Which futures company has a relatively low handling fee for futures and is suitable for retail investors to open an account?
2021-05-08
百万奖金等你来拿,首届中国元宇宙创新应用大赛联合创业黑马火热招募中!
打印内存站信息
微信小程序引导用户添加小程序动画页
Sectigo(Comodo)证书的由来
Moher College - manual SQL injection vulnerability test (MySQL database)
JS里的数组
Why is Xiaomi stuck in the chip quagmire?
[普通物理] 半波损失 等厚与等倾干涉