

# CloudFront 함수에 대한 JavaScript 런타임 기능
<a name="functions-javascript-runtime-features"></a>

CloudFront Functions JavaScript 런타임 환경은 [ECMAScript(ES) 버전 5.1](https://www.ecma-international.org/ecma-262/5.1/)을 준수하며, ES 버전 6에서 12까지의 일부 기능을 지원합니다.

최신 기능을 이용하려면 JavaScript 런타임 2.0을 사용하는 것이 좋습니다.

JavaScript 1.0과 비교한 JavaScript 2.0의 변경 사항은 다음과 같습니다.
+ 버퍼 모듈 메서드 사용 가능
+ 다음과 같은 비표준 문자열 프로토타입 메서드는 사용할 수 없습니다.
  + `String.prototype.bytesFrom()`
  + `String.prototype.fromBytes()`
  + `String.prototype.fromUTF8()`
  + `String.prototype.toBytes()`
  + `String.prototype.toUTF8()`
+ 암호화 모듈의 변경 사항은 다음과 같습니다.
  + `hash.digest()` - 인코딩이 제공되지 않은 경우 반환 유형이 `Buffer`로 변경됩니다.
  + `hmac.digest()` - 인코딩이 제공되지 않은 경우 반환 유형이 `Buffer`로 변경됩니다.
+ 이 밖의 새로운 기능에 대한 자세한 내용은 [CloudFront Functions를 위한 JavaScript 런타임 2.0 기능](functions-javascript-runtime-20.md) 섹션을 참조하세요.

**Topics**
+ [JavaScript 런타임 1.0 기능](functions-javascript-runtime-10.md)
+ [JavaScript 런타임 2.0 기능](functions-javascript-runtime-20.md)

# CloudFront Functions를 위한 JavaScript 런타임 1.0 기능
<a name="functions-javascript-runtime-10"></a>

CloudFront 함수 JavaScript 런타임 환경은 [ECMAScript(ES) 버전 5.1](https://262.ecma-international.org/5.1/)을 준수하며, ES 버전 6에서 9까지의 일부 기능을 지원합니다. 또한 ES 사양의 일부가 아닌 일부 비표준 방법을 제공합니다.

다음 항목에는 지원되는 모든 언어 기능이 나열되어 있습니다.

**Topics**
+ [

## 핵심 기능
](#writing-functions-javascript-features-core)
+ [

## 기본 객체
](#writing-functions-javascript-features-primitive-objects)
+ [

## 기본 제공 객체
](#writing-functions-javascript-features-builtin-objects)
+ [

## 오류 유형
](#writing-functions-javascript-features-error-types)
+ [

## Globals
](#writing-functions-javascript-features-globals)
+ [

## 기본 제공 모듈
](#writing-functions-javascript-features-builtin-modules)
+ [

## 제한된 기능
](#writing-functions-javascript-features-restricted-features)

## 핵심 기능
<a name="writing-functions-javascript-features-core"></a>

ES의 다음과 같은 핵심 기능이 지원됩니다.

**유형**  
모든 ES 5.1 유형이 지원됩니다. 여기에는 부울 값, 숫자, 문자열, 객체, 배열, 함수, 함수 생성자 및 정규 표현식이 포함됩니다.

**연산자**  
모든 ES 5.1 연산자가 지원됩니다.  
ES 7 거듭제곱 연산자(`**`)가 지원됩니다.

**Statement**  
`const` 및 `let` 문은 지원되지 않습니다.
다음 ES 5.1 문이 지원됩니다.  
+ `break`
+ `catch`
+ `continue`
+ `do-while`
+ `else`
+ `finally`
+ `for`
+ `for-in`
+ `if`
+ `return`
+ `switch`
+ `throw`
+ `try`
+ `var`
+ `while`
+ 레이블이 지정된 명령문

**리터럴**  
ES 6 템플릿 리터럴은 여러 줄 문자열, 표현식 보간 및 중첩 템플릿에 대해 지원됩니다..

**함수**  
모든 ES 5.1 함수 기능이 지원됩니다.  
ES 6 화살표 함수가 지원되며 ES 6 나머지 파라미터 구문이 지원됩니다.

**유니코드**  
소스 텍스트 및 문자열 리터럴에는 유니코드로 인코딩된 문자가 포함될 수 있습니다. 6자의 유니코드 코드 포인트 이스케이프 시퀀스(예: `\uXXXX`)도 지원됩니다.

**엄격 모드**  
함수는 기본적으로 엄격 모드에서 작동하므로 함수 코드에 `use strict` 명령문을 추가할 필요가 없습니다. 이것은 변경할 수 없습니다.

## 기본 객체
<a name="writing-functions-javascript-features-primitive-objects"></a>

ES의 다음과 같은 기본 객체가 지원됩니다.

**객체**  
객체에 대해 다음과 같은 ES 5.1 메서드가 지원됩니다.  
+ `create`(속성 목록 제외)
+ `defineProperties`
+ `defineProperty`
+ `freeze`
+ `getOwnPropertyDescriptor`
+ `getOwnPropertyNames`
+ `getPrototypeOf`
+ `hasOwnProperty`
+ `isExtensible`
+ `isFrozen`
+ `prototype.isPrototypeOf`
+ `isSealed`
+ `keys`
+ `preventExtensions`
+ `prototype.propertyIsEnumerable`
+ `seal`
+ `prototype.toString`
+ `prototype.valueOf`
객체에 대해 다음 ES 6 메서드가 지원됩니다.  
+ `assign`
+ `is`
+ `prototype.setPrototypeOf`
객체에 대해 다음과 같은 ES 8 메서드가 지원됩니다.  
+ `entries`
+ `values`

**문자열**  
문자열에 대해 다음 ES 5.1 메서드가 지원됩니다.  
+ `fromCharCode`
+ `prototype.charAt`
+ `prototype.concat`
+ `prototype.indexOf`
+ `prototype.lastIndexOf`
+ `prototype.match`
+ `prototype.replace`
+ `prototype.search`
+ `prototype.slice`
+ `prototype.split`
+ `prototype.substr`
+ `prototype.substring`
+ `prototype.toLowerCase`
+ `prototype.trim`
+ `prototype.toUpperCase`
문자열에 대해 다음 ES 6 메서드가 지원됩니다.  
+ `fromCodePoint`
+ `prototype.codePointAt`
+ `prototype.endsWith`
+ `prototype.includes`
+ `prototype.repeat`
+ `prototype.startsWith`
문자열에 대해 다음 ES 8 메서드가 지원됩니다.  
+ `prototype.padStart`
+ `prototype.padEnd`
문자열에 대해 다음 ES 9 메서드가 지원됩니다.  
+ `prototype.trimStart`
+ `prototype.trimEnd`
문자열에 대해 다음과 같은 비표준 메서드가 지원됩니다.  
+ `prototype.bytesFrom(array | string, encoding)`

  옥텟 배열 또는 인코딩된 문자열에서 바이트 문자열을 만듭니다. 문자열 인코딩 옵션은 `hex`, `base64` 및 `base64url`입니다.
+ `prototype.fromBytes(start[, end])`

  각 바이트가 해당 유니코드 코드 포인트로 대체되는 바이트 문자열에서 유니코드 문자열을 만듭니다.
+ `prototype.fromUTF8(start[, end])`

  UTF-8 인코딩된 바이트 문자열에서 유니코드 문자열을 만듭니다. 인코딩이 올바르지 않으면 `null`이(가) 반환됩니다.
+ `prototype.toBytes(start[, end])`

  유니코드 문자열에서 바이트 문자열을 만듭니다. 모든 문자는 [0,255] 범위에 있어야 합니다. 그렇지 않은 경우 `null`이 반환됩니다.
+ `prototype.toUTF8(start[, end])`

  유니코드 문자열에서 UTF-8 인코딩된 바이트 문자열을 만듭니다.

**번호**  
숫자에 대한 모든 ES 5.1 메서드가 지원됩니다.  
숫자에 대해 다음 ES 6 메서드가 지원됩니다.  
+ `isFinite`
+ `isInteger`
+ `isNaN`
+ `isSafeInteger`
+ `parseFloat`
+ `parseInt`
+ `prototype.toExponential`
+ `prototype.toFixed`
+ `prototype.toPrecision`
+ `EPSILON`
+ `MAX_SAFE_INTEGER`
+ `MAX_VALUE`
+ `MIN_SAFE_INTEGER`
+ `MIN_VALUE`
+ `NEGATIVE_INFINITY`
+ `NaN`
+ `POSITIVE_INFINITY`

## 기본 제공 객체
<a name="writing-functions-javascript-features-builtin-objects"></a>

ES의 다음 내장 객체가 지원됩니다.

**수학 연산**  
모든 ES 5.1 수학 메서드가 지원됩니다.  
CloudFront 함수 런타임 환경에서 `Math.random()` 구현은 함수가 실행될 때의 타임스탬프와 함께 시드된 OpenBSD `arc4random`을(를) 사용합니다.
다음 ES 6 수학 메서드가 지원됩니다.  
+ `acosh`
+ `asinh`
+ `atanh`
+ `cbrt`
+ `clz32`
+ `cosh`
+ `expm1`
+ `fround`
+ `hypot`
+ `imul`
+ `log10`
+ `log1p`
+ `log2`
+ `sign`
+ `sinh`
+ `tanh`
+ `trunc`
+ `E`
+ `LN10`
+ `LN2`
+ `LOG10E`
+ `LOG2E`
+ `PI`
+ `SQRT1_2`
+ `SQRT2`

**날짜**  
모든 ES 5.1 `Date` 기능이 지원됩니다.  
보안상의 이유로 단일 함수 실행의 수명 동안 `Date`은(는) 항상 동일한 값(함수의 시작 시간)을 반환합니다. 자세한 내용은 [제한된 기능](#writing-functions-javascript-features-restricted-features) 단원을 참조하세요.

**함수**  
`apply`, `bind` 및 `call` 메서드가 지원됩니다.  
함수 생성자는 지원되지 않습니다.

**정규식**  
모든 ES 5.1 정규 표현식 기능이 지원됩니다. 정규 표현식 언어는 Perl과 호환됩니다. ES 9 명명된 캡처 그룹이 지원됩니다.

**JSON**  
`parse` 및 `stringify`을(를) 포함하여 모든 ES 5.1 JSON 기능이 지원됩니다.

**배열**  
배열에 대해 다음 ES 5.1 메서드가 지원됩니다.  
+ `isArray`
+ `prototype.concat`
+ `prototype.every`
+ `prototype.filter`
+ `prototype.forEach`
+ `prototype.indexOf`
+ `prototype.join`
+ `prototype.lastIndexOf`
+ `prototype.map`
+ `prototype.pop`
+ `prototype.push`
+ `prototype.reduce`
+ `prototype.reduceRight`
+ `prototype.reverse`
+ `prototype.shift`
+ `prototype.slice`
+ `prototype.some`
+ `prototype.sort`
+ `prototype.splice`
+ `prototype.unshift`
배열에 대해 다음 ES 6 메서드가 지원됩니다.  
+ `of`
+ `prototype.copyWithin`
+ `prototype.fill`
+ `prototype.find`
+ `prototype.findIndex`
배열에 대해 다음 ES 7 메서드가 지원됩니다.  
+ `prototype.includes`

**형식화된 배열**  
다음 ES 6 형식화된 배열이 지원됩니다.  
+ `Int8Array`
+ `Uint8Array`
+ `Uint8ClampedArray`
+ `Int16Array`
+ `Uint16Array`
+ `Int32Array`
+ `Uint32Array`
+ `Float32Array`
+ `Float64Array`
+ `prototype.copyWithin`
+ `prototype.fill`
+ `prototype.join`
+ `prototype.set`
+ `prototype.slice`
+ `prototype.subarray`
+ `prototype.toString`

**배열 버퍼**  
`ArrayBuffer`에 대해 메서드가 지원됩니다.  
+ `prototype.isView`
+ `prototype.slice`

**Promise**  
Promise에 대해 다음 메서드가 지원됩니다.  
+ `reject`
+ `resolve`
+ `prototype.catch`
+ `prototype.finally`
+ `prototype.then`

**crypto**  
암호화 모듈은 표준 해싱 및 HMAC(해시 기반 메시지 인증 코드) 헬퍼를 제공합니다. `require('crypto')`을(를) 사용하여 모듈을 로드할 수 있습니다. 모듈은 해당 Node.js 대응으로 정확하게 동작하는 다음과 같은 메서드를 노출합니다.  
+ `createHash(algorithm)`
+ `hash.update(data)`
+ `hash.digest([encoding])`
+ `createHmac(algorithm, secret key)`
+ `hmac.update(data)`
+ `hmac.digest([encoding])`
자세한 내용은 기본 제공 모듈 단원의 [암호화(해시 및 HMAC)](#writing-functions-javascript-features-builtin-modules-crypto)를 참조하세요.

**콘솔**  
디버깅을 위한 헬퍼 객체입니다. 로그 메시지를 기록하는 `log()` 메서드만 지원합니다.  
CloudFront 함수는 `console.log('a', 'b')`와 같은 쉼표 구문을 지원하지 않습니다. 대신 `console.log('a' + ' ' + 'b')` 형식을 사용합니다.

## 오류 유형
<a name="writing-functions-javascript-features-error-types"></a>

다음과 같은 오류 객체가 지원됩니다.
+ `Error`
+ `EvalError`
+ `InternalError`
+ `MemoryError`
+ `RangeError`
+ `ReferenceError`
+ `SyntaxError`
+ `TypeError`
+ `URIError`

## Globals
<a name="writing-functions-javascript-features-globals"></a>

`globalThis` 객체가 지원됩니다.

다음 ES 5.1 전역 함수가 지원됩니다.
+ `decodeURI`
+ `decodeURIComponent`
+ `encodeURI`
+ `encodeURIComponent`
+ `isFinite`
+ `isNaN`
+ `parseFloat`
+ `parseInt`

다음과 같은 글로벌 제약이 지원됩니다.
+ `NaN`
+ `Infinity`
+ `undefined`

## 기본 제공 모듈
<a name="writing-functions-javascript-features-builtin-modules"></a>

다음 기본 제공 모듈이 지원됩니다.

**Topics**
+ [

### 암호화(해시 및 HMAC)
](#writing-functions-javascript-features-builtin-modules-crypto)
+ [

### 쿼리 문자열
](#writing-functions-javascript-features-builtin-modules-query-string)

### 암호화(해시 및 HMAC)
<a name="writing-functions-javascript-features-builtin-modules-crypto"></a>

암호화 모듈(`crypto`)은 표준 해싱 및 HMAC(해시 기반 메시지 인증 코드) 헬퍼를 제공합니다. `require('crypto')`을(를) 사용하여 모듈을 로드할 수 있습니다. 이 모듈은 Node.js 대응물과 정확히 동일하게 동작하는 다음과 같은 메서드를 제공합니다.

**해싱 메서드**

`crypto.createHash(algorithm)`  
지정된 알고리즘(`md5`, `sha1` 또는 `sha256`)을 사용하여 해시 다이제스트를 생성하는 데 사용할 수 있는 해시 객체를 생성하고 반환합니다.

`hash.update(data)`  
지정된 `data`(으)로 해시 콘텐츠를 업데이트합니다.

`hash.digest([encoding])`  
`hash.update()`을(를) 사용하여 전달된 모든 데이터의 다이제스트를 계산합니다. 인코딩은 `hex`, `base64` 또는 `base64url`일 수 있습니다.

**HMAC 메서드**

`crypto.createHmac(algorithm, secret key)`  
지정된 `algorithm` 및 `secret key`을(를) 사용하는 HMAC 객체를 생성 및 반환합니다. 알고리즘은 `md5`, `sha1` 또는 `sha256`일 수 있습니다.

`hmac.update(data)`  
지정된 `data`(으)로 HMAC 콘텐츠를 업데이트합니다.

`hmac.digest([encoding])`  
`hmac.update()`을(를) 사용하여 전달된 모든 데이터의 다이제스트를 계산합니다. 인코딩은 `hex`, `base64` 또는 `base64url`일 수 있습니다.

### 쿼리 문자열
<a name="writing-functions-javascript-features-builtin-modules-query-string"></a>

**참고**  
[CloudFront 함수 이벤트 객체](functions-event-structure.md)는 URL 쿼리 문자열을 자동으로 구문 분석합니다. 즉, 대부분의 경우 이 모듈을 사용할 필요가 없습니다.

쿼리 문자열 모듈(`querystring`)은 URL 쿼리 문자열을 구문 분석하고 서식을 지정하는 메서드를 제공합니다. `require('querystring')`을 사용하여 모듈을 로드할 수 있습니다. 이 모듈은 다음과 같은 방법을 제공합니다.

`querystring.escape(string)`  
지정된 `string`을 URL-인코딩하여 이스케이프된 쿼리 문자열을 반환합니다. 이 방법은 `querystring.stringify()`에서 사용되며 직접 사용해서는 안 됩니다.

`querystring.parse(string[, separator[, equal[, options]]])`  
쿼리 문자열(`string`)을 구문 분석하고 객체를 반환합니다.  
`separator` 파라미터는 쿼리 문자열에서 키와 값 페어를 구분하기 위한 하위 문자열입니다. 기본 설정은 `&`입니다.  
`equal` 파라미터는 쿼리 문자열에서 키와 값을 구분하기 위한 하위 문자열입니다. 기본 설정은 `=`입니다.  
`options` 파라미터는 다음 키를 가진 객체입니다.    
`decodeURIComponent function`  
쿼리 문자열에서 백분율로 인코딩된 문자를 디코딩하는 함수입니다. 기본 설정은 `querystring.unescape()`입니다.  
`maxKeys number`  
구문 분석할 최대 키 수입니다. 기본 설정은 `1000`입니다. `0` 값을 사용하여 키 카운트 제한을 제거합니다.
기본적으로 쿼리 문자열 내의 백분율로 인코딩된 문자는 UTF-8 인코딩을 사용하는 것으로 간주됩니다. 잘못된 UTF-8 시퀀스는 `U+FFFD` 대체 문자로 대체됩니다.  
예를 들어 다음 쿼리 문자열의 경우:  

```
'name=value&abc=xyz&abc=123'
```
`querystring.parse()`의 반환 값:  

```
{
name: 'value',
abc: ['xyz', '123']
}
```
`querystring.decode()`는 `querystring.parse()`의 별칭입니다.

`querystring.stringify(object[, separator[, equal[, options]]])`  
`object`를 직렬화하고 쿼리 문자열을 반환합니다.  
`separator` 파라미터는 쿼리 문자열에서 키와 값 쌍을 구분하기 위한 하위 문자열입니다. 기본 설정은 `&`입니다.  
`equal` 파라미터는 쿼리 문자열에서 키와 값을 구분하기 위한 하위 문자열입니다. 기본 설정은 `=`입니다.  
`options` 파라미터는 다음 키를 가진 객체입니다.    
`encodeURIComponent function`  
URL에 안전하지 않은 문자를 쿼리 문자열에서 백분율 인코딩으로 변환하는 데 사용할 함수입니다. 기본 설정은 `querystring.escape()`입니다.
기본적으로 쿼리 문자열 내에서 백분율 인코딩이 필요한 문자는 UTF-8로 인코딩됩니다. 다른 인코딩을 사용하려면 `encodeURIComponent` 옵션을 지정합니다.  
예를 들어, 다음 코드의 경우:  

```
querystring.stringify({ name: 'value', abc: ['xyz', '123'], anotherName: '' });
```
반환 값:  

```
'name=value&abc=xyz&abc=123&anotherName='
```
`querystring.encode()`는 `querystring.stringify()`의 별칭입니다.

`querystring.unescape(string)`  
지정된 `string`의 URL 백분율로 인코딩된 문자를 디코딩하여 이스케이프되지 않은 쿼리 문자열을 반환합니다. 이 방법은 `querystring.parse()`에서 사용되며 직접 사용해서는 안 됩니다.

## 제한된 기능
<a name="writing-functions-javascript-features-restricted-features"></a>

다음 JavaScript 언어 기능은 보안 문제로 인해 지원되지 않거나 제한됩니다.

**동적 코드 평가**  
동적 코드 평가는 지원되지 않습니다. 시도하면 `eval()` 및 `Function` 생성자 모두 오류가 발생합니다. 예를 들어 `const sum = new Function('a', 'b', 'return a + b')`에서 오류가 발생합니다.

**타이머**  
`setTimeout()`, `setImmediate()` 및 `clearTimeout()` 함수는 지원되지 않습니다. 함수 실행 내에서 연기하거나 출력할 프로비전이 없습니다. 함수가 완료되려면 동기적으로 실행되어야 합니다.

**날짜 및 타임스탬프**  
보안상의 이유로 고해상도 타이머에 액세스할 수 없습니다. 현재 시간을 쿼리하는 모든 `Date` 메서드는 단일 함수 실행의 수명 동안 항상 동일한 값을 반환합니다. 반환된 타임 스탬프는 함수가 실행을 시작한 시간입니다. 따라서 함수에서 경과 시간을 측정할 수 없습니다.

**파일 시스템 액세스**  
파일 시스템 액세스가 없습니다. 예를 들어 Node.js에서처럼 파일 시스템 액세스를 위한 `fs` 모듈이 없습니다.

**프로세스 액세스**  
프로세스 액세스가 없습니다. 예를 들어 Node.js와는 달리 정보 액세스를 처리하기 위한 `process` 글로벌 객체가 없습니다.

**환경 변수**  
환경 변수에 액세스할 수 없습니다.  
대신 CloudFront KeyValueStore를 사용하여 CloudFront Functions에 대한 키 값 페어의 중앙 집중식 데이터 스토어를 생성할 수 있습니다. CloudFront KeyValueStore를 사용하면 코드 변경 사항을 배포할 필요 없이 구성 데이터를 동적으로 업데이트할 수 있습니다. CloudFront KeyValueStore를 사용하려면 [JavaScript 런타임 2.0](functions-javascript-runtime-20.md)을 사용해야 합니다. 자세한 내용은 [Amazon CloudFront KeyValueStore](kvs-with-functions.md) 섹션을 참조하세요.

**네트워크 액세스**  
네트워크 통화에 대한 지원이 없습니다. 예를 들어 XHR, HTTP(S) 및 소켓은 지원되지 않습니다.

# CloudFront Functions를 위한 JavaScript 런타임 2.0 기능
<a name="functions-javascript-runtime-20"></a>

CloudFront Functions JavaScript 런타임 환경은 [ECMAScript(ES) 버전 5.1](https://262.ecma-international.org/5.1/)을 준수하며, ES 버전 6에서 12까지의 일부 기능을 지원합니다. 또한 ES 사양의 일부가 아닌 일부 비표준 방법을 제공합니다. 다음 주제에는 이 런타임에서 지원되는 모든 기능이 나열되어 있습니다.

**Topics**
+ [

## 핵심 기능
](#writing-functions-javascript-features-core-20)
+ [

## 기본 객체
](#writing-functions-javascript-features-primitive-objects-20)
+ [

## 기본 제공 객체
](#writing-functions-javascript-features-builtin-objects-20)
+ [

## 오류 유형
](#writing-functions-javascript-features-error-types-20)
+ [

## Globals
](#writing-functions-javascript-features-globals-20)
+ [

## 기본 제공 모듈
](#writing-functions-javascript-features-builtin-modules-20)
+ [

## 제한된 기능
](#writing-functions-javascript-features-restricted-features-20)

## 핵심 기능
<a name="writing-functions-javascript-features-core-20"></a>

ES의 다음과 같은 핵심 기능이 지원됩니다.

**유형**  
모든 ES 5.1 유형이 지원됩니다. 여기에는 부울 값, 숫자, 문자열, 객체, 배열, 함수, 정규 표현식이 포함됩니다.

**연산자**  
모든 ES 5.1 연산자가 지원됩니다.  
ES 7 거듭제곱 연산자(`**`)가 지원됩니다.

**Statement**  
다음 ES 5.1 문이 지원됩니다.  
+ `break`
+ `catch`
+ `continue`
+ `do-while`
+ `else`
+ `finally`
+ `for`
+ `for-in`
+ `if`
+ `label`
+ `return`
+ `switch`
+ `throw`
+ `try`
+ `var`
+ `while`
다음 ES 6 문이 지원됩니다.  
+ `const`
+ `let`
다음 ES 8 문이 지원됩니다.  
+ `async`
+ `await`
`async`, `await`, `const` 및 `let`가 JavaScript 런타임 2.0에서 지원됩니다.  
`await`는 `async` 함수 내에서만 사용할 수 있습니다. `async` 인수 및 종료는 지원되지 않습니다.

**리터럴**  
ES 6 템플릿 리터럴은 여러 줄 문자열, 표현식 보간 및 중첩 템플릿에 대해 지원됩니다..

**함수**  
모든 ES 5.1 함수 기능이 지원됩니다.  
ES 6 화살표 함수가 지원되며 ES 6 나머지 파라미터 구문이 지원됩니다.

**유니코드**  
소스 텍스트 및 문자열 리터럴에는 유니코드로 인코딩된 문자가 포함될 수 있습니다. 6자의 유니코드 코드 포인트 이스케이프 시퀀스(예: `\uXXXX`)도 지원됩니다.

**엄격 모드**  
함수는 기본적으로 엄격 모드에서 작동하므로 함수 코드에 `use strict` 명령문을 추가할 필요가 없습니다. 이것은 변경할 수 없습니다.

## 기본 객체
<a name="writing-functions-javascript-features-primitive-objects-20"></a>

ES의 다음과 같은 기본 객체가 지원됩니다.

**객체**  
객체에 대해 다음과 같은 ES 5.1 메서드가 지원됩니다.  
+ `Object.create()`(속성 목록 제외)
+ `Object.defineProperties()`
+ `Object.defineProperty()`
+ `Object.freeze()`
+ `Object.getOwnPropertyDescriptor()`
+ `Object.getOwnPropertyDescriptors()`
+ `Object.getOwnPropertyNames()`
+ `Object.getPrototypeOf()`
+ `Object.isExtensible()`
+ `Object.isFrozen()`
+ `Object.isSealed()`
+ `Object.keys()`
+ `Object.preventExtensions()`
+ `Object.seal()`
객체에 대해 다음 ES 6 메서드가 지원됩니다.  
+ `Object.assign()`
객체에 대해 다음과 같은 ES 8 메서드가 지원됩니다.  
+ `Object.entries()`
+ `Object.values()`
객체에 대해 다음과 같은 ES 5.1 프로토타입 메서드가 지원됩니다.  
+ `Object.prototype.hasOwnProperty()`
+ `Object.prototype.isPrototypeOf()`
+ `Object.prototype.propertyIsEnumerable()`
+ `Object.prototype.toString()`
+ `Object.prototype.valueOf()`
객체에 대해 다음과 같은 ES 6 프로토타입 메서드가 지원됩니다.  
+ `Object.prototype.is()`
+ `Object.prototype.setPrototypeOf()`

**문자열**  
문자열에 대해 다음 ES 5.1 메서드가 지원됩니다.  
+ `String.fromCharCode()`
문자열에 대해 다음 ES 6 메서드가 지원됩니다.  
+ `String.fromCodePoint()`
문자열에 대해 다음 ES 5.1 프로토타입 메서드가 지원됩니다.  
+ `String.prototype.charAt()`
+ `String.prototype.concat()`
+ `String.prototype.indexOf()`
+ `String.prototype.lastIndexOf()`
+ `String.prototype.match()`
+ `String.prototype.replace()`
+ `String.prototype.search()`
+ `String.prototype.slice()`
+ `String.prototype.split()`
+ `String.prototype.substr()`
+ `String.prototype.substring()`
+ `String.prototype.toLowerCase()`
+ `String.prototype.trim()`
+ `String.prototype.toUpperCase()`
문자열에 대해 다음 ES 6 프로토타입 메서드가 지원됩니다.  
+ `String.prototype.codePointAt()`
+ `String.prototype.endsWith()`
+ `String.prototype.includes()`
+ `String.prototype.repeat()`
+ `String.prototype.startsWith()`
문자열에 대해 다음 ES 8 프로토타입 메서드가 지원됩니다.  
+ `String.prototype.padStart()`
+ `String.prototype.padEnd()`
문자열에 대해 다음 ES 9 프로토타입 메서드가 지원됩니다.  
+ `String.prototype.trimStart()`
+ `String.prototype.trimEnd()`
문자열에 대해 다음 ES 12 프로토타입 메서드가 지원됩니다.  
+ `String.prototype.replaceAll()`
**참고**  
`String.prototype.replaceAll()`이 JavaScript 런타임 2.0에 새로 추가되었습니다.

**숫자**  
모든 ES 5.1 숫자가 지원됩니다.  
숫자에 대해 다음 ES 6 속성이 지원됩니다.  
+ `Number.EPSILON`
+ `Number.MAX_SAFE_INTEGER`
+ `Number.MIN_SAFE_INTEGER`
+ `Number.MAX_VALUE`
+ `Number.MIN_VALUE`
+ `Number.NaN`
+ `Number.NEGATIVE_INFINITY`
+ `Number.POSITIVE_INFINITY`
숫자에 대해 다음 ES 6 메서드가 지원됩니다.  
+ `Number.isFinite()`
+ `Number.isInteger()`
+ `Number.isNaN()`
+ `Number.isSafeInteger()`
+ `Number.parseInt()`
+ `Number.parseFloat()`
숫자에 대해 다음 ES 5.1 프로토타입 메서드가 지원됩니다.  
+ `Number.prototype.toExponential()`
+ `Number.prototype.toFixed()`
+ `Number.prototype.toPrecision()`
ES 12 숫자 구분자가 지원됩니다.  
ES 12 숫자 구분자가 JavaScript 런타임 2.0에 새로 추가되었습니다.

## 기본 제공 객체
<a name="writing-functions-javascript-features-builtin-objects-20"></a>

ES의 다음 내장 객체가 지원됩니다.

**수학 연산**  
모든 ES 5.1 수학 메서드가 지원됩니다.  
CloudFront 함수 런타임 환경에서 `Math.random()` 구현은 함수가 실행될 때의 타임스탬프와 함께 시드된 OpenBSD `arc4random`을(를) 사용합니다.
다음 ES 6 수학 속성이 지원됩니다.  
+ `Math.E`
+ `Math.LN10`
+ `Math.LN2`
+ `Math.LOG10E`
+ `Math.LOG2E`
+ `Math.PI`
+ `Math.SQRT1_2`
+ `Math.SQRT2`
다음 ES 6 수학 메서드가 지원됩니다.  
+ `Math.abs()`
+ `Math.acos()`
+ `Math.acosh()`
+ `Math.asin()`
+ `Math.asinh()`
+ `Math.atan()`
+ `Math.atan2()`
+ `Math.atanh()`
+ `Math.cbrt()`
+ `Math.ceil()`
+ `Math.clz32()`
+ `Math.cos()`
+ `Math.cosh()`
+ `Math.exp()`
+ `Math.expm1()`
+ `Math.floor()`
+ `Math.fround()`
+ `Math.hypot()`
+ `Math.imul()`
+ `Math.log()`
+ `Math.log1p()`
+ `Math.log2()`
+ `Math.log10()`
+ `Math.max()`
+ `Math.min()`
+ `Math.pow()`
+ `Math.random()`
+ `Math.round()`
+ `Math.sign()`
+ `Math.sinh()`
+ `Math.sin()`
+ `Math.sqrt()`
+ `Math.tan()`
+ `Math.tanh()`
+ `Math.trunc()`

**날짜**  
모든 ES 5.1 `Date` 기능이 지원됩니다.  
보안상의 이유로 단일 함수 실행의 수명 동안 `Date`은(는) 항상 동일한 값(함수의 시작 시간)을 반환합니다. 자세한 내용은 [제한된 기능](functions-javascript-runtime-10.md#writing-functions-javascript-features-restricted-features) 단원을 참조하세요.

**함수**  
다음 ES 5.1 프로토타입 메서드가 지원됩니다.  
+ `Function.prototype.apply()`
+ `Function.prototype.bind()`
+ `Function.prototype.call()`
함수 생성자는 지원되지 않습니다.

**정규식**  
모든 ES 5.1 정규 표현식 기능이 지원됩니다. 정규 표현식 언어는 Perl과 호환됩니다.  
다음 ES 5.1 프로토타입 접근자 속성이 지원됩니다.  
+ `RegExp.prototype.global`
+ `RegExp.prototype.ignoreCase`
+ `RegExp.protoype.multiline`
+ `RegExp.protoype.source`
+ `RegExp.prototype.sticky`
+ `RegExp.prototype.flags`
**참고**  
`RegExp.prototype.sticky`, `RegExp.prototype.flags`가 JavaScript 런타임 2.0에 새로 추가되었습니다.
다음 ES 5.1 프로토타입 메서드가 지원됩니다.  
+ `RegExp.prototype.exec()`
+ `RegExp.prototype.test()`
+ `RegExp.prototype.toString()`
+ `RegExp.prototype[@@replace]()`
+ `RegExp.prototype[@@split]()`
**참고**  
`RegExp.prototype[@@split]()`이 JavaScript 런타임 2.0에 새로 추가되었습니다.
다음 ES 5.1 인스턴스 속성이 지원됩니다.  
+ `lastIndex`
ES 9 명명된 캡처 그룹이 지원됩니다.

**JSON**  
다음 ES 5.1 메서드가 지원됩니다.  
+ `JSON.parse()`
+ `JSON.stringify()`

**배열**  
배열에 대해 다음 ES 5.1 메서드가 지원됩니다.  
+ `Array.isArray()`
배열에 대해 다음 ES 6 메서드가 지원됩니다.  
+ `Array.of()`
다음 ES 5.1 프로토타입 메서드가 지원됩니다.  
+ `Array.prototype.concat()`
+ `Array.prototype.every()`
+ `Array.prototype.filter()`
+ `Array.prototype.forEach()`
+ `Array.prototype.indexOf()`
+ `Array.prototype.join()`
+ `Array.prototype.lastIndexOf()`
+ `Array.prototype.map()`
+ `Array.prototype.pop()`
+ `Array.prototype.push()`
+ `Array.prototype.reduce()`
+ `Array.prototype.reduceRight()`
+ `Array.prototype.reverse()`
+ `Array.prototype.shift()`
+ `Array.prototype.slice()`
+ `Array.prototype.some()`
+ `Array.prototype.sort()`
+ `Array.prototype.splice()`
+ `Array.prototype.unshift()`
다음 ES 6 프로토타입 메서드가 지원됩니다.  
+ `Array.prototype.copyWithin()`
+ `Array.prototype.fill()`
+ `Array.prototype.find()`
+ `Array.prototype.findIndex()`
다음 ES 7 프로토타입 메서드가 지원됩니다.  
+ `Array.prototype.includes()`

**형식화된 배열**  
다음 ES 6 형식화된 배열 생성자가 지원됩니다.  
+ `Float32Array`
+ `Float64Array`
+ `Int8Array`
+ `Int16Array`
+ `Int32Array`
+ `Uint8Array`
+ `Uint8ClampedArray`
+ `Uint16Array`
+ `Uint32Array`
다음 ES 6 메서드가 지원됩니다.  
+ `TypedArray.from()`
+ `TypedArray.of()`
**참고**  
`TypedArray.from()`, `TypedArray.of()`가 JavaScript 런타임 2.0에 새로 추가되었습니다.
다음 ES 6 프로토타입 메서드가 지원됩니다.  
+ `TypedArray.prototype.copyWithin()`
+ `TypedArray.prototype.every()`
+ `TypedArray.prototype.fill()`
+ `TypedArray.prototype.filter()`
+ `TypedArray.prototype.find()`
+ `TypedArray.prototype.findIndex()`
+ `TypedArray.prototype.forEach()`
+ `TypedArray.prototype.includes()`
+ `TypedArray.prototype.indexOf()`
+ `TypedArray.prototype.join()`
+ `TypedArray.prototype.lastIndexOf()`
+ `TypedArray.prototype.map()`
+ `TypedArray.prototype.reduce()`
+ `TypedArray.prototype.reduceRight()`
+ `TypedArray.prototype.reverse()`
+ `TypedArray.prototype.some()`
+ `TypedArray.prototype.set()`
+ `TypedArray.prototype.slice()`
+ `TypedArray.prototype.sort()`
+ `TypedArray.prototype.subarray()`
+ `TypedArray.prototype.toString()`
**참고**  
`TypedArray.prototype.every()`, `TypedArray.prototype.fill()`, `TypedArray.prototype.filter()`, `TypedArray.prototype.find()`, `TypedArray.prototype.findIndex()`, `TypedArray.prototype.forEach()`, `TypedArray.prototype.includes()`, `TypedArray.prototype.indexOf()`, `TypedArray.prototype.join()`, `TypedArray.prototype.lastIndexOf()`, `TypedArray.prototype.map()`, `TypedArray.prototype.reduce()`, `TypedArray.prototype.reduceRight()`, `TypedArray.prototype.reverse()`, `TypedArray.prototype.some()`이 JavaScript 런타임 2.0에 새로 추가되었습니다.

**배열 버퍼**  
ArrayBuffer에 대해 다음 ES 6 메서드가 지원됩니다.  
+ `isView()`
ArrayBuffer에 대해 다음 ES 6 프로토타입 메서드가 지원됩니다.  
+ `ArrayBuffer.prototype.slice()`

**Promise**  
프로미스에 대해 다음 ES 6 메서드가 지원됩니다.  
+ `Promise.all()`
+ `Promise.allSettled()`
+ `Promise.any()`
+ `Promise.reject()`
+ `Promise.resolve()`
+ `Promise.race()`
**참고**  
`Promise.all()`, `Promise.allSettled()`, `Promise.any()`, `Promise.race()`가 JavaScript 런타임 2.0에 새로 추가되었습니다.
프로미스에 대해 다음 ES 6 프로토타입 메서드가 지원됩니다.  
+ `Promise.prototype.catch()`
+ `Promise.prototype.finally()`
+ `Promise.prototype.then()`

**DataView**  
다음 ES 6 프로토타입 메서드가 지원됩니다.  
+ `DataView.prototype.getFloat32()`
+ `DataView.prototype.getFloat64()`
+ `DataView.prototype.getInt16()`
+ `DataView.prototype.getInt32()`
+ `DataView.prototype.getInt8()`
+ `DataView.prototype.getUint16()`
+ `DataView.prototype.getUint32()`
+ `DataView.prototype.getUint8()`
+ `DataView.prototype.setFloat32()`
+ `DataView.prototype.setFloat64()`
+ `DataView.prototype.setInt16()`
+ `DataView.prototype.setInt32()`
+ `DataView.prototype.setInt8()`
+ `DataView.prototype.setUint16()`
+ `DataView.prototype.setUint32()`
+ `DataView.prototype.setUint8()`
**참고**  
모든 Dataview ES 6 프로토타입 메서드가 JavaScript 런타임 2.0에 새로 추가되었습니다.

**Symbol**  
다음 ES 6 메서드가 지원됩니다.  
+ `Symbol.for()`
+ `Symbol.keyfor()`
**참고**  
모든 Symbol ES 6 메서드가 JavaScript 런타임 2.0에 새로 추가되었습니다.

**텍스트 디코더**  
다음 프로토타입 메서드가 지원됩니다.  
+ `TextDecoder.prototype.decode()`
다음 프로토타입 접근자 속성이 지원됩니다.  
+ `TextDecoder.prototype.encoding`
+ `TextDecoder.prototype.fatal`
+ `TextDecoder.prototype.ignoreBOM`

**텍스트 인코더**  
다음 프로토타입 메서드가 지원됩니다.  
+ `TextEncoder.prototype.encode()`
+ `TextEncoder.prototype.encodeInto()`

## 오류 유형
<a name="writing-functions-javascript-features-error-types-20"></a>

다음과 같은 오류 객체가 지원됩니다.
+ `Error`
+ `EvalError`
+ `InternalError`
+ `RangeError`
+ `ReferenceError`
+ `SyntaxError`
+ `TypeError`
+ `URIError`

## Globals
<a name="writing-functions-javascript-features-globals-20"></a>

`globalThis` 객체가 지원됩니다.

다음 ES 5.1 전역 함수가 지원됩니다.
+ `decodeURI()`
+ `decodeURIComponent()`
+ `encodeURI()`
+ `encodeURIComponent()`
+ `isFinite()`
+ `isNaN()`
+ `parseFloat()`
+ `parseInt()`

다음 ES 6 전역 함수가 지원됩니다.
+ `atob()`
+ `btoa()`
**참고**  
`atob()`, `btoa()`가 JavaScript 런타임 2.0에 새로 추가되었습니다.

다음과 같은 글로벌 제약이 지원됩니다.
+ `NaN`
+ `Infinity`
+ `undefined`
+ `arguments`

## 기본 제공 모듈
<a name="writing-functions-javascript-features-builtin-modules-20"></a>

다음 기본 제공 모듈이 지원됩니다.

**Topics**
+ [

### Buffer
](#writing-functions-javascript-features-builtin-modules-buffer-20)
+ [

### 쿼리 문자열
](#writing-functions-javascript-features-builtin-modules-query-string-20)
+ [

### crypto
](#writing-functions-javascript-features-builtin-modules-crypto-20)

### Buffer
<a name="writing-functions-javascript-features-builtin-modules-buffer-20"></a>

이 모듈은 다음과 같은 메서드를 제공합니다.
+ `Buffer.alloc(size[, fill[, encoding]])`

  `Buffer`를 할당합니다.
  + `size`: 버퍼 크기입니다. 정수를 입력합니다.
  + `fill`: 선택 사항입니다. 문자열, `Buffer`, Uint8Array 또는 정수를 입력합니다. 기본값은 `0`입니다.
  + `encoding`: 선택 사항입니다. `fill`이 문자열인 경우 `utf8`, `hex`, `base64`, `base64url` 중 하나를 입력합니다. 기본값은 `utf8`입니다.
+ `Buffer.allocUnsafe(size)`

  초기화되지 않은 `Buffer` 값을 할당합니다.
  + `size`: 정수를 입력합니다.
+ `Buffer.byteLength(value[, encoding])`

  값의 길이를 바이트 단위로 반환합니다.
  + `value`: 문자열, `Buffer`, TypedArray, Dataview 또는 Arraybuffer입니다.
  + `encoding`: 선택 사항입니다. `value`가 문자열인 경우 `utf8`, `hex`, `base64`, `base64url` 중 하나를 입력합니다. 기본값은 `utf8`입니다.
+ `Buffer.compare(buffer1, buffer2)`

  두 `Buffer`를 비교하면 배열을 정렬하는 데 도움이 됩니다. 두 값이 같으면 `0`, `buffer1`이 먼저 오면 `-1`, `buffer2`가 먼저 오면 `1`을 반환합니다.
  + `buffer1`: `Buffer`를 입력합니다.
  + `buffer2`: 다른 `Buffer`를 입력합니다.
+ `Buffer.concat(list[, totalLength])`

  여러 개의 `Buffer`를 연결합니다. 없으면 `0`을 반환합니다. `totalLength`까지 반환합니다.
  + `list`: `Buffer` 목록을 입력합니다. 이 항목은 `totalLength` 기준으로 잘려서 표시된다는 점에 유의하세요.
  + `totalLength`: 선택 사항입니다. 부호 없는 정수를 입력합니다. 비어 있는 경우 목록에 있는 `Buffer` 인스턴스의 합계를 사용하세요.
+ `Buffer.from(array)`

  배열에서 `Buffer`를 생성합니다.
  + `array`: `0`에서 `255`까지 바이트 배열을 입력합니다.
+ `Buffer.from(arrayBuffer, byteOffset[, length]))`

  `byteOffset` 오프셋에서 시작하여 `length` 길이를 기준으로 `arrayBuffer`에서 뷰를 생성합니다.
  + `arrayBuffer`: `Buffer` 배열을 입력합니다.
  + `byteOffset`: 정수를 입력합니다.
  + `length`: 선택 사항입니다. 정수를 입력합니다.
+ `Buffer.from(buffer)`

  `Buffer`의 사본을 생성합니다.
  + `buffer`: `Buffer`를 입력합니다.
+ `Buffer.from(object[, offsetOrEncoding[, length]])`

  객체에서 `Buffer`를 생성합니다. `valueOf()` 값이 객체와 동일하지 않으면 `Buffer.from(object.valueOf(), offsetOrEncoding, length)` 값을 반환합니다.
  + `object`: 객체를 입력합니다.
  + `offsetOrEncoding`: 선택 사항입니다. 정수 또는 인코딩 문자열을 입력합니다.
  + `length`: 선택 사항입니다. 정수를 입력합니다.
+ `Buffer.from(string[, encoding])`

  문자열에서 `Buffer`를 생성합니다.
  + `string`: 문자열을 입력합니다.
  + `encoding`: 선택 사항입니다. `utf8`, `hex`, `base64`, `base64url` 중 하나를 입력합니다. 기본값은 `utf8`입니다.
+ `Buffer.isBuffer(object)`

  `object`가 버퍼인지 확인합니다. `true` 또는 `false`를 반환합니다.
  + `object`: 객체를 입력합니다.
+ `Buffer.isEncoding(encoding)`

  `encoding`이 지원되는지 확인합니다. `true` 또는 `false`를 반환합니다.
  + `encoding`: 선택 사항입니다. `utf8`, `hex`, `base64`, `base64url` 중 하나를 입력합니다. 기본값은 `utf8`입니다.

이 모듈은 다음과 같은 버퍼 프로토타입 메서드를 제공합니다.
+ `Buffer.prototype.compare(target[, targetStart[, targetEnd[, sourceStart[, sourceEnd]]]])`

  `Buffer`를 대상과 비교합니다. 두 값이 같으면 `0`, `buffer`이 먼저 오면 `1`, `target`가 먼저 오면 `-1`을 반환합니다.
  + `target`: `Buffer`를 입력합니다.
  + `targetStart`: 선택 사항입니다. 정수를 입력합니다. 기본값은 0.
  + `targetEnd`: 선택 사항입니다. 정수를 입력합니다. 기본값은 `target` 길이입니다.
  + `sourceStart`: 선택 사항입니다. 정수를 입력합니다. 기본값은 0.
  + `sourceEnd`: 선택 사항입니다. 정수를 입력합니다. 기본값은 `Buffer` 길이입니다.
+ `Buffer.prototype.copy(target[, targetStart[, sourceStart[, sourceEnd]]])`

  버퍼를 `target`으로 복사합니다.
  + `target`: `Buffer` 또는 `Uint8Array`를 입력합니다.
  + `targetStart`: 선택 사항입니다. 정수를 입력합니다. 기본값은 0.
  + `sourceStart`: 선택 사항입니다. 정수를 입력합니다. 기본값은 0.
  + `sourceEnd`: 선택 사항입니다. 정수를 입력합니다. 기본값은 `Buffer` 길이입니다.
+ `Buffer.prototype.equals(otherBuffer)`

  `Buffer`와 `otherBuffer`를 비교합니다. `true` 또는 `false`를 반환합니다.
  + `otherBuffer`: 문자열을 입력합니다.
+ `Buffer.prototype.fill(value[, offset[, end][, encoding])`

  `Buffer`를 `value`로 채웁니다.
  + `value`: 문자열, `Buffer` 또는 정수를 입력합니다.
  + `offset`: 선택 사항입니다. 정수를 입력합니다.
  + `end`: 선택 사항입니다. 정수를 입력합니다.
  + `encoding`: 선택 사항입니다. `utf8`, `hex`, `base64`, `base64url` 중 하나를 입력합니다. 기본값은 `utf8`입니다.
+ `Buffer.prototype.includes(value[, byteOffset][, encoding])`

  `Buffer`에서 `value`를 찾습니다. `true` 또는 `false`를 반환합니다.
  + `value`: 문자열, `Buffer`, `Uint8Array` 또는 정수를 입력합니다.
  + `byteOffset`: 선택 사항입니다. 정수를 입력합니다.
  + `encoding`: 선택 사항입니다. `utf8`, `hex`, `base64`, `base64url` 중 하나를 입력합니다. 기본값은 `utf8`입니다.
+ `Buffer.prototype.indexOf(value[, byteOffset][, encoding])`

  `Buffer`에서 첫 번째 `value`를 찾습니다. 값이 발견되면 `index`, 발견되지 않으면 `-1`을 반환합니다.
  + `value`: 문자열, `Buffer`, Unit8Array 또는 0에서 255 사이의 정수를 입력합니다.
  + `byteOffset`: 선택 사항입니다. 정수를 입력합니다.
  + `encoding`: 선택 사항입니다. `value`가 문자열인 경우 `utf8`, `hex`, `base64`, `base64url` 중 하나를 입력합니다. 기본값은 `utf8`입니다.
+ `Buffer.prototype.lastIndexOf(value[, byteOffset][, encoding])`

  `Buffer`에서 마지막 `value`를 찾습니다. 값이 발견되면 `index`, 발견되지 않으면 `-1`을 반환합니다.
  + `value`: 문자열, `Buffer`, Unit8Array 또는 0에서 255 사이의 정수를 입력합니다.
  + `byteOffset`: 선택 사항입니다. 정수를 입력합니다.
  + `encoding`: 선택 사항입니다. `value`가 문자열인 경우 `utf8`, `hex`, `base64`, `base64url` 중 하나를 입력합니다. 기본값은 `utf8`입니다.
+ `Buffer.prototype.readInt8(offset)`

  `Buffer`의 `offset`에서 `Int8`을 읽습니다.
  + `offset`: 정수를 입력합니다.
+ `Buffer.prototype.readIntBE(offset, byteLength)`

  `Buffer`의 `offset`에서 `Int`를 빅 엔디안으로 읽습니다.
  + `offset`: 정수를 입력합니다.
  + `byteLength`: 선택 사항입니다. `1`에서 `6`까지의 정수를 입력합니다.
+ `Buffer.prototype.readInt16BE(offset)`

  `Buffer`의 `offset`에서 `Int16`을 빅 엔디안으로 읽습니다.
  + `offset`: 정수를 입력합니다.
+ `Buffer.prototype.readInt32BE(offset)`

  `Buffer`의 `offset`에서 `Int32`를 빅 엔디안으로 읽습니다.
  + `offset`: 정수를 입력합니다.
+ `Buffer.prototype.readIntLE(offset, byteLength)`

  `Buffer`의 `offset`에서 `Int`를 리틀 엔디안으로 읽습니다.
  + `offset`: 정수를 입력합니다.
  + `byteLength`: `1`에서 `6`까지의 정수를 입력합니다.
+ `Buffer.prototype.readInt16LE(offset)`

  `Buffer`의 `offset`에서 `Int16`을 리틀 엔디안으로 읽습니다.
  + `offset`: 정수를 입력합니다.
+ `Buffer.prototype.readInt32LE(offset)`

  `Buffer`의 `offset`에서 `Int32`을 리틀 엔디안으로 읽습니다.
  + `offset`: 정수를 입력합니다.
+ `Buffer.prototype.readUInt8(offset)`

  `Buffer`의 `offset`에서 `UInt8`을 읽습니다.
  + `offset`: 정수를 입력합니다.
+ `Buffer.prototype.readUIntBE(offset, byteLength)`

  `Buffer`의 `offset`에서 `UInt`를 빅 엔디안으로 읽습니다.
  + `offset`: 정수를 입력합니다.
  + `byteLength`: `1`에서 `6`까지의 정수를 입력합니다.
+ `Buffer.prototype.readUInt16BE(offset)`

  `Buffer`의 `offset`에서 `UInt16`을 빅 엔디안으로 읽습니다.
+ 
  + `offset`: 정수를 입력합니다.
+ `Buffer.prototype.readUInt32BE(offset)`

  `Buffer`의 `offset`에서 `UInt32`를 빅 엔디안으로 읽습니다.
  + `offset`: 정수를 입력합니다.
+ `Buffer.prototype.readUIntLE(offset, byteLength)`

  `Buffer`의 `offset`에서 `UInt`을 리틀 엔디안으로 읽습니다.
  + `offset`: 정수를 입력합니다.
  + `byteLength`: `1`에서 `6`까지의 정수를 입력합니다.
+ `Buffer.prototype.readUInt16LE(offset)`

  `Buffer`의 `offset`에서 `UInt16`을 리틀 엔디안으로 읽습니다.
  + `offset`: 정수를 입력합니다.
+ `Buffer.prototype.readUInt32LE(offset)`

  `Buffer`의 `offset`에서 `UInt32`을 리틀 엔디안으로 읽습니다.
  + `offset`: 정수를 입력합니다.
+ `Buffer.prototype.readDoubleBE([offset])`

  `Buffer`의 `offset`에서 64비트 배정도를 빅 엔디안으로 읽습니다.
  + `offset`: 선택 사항입니다. 정수를 입력합니다.
+ `Buffer.prototype.readDoubleLE([offset])`

  `Buffer`의 `offset`에서 64비트 배정도를 리틀 엔디안으로 읽습니다.
  + `offset`: 선택 사항입니다. 정수를 입력합니다.
+ `Buffer.prototype.readFloatBE([offset])`

  `Buffer`의 `offset`에서 32비트 부동소수점을 빅 엔디안으로 읽습니다.
  + `offset`: 선택 사항입니다. 정수를 입력합니다.
+ `Buffer.prototype.readFloatLE([offset])`

  `Buffer`의 `offset`에서 32비트 부동소수점을 리틀 엔디안으로 읽습니다.
  + `offset`: 선택 사항입니다. 정수를 입력합니다.
+ `Buffer.prototype.subarray([start[, end]])`

  오프셋되고 새 `start` 및 `end`로 크롭된 `Buffer`의 복사본을 반환합니다.
  + `start`: 선택 사항입니다. 정수를 입력합니다. 기본값은 0.
  + `end`: 선택 사항입니다. 정수를 입력합니다. 기본값은 버퍼 길이입니다.
+ `Buffer.prototype.swap16()`

  `Buffer` 배열을 16비트 숫자로 구성된 배열로 취급하여 바이트 순서를 바꿉니다. `Buffer` 길이는 2로 나눌 수 있어야 합니다. 그렇지 않으면 오류가 발생합니다.
+ `Buffer.prototype.swap32()`

  `Buffer` 배열을 32비트 숫자로 구성된 배열로 취급하여 바이트 순서를 바꿉니다. `Buffer` 길이는 4로 나눌 수 있어야 합니다. 그렇지 않으면 오류가 발생합니다.
+ `Buffer.prototype.swap64()`

  `Buffer` 배열을 64비트 숫자로 구성된 배열로 취급하여 바이트 순서를 바꿉니다. `Buffer` 길이는 8로 나눌 수 있어야 합니다. 그렇지 않으면 오류가 발생합니다.
+ `Buffer.prototype.toJSON()`

  `Buffer`를 JSON으로 반환합니다.
+ `Buffer.prototype.toString([encoding[, start[, end]]])`

  `start`에서 `end`로, 인코딩된 문자열로 `Buffer`를 변환합니다.
  + `encoding`: 선택 사항입니다. `utf8`, `hex`, `base64`, `base64url` 중 하나를 입력합니다. 기본값은 `utf8`입니다.
  + `start`: 선택 사항입니다. 정수를 입력합니다. 기본값은 0.
  + `end`: 선택 사항입니다. 정수를 입력합니다. 기본값은 버퍼 길이입니다.
+ `Buffer.prototype.write(string[, offset[, length]][, encoding])`

  공간이 있는 경우 인코딩된 `string`을 `Buffer`에 쓰고, 공간이 충분하지 않으면 잘라낸 `string`을 씁니다.
  + `string`: 문자열을 입력합니다.
  + `offset`: 선택 사항입니다. 정수를 입력합니다. 기본값은 0.
  + `length`: 선택 사항입니다. 정수를 입력합니다. 기본값은 문자열 길이입니다.
  + `encoding`: 선택 사항입니다. 필요에 따라 `utf8`, `hex`, `base64`, `base64url` 중 하나를 입력합니다. 기본값은 `utf8`입니다.
+ `Buffer.prototype.writeInt8(value, offset, byteLength)`

  `offset`에서 `byteLength`의 `Int8` `value`를 `Buffer`에 씁니다.
  + `value`: 정수를 입력합니다.
  + `offset`: 정수를 입력합니다.
  + `byteLength`: `1`에서 `6`까지의 정수를 입력합니다.
+ `Buffer.prototype.writeIntBE(value, offset, byteLength)`

  빅 엔디안을 사용하여 `offset`에서 `value`를 `Buffer`에 씁니다.
  + `value`: 정수를 입력합니다.
  + `offset`: 정수를 입력합니다.
  + `byteLength`: `1`에서 `6`까지의 정수를 입력합니다.
+ `Buffer.prototype.writeInt16BE(value, offset, byteLength)`

  빅 엔디안을 사용하여 `offset`에서 `value`를 `Buffer`에 씁니다.
  + `value`: 정수를 입력합니다.
  + `offset`: 정수를 입력합니다.
  + `byteLength`: `1`에서 `6`까지의 정수를 입력합니다.
+ `Buffer.prototype.writeInt32BE(value, offset, byteLength)`

  빅 엔디안을 사용하여 `offset`에서 `value`를 `Buffer`에 씁니다.
  + `value`: 정수를 입력합니다.
  + `offset`: 정수를 입력합니다.
  + `byteLength`: `1`에서 `6`까지의 정수를 입력합니다.
+ `Buffer.prototype.writeIntLE(offset, byteLength)`

  리틀 엔디안을 사용하여 `offset`에서 `value`를 `Buffer`에 씁니다.
  + `offset`: 정수를 입력합니다.
  + `byteLength`: `1`에서 `6`까지의 정수를 입력합니다.
+ `Buffer.prototype.writeInt16LE(offset, byteLength)`

  리틀 엔디안을 사용하여 `offset`에서 `value`를 `Buffer`에 씁니다.
  + `offset`: 정수를 입력합니다.
  + `byteLength`: `1`에서 `6`까지의 정수를 입력합니다.
+ `Buffer.prototype.writeInt32LE(offset, byteLength)`

  리틀 엔디안을 사용하여 `offset`에서 `value`를 `Buffer`에 씁니다.
  + `offset`: 정수를 입력합니다.
  + `byteLength`: `1`에서 `6`까지의 정수를 입력합니다.
+ `Buffer.prototype.writeUInt8(value, offset, byteLength)`

  `offset`에서 `byteLength`의 `UInt8` `value`를 `Buffer`에 씁니다.
  + `value`: 정수를 입력합니다.
  + `offset`: 정수를 입력합니다.
  + `byteLength`: `1`에서 `6`까지의 정수를 입력합니다.
+ `Buffer.prototype.writeUIntBE(value, offset, byteLength)`

  빅 엔디안을 사용하여 `offset`에서 `value`를 `Buffer`에 씁니다.
  + `value`: 정수를 입력합니다.
  + `offset`: 정수를 입력합니다.
  + `byteLength`: `1`에서 `6`까지의 정수를 입력합니다.
+ `Buffer.prototype.writeUInt16BE(value, offset, byteLength)`

  빅 엔디안을 사용하여 `offset`에서 `value`를 `Buffer`에 씁니다.
  + `value`: 정수를 입력합니다.
  + `offset`: 정수를 입력합니다.
  + `byteLength`: `1`에서 `6`까지의 정수를 입력합니다.
+ `Buffer.prototype.writeUInt32BE(value, offset, byteLength)`

  빅 엔디안을 사용하여 `offset`에서 `value`를 `Buffer`에 씁니다.
  + `value`: 정수를 입력합니다.
  + `offset`: 정수를 입력합니다.
  + `byteLength`: `1`에서 `6`까지의 정수를 입력합니다.
+ `Buffer.prototype.writeUIntLE(value, offset, byteLength)`

  리틀 엔디안을 사용하여 `offset`에서 `value`를 `Buffer`에 씁니다.
  + `value`: 정수를 입력합니다.
  + `offset`: 정수를 입력합니다.
  + `byteLength`: `1`에서 `6`까지의 정수를 입력합니다.
+ `Buffer.prototype.writeUInt16LE(value, offset, byteLength)`

  리틀 엔디안을 사용하여 `offset`에서 `value`를 `Buffer`에 씁니다.
  + `value`: 정수를 입력합니다.
  + `offset`: 정수를 입력합니다.
  + `byteLength`: `1`에서 `6`까지의 정수를 입력합니다.
+ `Buffer.prototype.writeUInt32LE(value, offset, byteLength)`

  리틀 엔디안을 사용하여 `offset`에서 `value`를 `Buffer`에 씁니다.
  + `value`: 정수를 입력합니다.
  + `offset`: 정수를 입력합니다.
  + `byteLength`: `1`에서 `6`까지의 정수를 입력합니다.
+ `Buffer.prototype.writeDoubleBE(value, [offset])`

  빅 엔디안을 사용하여 `offset`에서 `value`를 `Buffer`에 씁니다.
  + `value`: 정수를 입력합니다.
  + `offset`: 선택 사항입니다. 정수를 입력합니다. 기본값은 0.
+ `Buffer.prototype.writeDoubleLE(value, [offset])`

  리틀 엔디안을 사용하여 `offset`에서 `value`를 `Buffer`에 씁니다.
  + `value`: 정수를 입력합니다.
  + `offset`: 선택 사항입니다. 정수를 입력합니다. 기본값은 0.
+ `Buffer.prototype.writeFloatBE(value, [offset])`

  빅 엔디안을 사용하여 `offset`에서 `value`를 `Buffer`에 씁니다.
  + `value`: 정수를 입력합니다.
  + `offset`: 선택 사항입니다. 정수를 입력합니다. 기본값은 0.
+ `Buffer.prototype.writeFloatLE(value, [offset])`

  리틀 엔디안을 사용하여 `offset`에서 `value`를 `Buffer`에 씁니다.
  + `value`: 정수를 입력합니다.
  + `offset`: 선택 사항입니다. 정수를 입력합니다. 기본값은 0.

다음 인스턴스 메서드가 지원됩니다.
+ `buffer[index]`

  `Buffer`에 `index`의 8진수(바이트)를 가져와 설정합니다.
  + `0`에서 `255`의 숫자를 가져옵니다. 또는 `0`부터 `255`까지의 숫자를 설정할 수도 있습니다.

다음 인스턴스 속성이 지원됩니다.
+ `buffer`

  버퍼의 `ArrayBuffer` 객체를 가져옵니다.
+ `byteOffset`

  버퍼의 `Arraybuffer` 객체에 대한 `byteOffset`을 가져옵니다.
+ `length`

  버퍼 바이트 수를 가져옵니다.

**참고**  
모든 버퍼 모듈 메서드가 JavaScript 런타임 2.0에 새로 추가되었습니다.

### 쿼리 문자열
<a name="writing-functions-javascript-features-builtin-modules-query-string-20"></a>

**참고**  
[CloudFront 함수 이벤트 객체](functions-event-structure.md)는 URL 쿼리 문자열을 자동으로 구문 분석합니다. 즉, 대부분의 경우 이 모듈을 사용할 필요가 없습니다.

쿼리 문자열 모듈(`querystring`)은 URL 쿼리 문자열을 구문 분석하고 서식을 지정하는 메서드를 제공합니다. `require('querystring')`을 사용하여 모듈을 로드할 수 있습니다. 이 모듈은 다음과 같은 방법을 제공합니다.

`querystring.escape(string)`  
지정된 `string`을 URL-인코딩하여 이스케이프된 쿼리 문자열을 반환합니다. 이 방법은 `querystring.stringify()`에서 사용되며 직접 사용해서는 안 됩니다.

`querystring.parse(string[, separator[, equal[, options]]])`  
쿼리 문자열(`string`)을 구문 분석하고 객체를 반환합니다.  
`separator` 파라미터는 쿼리 문자열에서 키와 값 페어를 구분하기 위한 하위 문자열입니다. 기본 설정은 `&`입니다.  
`equal` 파라미터는 쿼리 문자열에서 키와 값을 구분하기 위한 하위 문자열입니다. 기본 설정은 `=`입니다.  
`options` 파라미터는 다음 키를 가진 객체입니다.    
`decodeURIComponent function`  
쿼리 문자열에서 백분율로 인코딩된 문자를 디코딩하는 함수입니다. 기본 설정은 `querystring.unescape()`입니다.  
`maxKeys number`  
구문 분석할 최대 키 수입니다. 기본 설정은 `1000`입니다. `0` 값을 사용하여 키 카운트 제한을 제거합니다.
기본적으로 쿼리 문자열 내의 백분율로 인코딩된 문자는 UTF-8 인코딩을 사용하는 것으로 간주됩니다. 잘못된 UTF-8 시퀀스는 `U+FFFD` 대체 문자로 대체됩니다.  
예를 들어 다음 쿼리 문자열의 경우:  

```
'name=value&abc=xyz&abc=123'
```
`querystring.parse()`의 반환 값:  

```
{
name: 'value',
abc: ['xyz', '123']
}
```
`querystring.decode()`는 `querystring.parse()`의 별칭입니다.

`querystring.stringify(object[, separator[, equal[, options]]])`  
`object`를 직렬화하고 쿼리 문자열을 반환합니다.  
`separator` 파라미터는 쿼리 문자열에서 키와 값 쌍을 구분하기 위한 하위 문자열입니다. 기본 설정은 `&`입니다.  
`equal` 파라미터는 쿼리 문자열에서 키와 값을 구분하기 위한 하위 문자열입니다. 기본 설정은 `=`입니다.  
`options` 파라미터는 다음 키를 가진 객체입니다.    
`encodeURIComponent function`  
URL에 안전하지 않은 문자를 쿼리 문자열에서 백분율 인코딩으로 변환하는 데 사용할 함수입니다. 기본 설정은 `querystring.escape()`입니다.
기본적으로 쿼리 문자열 내에서 백분율 인코딩이 필요한 문자는 UTF-8로 인코딩됩니다. 다른 인코딩을 사용하려면 `encodeURIComponent` 옵션을 지정합니다.  
예를 들어, 다음 코드의 경우:  

```
querystring.stringify({ name: 'value', abc: ['xyz', '123'], anotherName: '' });
```
반환 값:  

```
'name=value&abc=xyz&abc=123&anotherName='
```
`querystring.encode()`는 `querystring.stringify()`의 별칭입니다.

`querystring.unescape(string)`  
지정된 `string`의 URL 백분율로 인코딩된 문자를 디코딩하여 이스케이프되지 않은 쿼리 문자열을 반환합니다. 이 방법은 `querystring.parse()`에서 사용되며 직접 사용해서는 안 됩니다.

### crypto
<a name="writing-functions-javascript-features-builtin-modules-crypto-20"></a>

암호화 모듈(`crypto`)은 표준 해싱 및 HMAC(해시 기반 메시지 인증 코드) 헬퍼를 제공합니다. `require('crypto')`을(를) 사용하여 모듈을 로드할 수 있습니다.

**해싱 메서드**

`crypto.createHash(algorithm)`  
지정된 알고리즘(`md5`, `sha1` 또는 `sha256`)을 사용하여 해시 다이제스트를 생성하는 데 사용할 수 있는 해시 객체를 생성하고 반환합니다.

`hash.update(data)`  
지정된 `data`(으)로 해시 콘텐츠를 업데이트합니다.

`hash.digest([encoding])`  
`hash.update()`을(를) 사용하여 전달된 모든 데이터의 다이제스트를 계산합니다. 인코딩은 `hex`, `base64` 또는 `base64url`일 수 있습니다.

**HMAC 메서드**

`crypto.createHmac(algorithm, secret key)`  
지정된 `algorithm` 및 `secret key`을(를) 사용하는 HMAC 객체를 생성 및 반환합니다. 알고리즘은 `md5`, `sha1` 또는 `sha256`일 수 있습니다.

`hmac.update(data)`  
지정된 `data`(으)로 HMAC 콘텐츠를 업데이트합니다.

`hmac.digest([encoding])`  
`hmac.update()`을(를) 사용하여 전달된 모든 데이터의 다이제스트를 계산합니다. 인코딩은 `hex`, `base64` 또는 `base64url`일 수 있습니다.

## 제한된 기능
<a name="writing-functions-javascript-features-restricted-features-20"></a>

다음 JavaScript 언어 기능은 보안 문제로 인해 지원되지 않거나 제한됩니다.

**동적 코드 평가**  
동적 코드 평가는 지원되지 않습니다. 시도하면 `eval()` 및 `Function` 생성자 모두 오류가 발생합니다. 예를 들어 `const sum = new Function('a', 'b', 'return a + b')`에서 오류가 발생합니다.

**타이머**  
`setTimeout()`, `setImmediate()` 및 `clearTimeout()` 함수는 지원되지 않습니다. 함수 실행 내에서 연기하거나 출력할 프로비전이 없습니다. 함수가 완료되려면 동기적으로 실행되어야 합니다.

**날짜 및 타임스탬프**  
보안상의 이유로 고해상도 타이머에 액세스할 수 없습니다. 현재 시간을 쿼리하는 모든 `Date` 메서드는 단일 함수 실행의 수명 동안 항상 동일한 값을 반환합니다. 반환된 타임 스탬프는 함수가 실행을 시작한 시간입니다. 따라서 함수에서 경과 시간을 측정할 수 없습니다.

**파일 시스템 액세스**  
파일 시스템 액세스가 없습니다. 예를 들어 Node.js에서처럼 파일 시스템 액세스를 위한 `fs` 모듈이 없습니다.

**프로세스 액세스**  
프로세스 액세스가 없습니다. 예를 들어 Node.js와는 달리 정보 액세스를 처리하기 위한 `process` 글로벌 객체가 없습니다.

**환경 변수**  
환경 변수에 액세스할 수 없습니다. 대신 CloudFront KeyValueStore를 사용하여 CloudFront Functions에 대한 키 값 페어의 중앙 집중식 데이터 스토어를 생성할 수 있습니다. CloudFront KeyValueStore를 사용하면 코드 변경 사항을 배포할 필요 없이 구성 데이터를 동적으로 업데이트할 수 있습니다. 자세한 내용은 [Amazon CloudFront KeyValueStore](kvs-with-functions.md) 섹션을 참조하세요.

**네트워크 액세스**  
네트워크 통화에 대한 지원이 없습니다. 예를 들어 XHR, HTTP(S) 및 소켓은 지원되지 않습니다.