js 回收機制
標(biāo)記清除 引用計數(shù)
js 代碼存在內(nèi)存中, css存在硬盤中, 資源在內(nèi)存中
es6 新特性
·· 字符串模板
startsWith()是不是以什么開頭
endsWith()是不是以什么結(jié)尾
includes()是不是包含什么
函數(shù)
function(a="",b){} 函數(shù)參數(shù) 默認(rèn)值
擴展運算符...
箭頭函數(shù)()=》
運算符
** 新增階乘運算符
數(shù)組
some((item,index,arr)=》{}) 判斷是否有條件滿足
map((item,index,arr)=》{})修改數(shù)組 并返回新的數(shù)組
forEach((item,index,arr)=》{})循環(huán)數(shù)組
filter((item,index,arr)=》{})返回符合條件的數(shù)組
reduce((preitem,curitem,index,arr)=》{})求和方法
every((item,index,arr)=》{})判斷是不是全滿足條件
for。。。of循環(huán)
find((item,index,arr)=》{})查找,找出第一個符合條件的內(nèi)容,沒找到返回undefined
findIndex((item,index,arr)=》{})返回第一個的位置,否則返回-1
keys()數(shù)組下標(biāo)
entries()數(shù)組某一項
fill('想要填充的內(nèi)容',statidex,endindex) 數(shù)組填充
includes()查找是否存在,返回true、false
解構(gòu) 第一級屬性深拷貝,第一級以下的級別屬性淺拷貝
對象
let name = 'strive'
let age = 18
let obj ={
name,
age,
showA(){ return this.name},
showB(){ return this.age }
}
屬性名和值一樣 ,可以縮寫,函數(shù)可以直接函數(shù)名加{ }定義
is(x,y)比較兩個值是否相等
Object.assign({}或者[],source1,source2.。。。)方法,第一級屬性深拷貝,第一級以下的級別屬性淺拷貝,用來合并對象或者數(shù)組,返回新對象或者數(shù)組 。
Object.keys(obj)方法 返回索引
for ( let key of Object.keys(obj) ){
console.log(key)
}
Object.values(obj)方法 返回值
for (let value of Object.values(obj)){
console.log(value)
}
Object.entries(obj)方法 返回索引和值
for (let item of Object.entries(obj)){
console.log(item)
}
for (let [key,value] of Object.entries(obj)){
console.log(key,value)
}