Toggle navigation
Genres
Frontend (2)
JavaScript (6)
Database (2)
Linux Server (3)
Web Apps (4)
Misc (4)
Search
List
New Tutorials
Last Modified Tutorials
</>
Code examples
code
smiko
javascript
advanced
variables
10var_local_global_outside_function.js
10var_local_global_outside_function.js
/** * How to define local and global variable inside function. * Notice that if we don't call function with fja() then y returns error in global scope. */ var x=5; //global variable y=8; //global variable too function fja() { console.log('in function x='+x); console.log('in function y='+y); } fja(); console.log('out of function x='+x); console.log('out of function y='+y);
Reload page
Preview
W3C validation
Edit Code
JS Console