1.短路写法 // 如果该项没有订阅,设置初始存储集合 if (!this.clientList[key]) { this.clientList[key] = [] } // 然后添加回调函数 this.clientList[key].push(fn) 以上代码可以简写为: (this.clientList[key] || this.clientList[key] = []).push(fn)