Prev Demo
Accessing Var Variable In Function
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> <script> function foo() { var name = 'sheo'; return function getName() { var myName = name + ' narayan'; return myName; } } var getName = foo(); alert(getName()); </script> </head> <body> <p>Accessing a variable declared with 'var' keyword in function.</p> </body> </html>
Note: We DO NOT save your trial code in our database.
Output