Possible Duplicate:
Overloading Arithmetic Operators in JavaScript?
Is it possible to add Javascript Objects in a custom way? Javascript allows you to use the +
symbol to merge Strings
together as well as add Numbers
together.
I am wondering if you could define new ways for things to be merged such as adding arrays. What I'm looking for is something like this:
var output = [0,1,2] + [3,4,5];
console.log(output);
//I want this to log [3,5,7]
I know I could easily do this with some addArray()
function but I was wondering if it can be done by using the +
symbol.