当前位置:网站首页>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>
边栏推荐
- 全网最全的知识库管理工具综合评测和推荐:FlowUs、Baklib、简道云、ONES Wiki 、PingCode、Seed、MeBox、亿方云、智米云、搜阅云、天翎
- SSO single sign on
- Common doubts about the introduction of APS by enterprises
- 2022菲尔兹奖揭晓!首位韩裔许埈珥上榜,四位80后得奖,乌克兰女数学家成史上唯二获奖女性
- 拼多多败诉,砍价始终差0.9%一案宣判;微信内测同一手机号可注册两个账号功能;2022年度菲尔兹奖公布|极客头条
- It's almost the new year, and my heart is lazy
- Taylor series fast Fourier transform (FFT)
- Mécanisme de fonctionnement et de mise à jour de [Widget Wechat]
- Select data Column subset in table R [duplicate] - select subset of columns in data table R [duplicate]
- SAP Fiori应用索引大全工具和 SAP Fiori Tools 的使用介绍
猜你喜欢
3D人脸重建:从基础知识到识别/重建方法!
OAI 5G NR+USRP B210安装搭建
全网最全的新型数据库、多维表格平台盘点 Notion、FlowUs、Airtable、SeaTable、维格表 Vika、飞书多维表格、黑帕云、织信 Informat、语雀
[wechat applet] operation mechanism and update mechanism
性能测试过程和计划
1_ Introduction to go language
Laravel笔记-自定义登录中新增登录5次失败锁账户功能(提高系统安全性)
PHP saves session data to MySQL database
面试官:Redis中有序集合的内部实现方式是什么?
使用.Net驱动Jetson Nano的OLED显示屏
随机推荐
快过年了,心也懒了
[200 opencv routines] 220 Mosaic the image
Entity alignment two of knowledge map
Comment faire une radio personnalisée
Pytest (3) - Test naming rules
Distributed ID
Statistical inference: maximum likelihood estimation, Bayesian estimation and variance deviation decomposition
Can novices speculate in stocks for 200 yuan? Is the securities account given by qiniu safe?
R語言可視化兩個以上的分類(類別)變量之間的關系、使用vcd包中的Mosaic函數創建馬賽克圖( Mosaic plots)、分別可視化兩個、三個、四個分類變量的關系的馬賽克圖
R language visualizes the relationship between more than two classification (category) variables, uses mosaic function in VCD package to create mosaic plots, and visualizes the relationship between tw
OAI 5G NR+USRP B210安装搭建
The most comprehensive new database in the whole network, multidimensional table platform inventory note, flowus, airtable, seatable, Vig table Vika, flying Book Multidimensional table, heipayun, Zhix
2022 construction electrician (special type of construction work) free test questions and construction electrician (special type of construction work) certificate examination
c#使用oracle存储过程获取结果集实例
Database - how to get familiar with hundreds of tables of the project -navicat these unique skills, have you got it? (exclusive experience)
[DIY]如何制作一款个性的收音机
3D face reconstruction: from basic knowledge to recognition / reconstruction methods!
请问sql group by 语句问题
使用.Net分析.Net达人挑战赛参与情况
新型数据库、多维表格平台盘点 Notion、FlowUs、Airtable、SeaTable、维格表 Vika、飞书多维表格、黑帕云、织信 Informat、语雀