I could not find an explanation of why this does not cause an error.
In the first example, you are trying to read the value of a full undefined identifier. In the second example, you are trying to read a property of an object that the object may not have.
undefined - ReferenceError
; JavaScript , . , , undefined
.
, , : " , , .
: typeof
. undefined typeof
:
if (typeof AdMob === "undefined")
ReferenceError
, AdMob
; typeof
"undefined"
. ( "undefined'
, AdMob
undefined
.)
:
... , .
ECMAScript, §6.2.3.1 ReferenceError
§9.1.8 undefined
, . , , 6- , .: -)