Q:

Please explain Date object type conversion

I just found a strange behaviour in SpiderMonkey and V8 javascript engines. Suggest finding an explanation would be a good school for everyone
The strange working code:
 var x = (new Date()).setHours(24, 0, 0, 0);
 typeof x; // "number"

The working-as-expected code:
var x = new Date(); 
x.setHours(24, 0, 0, 0);
typeof x; // "object"
x instanceof Date; // true

If we find the reason we'll understand how JavaScript works better

A:

From MDN setHours sets the date and returns the number of milliseconds since 1 January 1970 00:00:00.
So in the first example, x gets assigned the resulting timestamp which is a number.
To better illustrate, do
var y = new Date(),
    x = y.setHours(24,0,0,0)

typeof x // number

