Just trying to wrap scoping around my head :-)
How can I refactor this code in order to be able to output
'a', 'b' and 'c'
within function third()
?
Any explanation without confusion and unnecessary theory would help.
var a = 1;
first = () => {
let b = 2;
second = () => {
let c = 3;
console.log(a, b); // Output 1, 2
third(); // Output 1, 2, 3
}
console.log(a); // Output 1
second();
}
third = () => {
console.log(a, b, c);
}
first();