如何获取绑定到函数的参数?
function add(x){
return x + 1
}
var func = add.bind(null, x)
// how do I get the value of `x` from the `func` variable alone?发布于 2017-03-05 08:26:40
var claser = function(x) {
var internalX = x;
this.add = function(adderValue) {
internalX += adderValue;
}
this.getX = function() {
return internalX;
}
}
var theX = 5; // Setting X
var cls = new claser(theX);
cls.add(1); // Adding X
var gettingX = cls.getX(); // Getting X
alert(gettingX);这就是你需要的?
https://stackoverflow.com/questions/42602954
复制相似问题