JS中的对象都包含valueOf方法,我们可以通过自定义valueOf函数替换掉原始object的valueOf
function foo() { this.valueOf = function() { return 'this is my value'; } } var bar = new foo(); Print( bar ); // prints: this is my value Print( bar == 'this is my value' ) // prints: true // http://www.75271.com Print( bar === 'this is my value' ) // prints: false