• javaScript编码技巧


    javaScript编码技巧
    1.添加{}进行输出一个对象,更加直观的看到所需要的信息

    2.console.table()

    3.控制台样式

    使用%c,之后的第二个参数为我们添加的css样式

    4.执行时间

    5.堆栈跟踪

    console.trace("del data")

    6.对象解构



    7.对象/数组合并

    对象



    数组

    8.async


    const random = () => {
        return Promise.resolve(Math.random())
    }
    
    const sunRandomAsyncNums = () => {
        let first;
        let second;
        // ...
        let end;
    
        return random()
            .then(res => {
                first = res
                return random()
            })
            .then(res => {
                second = res
                return random()
            })
            .then(res => {
                end = res
                return first + second + end
            })
            .then(res => {
                 console.log(`result ${first + second + end}`);
            })
    }
    
    const sunRandomAsyncNums2 = async() => {
    
        const first = await random();
        const second = await random();
        const end = await random();
    
        console.log(`result ${first + second + end}`);
    }
    
    sunRandomAsyncNums();
    sunRandomAsyncNums2();
    ```![](https://img2020.cnblogs.com/blog/1990597/202101/1990597-20210111154133083-1793145487.png)
    愿以往所学皆有所获
  • 相关阅读:
    hashlib模块
    logging模块
    Python的富比较方法
    格式化符号说明
    __str__与__repr__区别
    2014-07-18 10:25

    2014-07-17 17:04
    2014-07-17 16:44
    2014-07-16 15:54
  • 原文地址:https://www.cnblogs.com/Azune/p/14262499.html
Copyright © 2020-2023  润新知