typeof, valueOf, toString and +++

by podlipensky

JavaScript

var a = { toString: function(){ return 'abc'; }, valueOf: function(){ return 'b'; } };
var b = { toString: function(){ return 'a'; } };
document.write(a > b);

/* Type Error
var s = new String({
    valueOf: function(){
        return this;
    },
    toString: function(){
        return this;
    }
});
*/

document.write('<br/>');
var c = 5;
document.write(c+++c);

document.write('<br/>');
var d = 5;
var e = 5;
document.write(d+++e);


document.write('<br/>');
document.write(typeof(new Date() + new Date()));

document.write('<br/>');
document.writeln(typeof (null));
document.write('<br/>');
document.write(typeof(void null));

document.write('<br/>');
var bar = function foo(){};
document.write(typeof(foo));