zoukankan      html  css  js  c++  java
  • 前端学习笔记

    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 

  • 相关阅读:
    iframe引入网页
    input同名
    混合框架
    <header><footer>引用
    <dl>
    凸包性质——cf1044C
    几何求叉积+最短路——cf1032D
    fresco 设置资源路径时的一个坑
    马拉车+贪心——cf1326D
    【模板变形】凸壳二分+斜率优化dp——cf1083E
  • 原文地址:https://www.cnblogs.com/dusf/p/10005948.html
Copyright © 2011-2022 走看看