I wrote a function with a closure within it and i also wrote another function.
function argum(){
let ist = arguments[0];
return function(){
return ist + ' ' + arguments[0]
}
}
function logAll(){
console.log(arguments.length);
}
var sh = argum('hello')
sh('world')
logAll(2,4,5,6,7)
As shown above, but i can't understand why the first call on the closure generates undefined. Meanwhile if i rewrite the code like this
function argum(){
let ist = arguments[0];
return function(){
return ist + ' ' + arguments[0]
}
}
function logAll(){
console.log(arguments.length);
}
logAll(2,4,5,6,7)
var sh = argum('hello')
sh('world')
it seems to work fine. Any hint on what's happening there? Also use your browser dev tools to run this code, for a better understanding of what am asking.