石川es6课程---17、ES7 预览
石川es6課程---17、ES7 預(yù)覽
一、總結(jié)
一句話總結(jié):
人的價(jià)值恒定規(guī)律:無(wú)論得意還是迷茫之時(shí),你的價(jià)值都不靠外界的評(píng)判或者你內(nèi)心的悲喜而決定。而是當(dāng)時(shí)的恒定的。能夠提升他只能靠你提升自己的能力和實(shí)力。
?
1、ES7 預(yù)覽:數(shù)組?
~ arr.includes() 數(shù)組是否包含某個(gè)東西
~ 數(shù)組的 arr.keys(), arr,entries()
~ for ... in 遍歷數(shù)組 下標(biāo) key
~ for ... of 遍歷數(shù)組 值 value, 不能用于json
let arr = ['a', 'b', 'c'] console.log(arr.includes(1))for (let i in arr) {console.log(i) // 循環(huán)的時(shí)下標(biāo) key }for (let i of arr) {console.log(i) // 循環(huán)的是值 value } for (let i of arr.keys()) {console.log('>'+i) } for (let [key, value] of arr.entries()) {console.log('>' + key + value) }let json = { a: 12, b: 5, c: 7 } for (let i in json) {console.log(i) }?
?
2、ES7 預(yù)覽:字符串?
padStart()/padEnd() 指定寬度,不夠就補(bǔ)空格或指定字符
console.log('=' + 'abcd'.padStart(6, '0') + '=') console.log('=' + 'abcd'.padEnd(6, '0') + '=') =00abcd= =abcd00=?
?
3、ES7 預(yù)覽:容忍度?
[1, 2, 3,] 老版數(shù)組最后不能有逗號(hào),新的可以有,函數(shù)參數(shù)最后多的逗號(hào)也可以
?
4、ES7 預(yù)覽:async await?
和 generator yield 類似,generator 不可以寫(xiě)成箭頭函數(shù), async 可以
async function show() {console.log(1)awaitconsole.log(2) }?
?
?
二、ES7 預(yù)覽
數(shù)組
~ arr.includes() 數(shù)組是否包含某個(gè)東西
~ 數(shù)組的 arr.keys(), arr,entries()
~ for ... in 遍歷數(shù)組 下標(biāo) key
~ for ... of 遍歷數(shù)組 值 value, 不能用于json
let arr = ['a', 'b', 'c']
console.log(arr.includes(1))
for (let i in arr) {
??? console.log(i) // 循環(huán)的時(shí)下標(biāo) key
}
for (let i of arr) {
??? console.log(i) // 循環(huán)的是值 value
}
for (let i of arr.keys()) {
??? console.log('>'+i)
}
for (let [key, value] of arr.entries()) {
??? console.log('>' + key + value)
}
let json = { a: 12, b: 5, c: 7 }
for (let i in json) {
??? console.log(i)
}
字符串
padStart()/padEnd() 指定寬度,不夠就補(bǔ)空格或指定字符
console.log('=' + 'abcd'.padStart(6, '0') + '=')
console.log('=' + 'abcd'.padEnd(6, '0') + '=')
=00abcd=
=abcd00=
容忍度
[1, 2, 3,] 老版數(shù)組最后不能有逗號(hào),新的可以有
函數(shù)參數(shù)最后多的逗號(hào)也可以
async await
和 generator yield 類似
generator 不可以寫(xiě)成箭頭函數(shù), async 可以
async function show() {
??? console.log(1)
??? await
??? console.log(2)
}
?
?
轉(zhuǎn)載于:https://www.cnblogs.com/Renyi-Fan/p/11617933.html
總結(jié)
以上是生活随笔為你收集整理的石川es6课程---17、ES7 预览的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 石川es6课程---13-16、gene
- 下一篇: 石川es6课程---18、ES6 复习