我想知道这是否可行.
number = function(n){
var num = n;
this.add = function(x){
return num + x;
}
return num;
}
alert(number(7)); //returns 7
seven = new number(7);
alert(seven.add(3)); // returns 10
alert(seven); // want this to return 7, but will return [object Object]
Run Code Online (Sandbox Code Playgroud)
我不需要数字(7)来返回7,但它会很好.