In Documentaion said that let and const are hoisted.
Variables declared with let and const are also hoisted but, unlike var, are not initialized with a default value. An exception will be thrown if a variable declared with let or const is read before it is initialized.
Also there are a pretty clear sample there:
console.log(num); // Throws ReferenceError exception as the variable value is uninitialized
let num = 6; // Initialization
But I don't understand why this rise the ReferenceError also:
x = 9
console.log(x) // Why: "Throws ReferenceError exception as the variable value is uninitialized" here ?
let x;
Specs says 'let' supports hoising. Initialization is going before using this variable. What's wrong? If the reason of the ReferenceError is TDZ then why in specs says that 'let' supports hoising, becouse of TDZ and hoising are mutually exclusive things... And what could be an example of hoising for 'let' if I can't use this varibable before declaration...