Uncaught TypeError: Assignment to constant variable

Error Uncaught TypeError: Assignment to constant variable occurs when you try to update the value of declared const in javascript. It cannot be updated or re-declared

Answers 1
  • Uncaught TypeError: Assignment to constant variable

    <script>
    const CODE = 7;
    </script>
    //CODE = 20;
    
    0

    Just remove the const from script which is same within the document. You can not update the value of declared const CODE. The value of a variable declared with const remains the same within its scope. It cannot be updated or re-declared. 

  • Back to code snippet queries related javascript