Change the primitive value of an object with valueOf

by Mohan 2012-09-20 22:49:34



Change the primitive value of an object with 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

Print( bar === 'this is my value' ) // prints: false




417
like
0
dislike
0
mail
flag

You must LOGIN to add comments