I'm not sure what you're trying to achieve but there are two problems. The first part is checking for a property being defined in an object. The first if is checking if the type of the property is defined or not but it could be "undefined" on purpose.
Use to check if the object has the property.
if(b.hasOwnProperty("c")) {
}
If you want to "lookup" for the property in the whole prototype chain then use in
:
if ("c" in b) {
}
Otherwise checking of b.c is "undefined" means that the value returned by "b.c" is of type "undefined". It doesn't mean that b has or doesn't have the property "c".
The second block is failing because "c" isn't defined in the global scope. You cannot access a property of an undefined object which will cause an error.
note
If you don't have prototype chains, hasOwnProperty should be faster in most cases.