-3

let a = 'Fred Flinstone'; // This is a global variable
function alpha() {
alert(a);
}
alert(alpha());

why the following code displaying undefined after displaying fred flinston? and what properties does "const" in ES6 have and what is meant by " referencing to memory " in const? Thanks

1 Answers1

0

Actually, after you use alert(alpha()),this code will do 2 steps: 1.get the return value from alpha() 2.execute the alert function

Because there is no return code from the function alpha , so it return 'undefined' and which will be print in the alert box

gscHeartA
  • 44
  • 4