Can anybody explain to me why A is true and B is false? I would have expected B to be true as well.
A
B
function MyObject() { }; MyOb
this is set based on how you call the function. Your anonymous function is a normal function call, so this is the global object.
this
You could write (function() { ... }).call(this) to explicitly call it with your this.
(function() { ... }).call(this)