• 前端学习笔记


    1. npm命令

    设置代理,命令或修改配置文件。命令都是直接写入配置文件的。

    npm config set proxy http://proxynj.zte.com.cn

    npm config edit

    npm install semserver

    package

    a、"~1.2.3" 是神马意思呢,看下面领悟

    "~1.2.3" = ">=1.2.3 <1.3.0"

    "~1.2" = ">=1.2.0 <1.3.0"

    "~1" = ">=1.0.0 <1.1.0"

    b、"1.x.x"是什么意思呢,继续自行领悟

    "1.2.x" = ">=1.2.0 <1.3.0"

    "1.x.x" = ">=1.0.0 <2.0.0"

    "1.2" = "1.2.x"

    "1.x" = "1.x.x"

    "1" = "1.x.x"

     

    2. 箭头函数里的变量都是全局的,函数里闭包箭头函数和闭包普通函数不一样的。参考如下例子:

    2.1

    var tahoe = {
    resorts: ["Kirkwood","Squaw","Alpine","Heavenly","Northstar"],
    print: function(delay=1000) {
    setTimeout(() => {
    console.log(this === window)
    }, delay)
    }
    }
    tahoe.print() // false 

    2.2

    var tahoe = {
    resorts: ["Kirkwood","Squaw","Alpine","Heavenly","Northstar"],
    print: (delay=1000)=> {
    setTimeout(() => {
    console.log(this === window)
    }, delay)
    }
    }
    tahoe.print()  // true

     

    var tahoe = {
    resorts: ["Kirkwood","Squaw","Alpine","Heavenly","Northstar"],
    print: function(delay=1000) {
    setTimeout(function() {
    console.log(this.resorts.join(","))
    }, delay)
    }
    }
    tahoe.print() // Cannot read property 'join' of undefined 

     

    var tahoe = {
    resorts: ["Kirkwood","Squaw","Alpine","Heavenly","Northstar"],
    print: function(delay=1000) {
    setTimeout(() => {
    console.log(this.resorts.join(","))
    }, delay)
    }
    }
    tahoe.print() // Kirkwood, Squaw, Alpine, Heavenly, Northstar 

     

     

    var tahoe = {
    resorts: ["Kirkwood","Squaw","Alpine","Heavenly","Northstar"],
    print: (delay=1000) => {
    setTimeout(() => {
    console.log(this.resorts.join(","))
    }, delay)

    }
    tahoe.print() // Cannot read property resorts of undefined 

  • 相关阅读:
    JAVA 桥接模式
    字模生成/提取原理
    const修饰指针
    BMP格式分析
    [转载]在.Net中使用SMTP发送邮件
    [转载]MD5加密解密
    四十二。java
    四十四。java
    四十一。复习第十二章内容
    三十六。文件流
  • 原文地址:https://www.cnblogs.com/dusf/p/10005948.html
Copyright © 2020-2023  润新知