<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JavaScript variable override</title>
</head>
<body>
<pre> <!-- Use pre element for work document.writeln() method -->
<script type="text/javascript">
var a = "A";
if (a){
document.writeln("variable a: " + a);
}
var a ="AA";
document.writeln("reinitializing a: " + a);
</script>
</pre>
</body>
</html>