mirror of
https://github.com/espruino/Espruino.git
synced 2025-12-08 19:06:15 +00:00
17 lines
473 B
JavaScript
17 lines
473 B
JavaScript
// Variable creation and scope from http://en.wikipedia.org/wiki/JavaScript_syntax
|
|
x = 0; // A global variable
|
|
var y = 'Hello!'; // Another global variable
|
|
z = 0; // yet another global variable
|
|
|
|
function f(){
|
|
var z = 'foxes'; // A local variable
|
|
twenty = 20; // Global because keyword var is not used
|
|
return x; // We can use x here because it is global
|
|
}
|
|
// The value of z is no longer available
|
|
|
|
|
|
// testing
|
|
blah = f();
|
|
result = blah==0 && z!='foxes' && twenty==20;
|