翻譯不完整。請協助 翻譯此英文文件。
This part of the JavaScript section on MDN serves as a repository of facts about the JavaScript language. Read more about this reference.
全域物件
本章節記錄了所有 JavaScript 標準內建物件 以及其方法與屬性。
數值屬性
These global properties return a simple value; they have no properties or methods.
函數屬性
These global functions—functions which are called globally rather than on an object—directly return their results to the caller.
eval()
uneval()
isFinite()
isNaN()
parseFloat()
parseInt()
decodeURI()
decodeURIComponent()
encodeURI()
encodeURIComponent()
escape()
unescape()
基礎物件
These are the fundamental, basic objects upon which all other objects are based. This includes objects that represent general objects, functions, and errors.
Object
Function
Boolean
Symbol
Error
EvalError
InternalError
RangeError
ReferenceError
SyntaxError
TypeError
URIError
數字與日期
These are the base objects representing numbers, dates, and mathematical calculations.
文字處理
These objects represent strings and support manipulating them.
具索引的集合
These objects represent collections of data which are ordered by an index value. This includes (typed) arrays and array-like constructs.
Array
Int8Array
Uint8Array
Uint8ClampedArray
Int16Array
Uint16Array
Int32Array
Uint32Array
Float32Array
Float64Array
具鍵值的集合
These objects represent collections which use keys; these contain elements which are iterable in the order of insertion.
向量集合
SIMD vector data types are objects where data is arranged into lanes.
SIMD
SIMD.Float32x4
SIMD.Float64x2
SIMD.Int8x16
SIMD.Int16x8
SIMD.Int32x4
SIMD.Uint8x16
SIMD.Uint16x8
SIMD.Uint32x4
SIMD.Bool8x16
SIMD.Bool16x8
SIMD.Bool32x4
SIMD.Bool64x2
結構化資料
These objects represent and interact with structured data buffers and data coded using JavaScript Object Notation (JSON).
控制抽象化物件
Reflection
國際化
Additions to the ECMAScript core for language-sensitive functionalities.
非標準物件
其他
敘述句
本章節記錄了所有 JavaScript 敘述句與宣告。
For an alphabetical listing see the sidebar on the left.
流程控制
Block
- A block statement is used to group zero or more statements. The block is delimited by a pair of curly brackets.
break
- Terminates the current loop, switch, or label statement and transfers program control to the statement following the terminated statement.
continue
- Terminates execution of the statements in the current iteration of the current or labeled loop, and continues execution of the loop with the next iteration.
Empty
- An empty statement is used to provide no statement, although the JavaScript syntax would expect one.
if...else
- Executes a statement if a specified condition is true. If the condition is false, another statement can be executed.
switch
- Evaluates an expression, matching the expression's value to a case clause, and executes statements associated with that case.
throw
- Throws a user-defined exception.
try...catch
- Marks a block of statements to try, and specifies a response, should an exception be thrown.
宣告
var
- Declares a variable, optionally initializing it to a value.
let
- Declares a block scope local variable, optionally initializing it to a value.
const
- Declares a read-only named constant.
函數與類別 (Class)
function
- Declares a function with the specified parameters.
function*
- Generators functions enable writing iterators more easily.
-
async function
- Declares an async function with the specified parameters.
return
- Specifies the value to be returned by a function.
class
- Declares a class.
迴圈 (Iteration)
do...while
- Creates a loop that executes a specified statement until the test condition evaluates to false. The condition is evaluated after executing the statement, resulting in the specified statement executing at least once.
for
- Creates a loop that consists of three optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.
-
for each...in
- Iterates a specified variable over all values of object's properties. For each distinct property, a specified statement is executed.
for...in
- Iterates over the enumerable properties of an object, in arbitrary order. For each distinct property, statements can be executed.
for...of
- Iterates over iterable objects (including arrays, array-like objects, iterators and generators), invoking a custom iteration hook with statements to be executed for the value of each distinct property.
while
- Creates a loop that executes a specified statement as long as the test condition evaluates to true. The condition is evaluated before executing the statement.
其他
debugger
- Invokes any available debugging functionality. If no debugging functionality is available, this statement has no effect.
export
- Used to export functions to make them available for imports in external modules, another scripts.
import
- Used to import functions exported from an external module, another script.
label
- Provides a statement with an identifier that you can refer to using a
break
orcontinue
statement.
-
with
- Extends the scope chain for a statement.
表示法與運算子
本章節記錄了所有 JavaScript 表示法與運算子。
以字母排列的清單請參考左側的側邊欄。
主要表示法
在 JavaScript 中基本的關鍵字與一般的表示法。
this
this
關鍵字可以參考執行函數的所在位置。function
function
關鍵字可以定義一個函數表示法。class
class
關鍵字可以定義一個類別表示法。function*
function*
關鍵字可以定義一個 Generator 函數表示法yield
- 暫停與繼續一個產生器 (Generator) 函數。
yield*
- 轉交另一個產生器 (Generator) 函數或可迭代 (Iterable) 的物件。
-
async function*
async
函數可以定義一個非同步函數表示法。-
await
- 暫停與繼續一個非同步函數並等候承諾的結果/拒絕。
[]
- 陣列初始化/書寫格式。
{}
- 物件初始化/書寫格式。
/ab+c/i
- 正規表示法書寫格式。
( )
- 分組運算子。
左手邊表示法
左側值為賦值的目標。
- Property accessors
- 成員運算子可存取物件的屬性或方法
(object.property
andobject["property"]
)。 new
new
運算子可以建立一個建構子 (Constructor) 的實例。- new.target
- 在建構子中
new.target
可以參考被new
呼叫的建構子 (Constructor) 。 super
super
關鍵字可以呼叫父建構子 (Constructor) 。...obj
- The spread operator allows an expression to be expanded in places where multiple arguments (for function calls) or multiple elements (for array literals) are expected.
遞增與遞減
字尾/字首遞增與字尾/字首遞減運算子。
一元運算子
一元運算是指只需要使用一個運算元的運算。
delete
delete
運算子可刪除物件中的屬性。void
void
運算子可放棄一個表示法的回傳值。typeof
typeof
運算子可以判斷一個指定物件的型態。+
- 一元正運算子可以轉換其運算元成為數值 (Number) 型態。
-
- 一元負運算子可以轉換其運算元成為數值 (Number) 型態並轉為負值。
~
- 元位 NOT 運算子。
!
- 邏輯 NOT 運算子。
算術運算子
算術運算子會要用到數值 (不論是字面值或者變數) 做為運算元,並且會回傳單一數值結果。
**
- 指數運算子。
關係運算子
比較運算子會比較其運算元並根據比較的結果是否成立回傳一個 Boolean
值的結果。
in
in
運算子會判斷一個物件是否有指定的屬性。instanceof
instanceof
運算子會判斷一個物件是否為另一個物件的實例。<
- 小於運算子。
>
- 大於運算子。
<=
- 小於等於運算子。
>=
- 大於等於運算子。
Note: => is not an operator, but the notation for Arrow functions.
相等運算子
執行相對運算子後的結果為比較結果是否成立的 Boolean
值。
位元移位運算子
用來位移運算元所有位元的運算。
二元位元運算子
位元運算子將其運算元當做是 32 位元 (32 個零與一) 的數值處理並回傳標準 JavaScript 數值。
二元邏輯運算子
邏輯運算子一般用在處理布林 (邏輯) 值,它們存在的地方會回傳一個布林 (Boolean) 值。
條件 (三元) 運算子
(condition ? ifTrue : ifFalse)
-
條件運算子會根據條件的邏輯值判斷並回傳其中一個值。
賦值運算子
賦值運算子會根據其右側運算元的數值處理後賦值給其左側的運算元。
=
- 賦值運算子。
*=
- 乘法賦值。
/=
- 除法賦值。
%=
- 餘數賦值。
+=
- 加法賦值。
-=
- 減法賦值。
<<=
- 左移賦值。
>>=
- 右移賦值。
>>>=
- 無號右移賦值。
&=
- 位元 AND 賦值。
^=
- 位元 XOR 賦值。
|=
- 位元 OR 賦值。
[a, b] = [1, 2]
{a, b} = {a:1, b:2}
-
解構賦值讓您可使用如陣列或物件書寫格式來賦值給陣列或物件的屬性。
逗號運算子
,
- 逗號運算子允許在一個敘述句中執行多個表示法並回傳最後一個表示法的結果。
非標準功能
- Legacy generator function
- The
function
keyword can be used to define a legacy generator function inside an expression. To make the function a legacy generator, the function body should contains at least oneyield
expression. - Expression closures
- The expression closure syntax is a shorthand for writing simple function.
-
[for (x of y) x]
- Array comprehensions.
-
(for (x of y) y)
- Generator comprehensions.
函數
本章節說明如何使用 JavaScript 函數 來開發您的應用程式。