rfc 1928.
/usr/local/gopath/src/golang.org/x/net/proxy/sock5.go
https://github.com/MDGSF/sock5
var obj = {
birth: 1990,
// 由于JavaScript函数对this绑定的错误处理,下面的例子无法得到预期结果
getAge1: function () {
var b = this.birth; // 1990
var fn = function () {
return new Date().getFullYear() - this.birth; // this指向window或undefined
};
return fn();
},
// 箭头函数完全修复了this的指向,this总是指向词法作用域,也就是外层调用者obj
getAge2: function () {
var b = this.birth; // 1990
var fn = () => new Date().getFullYear() - this.birth; // this指向obj对象
return fn();
},
// 由于this在箭头函数中已经按照词法作用域绑定了,所以,用call()或者apply()调用箭头函数时,无法对this进行绑定,即传入的第一个参数被忽略
getAge3: function (year) {
var b = this.birth; // 1990
var fn = (y) => y - this.birth; // this.birth仍是1990
return fn.call({birth:2000}, year);
}
};
console.log(obj.getAge1()); // NaN
console.log(obj.getAge2()); // 28
console.log(obj.getAge3(2018)); // 28
var now = new Date();
console.log(now); // 2018-07-16T09:18:52.740Z
console.log("now.getFullYear() = ", now.getFullYear()); // 2018 年份。
console.log("now.getMonth() = ", now.getMonth()); // 0~11, 5 表示 6 月。
console.log("now.getDate() = ", now.getDate()); // 16 表示 16 号。
console.log("now.getDay() = ", now.getDay()); // 1 表示星期一,3 表示星期三。
console.log("now.getHours() = ", now.getHours()); // 17
console.log("now.getMinutes() = ", now.getMinutes()); // 18
console.log("now.getSeconds() = ", now.getSeconds()); // 52
console.log("now.getMilliseconds() = ", now.getMilliseconds()); // 740
console.log("now.getTime() = ", now.getTime()); // 1531732732740
console.log("-----------------------------------------------");
var d = Date.parse('2018-07-16T09:25:00.320Z');
console.log("d = ", d);
console.log("-----------------------------------------------");
var d = new Date(1435146562875)
console.log("d.toLocaleString() = ", d.toLocaleString()); // 2015-6-24 19:49:22
console.log("d.toUTCString() = ", d.toUTCString()); // Wed, 24 Jun 2015 11:49:22 GMT
console.log("-----------------------------------------------");
var d = new Date(2015, 5, 19, 20, 15, 30, 123);
console.log("d = ", d);
npm install
gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/test/s5_repo/node_modules/msgpack/.node-gyp/8.11.1"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/root/test/s5_repo/node_modules/msgpack/.node-gyp"
npm install cnpm -g --registry=https://registry.npm.taobao.org
rm -rf node_modules/msgpack/
cnpm install
在同一个目录下建立 hello.js 和 main.js
'use strict';
var s = 'Hello';
function greet(name) {
console.log(s + ', ' + name + '!');
}
module.exports = greet;
'use strict';
var greet = require('./hello');
var s = 'Michael';
greet(s);
https://www.liaoxuefeng.com/wiki/001434446689867b27157e896e74d51a89c25cc8b43bdb3000/001434502419592fd80bbb0613a42118ccab9435af408fd000
ctrl + shift + I //打开调试器
shift + F4 //打开代码草稿本