I have this code which is for a LeetCode problem.
class Solution:
    def isRobotBounded(instructions: str) -> bool:
        dirX, dirY = 0, 1
        x, y = 0, 0
        for d in instructions:
            if d == "G":
                x, y = x + dirX, y + dirY
            elif d == "L":
                dirX, dirY = -1*dirY, dirX
            else:
                dirX, dirY = dirY, -1*dirX
        return (x, y) == (0, 0) or (dirX, dirY) != (0, 1)
    print(isRobotBounded('GGLLGG'))
Now, in d == "L", why is dirX used as 0 to calculate the value of dirY? In JavaScript, dirX would be calculated (-1*dirY) and then used to calculate dirY.
What am I missing here regarding Python? It looks like Python is using the initial values of the variables. What is this behavior called? And how to replicate it in JavaScript?
Thank you.
