2 ms·
The default behaviour is not to shadow variables. If you want to shadow a variable, you have to do so explicitly with the 'let' keyword. Here is a NodeScript s
by pretodor 10y ago
The default behaviour is not to shadow variables. If you want to shadow a variable, you have to do so explicitly with the 'let' keyword.
Here is a NodeScript snippet and its equivalent in Python:
// NodeScript
x = 10
function outer() {
y = 20
function inner() {
x = 100
y = 200
}
inner()
console.log(x, y)
}
outer()
# Python
x = 10
def outer():
y = 20
def inner():
global x
nonlocal y
x = 100
y = 200
inner()
print(x, y)
outer()