Why does typeof let
return 'undefined'
and is not throwing an SyntaxError instead?
console.log(typeof let);
The unary typeof operator expects an expression. Am I missing something about the let
statement?
Why does typeof let
return 'undefined'
and is not throwing an SyntaxError instead?
console.log(typeof let);
The unary typeof operator expects an expression. Am I missing something about the let
statement?
The typeof
operator is treating let
as a undeclared variable.
See more in MDN docs.
Look at this with an undeclared variable.
console.log(typeof elefromstack)
In strict mode, an error is thrown.
'use strict'
console.log(typeof let);