This article describes the method of JavaScript to change the original object valueOf. Share it for your reference. The specific analysis is as follows:
All objects in JS contain valueOf methods. We can replace the valueOf of the original object through the custom valueOf function.
function foo() { this.valueOf = function() { return 'this is my value'; }}var bar = new foo();Print( bar ); // prints: this is my valuePrint( bar == 'this is my value' ) // prints: truePrint( bar === 'this is my value' ) // prints: falseI hope this article will be helpful to everyone's JavaScript programming.