pull down to refresh

Interesting, I thought all this time this isn't limited to Python but a general reference vs value problem. However, Javascript doesn't express this behavior:
function surprise(myList = []) { console.log(myList) myList.push(1) } surprise() // prints [] surprise() // prints []
I definitely just assumed argument default values were instantiated on each function call. Python’s behavior would be like defining an array outside the scope of the function and using its reference as the default parameter value. I guess it’s clear in JavaScript because [] constructs a new array?
reply