| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Lexical_grammar | [Back] [Original] |
Get to know MDN better
Javascript lexical grammarECMAScript tokenECMAScript
U+200C |
<ZWNJ> | ||
U+200D |
<ZWJ> | ||
U+FEFF |
<BOM> | Unicode |
| U+0009 | <HT> | \t | ||
| U+000B | <VT> | \v | ||
| U+000C | <FF> | \f | ||
| U+0020 | <SP> | |||
| U+00A0 | <NBSP> | |||
| Unicode | <USP> |
ECMAScript Unicode Next Line, NEL, U+0085
| U+000A | <LF> | UNIX | \n | |
| U+000D | <CR> | Commodore Mac | \r | |
| U+2028 | <LS> | |||
| U+2029 | <PS> |
Javascript
Javascript
//;
function comment() {
// Javascript
console.log("Hello world!");
}
comment();
/* */
function comment() {
/* Javascript */
console.log("Hello world!");
}
comment();
function comment() {
/*
*/
console.log("Hello world!");
}
comment();
function comment(x) {
console.log("Hello " + x /* x */ + " !");
}
comment("world");
function comment() {
/* console.log('Hello world!'); */
}
comment();
console.log()
breakcasecatchclassconstcontinuedebuggerdefaultdeletedoelseexportextendsfinallyforfunctionifimportininstanceofnewreturnsuperswitchthisthrowtrytypeofvarvoidwhilewithyieldECMAScript
enumimplementsinterfaceletpackageprivateprotectedpublicstaticawaitECMAScript (ECMAScript 1 3)
abstractbooleanbytechardoublefinalfloatgotointlongnativeshortsynchronizedthrowstransientvolatile null, true false (literal) ECMAScript
( IdentifierNames) es5.github.com/#A.1 IdentifierNames
a.import
a['import']
a = { import: 'test' }.
IdentifierName FunctionDeclaration, FunctionExpression, VariableDeclaration ? IdentifierName MemberExpression, CallExpression
function import() {} // .
null
true
false
1234567890
42
//
0888 // 888
0777 // , 511
(0) 8 Firefox bug 957513 parseInt()
B0b 0B ECMAScript 2015 0b 0 10b SyntaxError
0b10000000000000000000000000000000 // 2147483648
0b01111111100000000000000000000000 // 2139095040
0B00000000011111111111111111111111 // 8388607
O0o 0O ECMAScript 2015 0o 012345670o SyntaxError
0O755 // 493
0o644 // 420
"X" (0x 0X) 0x (0123456789ABCDEF) "" SyntaxError
0xFFFFFFFFFFFFFFFFF // 295147905179352830000
0x123456789ABCDEF // 81985529216486900
0XA // 10
var o = { a: "foo", b: "bar", c: 42 };
// (ES2015 )
var a = "foo",
b = "bar",
c = 42;
var o = { a, b, c };
// ES2015
var o = { a: a, b: b, c: c };
[1954, 1974, 1990, 2014]
'foo'
"bar"
"\xA9" // ""
Unicode \u 4 UTF-16 2 0~FFFF Unicode (surrogate pair) ( wiki)
"\u00A9" // ""
ECMAScript 2015 Unicode ( 0x10FFFF) FFFF
String.fromCodePoint() String.prototype.codePointAt()
"\u{2F804}"
//
"\uD87E\uDC04"
/ab+c/g
//
//
/(?:)/
`string text`
`string text line 1
string text line 2`
`string text ${expression} string text`
tag `string text ${expression} string text`
JavaScript statements (ASI)
let, const, import, export, debuggercontinue, break, throwreturn{ 1 2 } 3
// ASI
{ 1 2 ;} 3;
2. token
a = b
++c
// ASI
a = b;
++c;
3. restricted productions ""
++ and --)continuebreakreturnyield, yield*modulereturn
a + b
// ASI
return;
a + b;
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification |
BooleanNumberRegExpStringThis page was last modified on 2026526 by MDN contributors.
Your blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |