当前位置:网站首页>js之遍历数组、字符串
js之遍历数组、字符串
2022-07-06 12:51:00 【viceen】
js之遍历数组、字符串
1、遍历数组
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>遍历数组</title>
</head>
<body>
<script> const arr = [11, 22, 33, 44, 55, 66] // 创建数组 // 遍历数组 for (let i = 0; i < arr.length; i++) {
console.log(arr[i]) } // 遍历数组 for (let key in arr) {
console.log(key + '---' + arr[key]) } // 遍历数组 for (let key of arr) {
console.log(key); } // 遍历数组 </script>
</body>
</html>
2、遍历字符串
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>遍历字符串</title>
</head>
<body>
<script> let data1 = "你好,嗨,哈喽,Hi,Hello,非常高兴"; let arr1 = data1.split(","); // 字符串转数组(通过",") console.log("arr1:", arr1); for (let i = 0; i < arr1.length; i++) {
console.log(arr1[i]) } </script>
</body>
</html>
边栏推荐
- Laravel笔记-自定义登录中新增登录5次失败锁账户功能(提高系统安全性)
- Pytest (3) - Test naming rules
- Interviewer: what is the internal implementation of ordered collection in redis?
- 什么是RDB和AOF
- Le langage r visualise les relations entre plus de deux variables de classification (catégories), crée des plots Mosaiques en utilisant la fonction Mosaic dans le paquet VCD, et visualise les relation
- [DIY]自己设计微软MakeCode街机,官方开源软硬件
- What key progress has been made in deep learning in 2021?
- 硬件开发笔记(十): 硬件开发基本流程,制作一个USB转RS232的模块(九):创建CH340G/MAX232封装库sop-16并关联原理图元器件
- Mécanisme de fonctionnement et de mise à jour de [Widget Wechat]
- OSPF multi zone configuration
猜你喜欢
##无yum源安装spug监控
2022 Guangdong Provincial Safety Officer C certificate third batch (full-time safety production management personnel) simulation examination and Guangdong Provincial Safety Officer C certificate third
Variable star --- article module (1)
Logic is a good thing
全网最全的新型数据库、多维表格平台盘点 Notion、FlowUs、Airtable、SeaTable、维格表 Vika、飞书多维表格、黑帕云、织信 Informat、语雀
Laravel笔记-自定义登录中新增登录5次失败锁账户功能(提高系统安全性)
爱可可AI前沿推介(7.6)
Manifest of SAP ui5 framework json
Reviewer dis's whole research direction is not just reviewing my manuscript. What should I do?
Laravel notes - add the function of locking accounts after 5 login failures in user-defined login (improve system security)
随机推荐
[DIY]自己设计微软MakeCode街机,官方开源软硬件
正则表达式收集
拼多多败诉,砍价始终差0.9%一案宣判;微信内测同一手机号可注册两个账号功能;2022年度菲尔兹奖公布|极客头条
document.write()的用法-写入文本——修改样式、位置控制
Kubernetes learning summary (20) -- what is the relationship between kubernetes and microservices and containers?
R语言可视化两个以上的分类(类别)变量之间的关系、使用vcd包中的Mosaic函数创建马赛克图( Mosaic plots)、分别可视化两个、三个、四个分类变量的关系的马赛克图
[MySQL] trigger
OSPF multi zone configuration
15million employees are easy to manage, and the cloud native database gaussdb makes HR office more efficient
[diy] self designed Microsoft makecode arcade, official open source software and hardware
基于深度学习的参考帧生成
HMS Core 机器学习服务打造同传翻译新“声”态,AI让国际交流更顺畅
How to turn a multi digit number into a digital list
Huawei device command
(work record) March 11, 2020 to March 15, 2021
华为设备命令
Notes - detailed steps of training, testing and verification of yolo-v4-tiny source code
Yyds dry goods count re comb this of arrow function
新型数据库、多维表格平台盘点 Notion、FlowUs、Airtable、SeaTable、维格表 Vika、飞书多维表格、黑帕云、织信 Informat、语雀
What key progress has been made in deep learning in 2021?