How to declare a constant array in JavaScript?

  • const arr = [];
  • const arr = new Array();
  • const arr = {}
  • const arr = [1, 2, 3];
To declare a constant array in JavaScript, you can use the const keyword followed by square brackets, like const arr = [];. The const keyword ensures that the variable arr cannot be reassigned, making it a constant array.
Add your answer
Loading...

Leave a comment

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