## An HTML element with ID behaves like a global constant in IE

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<title>Experiments on ID attributes</title>
<script type="text/javascript">
function foo()
{
try {
a = 10
} catch (e) {
alert(e.name + ': ' +  e.message)
}
}
</script>
<p id="a">
hello, world
</p>
</body>
</html>

This code works fine in Firefox 3.6 and Chrome 5.0.

However, the statement a = 10 causes an error in Internet Explorer 6.0.

To confirm my guess that a indeed behaves like a global constant object, I replaced function foo() with this.
function foo()
{
try {
} catch (e) {
alert(e.name + ': ' +  e.message)
}
}

Indeed, in IE, the alert dialog box displays what I expected.

However, on Firefox it is an error:

One way I could fix the code is by defining function foo in this manner
function foo()
{
try {
var a = 10

Note the var in the declaration.
Realized while writing this note that e.description is not a standard way of getting the error description from the Error object. The description property is defined for Error objects in IE only. The message property is standard and works on IE as well as other browsers.