Prev Demo
Scope Test Of Let Variable In Javascript
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> <script> function getName(t) { let name = 'sheo'; if (t) { let fullName = name + ' narayan'; return fullName; } return fullName; // will throw error } alert(getName(true)); // shows 'sheo narayan' alert(getName(false)); // 'fullName' is undefined </script> </head> <body> <p>Scope test of 'let' variable</p> </body> </html>
Note: We DO NOT save your trial code in our database.
Output