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)
    }

     
  • 相关阅读:
    两个栈实现一个队列,C语言实现,队列可伸缩,容纳任意数目的元素。
    创建双向链表的一个陷阱!!
    实现单链表的倒置
    《征服c指针》学习笔记-----统计文本单词数目的程序word_count
    [stm32]IAR环境 hardfault定位
    [FreeRTOS] 函数笔记
    [C语言]字符串函数大全
    [verilog]常用任务之模拟UART Rxd引脚输入数据
    [git] 知识点
    [FreeRTOS] 临界区处理
  • 原文地址:https://www.cnblogs.com/Renyi-Fan/p/11617933.html
Copyright © 2011-2022 走看看