• 前端学习笔记


    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 

  • 相关阅读:
    12个Web开发者应该掌握的Firebug技巧
    sql语句修改表结构
    从数据库中查询数据
    收发短信API
    日志12.03
    监听短信数据库变化
    漫谈C语言及如何学习C语言(转)
    阅读短信
    在src文件中寻找短信数据库表
    拦截短信示例1
  • 原文地址:https://www.cnblogs.com/dusf/p/10005948.html
Copyright © 2020-2023  润新知