

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 支援的執行時間功能
<a name="supported-features"></a>

以下各節說明 APPSYNC\$1JS 執行時間的支援功能集。

## 核心功能
<a name="core-features"></a>

支援下列核心功能。

------
#### [ Types ]

以下是支援的類型：
+ 數字
+ 字串
+ 布林值
+ objects
+ 陣列
+ 函數

------
#### [ Operators ]

支援運算子，包括：
+ 標準數學運算子 (`+`、`-`、`/``%`、、 `*`等）
+ nullish coalescing 運算子 (`??`)
+ 選用鏈結 (`?.`)
+ 位元運算子
+ `void` 和 `typeof` 運算子
+ 分散運算子 (`...`)

不支援下列運算子：
+ 統一運算子 `++`(`--`、 和 `~`)
+ `in`運算子
**注意**  
使用 `Object.hasOwn` 運算子來檢查指定的屬性是否位於指定的物件中。

------
#### [ Statements ]

支援下列陳述式：
+ `const`
+ `let`
+ `var`
+ `break`
+ `else`
+ `for-in`
+ `for-of` 
+ `if`
+ `return`
+ `switch`
+ 分散語法

不支援下列項目：
+ `catch`
+ `continue`
+ `do-while`
+ `finally`
+ `for(initialization; condition; afterthought)`
**注意**  
支援的例外是 `for-in`和 `for-of`表達式。
+ `throw`
+ `try`
+ `while`
+ 標籤陳述式

------
#### [ Literals ]

支援下列 ES 6 [範本常值](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals)：
+ 多行字串
+ 表達式插補
+ 巢狀化範本

------
#### [ Functions ]

支援下列函數語法：
+ 支援函數宣告。
+ 支援 ES 6 箭頭函數。
+ 支援 ES 6 靜態參數語法。

------
#### [ Strict mode ]

函數按預設會在嚴格模式下運作，因此您不需要在函數程式碼中新增 `use_strict` 陳述式。無法對此進行變更。

------

## 基本物件
<a name="primitive-objects"></a>

支援以下基本的 ES 物件及其函數。

------
#### [ Object ]

支援下列物件：
+ `Object.assign()`
+ `Object.entries()` 
+ `Object.hasOwn()`
+ `Object.keys()` 
+ `Object.values()`
+ `delete` 

------
#### [ String ]

支援下列字串：
+  `String.prototype.length()` 
+  `String.prototype.charAt()` 
+  `String.prototype.concat()` 
+  `String.prototype.endsWith()` 
+  `String.prototype.indexOf()` 
+  `String.prototype.lastIndexOf()` 
+  `String.raw()` 
+  `String.prototype.replace()`
**注意**  
不支援規則運算式。  
不過，提供的參數中支援 Java 樣式的規則表達式建構。如需詳細資訊，請參閱[模式](https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html)。
+ `String.prototype.replaceAll()`
**注意**  
不支援規則運算式。  
不過，提供的參數中支援 Java 樣式的規則表達式建構。如需詳細資訊，請參閱[模式](https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html)。
+  `String.prototype.slice()` 
+  `String.prototype.split()` 
+  `String.prototype.startsWith()` 
+  `String.prototype.toLowerCase()` 
+  `String.prototype.toUpperCase()` 
+  `String.prototype.trim()` 
+  `String.prototype.trimEnd()` 
+  `String.prototype.trimStart()` 

------
#### [ Number ]

支援下列號碼：
+  `Number.isFinite` 
+  `Number.isNaN` 

------

## 內建物件和函數
<a name="built-in-objects-functions"></a>

支援下列函數和物件。

------
#### [ Math ]

支援下列數學函數：
+  `Math.random()` 
+  `Math.min()` 
+  `Math.max()` 
+  `Math.round()` 
+  `Math.floor()` 
+  `Math.ceil()` 

------
#### [ Array ]

支援下列陣列方法：
+ `Array.prototype.length` 
+ `Array.prototype.concat()` 
+ `Array.prototype.fill()` 
+ `Array.prototype.flat()` 
+ `Array.prototype.indexOf()` 
+ `Array.prototype.join()` 
+ `Array.prototype.lastIndexOf()` 
+ `Array.prototype.pop()` 
+ `Array.prototype.push()` 
+ `Array.prototype.reverse()` 
+ `Array.prototype.shift()` 
+ `Array.prototype.slice()` 
+ `Array.prototype.sort()`
**注意**  
`Array.prototype.sort()` 不支援引數。
+ `Array.prototype.splice()` 
+ `Array.prototype.unshift()`
+ `Array.prototype.forEach()`
+ `Array.prototype.map()`
+ `Array.prototype.flatMap()`
+ `Array.prototype.filter()`
+ `Array.prototype.reduce()`
+ `Array.prototype.reduceRight()`
+ `Array.prototype.find()`
+ `Array.prototype.some()`
+ `Array.prototype.every()`
+ `Array.prototype.findIndex()`
+ `Array.prototype.findLast()`
+ `Array.prototype.findLastIndex()`
+ `delete` 

------
#### [ Console ]

主控台物件可用於偵錯。在即時查詢執行期間，主控台日誌/錯誤陳述式會傳送至 Amazon CloudWatch Logs （如果啟用記錄功能）。使用 進行程式碼評估期間`evaluateCode`，日誌陳述式會在命令回應中傳回。
+ `console.error()`
+ `console.log()`

------
#### [ Function ]
+ 不支援 `bind`、 `apply`和 `call`方法。
+ 不支援函數建構子。
+ 不支援將函數做為引數傳遞。
+ 不支援遞迴函數呼叫。

------
#### [ JSON ]

支援下列 JSON 方法：
+ `JSON.parse()`
**注意**  
如果剖析的字串不是有效的 JSON，則傳回空白字串。
+ `JSON.stringify()`

------
#### [ Promises ]

不支援非同步程序，也不支援 promise。

**注意**  
在 in. `APPSYNC_JS`執行時間內不支援網路和檔案系統存取 AWS AppSync。 會根據 AWS AppSync 解析程式或 AWS AppSync 函數提出的請求 AWS AppSync 來處理所有 I/O 操作。

------

## 全域變數
<a name="globals"></a>

支援以下全局常數：
+  `NaN` 
+  `Infinity` 
+  `undefined`
+ [https://docs.aws.amazon.com/appsync/latest/devguide/built-in-util-js.html](https://docs.aws.amazon.com/appsync/latest/devguide/built-in-util-js.html)
+ [https://docs.aws.amazon.com/appsync/latest/devguide/extensions-js.html](https://docs.aws.amazon.com/appsync/latest/devguide/extensions-js.html)
+ `runtime`

## 錯誤類型
<a name="error-types"></a>

`throw` 不支援使用 擲回錯誤。您可以使用 `util.error()`函數傳回錯誤。您可以使用 `util.appendError`函數在 GraphQL 回應中包含錯誤。

如需詳細資訊，請參閱[錯誤 utils](https://docs.aws.amazon.com/appsync/latest/devguide/built-in-util-js.html#utility-helpers-in-error-js)。