You are reviewing a junior developer's code and see the following line var x = 10;. You want to advise them to use a declaration that maintains block scope, which keyword should they use instead of var?

  • let
  • const
  • block
  • scope
Instead of var, they should use let to maintain block scope. var has function scope and can lead to unexpected behavior in certain situations, while let declares a variable with block scope, ensuring that it's limited to the block in which it's defined.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *