The effect of JavaScript or python code is well defined - they have an excellent model of what it will do.
The performance - how that is executed on the machine is what you were referring to. “As if” is the key to optimization