In a code review, you spot the line const arr = [10, 20, 30]; followed by arr = [40, 50, 60];. What will be the outcome when this code is executed?

  • It will result in an error.
  • The arr variable will now reference [40, 50, 60].
  • The original array [10, 20, 30] will be modified.
  • It will create a new variable arr with [40, 50, 60].
The code will result in an error. When you declare a variable using const, it cannot be reassigned to a different value or reference. Attempting to reassign arr to [40, 50, 60] will throw a "TypeError" because it violates the immutability of const variables.
Add your answer
Loading...

Leave a comment

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