Thanks to visit codestin.com
Credit goes to developer.mozilla.org

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

SyntaxError: identifier starts immediately after numeric literal

메세지

  SyntaxError: Unexpected identifier after numeric literal (Edge)
  SyntaxError: identifier starts immediately after numeric literal (Firefox)
  SyntaxError: Unexpected number (Chrome)

에러 타입

SyntaxError

무엇이 잘못되었을까?

식별자라고 불리는 변수의 이름은 반드시 지켜야 하는 특정 규칙을 따라야 합니다.

JavaScript의 식별자는 반드시 문자, 언더스코어(_), 또는 달러 표시($)로 시작돼야 합니다. 숫자로 시작될 수 없습니다. 글자 뒤에만 숫자(0-9)가 올 수 있습니다.

예제

숫자로 시작하는 변수 이름

JavaScript에서 변수 이름은 숫자로 시작될 수 없습니다. 아래 예제는 에러가 발생합니다:

js
var 1life = 'foo';
// SyntaxError: identifier starts immediately after numeric literal

var foo = 1life;
// SyntaxError: identifier starts immediately after numeric literal

alert(1.foo);
// SyntaxError: identifier starts immediately after numeric literal

숫자가 뒤에 오도록 변수 이름을 변경해야 합니다.

js
var life1 = "foo";
var foo = life1;

같이 보기