There's a surprising amount going on here, so I'll try to break it down into steps.
- 0is a primitive number. Primitives have no properties, and any attempt to retrieve a property (such as- (0).constructor) will cause Javascript to automatically convert it to an Object representation. E.g.- (0)becomes- Number(0).
- (0)is still a primitive, just with the addition of the grouping operators- (). This is done here because, without the parentheses, the- .in- 0.is interpreted as a decimal point rather than a property accessor. You could achieve the same thing with- 0..constructoror a number of other ways.
- All Javascript objects have a prototype. You can see an object's prototype using its__proto__property, e.g.(0).__proto__. Theprototypeis interesting because, when you try to access a property on the object, Javascript will also check the__proto__object to see if that property exists on it. (This is used mainly for inheritance).
- One of the properties on __proto__isconstructor. Theconstructoris a function that is called when the object is first created.
- constructoris of type- Function, which is itself an object with its own- constructorproperty.
So, (0).constructor.constructor is shorthand for Number(0).__proto__.constructor.__proto__.constructor. 
Your anonymous functions that return 9 do what they do because the constructor of a Function accepts as an argument a string representation of some Javascript code. It's equivalent to doing this:
Function('return 9')();
Edit: corrected a mistake regarding autoboxing and (0)