function foo(){
x = 0
x = x + 10;
console.log(x)
}
foo();
console.log(x)
$var = "Global";
sub inner {
print "inner: $var\n";
}
sub changelocal {
my $var = "Local";
print "changelocal: $var\n";
inner()
}
sub changedynamic {
local $var = "Dynamic";
print "changedynamic: $var\n";
inner()
}
inner();
changelocal();
changedynamic();
x = "Outside"
def myfunc():
t= (x := 300)
print(x)
myfunc()
print(x)
function foo(n){
for(i=0; i<n; ++i){
foo(n-1)
}
console.log(n)
}
foo(5);
console.log("i=="+i);
x = "Outside"
def myfunc():
x = 300
lst = [5, 10, 15, 20]
t = [[ (x:=item + 1) for item in lst]]
print(t)
print(x)
myfunc()
print(x)
function foo(obj){
var x = '???';
with(obj){
console.log(x)
}
}
foo({x:'test', txt:'hello'});
x = "Outside"
def myfunc():
try:
t = 5 / 0
except ZeroDivisionError as err:
print(err)
x = 25
print(err)
myfunc()
print(x)
function foo(obj){
var x = '???';
remove(obj);
with(obj){
console.log(x)
}
}
function remove(obj){
delete obj.x;
}
foo({x:'test', txt:'hello'});
"use strict";
function foo(obj){
var funs = [];
for(var i=0; i<10; ++i){
funs.push(
()=>{console.log("Val="+i)}
);
}
funs[3]();
}
foo();