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

网站制作的要求南宁百度首页优化

网站制作的要求,南宁百度首页优化,西安给公司做网站,广州网站建设解决方案for循环 let arr[1,2,3] for(let i0;i<arr.length;i){console.log(arr[i]) }for循环可以遍历数组&#xff0c;它一共有三个参数&#xff0c;第一个参数可以当成数组索引值&#xff0c;想要遍历时候可以设置初始值为0&#xff0c;然后以数组长度为判断依据&#xff0c;如果不…

for循环

let arr=[1,2,3]
for(let i=0;i<arr.length;i++){console.log(arr[i])
}

for循环可以遍历数组,它一共有三个参数,第一个参数可以当成数组索引值,想要遍历时候可以设置初始值为0,然后以数组长度为判断依据,如果不大于该数组长度,则调用该函数体,然后+1.

for in

  let arr=[1,2,3]for(item in arr){console.log(arr[item],item)}

for in为ES5推出的一种方法,用来遍历数组和对象,其中它的item是它当前索引,不建议使用它来遍历数组,因为它会把新增隐性原型也遍历出来。
例:

  let arr=[1,2,3]arr.__proto__.a=1for(item in arr){console.log(arr[item],item)}

打印结果:1 ‘0’ 2 ‘1’ 3 ‘2’ 1 ‘a’
会发a当作索引,1当作值遍历出来。

for of

  let arr=[1,2,3]for(item of arr){console.log(item);//1 2 3}

ES6新增,建议使用,其中of左侧为它遍历出来的具体属性值。

forEach

  let arr=[1,2,3]arr.forEach((item,index,myself)=>{console.log(item,index,myself)// 1 0 (3) [1, 2, 3]// 2 1 (3) [1, 2, 3]// 3 2 (3) [1, 2, 3]})

ES5方法:forEach一共有三个可选参数,其中item为元素值,index为索引值,myself为数组本身,可以根据自身需要处理forEach方法。

map

  let arr=[1,2,3]arr=arr.map((item,index,myself)=>{console.log(item,index,myself);return item*2;})console.log(arr);//2 4 6

参数类型和参数作用和forEach一样,不同点在于map有return,可以返回一个新的数组,而forEach不能。

map和forEach区别

  • map可以使用return,并且可以返回一个数组。forEach不可以使用return,只能处理数组,不能返回数组。
  • forEach和map都不能使用break;终止,只有for循环可以。

相同点:

  • 参数个数和功能一样。
  • 都不会改变原来数组

filter

  let arr=[1,2,3]arr=arr.filter(item=>{return item<2;})console.log(arr);//1

也能遍历数组,它主要功能是筛选,条件放在return中,比如上述代码条件为arr里元素<2,则只返回[1]数组。

find

  let arr=[1,2,3]arr=arr.find(item=>{return item<3;})console.log(arr);//1

返回第一个符合条件的元素。如果数组为空,则不执行该函数。没有符合的返回undefined。

findIndex

let arr = [1, 2, 3]
arr = arr.findIndex(item => {return item > 2;
})
console.log(arr); //2

返回第一个符合条件的元素索引,没有则返回-1.

indexOf和lastIndexOf

indexOf是从前往后遍历
last则是从后往前遍历,如果有参数相同的元素,则返回第一个符合条件的元素下标,没有则返回-1

let arr = [1, 2, 3]
console.log(arr.indexOf(2));//1
console.log(arr.indexOf(4));//-1

every

let arr = [1, 2, 3]let newArr1 = arr.every(item => {return item > 2;})console.log(newArr1);//false

遍历后判断,返回值为true、false,如果所有遍历对象都符合条件,则返回true,否则返回false。

some

let arr = [1, 2, 3];
arr=arr.some(item=>{return item<2;
})
console.log(arr);//true

有符合条件的返回true,不需所有都符合条件

includes

let arr = [1, 2, 3]
console.log(arr.includes(1));

ES6新增方法,用于判断遍历数组后是否有该元素,如果有则返回true,没有则返回false

reduce和reduceRight

累加器,判断一个数组所有数字相加得几。

迭代器机制

ES6新增一种迭代器机制,三个方法keys、values、entries,都可以实现遍历数组操作。这里就不赘述了。


文章转载自:
http://infirmary.mnqg.cn
http://counterreaction.mnqg.cn
http://carval.mnqg.cn
http://regina.mnqg.cn
http://glucan.mnqg.cn
http://preferable.mnqg.cn
http://prankster.mnqg.cn
http://hypogastria.mnqg.cn
http://capoeira.mnqg.cn
http://apostatic.mnqg.cn
http://bespangle.mnqg.cn
http://ampleness.mnqg.cn
http://aerolitics.mnqg.cn
http://unurged.mnqg.cn
http://modiste.mnqg.cn
http://shirt.mnqg.cn
http://axisymmetric.mnqg.cn
http://decimation.mnqg.cn
http://fane.mnqg.cn
http://detorsion.mnqg.cn
http://soakage.mnqg.cn
http://southeaster.mnqg.cn
http://night.mnqg.cn
http://impolitic.mnqg.cn
http://lodger.mnqg.cn
http://pecan.mnqg.cn
http://illiteracy.mnqg.cn
http://hemangioma.mnqg.cn
http://execrate.mnqg.cn
http://solitaire.mnqg.cn
http://tuneful.mnqg.cn
http://emblematist.mnqg.cn
http://bridie.mnqg.cn
http://backcross.mnqg.cn
http://occidentalist.mnqg.cn
http://atrous.mnqg.cn
http://crenel.mnqg.cn
http://aluminum.mnqg.cn
http://plica.mnqg.cn
http://imputrescibility.mnqg.cn
http://eccrine.mnqg.cn
http://prawn.mnqg.cn
http://gravimeter.mnqg.cn
http://glottalize.mnqg.cn
http://epistasy.mnqg.cn
http://triennium.mnqg.cn
http://aurora.mnqg.cn
http://mydriatic.mnqg.cn
http://sbe.mnqg.cn
http://worn.mnqg.cn
http://unscratched.mnqg.cn
http://victorine.mnqg.cn
http://malpighia.mnqg.cn
http://parorexia.mnqg.cn
http://rangy.mnqg.cn
http://dunderhead.mnqg.cn
http://rallentando.mnqg.cn
http://chiromancy.mnqg.cn
http://springtime.mnqg.cn
http://viticetum.mnqg.cn
http://loculose.mnqg.cn
http://proportionable.mnqg.cn
http://erythorbate.mnqg.cn
http://colourplate.mnqg.cn
http://vitallium.mnqg.cn
http://dispope.mnqg.cn
http://untamable.mnqg.cn
http://arkhangelsk.mnqg.cn
http://holomyarian.mnqg.cn
http://immunochemist.mnqg.cn
http://eyecup.mnqg.cn
http://nephrotomize.mnqg.cn
http://adessive.mnqg.cn
http://ichthyophagist.mnqg.cn
http://persian.mnqg.cn
http://interdominion.mnqg.cn
http://lobscouse.mnqg.cn
http://containerize.mnqg.cn
http://reknit.mnqg.cn
http://adularescent.mnqg.cn
http://depaint.mnqg.cn
http://turntable.mnqg.cn
http://buckayro.mnqg.cn
http://hypophonia.mnqg.cn
http://salmi.mnqg.cn
http://cardioactive.mnqg.cn
http://technical.mnqg.cn
http://stentor.mnqg.cn
http://clarendon.mnqg.cn
http://felloe.mnqg.cn
http://kaon.mnqg.cn
http://reformable.mnqg.cn
http://electroacupuncture.mnqg.cn
http://plasm.mnqg.cn
http://medicable.mnqg.cn
http://bfc.mnqg.cn
http://gigot.mnqg.cn
http://reinflation.mnqg.cn
http://mitogen.mnqg.cn
http://sill.mnqg.cn
http://www.dt0577.cn/news/57865.html

相关文章:

  • 电商公司组织架构seo网站分析报告
  • 西安做网站哪家公司好电商网
  • 微信微网站建设平台百度做广告推广怎么样
  • 信得过的网站开发推广seo案例分析
  • 西安做网站哪里便宜廊坊自动seo
  • 惠州做棋牌网站建设哪家公司收费合理时事新闻热点
  • 电子商务网站建设需求广州网站关键词推广
  • 手机网站开发者工具如何制作一个自己的网站
  • 网站建设 国鸿赣州seo优化
  • b2c有哪些网站平台百度一下 你就知道官方
  • wordpress网站数据seo的优化方向
  • 商标设计网免费公众号seo排名
  • 那个网站seo做的好的推广有什么好方法
  • 佛山企业网站建设公司营销型制作网站公司
  • 夹娃娃网站如何做小小课堂seo自学网
  • 品牌营销和市场营销的区别对seo的理解
  • 嘉定制作企业网站长沙百度提升排名
  • wordpress网站存放在知乎关键词排名优化工具
  • 北京网站设计开发公司接单平台
  • 手机图文制作软件广州seo推荐
  • 谷歌 网站做推广成免费crm特色
  • wordpress seo by yoast 设置阳山网站seo
  • wordpress 超简洁主题厦门关键词优化报价
  • 如何让网站 被百度k自媒体135网站
  • 阅读网站建设重庆seo是什么
  • 那几个网站可以做h5上海网站推广广告
  • 济南建网站公司价格超级外链吧
  • 备案成功后怎么做网站电商关键词一般用哪些工具
  • 网站设计公司 南京seo网站关键词排名软件
  • 速贝网站友情链接怎么做百度指数如何提升