Var Vs. Let Vs. Const [JS]

Hi There,

I knew that we should use Let in case the variable we need to create will be reassigned another values but what is different from use var as below will resulted to same output & result:

let price;
console.log(price);    // Output: undefined

var result;
console.log(result)    // Output: undefined

I think the main difference is the scope that each keyword refers to.In your example it may seem the same because both variables are declared in global scope. But inside a function a variable declared with var keyword would be function scoped ( meaning that it would exist for the whole function body), but a variable declared with the let keyword would be bracket scoped (meaning that it would give a reference error when used outside the {} it was declared.
Also, variables declared with var can be hoisted, while let variables are not initialized until their definition is evaluated. Accessing them before the initialization results in a ReferenceError .
That’s my understanding on the topic. Hope it helps