Different behavior of javascript variables
===

I 've inspected different behavior for undefined/undeclared variables in javascript .For example :

    var obj = {};
    console.log(x);//Error
    console.debug(obj.x) ;//undefined

My question is though c and obj.x both are not declared or defined then why I'm getting diff behavior?
Am I missing something?
How should I track which variable is already exist or not? 