The primitive value associated with the object, if any. Otherwise, returns the object itself.
For objects of type Number, however, valueOf() returns the primitive numeric value represented by the object. Similarly, it returns the primitive Boolean value associated with a Boolean object, the string associated with a String object, and the function associated with a Function object.
Complex.prototype.valueOf = new Function("return this.real");
With this valueOf() method defined for your Complex object type, you could then do things like pass one of your complex number objects to Math.sqrt(), which would compute the square root of the real portion of the complex number.