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)

μ—λŸ¬ νƒ€μž…

무엇이 잘λͺ»λ˜μ—ˆμ„κΉŒ?

μ‹λ³„μžλΌκ³  λΆˆλ¦¬λŠ” λ³€μˆ˜μ˜ 이름은 λ°˜λ“œμ‹œ μ§€μΌœμ•Ό ν•˜λŠ” νŠΉμ • κ·œμΉ™μ„ 따라야 ν•©λ‹ˆλ‹€.

μžλ°”μŠ€ν¬λ¦½νŠΈμ˜ μ‹λ³„μžλŠ” λ°˜λ“œμ‹œ 문자, μ–Έλ”μŠ€μ½”μ–΄(_), λ˜λŠ” λ‹¬λŸ¬ ν‘œμ‹œ($)둜 μ‹œμž‘λΌμ•Ό ν•©λ‹ˆλ‹€. 숫자둜 μ‹œμž‘λ  수 μ—†μŠ΅λ‹ˆλ‹€. κΈ€μž λ’€μ—λ§Œ 숫자(0-9)κ°€ 올 수 μžˆμŠ΅λ‹ˆλ‹€.

예제

숫자둜 μ‹œμž‘ν•˜λŠ” λ³€μˆ˜ 이름

μžλ°”μŠ€ν¬λ¦½νŠΈμ—μ„œ λ³€μˆ˜ 이름은 숫자둜 μ‹œμž‘λ  수 μ—†μŠ΅λ‹ˆλ‹€. μ•„λž˜ μ˜ˆμ œλŠ” μ—λŸ¬κ°€ λ°œμƒν•©λ‹ˆλ‹€:

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

μˆ«μžκ°€ 뒀에 μ˜€λ„λ‘ λ³€μˆ˜ 이름을 λ³€κ²½ν•΄μ•Ό ν•©λ‹ˆλ‹€.

var life1 = 'foo';
var foo = life1;

같이 보기