The problem is that I dynamically change 'div' content that contains script tags, so when I want to re-add and execute the same script that was removed previously, I get
Uncaught SyntaxError: Identifier 'var-name' has already been declared
error, because of variables that already declared in the re-executed script.
so these variables, for example, give me the same error when remove, re-add and then re-execute the same script tag:
let var1 = "111";
let var2= "222";
I have tried to declare with var
and remove them using delete
operator, but it didn't work, and I want to use let
to declare variables.
Edit: I got multiple scripts and each one calls functions and sometimes initiates variables from another scripts.