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:

https://developer.mozilla.org/en-US/docs/Glossary/Hoisting#only_declarations_are_hoisted

More about var:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var

For more tutorials and courses, visit: https://bit.ly/devtools-yt