function Container(val){
this.value = val
}
Container.of=function(value){
return new Container(value)
}
Container.prototype.map =function(fn){
return Container.of(fn(this.value))
}
let double = x=>x*2
let startFn =function(val){
val++
return Container.of(val)
}
let obj = startFn(3).map(double).map(double)
console.log(obj)
网友评论