JavaScript TypeError – Invalid assignment to const “X”
This JavaScript exception invalid assignment to const occurs if a user tries to change a constant value. Const declarations in JavaScript can not be re-assigned or re-declared.
Message:
TypeError: invalid assignment to const "x" (Firefox) TypeError: Assignment to constant variable. (Chrome) TypeError: Assignment to const (Edge) TypeError: Redeclaration of const 'x' (IE)
Error Type:
TypeError
Cause of Error: A const value in JavaScript is changed by the program which can not be altered during normal execution.
<script> const GFG = "This is GFG"; // Error here GFG = "This is GeeksForGeeks"; </script> Output(in console):
TypeError: Assignment to const

Comments
Post a Comment