ECMA6--字符串/数组
生活随笔
收集整理的這篇文章主要介紹了
ECMA6--字符串/数组
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
字符串
新增兩個(gè)字符串方法
startsWith()
字符串首開(kāi)通檢測(cè)
endsWith()
后綴名檢測(cè)
includes ()
字符串中是否包含
字符串模板
數(shù)組
let title = '頭部' let content = '內(nèi)容' let a = '<div>\<p>'+title+'<p>\<span>'+content+'</span>\</div>'; console.log(a)let b = `<div><p>${ title }<p><span>${ content }</span></div>`console.log(b);可以換行
forEach--迭代(循環(huán))
map
- 一個(gè)對(duì)一個(gè)
- 格式:數(shù)組
reduce
- 一堆出來(lái)一個(gè),匯總
- tmp: 上一個(gè)的和
- item 本身
- index下標(biāo)
filter
let arr1 = [54,45,88,86] // 注:這里的%必須是這個(gè) let go = arr1.filter(item=>{if(item % 3 == 0){return true}else{return false} }) alert(go)let b = arr1.filter(item=>{item % 3 == 0) alert(b)let arr = [{title:'2',price:1},{title:'3',price:5},{title:'4',price:55},{title:'5',price:2} ] let a = arr.filter(function(json){return json.title == 4 }) console.log(a)轉(zhuǎn)載于:https://www.cnblogs.com/LingXiangLi/p/10252657.html
總結(jié)
以上是生活随笔為你收集整理的ECMA6--字符串/数组的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: VS.NET 编译出来的DLL,XML注
- 下一篇: common lisp 学习第四天 变量