Prev Demo
Let Variable With Function And Block Scope
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> <script> function Test(t, lastName) { if (t) { let lastName = ' narayan' return lastName; } return lastName; } alert(Test(true, '')); // shows narayan alert(Test(false, 'Narayan')); // shows Narayan </script> </head> <body> <p>'let' variable with block-scoped and function-scoped</p> </body> </html>
Note: We DO NOT save your trial code in our database.
Output