Skip to content

Instantly share code, notes, and snippets.

@ramsunvtech
Created August 8, 2018 19:05
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramsunvtech/80e75ee317653895a33be69883233bd2 to your computer and use it in GitHub Desktop.
Save ramsunvtech/80e75ee317653895a33be69883233bd2 to your computer and use it in GitHub Desktop.
Various Syntax Error for const variables on Typo mistakes
/*
* Below are the possible syntax errors with all stupid typo mistakes for const variables.
* Tested in Chrome, Firefox, Safari and IE Edge.
* Venkat.R
*/
// const a=
// Chrome - SyntaxError: Unexpected end of input
// Firefox - SyntaxError: expected expression, got end of script
// Safari - SyntaxError: Unexpected EOF
// IE Edge - Syntax error
// const a='
// const a='hello
// Chrome - SyntaxError: Invalid or unexpected token
// Firefox - SyntaxError: '' literal not terminated before end of script
// Safari - SyntaxError: Unexpected EOF
// IE Edge - Unterminated string constant
// const a="
// const a="hello
// Chrome - SyntaxError: Invalid or unexpected token
// Firefox - SyntaxError: "" literal not terminated before end of script
// Safari - SyntaxError: Unexpected EOF
// IE Edge - Unterminated string constant
// const a(
// const a()
// Chrome - SyntaxError: Missing initializer in const declaration
// Firefox - SyntaxError: missing = in const declaration
// Safari - SyntaxError: Unexpected token '('
// IE Edge - Const must be initialized
// const a)
// Chrome - SyntaxError: Missing initializer in const declaration
// Firefox - SyntaxError: missing = in const declaration
// Safari - SyntaxError: Unexpected token ')'
// IE Edge - Const must be initialized
// const a[
// const a[]
// Chrome - SyntaxError: Missing initializer in const declaration
// Firefox - SyntaxError: missing = in const declaration
// Safari - SyntaxError: Unexpected token '['
// IE Edge - Const must be initialized
// const a]
// Chrome - SyntaxError: Missing initializer in const declaration
// Firefox - SyntaxError: missing = in const declaration
// Safari - SyntaxError: Unexpected token ']'
// IE Edge - Const must be initialized
// const a{
// const a{}
// Chrome - SyntaxError: Missing initializer in const declaration
// Firefox - SyntaxError: missing = in const declaration
// Safari - SyntaxError: Unexpected token '{'
// IE Edge - Const must be initialized
// const a}
// Chrome - SyntaxError: Missing initializer in const declaration
// Firefox - SyntaxError: missing = in const declaration
// Safari - SyntaxError: Parse error
// IE Edge - Const must be initialized
// const a.
// Chrome - SyntaxError: Missing initializer in const declaration
// Firefox - SyntaxError: missing = in const declaration
// Safari - SyntaxError: Unexpected token '.'
// IE Edge - Const must be initialized
// const a, {}
// Chrome - SyntaxError: Missing initializer in destructuring declaration
// Firefox - SyntaxError: missing = in destructuring declaration
// Safari - SyntaxError: Expected an identifier but found '{' instead
// IE Edge - Const must be initialized
// const "ram" = a;
// Chrome - SyntaxError: Unexpected string
// Firefox - SyntaxError: missing variable name
// Safari - SyntaxError: Unexpected string "ram"
// IE Edge - Expected identifier
// const a, [] = "ram";
// Chrome - SyntaxError: Missing initializer in const declaration
// Chrome - SyntaxError: missing = in const declaration
// Safari - SyntaxError: Expected an identifier but found '[' instead
// Chrome - Const must be initialized
// const a, {} = "ram";
// Chrome - SyntaxError: Missing initializer in const declaration
// Chrome - SyntaxError: missing = in const declaration
// Safari - SyntaxError: Expected an identifier but found '{' instead
// Chrome - Const must be initialized
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment