Can I do this?
JavaScript
x
2
1
var1 = some_function(var1)
2
When I tried to do this I got errors, but perhaps I was doing something wrong.
Advertisement
Answer
If the variable has been previously defined, you can do that yes.
Example:
JavaScript
1
7
1
def f(x):
2
return x+1
3
4
var1 = 5
5
var1 = f(var1)
6
# var1 is now 6
7
If the variable has not been defined previously, you can’t do that, simply because there is no value that could be passed to the function.