function N(value) { this.value = value; } N.prototype.valueOf = function() { return this.value; }; var n = new N(5); alert(3 + n);