Javascript examples for Data Type:Variable Scope
change a JavaScript global variable
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=( function() {/*w w w . j av a 2 s . c om*/ x = "1.0"; y = "2.0"; $ = x; withLib = (function(callback, $) { callback($) }) withLib(function($){ console.log($, $ == "2.0" ? "outer success" : 'outer fail') my = function() { console.log($, $=="2.0" ? "inner success" : "inner fail") } }, y); my(); }); </script> </head> <body> </body> </html>