zoukankan      html  css  js  c++  java
  • 石川es6课程---17、ES7 预览

    石川es6课程---17、ES7 预览

    一、总结

    一句话总结:

    人的价值恒定规律:无论得意还是迷茫之时,你的价值都不靠外界的评判或者你内心的悲喜而决定。而是当时的恒定的。能够提升他只能靠你提升自己的能力和实力。

    1、ES7 预览:数组?

    ~ arr.includes() 数组是否包含某个东西
    ~ 数组的 arr.keys(), arr,entries()
    ~ for ... in 遍历数组 下标 key
    ~ for ... of 遍历数组 值 value, 不能用于json
    let arr = ['a', 'b', 'c']
    console.log(arr.includes(1))
    
    for (let i in arr) {
        console.log(i) // 循环的时下标 key
    }
    
    for (let i of arr) {
        console.log(i) // 循环的是值 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 预览:字符串?

    padStart()/padEnd() 指定宽度,不够就补空格或指定字符
    console.log('=' + 'abcd'.padStart(6, '0') + '=')
    console.log('=' + 'abcd'.padEnd(6, '0') + '=')
    =00abcd=
    =abcd00=

    3、ES7 预览:容忍度?

    [1, 2, 3,] 老版数组最后不能有逗号,新的可以有,函数参数最后多的逗号也可以

    4、ES7 预览:async await?

    和 generator yield 类似,generator 不可以写成箭头函数, async 可以
    async function show() {
        console.log(1)
        await
        console.log(2)
    }

    二、ES7 预览

    数组


    ~ arr.includes() 数组是否包含某个东西
    ~ 数组的 arr.keys(), arr,entries()
    ~ for ... in 遍历数组 下标 key
    ~ for ... of 遍历数组 值 value, 不能用于json

    let arr = ['a', 'b', 'c']
    console.log(arr.includes(1))

    for (let i in arr) {
        console.log(i) // 循环的时下标 key
    }

    for (let i of arr) {
        console.log(i) // 循环的是值 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() 指定宽度,不够就补空格或指定字符
    console.log('=' + 'abcd'.padStart(6, '0') + '=')
    console.log('=' + 'abcd'.padEnd(6, '0') + '=')
    =00abcd=
    =abcd00=


    容忍度


    [1, 2, 3,] 老版数组最后不能有逗号,新的可以有
    函数参数最后多的逗号也可以



    async await


    和 generator yield 类似
    generator 不可以写成箭头函数, async 可以


    async function show() {
        console.log(1)
        await
        console.log(2)
    }

     
  • 相关阅读:
    基于摸板匹配的目標跟蹤算法
    spoj 2713 Can you answer these queries IV
    zoj 3633 Alice's present
    hdu 3642 Get The Treasury
    poj 1195 Mobile phones
    poj 2760 End of Windless Days
    zoj 3540 Adding New Machine
    spoj 1716 Can you answer these queries III
    spoj 1043 Can you answer these queries I
    spoj 2916 Can you answer these queries V
  • 原文地址:https://www.cnblogs.com/Renyi-Fan/p/11617933.html
Copyright © 2011-2022 走看看