I properly understand differences between let and var keywords, where and where they should be used, but in the code here i am stumped when i get this error.
Why does the following code work fine with Let keyword but gives error with var keyword..
let name = function () {
console.log('my name is Sid');
}
let age = function (str1) {
str1();
}
age(name);
this gives an error: Uncaught TypeError: str1 is not a function
var name = function () {
console.log('my name is Sid');
}
var age = function (str1) {
str1();
}
age(name);