I am a beginner learning javascript
Testing "this" key word The following showWidth function displays "undefined" but when I changed "let" to "var" it displays 600 as intended. Now I am not sure if I fully understand the difference between let and var :(. Please help me understand with the eg. given below. Thank you for your time.
let width = 600; // declared global variable
let shape = {
width: 300 // property inside an object
};
let showWidth = function() {
document.write(this.width);
}
showWidth(); // undefined with let, 600 with var. I expected 600 in both cases