Created
July 17, 2010 18:16
-
-
Save aarongustafson/479723 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function example() | |
{ | |
$a = $b = 0; | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | |
<title>Serial value assignment and scope</title> | |
<script type="text/javascript"> | |
(function(){ | |
var a = b = 0; | |
})(); | |
</script> | |
</head> | |
<body> | |
<h1>Serial variable assignment and scope test</h1> | |
<h2>Create a closure:</h2> | |
<pre><code class="js">(function(){ | |
var a = b = 0; | |
})();</code></pre> | |
<p>Test for variables in the global scope:</p> | |
<ul> | |
<li>Test for <var>window.i</var>: | |
<script type="text/javascript"> | |
try { | |
document.write( 'a is defined in the global namespace and has a value of ' + a ); | |
} | |
catch ( e ) | |
{ | |
document.write( 'a is undefined in the global namespace' ); | |
} | |
</script> | |
</li> | |
<li>Test for <var>window.j</var>: | |
<script type="text/javascript"> | |
try { | |
document.write( 'b is defined in the global namespace and has a value of ' + b ); | |
} | |
catch ( e ) | |
{ | |
document.write( 'b is undefined in the global namespace' ); | |
} | |
</script> | |
</li> | |
</ul> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var a = b = 0; | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var a = 0, b = 0; | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var a = 0, b = a; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment