variables declared using let and const are also hoisted but only difference is that in case of let/const , variables are not initialized with undefined as in case of var/function.
x=10;console.log(x);letx=20;
above code will throw reference error as variable x in temporal dead zone . If it was not hoisted then x would have been 10.
variables declared using let and const are also hoisted but only difference is that in case of let/const , variables are not initialized with undefined as in case of var/function.
above code will throw reference error as variable x in temporal dead zone . If it was not hoisted then x would have been 10.
Yes you are correct indeed. I've fixed my error. Thank You for pointing this major blunder out!