I’d like to know if this is possible.
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]
I don’t need number(7) to return 7, but it would be nice.
Give it a “toString”:
You can also give it a “valueOf” function:
That will let you do: