当前位置:网站首页>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>
边栏推荐
- [asp.net core] set the format of Web API response data -- formatfilter feature
- Mécanisme de fonctionnement et de mise à jour de [Widget Wechat]
- C # use Oracle stored procedure to obtain result set instance
- 全网最全的知识库管理工具综合评测和推荐:FlowUs、Baklib、简道云、ONES Wiki 、PingCode、Seed、MeBox、亿方云、智米云、搜阅云、天翎
- 知识图谱之实体对齐二
- Taylor series fast Fourier transform (FFT)
- 知识图谱构建流程步骤详解
- 正则表达式收集
- SSO single sign on
- [diy] how to make a personalized radio
猜你喜欢
Data Lake (VIII): Iceberg data storage format
Swagger UI教程 API 文档神器
Hardware development notes (10): basic process of hardware development, making a USB to RS232 module (9): create ch340g/max232 package library sop-16 and associate principle primitive devices
Laravel笔记-自定义登录中新增登录5次失败锁账户功能(提高系统安全性)
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
2022 nurse (primary) examination questions and new nurse (primary) examination questions
SSO single sign on
Reviewer dis's whole research direction is not just reviewing my manuscript. What should I do?
Mécanisme de fonctionnement et de mise à jour de [Widget Wechat]
Swagger UI tutorial API document artifact
随机推荐
正则表达式收集
R语言可视化两个以上的分类(类别)变量之间的关系、使用vcd包中的Mosaic函数创建马赛克图( Mosaic plots)、分别可视化两个、三个、四个分类变量的关系的马赛克图
How to upgrade high value-added links in the textile and clothing industry? APS to help
New database, multidimensional table platform inventory note, flowus, airtable, seatable, Vig table Vika, Feishu multidimensional table, heipayun, Zhixin information, YuQue
全网最全的新型数据库、多维表格平台盘点 Notion、FlowUs、Airtable、SeaTable、维格表 Vika、飞书多维表格、黑帕云、织信 Informat、语雀
What is the difference between procedural SQL and C language in defining variables
使用.Net分析.Net达人挑战赛参与情况
Interviewer: what is the internal implementation of ordered collection in redis?
It's almost the new year, and my heart is lazy
基于深度学习的参考帧生成
Swagger UI tutorial API document artifact
7. Data permission annotation
监控界的最强王者,没有之一!
ICML 2022 | Flowformer: 任务通用的线性复杂度Transformer
'class file has wrong version 52.0, should be 50.0' - class file has wrong version 52.0, should be 50.0
3D face reconstruction: from basic knowledge to recognition / reconstruction methods!
Spark SQL chasing Wife Series (initial understanding)
动态切换数据源
No Yum source to install SPuG monitoring
Common English vocabulary that every programmer must master (recommended Collection)