Answer would be Option 3 because of multiple of factors.

  1. We are using var here to declare the variable.
  2. The variable name already exists in the global scope.
  3. If we think in terms of hoisting then you might think answer would be Option 1 because inside the print function, name variable would be hoisted to the top and value would be undefined. However, one thing to remember about hoisting is that it is true that variable declarations are hoisted to the top but if the variable is already initialised with a value then the value is retained.
  4. We are capturing the variable in function arguments.

More about hoisting:

More about var:

For more tutorials and courses, visit: