sofu6

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

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 

posted on 2018-11-23 10:25  sofu6  阅读(144)  评论(0编辑  收藏  举报