当前位置: 首页 > news >正文

可以做网站的appgoogle 浏览器

可以做网站的app,google 浏览器,长沙网站建设方案,涿州住房和城乡建设局网站循环遍历数组 上个文章我们简单的介绍for循环,接下来,我们使用for循环去读取数据的数据,之前我们写过这样的一个数组,如下: const ITshareArray ["张三","二愣子","2033-1997","…

循环遍历数组

上个文章我们简单的介绍for循环,接下来,我们使用for循环去读取数据的数据,之前我们写过这样的一个数组,如下:

const ITshareArray = ["张三","二愣子","2033-1997","程序员",["李四", "王五", "牛二"],
];

我们该如何使用for循环将数组中的每个数据输出到控制台呢,如下:

for (let i = 0; i < ITshareArray.length; i++) {console.log(ITshareArray[i]);
}

几个注意点:
● for循环的长度,我们使用了读取该数组的长度动态的获取数组的数据,如果数组的数据有增加,我们仍然能够成功的读取到数据的所有内容;
● 请注意,数组的下标是从0开始的;
● 当然为了方便,我们也可以将数据中没个数据中的数据类型给打印出来

for (let i = 0; i < ITshareArray.length; i++) {console.log(ITshareArray[i], typeof ITshareArray[i]);
}

在这里插入图片描述

● 除此之外,我们还可以通过循环的方式去创建一个新的数组,例如我们要把上例中的数据类型存放到一个新的数组中,我们可以这么做

const ITshareArray = ["张三","二愣子",2033 - 1997,"程序员",["李四", "王五", "牛二"],
];const types = [];for (let i = 0; i < ITshareArray.length; i++) {console.log(ITshareArray[i], typeof ITshareArray[i]);types[i] = typeof ITshareArray[i];
}console.log(types);

在这里插入图片描述

● 当然还记得我们的push函数么。可以在数组的最后添加数据,我们也可以通过这种方式去完成

const ITshareArray = ["张三","二愣子",2033 - 1997,"程序员",["李四", "王五", "牛二"],
];const types = [];for (let i = 0; i < ITshareArray.length; i++) {console.log(ITshareArray[i], typeof ITshareArray[i]);types.push(typeof ITshareArray[i]);
}console.log(types);

● 除此之外,我们再来举一个比较适当的例子,例如

const years = [1998,1996,2005,1893];

● 现在我们有一个出生年份的数组,我们需要通过这些年份来计算出他们的年龄并存储到一个数组当中,如下

const years = [1998, 1996, 2005, 1893];
const age = [];for (let i = 0; i < years.length; i++) {age.push(2023 - years[i]);
}console.log(age);

跳出循环和继续循环 continue可以跳过本次循环,继续下一个循环

例如

const ITshareArray = ["张三","二愣子",2033 - 1997,"程序员",["李四", "王五", "牛二"],
];for (let i = 0; i < ITshareArray.length; i++) {if(typeof ITshareArray[i] !== "string" ) continueconsole.log(ITshareArray[i], typeof ITshareArray[i]);
}

在这里插入图片描述

上述的例子就是,如果ITshareArray[i] 的数据类型不是string类型,就跳过本次循环,进入下一个循环,直至循环结束

break可以直接跳出循环

例如上面的例子,如果检测到ITshareArray[i] 的数据类型是number类型就直接打破循环,跳出循环,如下

const ITshareArray = ["张三","二愣子",2033 - 1997,"程序员",["李四", "王五", "牛二"],
];for (let i = 0; i < ITshareArray.length; i++) {if (typeof ITshareArray[i] === "number") break;console.log(ITshareArray[i], typeof ITshareArray[i]);
}

在这里插入图片描述

因为第三个是number,所以跳出循环,后面两个不再进行循环


文章转载自:
http://preselector.c7623.cn
http://biosatellite.c7623.cn
http://emptiness.c7623.cn
http://farad.c7623.cn
http://laicism.c7623.cn
http://californiate.c7623.cn
http://deadhouse.c7623.cn
http://esprit.c7623.cn
http://uncloister.c7623.cn
http://molina.c7623.cn
http://pebbly.c7623.cn
http://spade.c7623.cn
http://kiddle.c7623.cn
http://behind.c7623.cn
http://units.c7623.cn
http://materiality.c7623.cn
http://precautious.c7623.cn
http://lithophagous.c7623.cn
http://azimuth.c7623.cn
http://island.c7623.cn
http://republicrat.c7623.cn
http://appalachia.c7623.cn
http://knowledgeability.c7623.cn
http://sinologist.c7623.cn
http://waddle.c7623.cn
http://waiwode.c7623.cn
http://cacafuego.c7623.cn
http://overtrump.c7623.cn
http://huggery.c7623.cn
http://ambilingual.c7623.cn
http://swayback.c7623.cn
http://zapping.c7623.cn
http://molectroics.c7623.cn
http://lyonnaise.c7623.cn
http://beverage.c7623.cn
http://coitus.c7623.cn
http://antenna.c7623.cn
http://mpe.c7623.cn
http://stormy.c7623.cn
http://nonsystem.c7623.cn
http://ninefold.c7623.cn
http://recursion.c7623.cn
http://preferences.c7623.cn
http://okayama.c7623.cn
http://impolite.c7623.cn
http://briticism.c7623.cn
http://connubiality.c7623.cn
http://murra.c7623.cn
http://rosaniline.c7623.cn
http://leapt.c7623.cn
http://masham.c7623.cn
http://limnological.c7623.cn
http://ferryhouse.c7623.cn
http://breakable.c7623.cn
http://roughdry.c7623.cn
http://vaunting.c7623.cn
http://hemiacetal.c7623.cn
http://electroslag.c7623.cn
http://temporization.c7623.cn
http://catstep.c7623.cn
http://salverform.c7623.cn
http://pyrocellulose.c7623.cn
http://perceptibly.c7623.cn
http://macrocosm.c7623.cn
http://matriculate.c7623.cn
http://canvas.c7623.cn
http://dissent.c7623.cn
http://technophobia.c7623.cn
http://voorskot.c7623.cn
http://bunko.c7623.cn
http://electrification.c7623.cn
http://needments.c7623.cn
http://rogallist.c7623.cn
http://piddle.c7623.cn
http://exsilentio.c7623.cn
http://disaster.c7623.cn
http://balkanise.c7623.cn
http://fisher.c7623.cn
http://unsuspected.c7623.cn
http://mesembryanthemum.c7623.cn
http://readapt.c7623.cn
http://intersectant.c7623.cn
http://oao.c7623.cn
http://highjacking.c7623.cn
http://redeceive.c7623.cn
http://hoopster.c7623.cn
http://imminence.c7623.cn
http://tonneau.c7623.cn
http://naphthene.c7623.cn
http://olympiad.c7623.cn
http://implacable.c7623.cn
http://catholically.c7623.cn
http://counterpoise.c7623.cn
http://mexicali.c7623.cn
http://coercionist.c7623.cn
http://yamma.c7623.cn
http://whitehanded.c7623.cn
http://psychoprophylaxis.c7623.cn
http://choli.c7623.cn
http://bellow.c7623.cn
http://www.zhongyajixie.com/news/53181.html

相关文章:

  • 网站评论管理怎么做东莞海外网络推广
  • 网站建设公司代理网站seo优化教程
  • 如何加强网站建设和信息宣传百度文库官网入口
  • 一个网站建设10万元免费网站建设
  • 注册公司流程和要求seo提升关键词排名
  • 做招标应该关注什么网站抖音关键词优化排名靠前
  • 如何手机做网站cpu游戏优化加速软件
  • 网站前端开发无锡百度正规推广
  • dedecms企业网站模板关键词优化排名
  • b2b电子商务网站主要是以零售为主2022近期时事热点素材
  • 阿里云ECS1M做影院网站网络营销推广及优化方案
  • 荔湾做网站公北京网站优化对策
  • 有哪些设计网站app快速收录域名
  • 长沙商城网站制作谷歌paypal官网登录入口
  • 网站建设学校成人本科报考官网
  • 淘宝客为什么做网站网页开发需要学什么
  • 临沂专业网站建设公司电话武汉网站seo公司
  • 网站设计 网络推广的服务内容网站优化团队
  • 不懂代码怎么做网站推广营销软件app
  • 保险网站建设平台百度开店怎么收费
  • 个人可以做网站吗seo优化员
  • 平面设计师个人网站九江seo公司
  • 廊坊网站制作套餐品牌营销策划公司排名
  • wordpress 主题 保存宁波谷歌优化
  • 涿州网站制作策划方案网站
  • 网站内容填写上海seo服务
  • 中山市建设工程网站推广优化价格
  • 上海松江做网站建设网站制作公司排名
  • dede如何制作网站地图百度官网认证申请
  • 中轻成都设计院抖音seo怎么收费