I'm trying to learn something about JScript engine.
I have the following example:
<script>(function() {
poop = "brown";
myFunction = function myFunction() {}
}) ();
alert( poop ); // "brown" in IE
alert( "myFunction" in window ); // false in IE.
alert( typeof myFunction ); // false in IE.
function asdf() {
alert( 'ddd' + myFunction); // doesn't run in IE.
}
</script>
<body onload='asdf()'>fdf</body>
<script>asdf(); // doesn't run in IE. </script>
but if I define:
window.myFunction = function myFunction() {}
I get: true for in operator, and "function" for typeof op.
poop variable gets resolved but myFunction doesn't unless you tack it
explicitly onto window.
What is IE doing here with the scope of function references? Where is
myFunction?
Garrett
--
Programming is a collaborative art.