Why is this initialized outside the onclick event handler function below?