在Array.prototype上添加函数时,例如Array.prototype.distinct = function () {console.log(this)const map = {}const result = []for (const n of this) { if (!(n in map)) { map[n] = 1 result.push(n) }}return result }[1,2,3,3,4,4].distinc..
网上看到如下两段代码:function createIncrement(i) {let value = 0;function increment() {value += i;console.log(value);const message = `Current value is ${value}`;return function logValue() {console.log(message);};}return increment;}..
在Array.prototype上添加函数时,例如Array.prototype.distinct = function () {console.log(this)const map = {}const result = []for (const n of this) { if (!(n in map)) { map[n] = 1 result.push(n) }}return result }[1,2,3,3,4,4].distinc..