U leest de Engelstalige versie van deze inhoud, omdat er nog geen vertaling voor deze taal beschikbaar is. Help ons dit artikel te vertalen!
SyntaxError: Const must be initalized (Edge) SyntaxError: missing = in const declaration (Firefox) SyntaxError: Missing initializer in const declaration (Chrome)
What went wrong?
const keyword. An initializer for a constant is required; that is, you must specify its value in the same statement in which it's declared (which makes sense, given that it can't be changed later).
Missing const initializer
let, you must specify a value for a
const declaration. This throws:
const COLUMNS; // SyntaxError: missing = in const declaration
Fixing the error
There are multiple options to fix this error. Check what was intended to be achieved with the constant in question.
Adding a constant value
Specify the constant value in the same statement in which it's declared:
const COLUMNS = 80;