Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is typeof let === 'undefined'?

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?

like image 232
Kristianmitk Avatar asked Apr 28 '18 00:04

Kristianmitk


1 Answers

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);
like image 159
Ele Avatar answered Sep 27 '22 18:09

Ele