I wrote the following Typescript code:
$('document').ready(() => {
let fileSystem = new FileSystem(fileSystemInputs);
$('#debug').click( () => {
console.log(fileSystem);
debug;
});
}
I found out that once I click '#debug',the console prints the 'fileSystem' object. When I open the debugger (in Chrome developer tools), I can see 'fileSystem' object in the watch window. It's vary clear since it's valid inside the arrow function.
However, when I remove the line "console.log(fileSystem);" and the code now is only:
$('document').ready(() => {
let fileSystem = new FileSystem(fileSystemInputs);
$('#debug').click( () => {
debug;
});
}
once I open the watch window in the debugger, however, I see that 'fileSystem' is undefined. The line:
console.log(fileSystem)
is not supposed to change the scope, so how is it possible that variables disappear?