Let's say i want an object that when multiplied with, it multiplies by two and subtracts 1. The syntax would look like this:
var a = {
on_multiply: function(context){
return context*2-1
}
};
alert(2*a);
This would output 3. I don't want to write "a.on_multiply(2)" Is there a way to do this? If yes, is it possible to do this with arrays or matrixes also?