초안 ECMA-262 / 2026년 10월 24일 ECMAScript® 2027 언어 명세
소개
이 Ecma 표준은 ECMAScript 2027 언어를 정의합니다. 이 문서는 ECMAScript 언어 명세의 제18판입니다. ECMAScript는 여러 초기 기술을 기반으로 하며, 그중 가장 잘 알려진 기술은 JavaScript(Netscape)와 JScript(Microsoft)입니다. 이 언어는 Netscape의 Brendan Eich가 만들었으며, 해당 회사의 Navigator 2.0 브라우저에서 처음 등장했습니다. 웹 브라우저에 내장된 언어로 가장 잘 알려져 있지만, 서버 및 임베디드 애플리케이션을 포함하여 브라우저 외부에서도 널리 채택되었으며, 세계에서 가장 널리 사용되는 범용 프로그래밍 언어 중 하나로 성장했습니다.
ECMAScript 언어 명세의 개발은 1996년 11월에 시작되었습니다. 이 Ecma 표준의 초판은 1997년 6월 Ecma 총회에서 채택되었습니다.
이 Ecma 표준은 신속 처리 절차에 따라 채택되도록 ISO/IEC JTC 1에 제출되었으며, 1998년 4월에 국제 표준 ISO/IEC 16262로 승인되었습니다. 1998년 6월 Ecma 총회는 ISO/IEC 16262와 완전히 일치하도록 ECMA-262 제2판을 승인했습니다. 초판과 제2판 사이의 변경 사항은 편집상의 변경입니다.
이 표준의 제3판에는 강력한 정규 표현식, 향상된 문자열 처리, 새로운 제어문, try/catch 예외 처리, 더욱 엄밀한 오류 정의, 숫자 출력 형식 지정 및 향후 언어의 발전을 고려한 사소한 변경 사항이 도입되었습니다. ECMAScript 표준 제3판은 1999년 12월 Ecma 총회에서 채택되었으며, 2002년 6월에 ISO/IEC 16262:2002로 발행되었습니다.
제3판이 발행된 후 ECMAScript는 월드 와이드 웹과 함께 광범위하게 채택되어 사실상 모든 웹 브라우저에서 지원하는 프로그래밍 언어가 되었습니다. ECMAScript 제4판을 개발하기 위해 상당한 작업이 이루어졌습니다. 그러나 해당 작업은 완료되지 않았고 ECMAScript 제4판으로 발행되지도 않았으며, 그 일부가 제6판의 개발에 반영되었습니다.
ECMAScript 제5판(ECMA-262 제5판 으로 발행)은 브라우저 구현체 사이에서 보편화된 언어 명세의 사실상 해석을 명문화하고, 제3판 발행 이후 등장한 새로운 기능에 대한 지원을 추가했습니다. 이러한 기능에는 접근자 프로퍼티 , 리플렉션을 통한 객체 생성 및 검사, 프로퍼티 속성에 대한 프로그램 제어, 추가 배열 조작 함수, JSON 객체 인코딩 형식 지원 및 향상된 오류 검사와 프로그램 보안을 제공하는 엄격 모드가 포함됩니다. 제5판은 2009년 12월 Ecma 총회에서 채택되었습니다.
제5판은 신속 처리 절차에 따라 채택되도록 ISO/IEC JTC 1에 제출되었으며, 국제 표준 ISO/IEC 16262:2011로 승인되었습니다. ECMAScript 표준 제5.1판에는 사소한 수정 사항이 반영되었으며, ISO/IEC 16262:2011과 동일한 내용을 담고 있습니다. 제5.1판은 2011년 6월 Ecma 총회에서 채택되었습니다.
제6판에 대한 본격적인 개발은 제5판의 발행을 준비하던 2009년에 시작되었습니다. 그러나 이에 앞서 1999년 제3판의 발행 시점부터 상당한 실험과 언어 개선 설계 작업이 이루어졌습니다. 실질적으로 제6판의 완성은 15년에 걸친 노력의 결실입니다. 이 판의 목표에는 대규모 애플리케이션과 라이브러리 제작에 대한 지원을 개선하고, ECMAScript를 다른 언어의 컴파일 대상으로 사용하는 데 대한 지원을 개선하는 것이 포함되었습니다. 주요 개선 사항에는 모듈, 클래스 선언, 렉시컬 블록 스코프, 이터레이터와 제너레이터, 비동기 프로그래밍을 위한 프로미스, 구조 분해 패턴 및 적절한 꼬리 호출이 포함되었습니다. ECMAScript 내장 라이브러리는 맵, 집합, 이진 숫자 값의 배열을 포함한 추가 데이터 추상화를 지원하도록 확장되었으며, 문자열과 정규 표현식에서 유니코드 보충 문자에 대한 지원도 추가되었습니다. 내장 기능은 서브클래싱을 통해 확장할 수 있게 되었습니다. 제6판은 언어와 라이브러리를 정기적으로 점진적으로 개선하기 위한 토대를 제공합니다. 제6판은 2015년 6월 총회에서 채택되었습니다.
ECMAScript 2016은 Ecma TC39의 새로운 연간 릴리스 주기와 공개 개발 절차에 따라 출시된 최초의 ECMAScript 판입니다. 이후의 모든 개발을 GitHub에서 진행하기 위한 기반으로 삼기 위해 ECMAScript 2015 소스 문서로부터 일반 텍스트 소스 문서를 만들었습니다. 이 표준이 개발된 1년 동안 수천 건의 버그 수정, 편집 수정 및 기타 개선 사항에 해당하는 수백 건의 풀 리퀘스트와 이슈가 등록되었습니다. 또한 이러한 작업을 지원하기 위해 Ecmarkup, Ecmarkdown, Grammarkdown을 비롯한 다양한 소프트웨어 도구가 개발되었습니다. ES2016에는 새로운 거듭제곱 연산자에 대한 지원도 포함되었으며, Array.prototype에 includes라는 새로운 메서드가 추가되었습니다.
ECMAScript 2017에는 소규모 언어 및 라이브러리 개선, 버그 수정, 편집상의 갱신과 함께 비동기 함수, 공유 메모리 및 원자적 연산이 도입되었습니다. 비동기 함수는 프로미스를 반환하는 함수를 위한 구문을 제공하여 비동기 프로그래밍 경험을 개선합니다. 공유 메모리와 원자적 연산은 병렬 CPU에서도 명확히 정의된 실행 순서를 보장하는 원자적 연산을 사용하여 여러 에이전트 로 구성된 프로그램이 통신할 수 있도록 하는 새로운 메모리 모델 을 도입합니다. Object에 새로운 정적 메서드인 Object.values, Object.entries, Object.getOwnPropertyDescriptors도 추가되었습니다.
ECMAScript 2018에는 비동기 이터레이터 프로토콜과 비동기 제너레이터를 통한 비동기 반복 지원이 도입되었습니다. 또한 네 가지 새로운 정규 표현식 기능인 dotAll 플래그, 이름 있는 캡처 그룹, 유니코드 프로퍼티 이스케이프 및 후방 탐색 단언 이 포함되었습니다. 마지막으로 객체의 나머지 프로퍼티와 전개 프로퍼티가 포함되었습니다.
ECMAScript 2019에는 몇 가지 새로운 내장 함수가 도입되었습니다. 배열을 평탄화하기 위한 Array.prototype의 flat과 flatMap, Object.entries의 반환값을 새 Object로 직접 변환하기 위한 Object.fromEntries, 널리 구현되어 있지만 비표준인 내장 함수 String.prototype.trimLeft와 trimRight를 더 적절한 이름으로 대체하는 String.prototype의 trimStart와 trimEnd가 포함되었습니다. 또한 구문과 의미에 대한 몇 가지 사소한 갱신이 포함되었습니다. 구문 갱신에는 선택적인 catch 바인딩 매개변수와 JSON에 맞추기 위한 문자열 리터럴 내 U+2028(줄 구분자) 및 U+2029(문단 구분자)의 허용이 포함되었습니다. 다른 갱신 사항에는 Array.prototype.sort가 안정 정렬을 수행하도록 하는 요구 사항, JSON.stringify가 입력과 관계없이 올바른 형식의 UTF-8을 반환하도록 하는 요구 사항, Function.prototype.toString이 해당하는 원래 소스 텍스트 또는 표준 자리표시자 중 하나를 반환하도록 하여 그 동작을 명확히 하는 사항이 포함되었습니다.
ECMAScript 2020은 제11판 으로, 전역 정규 표현식에서 생성된 모든 일치 객체에 대한 이터레이터를 생성하는 String의 matchAll 메서드; 동적 지정자를 사용하여 모듈을 비동기적으로 가져오는 구문인 import(); 임의 정밀도 정수 를 다루기 위한 새로운 숫자 원시형인 BigInt; 단락 평가하지 않는 새로운 Promise 조합자인 Promise.allSettled; 전역 this 값에 접근하는 범용적인 방법인 globalThis; 모듈 내부에서 사용하는 전용 export * as ns from 'module' 구문; for-in 열거 순서의 표준화 확대; 모듈에서 사용할 수 있으며 호스트 가 내용을 채우고 모듈에 관한 문맥 정보를 포함할 수 있는 객체인 import.meta를 도입했습니다. 또한 “nullish” 값(undefined 또는 null )을 더 편리하게 다루기 위한 두 가지 새로운 구문 기능인 값 선택 연산자 nullish 병합과, 접근하거나 호출할 값이 nullish이면 단락 평가하는 프로퍼티 접근 및 함수 호출 연산자 옵셔널 체이닝이 추가되었습니다.
ECMAScript 2021은 제12판 으로, String의 replaceAll 메서드; 입력값이 이행되면 단락 평가하는 Promise 조합자인 Promise.any; 여러 오류를 한 번에 나타내는 새로운 Error 유형인 AggregateError; 논리 할당 연산자(??=, &&=, ||=); 대상 객체가 가비지 컬렉션으로부터 유지되도록 하지 않으면서 해당 객체를 참조하는 WeakRef와, 대상 객체가 가비지 컬렉션될 때 수행되는 정리 작업의 등록 및 등록 해제를 관리하는 FinalizationRegistry; 숫자 리터럴의 구분자(1_000)를 도입했습니다. 또한 Array.prototype.sort가 더 정밀하게 정의되어 구현체 정의 정렬 순서 가 발생하는 경우의 수가 줄었습니다.
ECMAScript 2022는 제13판 으로, 모듈의 최상위 수준에서 해당 키워드 를 사용할 수 있게 하는 최상위 await; 새로운 클래스 요소인 공개 및 비공개 인스턴스 필드, 공개 및 비공개 정적 필드, 비공개 인스턴스 메서드와 접근자, 비공개 정적 메서드와 접근자; 클래스별 평가 초기화를 수행하는 클래스 내부의 정적 블록; 객체에 비공개 필드가 있는지 검사하는 #x in obj 구문; 일치한 부분 문자열 의 시작 및 끝 인덱스를 제공하는 /d 플래그를 통한 정규 표현식 일치 인덱스; 오류의 원인 연결 관계를 기록하는 데 사용할 수 있는 Error 객체의 cause 프로퍼티; 상대 인덱싱을 허용하는 String, Array 및 TypedArray 의 at 메서드; Object.prototype.hasOwnProperty를 편리하게 대체하는 Object.hasOwn을 도입했습니다.
ECMAScript 2023은 제14판 으로, Array.prototype과 TypedArray.prototype의 toSorted, toReversed, with, findLast, findLastIndex 메서드 및 Array.prototype의 toSpliced 메서드를 도입했습니다. 실행 가능한 ECMAScript 파일을 더 편리하게 만들 수 있도록 파일 시작 부분의 #! 주석에 대한 지원을 추가했으며, 대부분의 Symbol을 약한 컬렉션의 키로 사용할 수 있도록 허용했습니다.
ECMAScript 2024는 제15판 으로, ArrayBuffer와 SharedArrayBuffer의 크기를 조정하고 전송하는 기능을 추가했습니다. 문자열 집합을 다루는 고급 기능을 갖춘 RegExp를 생성하기 위한 새로운 RegExp /v 플래그를 추가했습니다. 또한 Promise를 구성하기 위한 편의 메서드 Promise.withResolvers, 데이터를 집계하기 위한 Object.groupBy와 Map.groupBy 메서드, 공유 메모리의 변경을 비동기적으로 기다리기 위한 Atomics.waitAsync 메서드, 문자열에 올바른 형식의 유니코드만 포함되는지 검사하고 이를 보장하기 위한 String.prototype.isWellFormed와 String.prototype.toWellFormed 메서드를 도입했습니다.
ECMAScript 2025는 제16판 으로, 이터레이터를 다루기 위한 관련 정적 메서드와 프로토타입 메서드를 갖춘 새로운 전역 Iterator를 추가했습니다. Set에 대한 일반적인 연산을 수행하기 위한 메서드를 Set.prototype에 추가했습니다. JSON 모듈 가져오기에 대한 지원과 가져오는 모듈의 속성을 선언하기 위한 구문을 추가했습니다. 문자열을 정규 표현식에서 안전하게 사용할 수 있도록 이스케이프하는 RegExp.escape 메서드를 추가했습니다. 정규 표현식 내부에서 수정자 플래그를 인라인으로 활성화하거나 비활성화하는 구문을 추가했습니다. Promise를 반환할 수도 있고 반환하지 않을 수도 있는 함수를 호출하면서 결과가 항상 Promise가 되도록 보장하는 Promise.try 메서드를 추가했습니다. 또한 새로운 TypedArray 종류인 Float16Array와 관련 메서드 DataView.prototype.getFloat16, DataView.prototype.setFloat16, Math.f16round를 추가했습니다.
ECMAScript 2026은 제17판 으로, 정밀도 손실을 최소화하면서 크기가 서로 다른 Number의 이터러블을 합산하는 Math.sumPrecise; 이터레이터를 순서대로 연결하는 Iterator.concat; 비동기 이터러블 및 기타 비동기 소스로부터 Array를 구성하는 Array.fromAsync; 오류 객체를 식별하는 Error.isError; 키가 아직 존재하지 않을 때 조회 시 사용할 기본값을 제공하기 위한 Map.prototype과 WeakMap.prototype의 메서드; 16진수 및 base64로 인코딩된 이진 데이터의 String으로 변환하거나 그로부터 변환하기 위한 Uint8Array의 메서드; 일치하는 JSON 소스 구간 에 접근하기 위한 JSON.parse reviver의 매개변수; 원시값에 대한 JSON.stringify 출력을 세밀하게 제어하기 위한 JSON.rawJSON을 추가했습니다.
여러 조직을 대표하는 수십 명의 개인이 Ecma TC39에서 이 판과 이전 판의 개발에 매우 중요한 기여를 했습니다. 또한 TC39의 ECMAScript 관련 활동을 지원하는 활발한 커뮤니티가 형성되었습니다. 이 커뮤니티는 수많은 초안을 검토하고, 수천 건의 버그 보고서를 제출하고, 구현 실험을 수행하고, 테스트 모음을 기여하고, 전 세계 개발자 커뮤니티에 ECMAScript를 교육했습니다. 안타깝게도 이 작업에 기여한 모든 개인과 조직을 확인하여 감사를 표하는 것은 불가능합니다.
Allen Wirfs-Brock
ECMA-262, 프로젝트 편집자, 제6판
Brian Terlson
ECMA-262, 프로젝트 편집자, 제7판 부터 제10판 까지
Jordan Harband
ECMA-262, 프로젝트 편집자, 제10판 부터 제12판 까지
Kevin Gibbons
ECMA-262, 프로젝트 편집자, 제12판 부터 제17판 까지
Shu-yu Guo
ECMA-262, 프로젝트 편집자, 제12판 부터 제18판 까지
Michael Ficarra
ECMA-262, 프로젝트 편집자, 제12판 부터 제18판 까지
Richard Gibson
ECMA-262, 프로젝트 편집자, 제18판
Ron Buckton
ECMA-262, 프로젝트 편집자, 제18판
Nicolò Ribaudo
ECMA-262, 프로젝트 편집자, 제18판
Linus Groh
ECMA-262, 프로젝트 편집자, 제18판
1 범위
이 표준은 범용 프로그래밍 언어인 ECMAScript 2027을 정의합니다.
2 적합성
ECMAScript의 적합한 구현체는 이 명세에 기술된 모든 타입, 값, 객체, 프로퍼티, 함수 및 프로그램의 구문과 의미를 제공하고 지원해야 합니다.
ECMAScript의 적합한 구현체는 최신 버전의 유니코드 표준과 ISO/IEC 10646에 따라 소스 텍스트 입력을 해석해야 합니다.
서로 다른 자연어와 국가에서 사용하는 언어적·문화적 관례에 맞춰야 하는 프로그램을 지원하는 애플리케이션 프로그래밍 인터페이스(API)를 제공하는 ECMAScript의 적합한 구현체는 이 명세와 호환되는 최신 ECMA-402 판에 정의된 인터페이스를 구현해야 합니다.
ECMAScript의 적합한 구현체는 이 명세에 기술된 것 외에 추가적인 타입, 값, 객체, 프로퍼티 및 함수를 제공할 수 있습니다. 특히 ECMAScript의 적합한 구현체는 이 명세에 기술된 객체에 대해 이 명세에 기술되지 않은 프로퍼티와 해당 프로퍼티의 값을 제공할 수 있습니다.
ECMAScript의 적합한 구현체는 이 명세에 기술되지 않은 프로그램 구문과 정규 표현식 구문을 지원할 수 있습니다. 특히 ECMAScript의 적합한 구현체는 이 명세의 하위 절 12.7.2 에 명시된 “미래 예약어 ”를 사용하는 프로그램 구문을 지원할 수 있습니다.
ECMAScript의 적합한 구현체는 하위 절 17.1 에서 금지된 확장으로 나열된 확장을 구현해서는 안 됩니다.
ECMAScript의 적합한 구현체는 구현체 정의 , 구현체 근사 또는 호스트 정의 가 아닌 기능을 재정의해서는 안 됩니다.
ECMAScript의 적합한 구현체는 달리 명시되지 않는 한 규범적 선택 사항 인 하위 절의 구현 여부를 선택할 수 있습니다. 웹 브라우저는 일반적으로 모든 규범적 선택 사항 하위 절을 구현해야 합니다. (부속서 B 를 참조하시기 바랍니다.) 규범적 선택 사항인 동작을 하나라도 구현하는 경우, 해당 동작을 포함하는 규범적 선택 사항 절의 모든 동작을 구현해야 합니다. 이 명세에서는 아래와 같이 색상이 있는 상자 안에 “규범적 선택 사항”이라는 문구를 표시하여 규범적 선택 사항 절을 나타냅니다.
규정 선택 사항
2.1 규범적 선택 사항 절 제목 예시
절 내용 예시입니다.
ECMAScript의 적합한 구현체는 규범적 선택 사항으로도 표시된 경우가 아니라면 레거시 하위 절을 구현해야 합니다. 레거시 하위 절에 명시된 모든 언어 기능과 동작에는 바람직하지 않은 특성이 하나 이상 있습니다. 그러나 기존 애플리케이션에서 계속 사용되고 있으므로 이 명세에서 제거할 수 없습니다. 이러한 기능은 ECMAScript 핵심 언어의 일부로 간주되지 않습니다. 프로그래머는 새로운 ECMAScript 코드를 작성할 때 이러한 기능과 동작을 사용하거나 그 존재를 가정하지 않는 것이 좋습니다.
2.2 레거시 절 제목 예시
절 내용 예시입니다.
2.3 레거시 규범적 선택 사항 절 제목 예시
절 내용 예시입니다.
3 규범적 참고 문헌
다음의 참조 문서는 이 문서를 적용하는 데 필수적입니다. 날짜가 명시된 참조의 경우 인용된 판만 적용됩니다. 날짜가 명시되지 않은 참조의 경우 참조 문서의 최신판(모든 개정 사항 포함)이 적용됩니다.
IEEE 754-2019 , 부동소수점 산술에 관한 IEEE 표준 .
유니코드 표준.
https://unicode.org/versions/latest
ISO/IEC 10646, 정보 기술 — 범용 다중 옥텟 부호화 문자 집합(UCS) 및 개정 1:2005, 개정 2:2006, 개정 3:2008, 개정 4:2008과 추가 개정 사항 및 정오표, 또는 후속 표준.
ECMA-402, ECMAScript 국제화 API 명세 , 구체적으로는 이 명세의 해당 판에 대응하는 연간 판.
https://www.ecma-international.org/publications-and-standards/standards/ecma-402/
ECMA-404, JSON 데이터 교환 형식 .
https://www.ecma-international.org/publications-and-standards/standards/ecma-404/
4 개요
이 절에는 ECMAScript 언어에 대한 비규범적 개요가 포함되어 있습니다.
ECMAScript는 호스트 환경 내에서 계산을 수행하고 계산 객체를 조작하기 위한 객체 지향 프로그래밍 언어입니다. 여기에서 정의하는 ECMAScript는 계산에 필요한 모든 기능을 자체적으로 제공하도록 설계되지 않았습니다. 실제로 이 명세에는 외부 데이터의 입력이나 계산 결과의 출력을 위한 규정이 없습니다. 대신 ECMAScript 프로그램의 계산 환경은 이 명세에 기술된 객체와 기타 기능뿐 아니라 특정 환경에 고유한 객체도 제공할 것으로 기대됩니다. 이러한 객체의 설명과 동작은 ECMAScript 프로그램에서 접근할 수 있는 특정 프로퍼티와 호출할 수 있는 특정 함수를 제공할 수 있다는 점을 명시하는 것 외에는 이 명세의 범위를 벗어납니다.
ECMAScript는 원래 스크립팅 언어로 사용하도록 설계되었으나, 현재는 범용 프로그래밍 언어로 널리 사용됩니다. 스크립팅 언어 는 기존 시스템의 기능을 조작하고, 사용자 정의하고, 자동화하는 데 사용하는 프로그래밍 언어입니다. 이러한 시스템에서는 유용한 기능이 사용자 인터페이스를 통해 이미 제공되며, 스크립팅 언어는 해당 기능을 프로그램으로 제어할 수 있도록 노출하는 수단입니다. 이러한 방식으로 기존 시스템은 객체와 기능으로 구성된 호스트 환경 을 제공하여 스크립팅 언어의 기능을 완성한다고 할 수 있습니다. 스크립팅 언어는 전문 프로그래머와 비전문 프로그래머 모두가 사용하도록 설계됩니다.
ECMAScript는 원래 웹 스크립팅 언어 로 설계되었으며, 브라우저의 웹 페이지를 동적으로 만들고 웹 기반 클라이언트-서버 아키텍처의 일부로 서버 계산을 수행하는 수단을 제공했습니다. 현재 ECMAScript는 다양한 호스트 환경 에 핵심 스크립팅 기능을 제공하는 데 사용됩니다. 따라서 이 문서에서는 특정 호스트 환경 과 독립적으로 핵심 언어를 명시합니다.
ECMAScript의 사용은 단순한 스크립팅을 넘어섰으며, 현재는 다양한 환경과 규모에서 모든 범위의 프로그래밍 작업에 사용됩니다. ECMAScript의 사용이 확대됨에 따라 제공하는 기능도 함께 확장되었습니다. ECMAScript는 이제 완전한 기능을 갖춘 범용 프로그래밍 언어입니다.
4.1 웹 스크립팅
웹 브라우저는 클라이언트 측 계산을 위한 ECMAScript 호스트 환경 을 제공하며, 여기에는 창, 메뉴, 팝업, 대화 상자, 텍스트 영역, 앵커, 프레임, 방문 기록, 쿠키 및 입출력을 나타내는 객체 등이 포함됩니다. 또한 호스트 환경 은 포커스 변경, 페이지와 이미지의 로드, 언로드, 오류와 중단, 선택, 폼 제출 및 마우스 동작과 같은 이벤트에 스크립팅 코드를 연결하는 수단을 제공합니다. 스크립팅 코드는 HTML 내부에 나타나며, 표시되는 페이지는 사용자 인터페이스 요소와 고정되거나 계산된 텍스트 및 이미지의 조합입니다. 스크립팅 코드는 사용자 상호 작용에 반응하며, 주 프로그램이 필요하지 않습니다.
웹 서버는 서버 측 계산을 위한 별도의 호스트 환경 을 제공하며, 여기에는 요청, 클라이언트 및 파일을 나타내는 객체와 데이터를 잠그고 공유하는 수단이 포함됩니다. 브라우저 측 스크립팅과 서버 측 스크립팅을 함께 사용하면 웹 기반 애플리케이션에 맞춤형 사용자 인터페이스를 제공하면서 클라이언트와 서버 사이에 계산을 분산할 수 있습니다.
ECMAScript를 지원하는 각 웹 브라우저와 서버는 자체 호스트 환경 을 제공하여 ECMAScript 실행 환경을 완성합니다.
4.2 호스트와 구현체
ECMAScript를 호스트 환경 에 통합하는 데 도움이 되도록 이 명세는 특정 기능(예: 추상 연산 )의 정의 전체 또는 일부를 이 명세 외부의 주체에 위임합니다. 편집상 이 명세는 다음과 같은 종류의 위임을 구분합니다.
구현체 는 부속서 D 에 열거된 기능 또는 구현체 정의 나 구현체 근사 로 표시된 기능을 추가로 정의하는 외부 주체입니다. 비공식적인 용법에서 구현체는 특정 웹 브라우저와 같은 구체적인 결과물을 가리킵니다.
구현체 정의 기능은 추가적인 제한 없이 그 정의를 외부 주체에 위임하는 기능입니다. 이 명세는 특정 동작을 권장하지 않으며, 적합한 구현체는 이 명세에서 제시한 제약 내에서 자유롭게 동작을 선택할 수 있습니다.
구현체 근사 기능은 이상적인 동작을 권장하면서 그 정의를 외부 주체에 위임하는 기능입니다. 적합한 구현체는 이 명세에서 제시한 제약 내에서 자유롭게 동작을 선택할 수 있지만, 이상적인 동작에 근접하도록 노력하는 것이 권장됩니다. Math.exp 와 같은 일부 수학 연산은 구현체 근사 입니다.
호스트 는 부속서 D 에 나열된 기능을 추가로 정의하지만, 그 밖의 구현체 정의 또는 구현체 근사 기능은 추가로 정의하지 않는 외부 주체입니다. 비공식적인 용법에서 호스트 는 모든 웹 브라우저의 집합과 같이 부속서 D 를 통해 이 명세와 동일한 방식으로 연동하는 모든 구현체의 집합을 가리킵니다. 호스트 는 WHATWG HTML(https://html.spec.whatwg.org/ )과 같은 외부 명세인 경우가 많습니다. 다시 말해, 호스트 정의 기능은 외부 명세에서 추가로 정의되는 경우가 많습니다.
호스트 훅 은 외부 주체가 전체 또는 일부를 정의하는 추상 연산 입니다. 모든 호스트 훅 은 부속서 D 에 나열되어야 합니다. 호스트 훅 은 적어도 다음 요구 사항을 준수해야 합니다:
정상 완료 또는 예외 완료 중 하나를 반환해야 합니다.
호스트 정의 기능은 추가적인 제한 없이 그 정의를 외부 주체에 위임하며 부속서 D 에 나열된 기능입니다. 호스트 가 아닌 구현체도 호스트 정의 기능에 대한 정의를 제공할 수 있습니다.
호스트 환경 은 모든 호스트 정의 기능에 대해 선택한 구체적인 정의의 조합입니다. 호스트 환경 에는 일반적으로 입력을 얻고 출력을 제공할 수 있는 객체 또는 함수가 전역 객체 의 호스트 정의 프로퍼티로 포함됩니다.
이 명세는 항상 가장 구체적인 용어를 사용하는 편집 관례를 따릅니다. 예를 들어 어떤 기능이 호스트 정의 라면 이를 구현체 정의 라고 지칭하지 않는 것이 좋습니다.
호스트 와 구현체 모두 이 명세에 정의된 언어 타입, 명세 타입, 추상 연산 , 문법 생성 규칙, 내재 객체 및 내재 심볼을 통해 이 명세와 연동할 수 있습니다.
4.3 ECMAScript 개요
다음은 ECMAScript에 대한 비공식적인 개요이며, 언어의 모든 부분을 설명하지는 않습니다. 이 개요는 표준 본문의 일부가 아닙니다.
ECMAScript는 객체 기반입니다. 기본적인 언어 기능과 호스트 기능은 객체를 통해 제공되며, ECMAScript 프로그램은 서로 통신하는 객체들의 집합입니다. ECMAScript에서 객체 는 0개 이상의 프로퍼티 로 구성되며, 각 프로퍼티에는 사용 방법을 결정하는 속성 이 있습니다. 예를 들어 프로퍼티의 Writable 속성이 false 로 설정되면 실행 중인 ECMAScript 코드가 해당 프로퍼티에 다른 값을 할당하려는 모든 시도는 실패합니다. 프로퍼티는 다른 객체, 원시값 또는 함수 를 담는 컨테이너입니다. 원시값은 다음 내장 타입 중 하나의 구성원입니다: Undefined , Null , Boolean , Number , BigInt , String , Symbol; 객체는 내장 타입 Object 의 구성원이며, 함수는 호출 가능한 객체입니다. 프로퍼티를 통해 객체와 연결된 함수는 메서드 라고 합니다.
ECMAScript는 ECMAScript 개체의 정의를 완성하는 내장 객체 의 집합을 정의합니다. 이러한 내장 객체에는 전역 객체 ; Object, Function, Boolean, Symbol 및 다양한 Error 객체를 포함하여 언어의 런타임 의미론 에 기본이 되는 객체; Math, Number, Date를 포함하여 숫자 값을 나타내고 조작하는 객체; 텍스트 처리 객체인 String과 RegExp; Array 및 요소가 각각 특정 숫자 데이터 표현을 갖는 9가지 종류의 TypedArray 를 포함하여 인덱스가 있는 값의 컬렉션인 객체; Map과 Set 객체를 포함하는 키 기반 컬렉션; JSON 객체, ArrayBuffer, SharedArrayBuffer, DataView를 포함하여 구조화된 데이터를 지원하는 객체; 제너레이터 함수와 Promise 객체를 포함하여 제어 추상화를 지원하는 객체; Proxy와 Reflect를 포함하는 리플렉션 객체가 있습니다.
ECMAScript는 내장 연산자 의 집합도 정의합니다. ECMAScript 연산자에는 다양한 단항 연산, 곱셈 연산자, 덧셈 연산자, 비트 이동 연산자, 관계 연산자, 동등 연산자, 이항 비트 연산자, 이항 논리 연산자, 할당 연산자 및 쉼표 연산자가 포함됩니다.
대규모 ECMAScript 프로그램은 프로그램을 여러 개의 문 및 선언 시퀀스로 나눌 수 있게 하는 모듈 을 통해 지원됩니다. 각 모듈은 자신이 사용하며 다른 모듈에서 제공해야 하는 선언과, 자신의 선언 중 다른 모듈이 사용할 수 있는 선언을 명시적으로 식별합니다.
ECMAScript 구문은 의도적으로 Java 구문과 유사하게 설계되었습니다. ECMAScript 구문은 사용하기 쉬운 스크립팅 언어로 활용할 수 있도록 제약이 완화되어 있습니다. 예를 들어 변수의 타입을 선언할 필요가 없으며, 프로퍼티에도 타입이 연결되지 않습니다. 또한 정의된 함수의 선언이 해당 함수를 호출하는 부분보다 소스 텍스트상 앞에 나타날 필요가 없습니다.
4.3.1 객체
ECMAScript에는 클래스 정의를 위한 구문이 포함되어 있지만, ECMAScript 객체는 C++, Smalltalk 또는 Java의 객체처럼 근본적으로 클래스 기반인 것은 아닙니다. 대신 객체는 리터럴 표기법이나 생성자 등 다양한 방법으로 생성할 수 있습니다. 생성자 는 객체를 생성한 다음, 프로퍼티에 초기값을 할당하여 객체 전체 또는 일부를 초기화하는 코드를 실행합니다. 각 생성자 는 프로토타입 기반 상속 과 공유 프로퍼티 를 구현하는 데 사용되는 "prototype" 이라는 프로퍼티를 갖는 함수입니다. 객체는 new 표현식에서 생성자 를 사용하여 생성합니다. 예를 들어 new Date(2009, 11)은 새 Date 객체를 생성합니다. new 를 사용하지 않고 생성자 를 호출했을 때의 결과는 생성자 에 따라 달라집니다. 예를 들어 Date()는 객체 대신 현재 날짜와 시간의 문자열 표현을 생성합니다.
생성자 로 생성한 모든 객체는 생성자 의 "prototype" 프로퍼티 값에 대한 암묵적인 참조를 가지며, 이를 객체의 프로토타입 이라고 합니다. 또한 프로토타입은 자신의 프로토타입에 대한 null 이 아닌 암묵적인 참조를 가질 수 있으며, 이러한 참조가 계속 이어질 수 있습니다. 이를 프로토타입 체인 이라고 합니다. 객체의 프로퍼티를 참조하면 프로토타입 체인에서 해당 이름의 프로퍼티를 포함하는 첫 번째 객체의 그 프로퍼티를 참조하게 됩니다. 다시 말해, 먼저 직접 언급된 객체에 해당 프로퍼티가 있는지 검사합니다. 그 객체에 해당 이름의 프로퍼티가 있으면 참조는 그 프로퍼티를 가리킵니다. 해당 이름의 프로퍼티가 없으면 다음으로 그 객체의 프로토타입을 검사하며, 이러한 과정이 계속됩니다.
그림 1: 객체/프로토타입 관계
클래스 기반 객체 지향 언어에서는 일반적으로 인스턴스가 상태를 갖고, 클래스가 메서드를 가지며, 구조와 동작만 상속됩니다. ECMAScript에서는 객체가 상태와 메서드를 가지며, 구조, 동작 및 상태가 모두 상속됩니다.
프로토타입에 있는 특정 프로퍼티를 직접 포함하지 않는 모든 객체는 해당 프로퍼티와 그 값을 공유합니다. 그림 1은 이를 보여 줍니다:
CF 는 생성자 이며 객체이기도 합니다. new 표현식을 사용하여 다섯 개의 객체 cf1 , cf2 , cf3 , cf4 , cf5 를 생성했습니다. 각 객체에는 "q1" 과 "q2" 라는 프로퍼티가 있습니다. 점선은 암묵적인 프로토타입 관계를 나타냅니다. 예를 들어 cf3 의 프로토타입은 CFp 입니다. 생성자 CF 자체에는 "P1" 과 "P2" 라는 두 개의 프로퍼티가 있으며, 이 프로퍼티는 CFp , cf1 , cf2 , cf3 , cf4 또는 cf5 에서 보이지 않습니다. CFp 에 있는 "CFP1" 이라는 프로퍼티는 cf1 , cf2 , cf3 , cf4 , cf5 가 공유하지만 CF 는 공유하지 않습니다. CFp 의 암묵적인 프로토타입 체인에 있는 프로퍼티 중 이름이 "q1" , "q2" 또는 "CFP1" 이 아닌 프로퍼티도 마찬가지로 공유됩니다. CF 와 CFp 사이에는 암묵적인 프로토타입 연결이 없다는 점에 유의하시기 바랍니다.
대부분의 클래스 기반 객체 언어와 달리, 프로퍼티에 값을 할당하여 객체에 프로퍼티를 동적으로 추가할 수 있습니다. 즉, 생성자 가 생성된 객체의 모든 프로퍼티 또는 일부 프로퍼티의 이름을 지정하거나 값을 할당할 필요는 없습니다. 위 그림에서는 cf1 , cf2 , cf3 , cf4 , cf5 를 위한 새로운 공유 프로퍼티를 CFp 의 프로퍼티에 새 값을 할당하여 추가할 수 있습니다.
ECMAScript 객체는 본질적으로 클래스 기반이 아니지만, 생성자 함수, 프로토타입 객체 및 메서드의 공통 패턴을 바탕으로 클래스와 유사한 추상화를 정의하는 것이 편리한 경우가 많습니다. ECMAScript 내장 객체 자체도 이러한 클래스와 유사한 패턴을 따릅니다. ECMAScript 2015부터 ECMAScript 언어에는 프로그래머가 내장 객체에서 사용하는 것과 동일한 클래스 유사 추상화 패턴을 따르는 객체를 간결하게 정의할 수 있도록 하는 클래스 정의 구문이 포함됩니다.
4.3.2 ECMAScript의 엄격 변형
ECMAScript 언어는 일부 사용자가 언어에서 사용할 수 있는 특정 기능의 사용을 제한하기를 원할 수 있음을 인정합니다. 사용자는 보안을 위해, 오류를 유발하기 쉽다고 생각하는 기능을 피하기 위해, 강화된 오류 검사를 얻기 위해 또는 자신이 선택한 다른 이유로 이러한 제한을 원할 수 있습니다. 이를 지원하기 위해 ECMAScript는 언어의 엄격 변형을 정의합니다. 언어의 엄격 변형은 일반 ECMAScript 언어의 특정 구문적·의미적 기능을 제외하고 일부 기능의 세부 의미를 수정합니다. 또한 엄격 변형은 비엄격 형태의 언어에서 오류로 명시되지 않은 상황에 대해 오류 예외를 던져 보고해야 하는 추가 오류 조건을 명시합니다.
ECMAScript의 엄격 변형은 일반적으로 언어의 엄격 모드 라고 합니다. 엄격 모드의 선택과 ECMAScript 엄격 모드 구문 및 의미의 사용은 11.2.2 에 설명된 대로 개별 ECMAScript 소스 텍스트 단위 수준에서 명시적으로 이루어집니다. 엄격 모드는 구문적인 소스 텍스트 단위 수준에서 선택되므로, 해당 소스 텍스트 단위 내에서 국소적으로 영향을 미치는 제한만 부과합니다. 엄격 모드는 여러 소스 텍스트 단위에 걸쳐 일관되게 동작해야 하는 ECMAScript 의미론의 어떠한 측면도 제한하거나 수정하지 않습니다. 하나의 완전한 ECMAScript 프로그램은 엄격 모드와 비엄격 모드의 ECMAScript 소스 텍스트 단위로 함께 구성될 수 있습니다. 이 경우 엄격 모드는 엄격 모드 소스 텍스트 단위 내에 정의된 코드를 실제로 실행할 때만 적용됩니다.
이 명세에 적합하려면 ECMAScript 구현체는 이 명세에 정의된 제한 없는 전체 ECMAScript 언어와 ECMAScript 언어의 엄격 변형을 모두 구현해야 합니다. 또한 구현체는 제한 없는 소스 텍스트 단위와 엄격 모드 소스 텍스트 단위를 하나의 복합 프로그램으로 결합하는 것을 지원해야 합니다.
4.4 용어 및 정의
이 문서에서는 다음 용어와 정의를 적용합니다.
4.4.1 구현체 근사
구현체 근사 기능은 외부 주체가 전체 또는 일부를 정의하지만, 이 명세에서 이상적인 동작을 권장하는 기능입니다
4.4.2 구현체 정의
구현체 정의 기능은 이 명세 외부의 주체가 전체 또는 일부를 정의하는 기능입니다
4.4.3 호스트 정의
구현체 정의 와 같습니다
참고
편집상의 구분에 대해서는 절 4.2 를 참조하시기 바랍니다.
4.4.4 타입
절 6 에 정의된 데이터 값의 집합입니다
4.4.5 원시값
절 6 에 정의된 Undefined, Null, Boolean, Number, BigInt, Symbol 또는 String 타입 중 하나의 구성원입니다
참고
원시값은 언어 구현의 가장 낮은 수준에서 직접 표현되는 데이터입니다.
4.4.6 객체
Object 타입 의 구성원입니다
참고
객체는 프로퍼티의 집합이며, 하나의 프로토타입 객체를 갖습니다. 프로토타입은 null 일 수 있습니다.
4.4.7 생성자
객체를 생성하고 초기화하는 함수 객체 입니다
참고
생성자 의 "prototype" 프로퍼티 값은 상속과 공유 프로퍼티를 구현하는 데 사용되는 프로토타입 객체입니다.
4.4.8 프로토타입
다른 객체에 공유 프로퍼티를 제공하는 객체입니다
참고
생성자 가 객체를 생성하면 해당 객체는 프로퍼티 참조를 해석하기 위해 생성자 의 "prototype" 프로퍼티를 암묵적으로 참조합니다. 생성자 의 "prototype" 프로퍼티는 프로그램 표현식 constructor .prototype으로 참조할 수 있으며, 객체의 프로토타입에 추가된 프로퍼티는 상속을 통해 해당 프로토타입을 공유하는 모든 객체가 공유합니다. 또는 내장 함수 Object.create를 사용하여 명시적으로 지정한 프로토타입을 갖는 새 객체를 생성할 수 있습니다.
4.4.9 일반 객체
모든 객체가 지원해야 하는 필수 내부 메서드에 대해 기본 동작을 갖는 객체입니다
4.4.10 특수 객체
하나 이상의 필수 내부 메서드에 대해 기본 동작을 갖지 않는 객체입니다
참고
일반 객체 가 아닌 모든 객체는 특수 객체 입니다.
4.4.11 표준 객체
이 명세에서 의미를 정의하는 객체입니다
4.4.12 내장 객체
ECMAScript 구현체가 명시하고 제공하는 객체입니다
참고
표준 내장 객체는 이 명세에 정의되어 있습니다. ECMAScript 구현체는 추가 종류의 내장 객체를 명시하고 제공할 수 있습니다.
4.4.13 undefined 값
변수에 값이 할당되지 않았을 때 사용하는 원시값입니다
4.4.14 Undefined 타입
undefined 값만을 유일한 값으로 갖는 타입입니다
4.4.15 null 값
어떠한 객체 값도 의도적으로 존재하지 않음을 나타내는 원시값입니다
4.4.16 Null 타입
null 값만을 유일한 값으로 갖는 타입입니다
4.4.17 Boolean 값
Boolean 타입 의 구성원입니다
참고
Boolean 값은 true 와 false 두 개뿐입니다.
4.4.18 Boolean 타입
원시값 true 와 false 로 구성된 타입입니다
4.4.19 Boolean 객체
표준 내장 Boolean 생성자 의 인스턴스인 Object 타입 의 구성원입니다
참고
Boolean 객체는 new 표현식에서 Boolean 생성자 를 사용하고 Boolean 값을 인수로 전달하여 생성합니다. 생성된 객체에는 해당 Boolean 값을 값으로 갖는 내부 슬롯이 있습니다. Boolean 객체는 Boolean 값으로 강제 변환할 수 있습니다.
4.4.20 String 값
0개 이상의 16비트 부호 없는 정숫값으로 이루어진 유한한 순서 있는 시퀀스인 원시값입니다
참고
String 값은 String 타입 의 구성원입니다. 시퀀스의 각 정숫값은 일반적으로 UTF-16 텍스트의 단일 16비트 단위를 나타냅니다. 그러나 ECMAScript는 이러한 값이 16비트 부호 없는 정수 여야 한다는 것 외에는 값에 어떠한 제한이나 요구 사항도 부과하지 않습니다.
4.4.21 String 타입
가능한 모든 String 값의 집합입니다
4.4.22 String 객체
표준 내장 String 생성자 의 인스턴스인 Object 타입 의 구성원입니다
참고
String 객체는 new 표현식에서 String 생성자 를 사용하고 String 값을 인수로 전달하여 생성합니다. 생성된 객체에는 해당 String 값을 값으로 갖는 내부 슬롯이 있습니다. String 생성자 를 함수로 호출하여 String 객체를 String 값으로 강제 변환할 수 있습니다(22.1.1.1 ).
4.4.23 Number 값
배정밀도 64비트 이진 형식의 IEEE 754-2019 값에 대응하는 원시값입니다
참고
Number 값 은 Number 타입 의 구성원이며, 수를 직접 표현합니다.
4.4.24 Number 타입
NaN (“숫자가 아님”), +∞ 𝔽 (양의 무한대), -∞ 𝔽 (음의 무한대)를 포함한 가능한 모든 Number 값 의 집합입니다
4.4.25 Number 객체
표준 내장 Number 생성자 의 인스턴스인 Object 타입 의 구성원입니다
참고
Number 객체는 new 표현식에서 Number 생성자 를 사용하고 Number 값 을 인수로 전달하여 생성합니다. 생성된 객체에는 해당 Number 값 을 값으로 갖는 내부 슬롯이 있습니다. Number 생성자 를 함수로 호출하여 Number 객체를 Number 값 으로 강제 변환할 수 있습니다(21.1.1.1 ).
4.4.26 Infinity
양의 무한대를 나타내는 Number 값 입니다
4.4.27 NaN
IEEE 754-2019 의 NaN(“숫자가 아님”) 값인 Number 값 입니다
4.4.28 BigInt 값
임의 정밀도 정숫값에 대응하는 원시값입니다
4.4.29 BigInt 타입
가능한 모든 BigInt 값 의 집합입니다
4.4.30 BigInt 객체
표준 내장 BigInt 생성자 의 인스턴스인 Object 타입 의 구성원입니다
4.4.31 Symbol 값
고유하며 String이 아닌 Object 프로퍼티 키 를 나타내는 원시값입니다
4.4.32 Symbol 타입
가능한 모든 Symbol 값의 집합입니다
4.4.33 Symbol 객체
표준 내장 Symbol 생성자 의 인스턴스인 Object 타입 의 구성원입니다
4.4.34 함수
서브루틴으로 호출할 수 있는 Object 타입 의 구성원입니다
참고
함수에는 프로퍼티 외에도 호출 시 동작을 결정하는 실행 가능한 코드와 상태가 포함됩니다. 함수의 코드는 ECMAScript로 작성되었을 수도 있고 그렇지 않을 수도 있습니다.
4.4.35 내장 함수
함수인 내장 객체입니다
참고
내장 함수의 예로는 parseInt와 Math.exp가 있습니다. 호스트 또는 구현체는 이 명세에 기술되지 않은 추가 내장 함수를 제공할 수 있습니다.
4.4.36 내장 생성자
생성자 인 내장 함수입니다
참고
내장 생성자 의 예로는 Object와 Function이 있습니다. 호스트 또는 구현체는 이 명세에 기술되지 않은 추가 내장 생성자 를 제공할 수 있습니다.
4.4.37 프로퍼티
키(String 값 또는 Symbol 값)와 값을 연결하는 객체의 일부입니다
참고
프로퍼티의 형태에 따라 값은 데이터 값(원시값, 객체 또는 함수 객체 )으로 직접 표현되거나 접근자 함수 쌍에 의해 간접적으로 표현될 수 있습니다.
4.4.38 메서드
프로퍼티의 값인 함수입니다
참고
함수를 객체의 메서드로 호출하면 해당 객체가 함수의 this 값으로 전달됩니다.
4.4.39 내장 메서드
내장 함수인 메서드입니다
참고
표준 내장 메서드는 이 명세에 정의되어 있습니다. 호스트 또는 구현체는 이 명세에 기술되지 않은 추가 내장 메서드를 제공할 수 있습니다.
4.4.40 속성
프로퍼티의 특정 특성을 정의하는 내부 값입니다
4.4.41 자체 프로퍼티
해당 객체에 직접 포함된 프로퍼티입니다
4.4.42 상속된 프로퍼티
객체의 자체 프로퍼티가 아니면서 해당 객체의 프로토타입에 있는 프로퍼티(자체 프로퍼티 또는 상속된 프로퍼티)인 객체의 프로퍼티입니다
4.5 이 명세의 구성
이 명세의 나머지 부분은 다음과 같이 구성됩니다:
절 5 에서는 명세 전반에 걸쳐 사용하는 표기 관례를 정의합니다.
절 6 부터 10 까지는 ECMAScript 프로그램이 동작하는 실행 환경을 정의합니다.
절 11 부터 17 까지는 구문적 인코딩과 모든 언어 기능의 실행 의미를 포함하여 실제 ECMAScript 프로그래밍 언어를 정의합니다.
절 18 부터 28 까지는 ECMAScript 표준 라이브러리를 정의합니다. 여기에는 ECMAScript 프로그램이 실행 중에 사용할 수 있는 모든 표준 객체의 정의가 포함됩니다.
절 29 에서는 SharedArrayBuffer를 기반으로 하는 메모리에 대한 접근의 메모리 일관성 모델과 Atomics 객체의 메서드를 설명합니다.
5 표기 관례
5.1 구문 문법과 어휘 문법
5.1.1 문맥 자유 문법
문맥 자유 문법 은 여러 생성 규칙 으로 구성됩니다. 각 생성 규칙은 비단말 기호 라고 하는 추상 기호를 좌변 으로 가지며, 0개 이상의 비단말 기호와 단말 기호 의 시퀀스를 우변 으로 갖습니다. 각 문법의 단말 기호는 지정된 알파벳에서 선택됩니다.
연쇄 생성 규칙 은 우변에 0개 이상의 단말 기호와 함께 정확히 하나의 비단말 기호를 갖는 생성 규칙입니다.
주어진 문맥 자유 문법은 목표 기호 라고 하는 하나의 특별한 비단말 기호로 구성된 문장에서 시작하여 언어 를 지정합니다. 이 언어는 시퀀스의 임의의 비단말 기호를 해당 비단말 기호가 좌변인 생성 규칙의 우변으로 반복해서 대체하여 얻을 수 있는 단말 기호 시퀀스들의 집합이며, 이 집합은 무한할 수도 있습니다.
5.1.2 어휘 문법과 RegExp 문법
ECMAScript의 어휘 문법 은 절 12 에 제시되어 있습니다. 이 문법은 11.1 에 정의된 SourceCharacter 규칙을 따르는 유니코드 코드 포인트를 단말 기호로 갖습니다. 이 문법은 목표 기호 InputElementDiv , InputElementTemplateTail , InputElementRegExp , InputElementRegExpOrTemplateTail 또는 InputElementHashbangOrRegExp 에서 시작하는 생성 규칙의 집합을 정의하며, 이러한 코드 포인트의 시퀀스가 입력 요소의 시퀀스로 변환되는 방법을 설명합니다.
공백과 주석을 제외한 입력 요소는 ECMAScript 구문 문법의 단말 기호를 구성하며, ECMAScript 토큰 이라고 합니다. 이러한 토큰은 ECMAScript 언어의 예약어 , 식별자, 리터럴 및 구두점 기호입니다. 또한 줄 종결자는 토큰으로 간주되지는 않지만 입력 요소 스트림의 일부가 되어 자동 세미콜론 삽입 과정(12.10 )을 안내합니다. 단순 공백과 한 줄 주석은 버려지며 구문 문법의 입력 요소 스트림에 나타나지 않습니다. MultiLineComment (즉, 여러 줄에 걸쳐 있는지와 관계없이 /*…*/ 형식의 주석)도 줄 종결자를 포함하지 않으면 단순히 버려집니다. 그러나 MultiLineComment 가 하나 이상의 줄 종결자를 포함하면 단일 줄 종결자로 대체되며, 이 줄 종결자는 구문 문법의 입력 요소 스트림의 일부가 됩니다.
ECMAScript의 RegExp 문법 은 22.2.1 에 제시되어 있습니다. 이 문법 역시 SourceCharacter 로 정의되는 코드 포인트를 단말 기호로 갖습니다. 이 문법은 목표 기호 Pattern 에서 시작하는 생성 규칙의 집합을 정의하며, 코드 포인트의 시퀀스가 정규 표현식 패턴으로 변환되는 방법을 설명합니다.
어휘 문법과 RegExp 문법의 생성 규칙은 구분 기호로 두 개의 콜론 “:: ”을 사용하여 구별합니다. 어휘 문법과 RegExp 문법은 일부 생성 규칙을 공유합니다.
5.1.3 숫자 문자열 문법
숫자 문자열 문법 은 7.1.4.1 에 제시되어 있습니다. 이 문법은 SourceCharacter 를 단말 기호로 가지며, 목표 기호 StringNumericLiteral 에서 시작하여 String을 숫자 값으로 변환하는 데 사용됩니다. 이는 숫자 리터럴의 어휘 문법 과 유사하지만 서로 다릅니다.
숫자 문자열 문법의 생성 규칙은 구분 기호로 세 개의 콜론 “::: ”을 사용하여 구별하며, 소스 텍스트를 파싱하는 데는 사용하지 않습니다.
5.1.4 구문 문법
ECMAScript의 구문 문법 은 절 13 부터 16 까지에 제시되어 있습니다. 이 문법은 어휘 문법에서 정의한 ECMAScript 토큰을 단말 기호로 갖습니다(5.1.2 ). 이 문법은 두 가지 대안적인 목표 기호 Script 와 Module 에서 시작하는 생성 규칙의 집합을 정의하며, 토큰 시퀀스가 ECMAScript 프로그램의 구문적으로 올바른 독립 구성 요소를 형성하는 방법을 설명합니다.
코드 포인트 스트림을 ECMAScript Script 또는 Module 로 파싱할 때는 먼저 어휘 문법을 반복 적용하여 입력 요소 스트림으로 변환합니다. 그런 다음 구문 문법을 한 번 적용하여 이 입력 요소 스트림을 파싱합니다. 입력 요소 스트림의 토큰을 남는 토큰 없이 목표 비단말 기호(Script 또는 Module )의 단일 인스턴스로 파싱할 수 없다면 입력 스트림에는 구문 오류가 있습니다.
파싱에 성공하면 각 노드가 파스 노드 인 루트가 있는 트리 구조인 파스 트리 를 구성합니다. 각 파스 노드는 문법 기호의 인스턴스 이며, 해당 기호로부터 유도할 수 있는 소스 텍스트 구간 을 나타냅니다. 전체 소스 텍스트를 나타내는 파스 트리의 루트 노드는 파싱 목표 기호 의 인스턴스입니다. 파스 노드가 비단말 기호의 인스턴스이면, 해당 비단말 기호를 좌변으로 갖는 어떤 생성 규칙의 인스턴스이기도 합니다. 또한 이 노드는 생성 규칙 우변의 각 기호에 하나씩 대응하는 0개 이상의 자식 을 갖습니다. 각 자식은 해당 기호의 인스턴스인 파스 노드입니다.
파서를 호출할 때마다 새로운 파스 노드를 생성하며, 동일한 소스 텍스트를 파싱하더라도 서로 다른 파싱 사이에서 재사용하지 않습니다. 파스 노드가 동일한 소스 텍스트 구간 을 나타내고, 동일한 문법 기호의 인스턴스이며, 동일한 파서 호출에서 생성된 경우에만 동일한 파스 노드 로 간주합니다.
참고 1
동일한 String을 여러 번 파싱하면 서로 다른 파스 노드가 생성됩니다. 예를 들어 다음을 고려하시기 바랍니다:
let str = "1 + 1;" ;
eval (str);
eval (str);
각 eval 호출은 str의 값을 ECMAScript 소스 텍스트 로 변환하고 독립적으로 파싱하여 별도의 파스 노드 트리를 생성합니다. 각 파싱이 동일한 String 값에서 유래한 소스 텍스트에 대해 수행되더라도 트리는 서로 다릅니다.
참고 2 파스 노드는 명세상의 구성 요소이며, 구현체가 유사한 데이터 구조를 사용할 필요는 없습니다.
구문 문법의 생성 규칙은 구분 기호로 하나의 콜론 “: ”만 사용하여 구별합니다.
절 13 부터 16 까지에 제시된 구문 문법은 어떤 토큰 시퀀스가 올바른 ECMAScript Script 또는 Module 로 허용되는지를 완전히 설명하지는 않습니다. 특정 추가 토큰 시퀀스도 허용됩니다. 즉, 시퀀스의 특정 위치(예: 줄 종결자 문자 앞)에 세미콜론을 추가하기만 하면 문법으로 설명할 수 있는 시퀀스도 허용됩니다. 또한 문법으로 설명되는 특정 토큰 시퀀스라도 줄 종결자 문자가 특정 “부적절한” 위치에 나타나면 허용되지 않는 것으로 간주됩니다.
특정 경우에는 모호성을 피하기 위해 구문 문법이 유효한 ECMAScript Script 또는 Module 을 형성하지 않는 토큰 시퀀스도 허용하는 일반화된 생성 규칙을 사용합니다. 예를 들어 객체 리터럴과 객체 구조 분해 패턴에 이 기법을 사용합니다. 이러한 경우에는 허용되는 토큰 시퀀스를 추가로 제한하는 더 엄격한 보충 문법 을 제공합니다. 일반적으로 조기 오류 규칙 은 특정 문맥에서 “p 는 n 을 포괄해야 합니다 ”라고 명시합니다. 여기에서 p 는 파스 노드(일반화된 생성 규칙의 인스턴스)이며, n 은 보충 문법의 비단말 기호입니다. 이는 다음을 의미합니다:
p 또는 그 하위 노드에는 어떠한 조기 오류 규칙 도 적용하지 않습니다.
원래 p 에 일치했던 토큰 시퀀스를 n 을 목표 기호 로 사용하여 다시 파싱합니다. n 이 문법 매개변수를 받으면, 해당 매개변수는 p 를 처음 파싱할 때 사용한 값과 동일하게 설정합니다.
남는 토큰 없이 토큰 시퀀스를 n 의 단일 인스턴스로 파싱할 수 있으면:
해당 n 의 인스턴스(주어진 p 에 대해 고유한 파스 노드)를 “p 에 의해 포괄되는 n ”이라고 합니다.
추가적인 “포괄해야 합니다 ”의 경우에 따라 수정된 조기 오류 규칙 을 p 에 의해 포괄되는 n 과 그 하위 노드에 적용합니다.
그렇지 않으면(파싱에 실패하면) 조기 구문 오류입니다.
5.1.5 문법 표기법
5.1.5.1 단말 기호
ECMAScript 문법에서 일부 단말 기호는 고정폭 글꼴로 표시됩니다. 이러한 기호는 소스 텍스트에 작성된 그대로 나타나야 합니다. 이 방식으로 명시된 모든 단말 기호의 코드 포인트는 다른 유니코드 범위의 비슷하게 생긴 코드 포인트가 아니라 기본 라틴 블록의 해당 유니코드 코드 포인트로 이해해야 합니다. 단말 기호의 코드 포인트는 \ UnicodeEscapeSequence 로 표현할 수 없습니다.
단말 기호가 개별 유니코드 코드 포인트인 문법(즉, 어휘 문법, RegExp 문법 및 숫자 문자열 문법)에서 생성 규칙에 연속해서 나타나는 여러 고정폭 코드 포인트는 동일한 코드 포인트 시퀀스를 각각 독립된 단말 기호로 작성한 것의 간단한 축약 표현입니다.
예를 들어 다음 생성 규칙은:
HexIntegerLiteral ::
0x
HexDigits
다음의 축약 표현입니다:
HexIntegerLiteral ::
0
x
HexDigits
반면 구문 문법에서는 연속된 고정폭 코드 포인트가 하나의 단말 기호입니다.
단말 기호에는 다음과 같은 두 가지 다른 형식도 있습니다:
5.1.5.2 비단말 기호와 생성 규칙
비단말 기호는 기울임꼴 로 표시됩니다. 비단말 기호의 정의(“생성 규칙”이라고도 함)는 정의할 비단말 기호의 이름과 그 뒤에 오는 하나 이상의 콜론으로 시작합니다. (콜론의 개수는 생성 규칙이 속하는 문법을 나타냅니다.) 그다음 줄에는 해당 비단말 기호의 대안적인 우변이 하나 이상 이어집니다. 예를 들어 다음 구문 정의는:
WhileStatement :
while
(
Expression
)
Statement
비단말 기호 WhileStatement 가 while 토큰, 여는 괄호 토큰, Expression , 닫는 괄호 토큰, Statement 가 차례로 이어지는 것을 나타낸다고 명시합니다. 여기에 나타나는 Expression 과 Statement 자체도 비단말 기호입니다. 다른 예로, 다음 구문 정의는:
ArgumentList :
AssignmentExpression
ArgumentList
,
AssignmentExpression
ArgumentList 가 단일 AssignmentExpression 또는 ArgumentList 뒤에 쉼표와 AssignmentExpression 이 차례로 이어지는 것을 나타낼 수 있다고 명시합니다. 이러한 ArgumentList 의 정의는 재귀적입니다. 즉, 자기 자신을 사용하여 정의됩니다. 그 결과 ArgumentList 는 쉼표로 구분된 임의의 양수 개의 인수를 포함할 수 있으며, 각 인수 표현식은 AssignmentExpression 입니다. 이러한 비단말 기호의 재귀적 정의는 흔히 사용됩니다.
5.1.5.3 선택적 기호
단말 기호 또는 비단말 기호 뒤에 나타날 수 있는 아래첨자 접미사 “opt ”는 선택적 기호를 나타냅니다. 선택적 기호를 포함하는 대안은 실제로 두 개의 우변을 지정합니다. 하나는 선택적 요소를 생략하고, 다른 하나는 이를 포함합니다. 즉, 다음은:
VariableDeclaration :
BindingIdentifier
Initializer opt
다음을 편리하게 축약한 표현입니다:
VariableDeclaration :
BindingIdentifier
BindingIdentifier
Initializer
또한 다음은:
ForStatement :
for
(
LexicalDeclaration
Expression opt
;
Expression opt
)
Statement
다음을 편리하게 축약한 표현입니다:
ForStatement :
for
(
LexicalDeclaration
;
Expression opt
)
Statement
for
(
LexicalDeclaration
Expression
;
Expression opt
)
Statement
이 표현은 다시 다음의 축약 표현입니다:
ForStatement :
for
(
LexicalDeclaration
;
)
Statement
for
(
LexicalDeclaration
;
Expression
)
Statement
for
(
LexicalDeclaration
Expression
;
)
Statement
for
(
LexicalDeclaration
Expression
;
Expression
)
Statement
따라서 이 예에서 비단말 기호 ForStatement 에는 실제로 네 개의 대안적인 우변이 있습니다.
5.1.5.4 문법 매개변수
생성 규칙은 “[parameters] ” 형식의 아래첨자 주석으로 매개변수화할 수 있으며, 이 주석은 해당 생성 규칙에서 정의하는 비단말 기호의 접미사로 나타날 수 있습니다. “parameters ”는 단일 이름 또는 쉼표로 구분된 이름 목록일 수 있습니다. 매개변수화된 생성 규칙은 매개변수 이름 앞에 밑줄을 붙여 매개변수화된 비단말 기호에 추가한 모든 조합을 정의하는 생성 규칙 집합의 축약 표현입니다. 즉, 다음은:
StatementList [Return] :
ReturnStatement
ExpressionStatement
다음을 편리하게 축약한 표현입니다:
StatementList :
ReturnStatement
ExpressionStatement
StatementList_Return :
ReturnStatement
ExpressionStatement
또한 다음은:
StatementList [Return, In] :
ReturnStatement
ExpressionStatement
다음의 축약 표현입니다:
StatementList :
ReturnStatement
ExpressionStatement
StatementList_Return :
ReturnStatement
ExpressionStatement
StatementList_In :
ReturnStatement
ExpressionStatement
StatementList_Return_In :
ReturnStatement
ExpressionStatement
여러 매개변수는 조합에 따른 수의 생성 규칙을 만들어 내며, 완전한 문법에서 이러한 생성 규칙이 모두 참조되는 것은 아닙니다.
생성 규칙 우변의 비단말 기호에 대한 참조도 매개변수화할 수 있습니다. 예를 들어:
StatementList :
ReturnStatement
ExpressionStatement [+In]
다음과 같이 표현하는 것과 같습니다:
StatementList :
ReturnStatement
ExpressionStatement_In
또한:
StatementList :
ReturnStatement
ExpressionStatement [~In]
다음과 같습니다:
StatementList :
ReturnStatement
ExpressionStatement
비단말 기호 참조에는 매개변수 목록과 “opt ” 접미사가 모두 있을 수 있습니다. 예를 들어:
VariableDeclaration :
BindingIdentifier
Initializer [+In] opt
다음의 축약 표현입니다:
VariableDeclaration :
BindingIdentifier
BindingIdentifier
Initializer_In
우변의 비단말 기호 참조에서 매개변수 이름 앞에 “? ”를 붙이면 해당 매개변수 값은 현재 생성 규칙의 좌변 기호에 대한 참조에 그 매개변수 이름이 나타나는지에 따라 달라집니다. 예를 들어:
VariableDeclaration [In] :
BindingIdentifier
Initializer [?In]
다음의 축약 표현입니다:
VariableDeclaration :
BindingIdentifier
Initializer
VariableDeclaration_In :
BindingIdentifier
Initializer_In
대안적인 우변 앞에 “[+parameter]”가 붙으면, 생성 규칙의 비단말 기호를 참조할 때 해당 이름의 매개변수를 사용한 경우에만 그 대안을 사용할 수 있습니다. 대안적인 우변 앞에 “[~parameter]”가 붙으면, 생성 규칙의 비단말 기호를 참조할 때 해당 이름의 매개변수를 사용하지 않은 경우에만 그 대안을 사용할 수 있습니다. 즉, 다음은:
StatementList [Return] : [+Return]
ReturnStatement
ExpressionStatement
다음의 축약 표현입니다:
StatementList :
ExpressionStatement
StatementList_Return :
ReturnStatement
ExpressionStatement
또한 다음은:
StatementList [Return] : [~Return]
ReturnStatement
ExpressionStatement
다음의 축약 표현입니다:
StatementList :
ReturnStatement
ExpressionStatement
StatementList_Return :
ExpressionStatement
5.1.5.5 one of
문법 정의의 콜론 뒤에 “one of ”라는 문구가 오면, 다음 한 줄 또는 여러 줄에 있는 각 단말 기호가 대안적인 정의임을 나타냅니다. 예를 들어 ECMAScript의 어휘 문법에는 다음 생성 규칙이 포함됩니다:
BinaryDigit :: one of 0 1
이는 단지 다음을 편리하게 축약한 표현입니다:
BinaryDigit ::
0
1
5.1.5.6 [empty]
생성 규칙의 우변에 “[empty]”라는 문구가 나타나면, 해당 생성 규칙의 우변에 단말 기호나 비단말 기호가 없음을 나타냅니다.
5.1.5.7 미리 보기 제한
생성 규칙의 우변에 “[lookahead = seq ]”라는 문구가 나타나면, 토큰 시퀀스 seq 가 바로 뒤에 오는 입력 토큰 시퀀스의 접두 시퀀스인 경우에만 해당 생성 규칙을 사용할 수 있음을 나타냅니다. 마찬가지로 “[lookahead ∈ set ]”는 set 이 토큰 시퀀스의 비어 있지 않은 유한 집합일 때, set 의 어떤 요소가 바로 뒤에 오는 토큰 시퀀스의 접두 시퀀스인 경우에만 해당 생성 규칙을 사용할 수 있음을 나타냅니다. 편의를 위해 집합을 비단말 기호로 작성할 수도 있으며, 이 경우에는 해당 비단말 기호가 전개될 수 있는 모든 토큰 시퀀스의 집합을 나타냅니다. 해당 비단말 기호가 무한히 많은 서로 다른 토큰 시퀀스로 전개될 수 있다면 편집 오류로 간주합니다.
이러한 조건은 부정할 수 있습니다. “[lookahead ≠ seq ]”는 seq 가 바로 뒤에 오는 입력 토큰 시퀀스의 접두 시퀀스가 아닌 경우에만 이를 포함하는 생성 규칙을 사용할 수 있음을 나타냅니다. “[lookahead ∉ set ]”는 set 의 어떤 요소도 바로 뒤에 오는 토큰 시퀀스의 접두 시퀀스가 아닌 경우에만 해당 생성 규칙을 사용할 수 있음을 나타냅니다.
예를 들어 다음 정의가 주어지면:
DecimalDigit :: one of 0 1 2 3 4 5 6 7 8 9
DecimalDigits ::
DecimalDigit
DecimalDigits
DecimalDigit
다음 정의는:
LookaheadExample ::
n
[lookahead ∉ { 1 , 3 , 5 , 7 , 9 }]
DecimalDigits
DecimalDigit
[lookahead ∉ DecimalDigit ]
문자 n 뒤에 첫 번째 숫자가 짝수인 하나 이상의 십진 숫자가 이어지는 경우 또는 뒤에 다른 십진 숫자가 이어지지 않는 하나의 십진 숫자와 일치합니다.
이러한 문구를 구문 문법에서 사용하는 경우, 이후 토큰을 결정하려면 이후 위치에서 어떤 어휘 목표 기호 를 사용할지 알아야 하므로 바로 뒤에 오는 토큰 시퀀스를 모호함 없이 식별할 수 없을 수 있습니다. 따라서 구문 문법에서 이를 사용할 때, 사용할 어휘 목표 기호 의 선택에 따라 토큰 시퀀스 seq 가 결과 토큰 시퀀스의 접두 시퀀스인지 여부가 달라질 수 있다면 seq 를 미리 보기 제한에 사용하는 것은 편집 오류로 간주합니다. 여기에는 시퀀스 집합의 일부로 사용하는 경우도 포함됩니다.
구문 문법의 생성 규칙 우변에 “[no LineTerminator here]”라는 문구가 나타나면, 해당 생성 규칙이 제한된 생성 규칙 임을 나타냅니다. 표시된 위치의 입력 스트림에 LineTerminator 가 있으면 해당 생성 규칙을 사용할 수 없습니다. 예를 들어 다음 생성 규칙은:
ThrowStatement :
throw
[no LineTerminator here]
Expression
;
스크립트의 throw 토큰과 Expression 사이에 LineTerminator 가 있으면 해당 생성 규칙을 사용할 수 없음을 나타냅니다.
제한된 생성 규칙에서 LineTerminator 의 존재를 금지하지 않는 한, 입력 요소 스트림에서 연속된 두 토큰 사이에는 임의의 개수의 LineTerminator 가 나타날 수 있으며, 이는 스크립트의 구문적 허용 여부에 영향을 주지 않습니다.
5.1.5.9 but not
생성 규칙의 우변에서는 “but not ”이라는 문구를 사용한 다음 제외할 전개를 표시하여 특정 전개가 허용되지 않음을 명시할 수 있습니다. 예를 들어 다음 생성 규칙은:
Identifier ::
IdentifierName but not ReservedWord
비단말 기호 Identifier 를 IdentifierName 을 대체할 수 있는 임의의 코드 포인트 시퀀스로 대체할 수 있음을 의미합니다. 단, 동일한 코드 포인트 시퀀스로 ReservedWord 를 대체할 수 없어야 합니다.
5.1.5.10 설명 문구
마지막으로, 모든 대안을 나열하기 어려운 경우에는 일부 비단말 기호를 산세리프 글꼴의 설명 문구로 기술합니다:
SourceCharacter ::
any Unicode code point
5.2 알고리즘 관례
이 명세는 알고리즘의 단계를 명시하기 위해 번호가 매겨진 목록을 자주 사용합니다. 이러한 알고리즘은 ECMAScript 언어 구문 요소에 요구되는 의미를 정확하게 명시하는 데 사용됩니다. 알고리즘은 특정 구현 기법의 사용을 암시하려는 것이 아닙니다. 실제로는 주어진 기능을 구현하는 데 더 효율적인 알고리즘이 있을 수 있습니다.
알고리즘은 쉼표로 구분된 순서 있는 별칭 이름의 시퀀스를 사용하여 명시적으로 매개변수화할 수 있습니다. 이러한 이름은 알고리즘 단계 내에서 해당 위치로 전달된 인수를 참조하는 데 사용할 수 있습니다. 선택적 매개변수는 대괄호로 둘러싸서 표시하며([ , name ]), 알고리즘 단계 내에서는 필수 매개변수와 다르지 않습니다. 나머지 매개변수는 매개변수 목록의 끝에 나타날 수 있으며, 앞에 줄임표를 붙여 표시합니다(, ...name ). 나머지 매개변수는 필수 매개변수와 선택적 매개변수 뒤에 제공된 모든 인수를 List 로 수집합니다. 이러한 추가 인수가 없으면 해당 List 는 비어 있습니다.
알고리즘 단계는 순차적인 하위 단계로 세분할 수 있습니다. 하위 단계는 들여쓰며, 하위 단계 자체도 들여쓴 하위 단계로 더 세분할 수 있습니다. 하위 단계는 개요 번호 매기기 관례로 식별하며, 첫 번째 수준의 하위 단계에는 소문자 알파벳을, 두 번째 수준의 하위 단계에는 소문자 로마 숫자를 붙입니다. 세 수준보다 더 많은 수준이 필요하면 네 번째 수준에서 숫자를 사용하면서 이 규칙을 반복합니다. 예를 들어:
최상위 단계하위 단계. 하위 단계.하위 단계의 하위 단계.하위 단계의 하위 단계의 하위 단계하위 단계의 하위 단계의 하위 단계의 하위 단계하위 단계의 하위 단계의 하위 단계의 하위 단계의 하위 단계
단계 또는 하위 단계는 그 하위 단계의 적용 조건을 지정하는 “만약” 술어로 작성할 수 있습니다. 이 경우 하위 단계는 해당 술어가 참일 때만 적용됩니다. 단계 또는 하위 단계가 “그렇지 않으면”이라는 말로 시작하면, 같은 수준에서 앞선 “만약” 술어 단계의 부정에 해당하는 술어입니다.
단계는 하위 단계의 반복 적용을 명시하기 위해 “각각에 대해” 또는 “반복”으로 시작할 수 있습니다.
“단언 :”으로 시작하는 단계는 해당 알고리즘의 불변 조건을 단언 합니다. 이러한 단언 은 그렇지 않으면 암묵적일 알고리즘의 불변 조건을 명시적으로 드러내는 데 사용됩니다. 마찬가지로 “참고 :”로 시작하는 단계는 인접한 단계와 관련된 문맥을 제공합니다. 단언 단계와 참고 단계는 순전히 정보 제공용입니다. 추가적인 의미적 요구 사항을 부과하지 않으므로 구현체가 검사할 필요가 없습니다.
알고리즘 단계는 “x 를 someValue 로 둡니다”라는 형식을 사용하여 임의의 값에 대해 이름 있는 별칭을 선언할 수 있습니다. 이러한 별칭은 x 와 someValue 가 동일한 기반 데이터를 참조하고 어느 쪽을 수정하든 양쪽 모두에서 보인다는 점에서 참조와 유사합니다. 이러한 참조 유사 동작을 피하려는 알고리즘 단계는 우변의 복사본을 명시적으로 만들어야 합니다. “x 를 someValue 의 복사본으로 둡니다”는 someValue 의 얕은 복사본을 생성합니다.
별칭은 선언된 이후의 모든 단계에서 참조할 수 있으며, 선언 이전의 단계에서는 참조해서는 안 됩니다. 별칭은 “x 를 someOtherValue 로 설정합니다”라는 형식으로 수정할 수 있습니다.
5.2.1 평가 순서
알고리즘 단계에 복합 표현식이 나타나면, 왼쪽에서 오른쪽으로, 안쪽에서 바깥쪽으로 평가되는 것으로 이해해야 합니다. 예를 들어 다음 단계는
A(B(), C.[[D]] ) + E(F())를 반환합니다.
다음과 같습니다
tmp1 을 B()로 둡니다.tmp2 를 C.[[D]] 로 둡니다.tmp3 을 A(tmp1 , tmp2 )로 둡니다.tmp4 를 F()로 둡니다.tmp5 를 E(tmp4 )로 둡니다.tmp6 을 tmp3 + tmp5 로 둡니다.tmp6 을 반환합니다.
여기에서 각 tmpN 별칭은 일시적이며 이 단계들에서만 보입니다.
5.2.2 추상 연산
이 명세의 여러 부분에서 쉽게 사용할 수 있도록 일부 알고리즘에는 이름을 붙이고 매개변수화된 함수 형식으로 작성하여 다른 알고리즘 내에서 이름으로 참조할 수 있게 합니다. 이러한 알고리즘을 추상 연산 이라고 합니다. 추상 연산은 일반적으로 OperationName(arg1 , arg2 )과 같은 함수 적용 형식으로 참조합니다. 일부 추상 연산은 클래스와 유사한 명세 추상화의 다형적으로 디스패치되는 메서드로 취급됩니다. 이러한 메서드 유사 추상 연산은 일반적으로 someValue .OperationName(arg1 , arg2 )과 같은 메서드 적용 형식으로 참조합니다.
5.2.3 구문 지향 연산
구문 지향 연산 은 이름이 있는 연산으로, 그 정의는 각각 ECMAScript 문법 중 하나의 생성 규칙 하나 이상과 연결된 알고리즘으로 구성됩니다. 여러 대안적인 정의를 갖는 생성 규칙에는 일반적으로 각 대안에 대해 별도의 알고리즘이 있습니다. 알고리즘이 문법 생성 규칙과 연결되면 해당 생성 규칙 대안의 단말 기호와 비단말 기호를 알고리즘의 매개변수처럼 참조할 수 있습니다. 이 방식으로 사용하는 비단말 기호는 소스 텍스트를 파싱할 때 일치하는 실제 대안 정의를 가리킵니다. 문법 생성 규칙 또는 그로부터 파생된 파스 노드 에 일치하는 소스 텍스트 는 일치에 참여한 첫 번째 단말 기호의 시작에서 일치에 참여한 마지막 단말 기호의 끝까지에 해당하는 소스 텍스트 부분입니다.
알고리즘이 생성 규칙의 대안과 연결되면 해당 대안은 일반적으로 “[ ]” 문법 주석 없이 표시됩니다. 이러한 주석은 대안의 구문적 인식에만 영향을 미쳐야 하며, 해당 대안에 연결된 의미에는 영향을 주지 않아야 합니다.
구문 지향 연산은 다음 알고리즘의 단계 1 , 3 및 4 에 있는 관례를 사용하여 파스 노드 와 선택적인 추가 매개변수로 호출합니다:
status 를 SomeNonTerminal 의 SyntaxDirectedOperation으로 둡니다.someParseNode 를 어떤 소스 텍스트의 파싱 결과로 둡니다.someParseNode 의 SyntaxDirectedOperation을 수행합니다.someParseNode 의 SyntaxDirectedOperation을 인수 "value" 로 수행합니다.
명시적으로 달리 지정하지 않는 한, 모든 연쇄 생성 규칙 에는 해당 생성 규칙의 좌변 비단말 기호에 적용할 수 있는 모든 연산에 대한 암묵적인 정의가 있습니다. 이 암묵적인 정의는 동일한 연산을 동일한 매개변수(있는 경우)와 함께 연쇄 생성 규칙 의 유일한 우변 비단말 기호에 다시 적용한 다음 결과를 반환합니다. 예를 들어 어떤 알고리즘에 “Block 의 Evaluation 을 반환합니다”라는 형식의 단계가 있고 다음 생성 규칙이 있다고 가정합니다:
Block :
{
StatementList
}
그러나 Evaluation 연산이 해당 생성 규칙에 알고리즘을 연결하지 않았다고 가정합니다. 이 경우 Evaluation 연산에는 다음 형식의 연결이 암묵적으로 포함됩니다:
Runtime Semantics: Evaluation
Block :
{
StatementList
}
StatementList 의 Evaluation 을 반환합니다.
5.2.4 런타임 의미론
런타임에 호출해야 하는 의미를 명시하는 알고리즘을 런타임 의미론 이라고 합니다. 런타임 의미론은 추상 연산 또는 구문 지향 연산 으로 정의됩니다.
5.2.4.1 Completion ( completionRecord )
추상 연산 Completion. 인수 completionRecord (완료 레코드 ). 반환값: 완료 레코드 . Completion Record 가 반환된다는 점을 강조하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
단언 : completionRecord 는 Completion Record 입니다.completionRecord 를 반환합니다.
5.2.4.2 예외 던지기
알고리즘 단계에서 “던집니다”라는 말은 ThrowCompletion 을 호출한 결과를 반환하는 것의 축약 표현입니다. 예를 들어,
만약 result .[[Error]] 가 none 이 아니면, result .[[Error]] 를 던집니다.
다음과 같습니다
만약 result .[[Error]] 가 none 이 아니면, ThrowCompletion (result .[[Error]] )을 반환합니다.
특정 타입의 예외를 던지도록 명시하는 알고리즘 단계는 던질 해당 타입의 예외를 구성합니다. 예를 들어,
TypeError 예외를 던집니다.
다음과 같습니다
ThrowCompletion (새로 생성한 TypeError 객체)을 반환합니다.
5.2.4.3 Completion Record의 래핑을 해제하는 축약 표현
접두사 “?”와 “!”는 Completion Record 의 래핑을 해제하는 축약 표현으로 사용됩니다. “?”는 비정상 완료 를 호출자에게 전파하거나, 그렇지 않으면 정상 완료 의 래핑을 해제하는 데 사용됩니다. “!”는 Completion Record 가 정상임을 단언 하고 래핑을 해제하는 데 사용됩니다. 형식적으로 다음 단계는
result 를 ? record 로 둡니다.
다음과 같습니다
단언 : record 는 Completion Record 입니다.만약 record 가 비정상 완료 이면, record 를 반환합니다. result 를 record .[[Value]] 로 둡니다.
마찬가지로 다음 단계는
result 를 ! record 로 둡니다.
다음과 같습니다
단언 : record 는 정상 완료 입니다.result 를 record .[[Value]] 로 둡니다.
“?” 또는 “!”가 다른 문맥에서 사용되면 먼저 이 규칙을 적용할 수 있을 때까지 평가 순서 에 제시된 재작성 방식을 적용한 다음 이 규칙을 적용합니다. 예를 들어 다음 단계는
AO(? Other())를 수행합니다.
다음과 같이 재작성할 수 있습니다
tmp1 을 Other()로 둡니다.tmp2 를 ? tmp1 으로 둡니다.AO(tmp2 )를 수행합니다.
이를 다시 전개하면 다음과 같습니다
tmp1 을 Other()로 둡니다.단언 : tmp1 은 Completion Record 입니다.만약 tmp1 이 비정상 완료 이면, tmp1 을 반환합니다. tmp2 를 tmp1 .[[Value]] 로 둡니다.AO(tmp2 )를 수행합니다.
5.2.4.4 암묵적인 정상 완료
Completion Record 를 반환하도록 선언된 추상 연산 내의 알고리즘과 모든 내장 함수에서는 반환값을 먼저 NormalCompletion 에 전달하고 그 결과를 대신 사용합니다. 이 규칙은 Completion 알고리즘 내부나 해당 단계에서 반환값이 Completion Record 임을 명확히 표시한 경우에는 적용되지 않습니다. 이러한 경우는 다음과 같습니다:
이러한 추상 연산 에서 다른 방법으로 Completion Record 를 반환하면 편집 오류입니다. 예를 들어 이러한 추상 연산 내에서,
true 를 반환합니다.
다음 중 어느 것과도 같은 의미입니다
NormalCompletion (true )를 반환합니다.
또는
completion 을 NormalCompletion (true )로 둡니다.Completion (completion )을 반환합니다.
또는
Completion Record { [[Type]] : normal , [[Value]] : true , [[Target]] : empty }를 반환합니다.
? 축약 표현의 전개 를 통해 다음 예가 허용된다는 점에 유의하시기 바랍니다. 전개된 단계에서 비정상인 경우에는 Completion 을 적용한 결과를 직접 반환하고, 정상인 경우에는 래핑을 해제한 후 암묵적인 NormalCompletion 적용이 이루어지기 때문입니다.
? completion 을 반환합니다.
다음 예는 해당 단계에 표시하지 않은 채 Completion Record 를 반환하므로 편집 오류입니다.
completion 을 NormalCompletion (true )로 둡니다.completion 을 반환합니다.
5.2.5 정적 의미론
문맥 자유 문법은 입력 요소 스트림이 평가할 수 있는 유효한 ECMAScript Script 또는 Module 을 형성하는지 여부를 정의하는 모든 규칙을 표현할 만큼 강력하지 않습니다. 일부 상황에서는 ECMAScript 알고리즘 관례 또는 산문 형태의 요구 사항으로 표현할 수 있는 추가 규칙이 필요합니다. 이러한 규칙은 항상 문법의 생성 규칙과 연결되며, 해당 생성 규칙의 정적 의미론 이라고 합니다.
정적 의미 규칙에는 이름이 있으며 일반적으로 알고리즘으로 정의됩니다. 이름 있는 정적 의미 규칙은 문법 생성 규칙과 연결됩니다. 여러 대안적인 정의를 갖는 생성 규칙에는 일반적으로 각 대안에 대해 적용 가능한 이름 있는 정적 의미 규칙마다 별도의 알고리즘이 있습니다.
정적 의미 규칙의 특별한 종류로 조기 오류 규칙 이 있습니다. 조기 오류 규칙 은 특정 문법 생성 규칙과 연결된 조기 오류 조건(절 17 참조)을 정의합니다. 대부분의 조기 오류 규칙 평가는 이 명세의 알고리즘 내에서 명시적으로 호출되지 않습니다. 적합한 구현체는 Script 또는 Module 을 처음 평가하기 전에 해당 Script 또는 Module 을 파싱하는 데 사용된 생성 규칙의 모든 조기 오류 규칙 을 검증해야 합니다. 조기 오류 규칙 중 하나라도 위반하면 해당 Script 또는 Module 은 유효하지 않으며 평가할 수 없습니다.
5.2.6 수학 연산
이 명세에서는 다음 종류의 숫자 값을 참조합니다:
이 명세의 표현에서는 서로 다른 숫자 종류를 아래 첨자 접미사를 사용하여 구별합니다. 아래 첨자 𝔽 는 Number를 나타내고, 아래 첨자 ℤ 는 BigInt를 나타냅니다. 아래 첨자 접미사가 없는 숫자 값은 수학적 값 을 나타냅니다. 이 명세에서는 대부분의 숫자 값을 10진수로 나타내며, 0x 뒤에 숫자 0-9 또는 A-F가 오는 형식의 숫자 값은 16진수 값으로도 사용합니다.
일반적으로 이 명세에서 “y 의 길이” 또는 “네 개의 16진수 숫자가 나타내는 정수 ...”와 같이 숫자 종류를 명시적으로 지정하지 않고 숫자 값을 언급하는 경우, 해당 표현은 수학적 값 을 나타냅니다. Number 또는 BigInt 값 을 나타내는 표현에는 이를 명시적으로 표시합니다. 예를 들어 “...의 코드 포인트 수에 대한 Number 값 ” 또는 “...에 대한 BigInt 값 ”과 같습니다.
이 명세에서 정수 라는 용어를 사용할 때는 달리 명시되지 않는 한 정수 집합에 속하는 수학적 값 을 나타냅니다. 이 명세에서 정수인 Number 라는 용어를 사용할 때는 그 수학적 값 이 정수 집합에 속하는 유한한 Number 값 을 나타냅니다.
+, ×, =, ≥와 같은 숫자 연산자는 피연산자의 타입에 따라 결정되는 해당 연산을 나타냅니다. 수학적 값 에 적용되는 경우 연산자는 일반적인 수학 연산을 나타냅니다. 확장 수학적 값 에 적용되는 경우 연산자는 확장 실수에 대한 일반적인 수학 연산을 나타냅니다. 부정형은 정의되지 않으며 이 명세에서 이를 사용하는 것은 편집상의 오류로 간주해야 합니다. Number에 적용되는 경우 연산자는 IEEE 754-2019 의 관련 연산을 나타냅니다. BigInt에 적용되는 경우 연산자는 BigInt의 수학적 값 에 적용되는 일반적인 수학 연산을 나타냅니다. 서로 다른 타입의 피연산자(예: Number와 수학적 값 )에 적용되는 숫자 연산자는 정의되지 않으며 이 명세의 편집상의 오류로 간주해야 합니다.
이 문서에서는 수학적 값 과 Number 또는 BigInt 사이의 변환을 항상 명시적으로 나타냅니다. 수학적 값 또는 확장 수학적 값 x 를 Number로 변환하는 것은 “x 에 대한 Number 값 ” 또는 𝔽(x ) 로 나타내며, 6.1.6.1 에 정의되어 있습니다. 정수 x 를 BigInt로 변환하는 것은 “x 에 대한 BigInt 값 ” 또는 ℤ(x ) 로 나타냅니다. Number 또는 BigInt x 를 수학적 값 으로 변환하는 것은 “x 의 수학적 값 ” 또는 ℝ(x ) 로 나타냅니다. +0 𝔽 및 -0 𝔽 의 수학적 값 은 수학적 값 0입니다. 유한하지 않은 값의 수학적 값 은 정의되지 않습니다. x 의 확장 수학적 값 은 유한한 값의 경우 x 의 수학적 값 이고, +∞ 𝔽 및 -∞ 𝔽 의 경우 각각 +∞ 및 -∞입니다. NaN 에 대해서는 정의되지 않습니다.
수학 함수 abs(x ) 는 x 의 절댓값을 산출하며, x < 0이면 -x 이고 그렇지 않으면 x 자체입니다.
수학 함수 ln(x ) 는 x 의 자연로그를 산출합니다. 수학 함수 log10(x ) 는 x 의 밑이 10인 로그를 산출합니다. 수학 함수 log2(x ) 는 x 의 밑이 2인 로그를 산출합니다.
수학 함수 min(x1 , x2 , … , xN ) 는 x1 부터 xN 까지 중 수학적으로 가장 작은 값을 산출합니다. 수학 함수 max(x1 , x2 , ..., xN ) 는 x1 부터 xN 까지 중 수학적으로 가장 큰 값을 산출합니다. 이러한 수학 함수의 정의역과 치역은 확장 수학적 값 입니다.
표기 “x modulo y ”(y 는 유한하고 0이 아니어야 합니다)는 어떤 정수 q 에 대해 abs (k ) < abs (y ) and x - k = q × y 를 만족하고 y 와 같은 부호(또는 0)를 갖는 값 k 를 계산합니다.
“x 를 lower 와 upper 사이로 클램핑한 결과”라는 표현(x 는 확장 수학적 값 이고 lower 및 upper 는 lower ≤ upper 를 만족하는 수학적 값 )은 x < lower 이면 lower 를 산출하고, x > upper 이면 upper 를 산출하며, 그렇지 않으면 x 를 산출합니다.
수학 함수 floor(x ) 는 x 보다 크지 않은 가장 큰 정수 (+∞에 가장 가까운 정수 )를 산출합니다.
참고
floor (x ) = x - (x modulo 1) .
수학 함수 truncate(x ) 는 0 방향으로 반올림하여 x 의 소수 부분을 제거합니다. x < 0이면 -floor (-x ) 를 생성하고, 그렇지 않으면 floor (x ) 를 생성합니다.
수학 함수 min , max , abs , floor 및 truncate 는 Number와 BigInt에 대해 정의되지 않으며, 이러한 메서드에 수학적 값 이 아닌 인수를 사용하는 것은 이 명세의 편집 오류입니다.
하한 a 에서 상한 b 까지의 구간 은 동일한 숫자 타입의 숫자 값으로 구성된 집합이며, 무한하거나 비어 있을 수 있습니다. 각 경계는 포함 또는 제외 중 하나로 기술되며, 둘 다일 수는 없습니다. 구간 에는 다음과 같은 네 가지 종류가 있습니다:
a (포함)에서 b (포함)까지의 구간 은 a 에서 b 까지의 닫힌 구간 이라고도 하며, a ≤ x ≤ b 를 만족하는 동일한 숫자 타입의 모든 값 x 를 포함하고 그 밖의 값은 포함하지 않습니다.
a (포함)에서 b (제외)까지의 구간 은 a ≤ x < b 를 만족하는 동일한 숫자 타입의 모든 값 x 를 포함하고 그 밖의 값은 포함하지 않습니다.
a (제외)에서 b (포함)까지의 구간 은 a < x ≤ b 를 만족하는 동일한 숫자 타입의 모든 값 x 를 포함하고 그 밖의 값은 포함하지 않습니다.
a (제외)에서 b (제외)까지의 구간 은 a < x < b 를 만족하는 동일한 숫자 타입의 모든 값 x 를 포함하고 그 밖의 값은 포함하지 않습니다.
예를 들어 1(포함)에서 2(제외)까지의 구간 은 1을 포함하고 2는 포함하지 않는, 1과 2 사이의 모든 수학적 값 으로 구성됩니다. 구간 을 정의할 때는 -0 𝔽 < +0 𝔽 이므로, 예를 들어 하한이 +0 𝔽 인 닫힌 구간 은 +0 𝔽 를 포함하지만 -0 𝔽 는 포함하지 않습니다. NaN 은 어떤 구간 에도 포함되지 않습니다.
5.2.7 값 표기법
이 명세에서 ECMAScript 언어 값 은 굵은 글씨 로 표시됩니다. 예로는 null , true 또는 "hello" 가 있습니다. 이러한 값은 Function.prototype.apply 또는 let n = 42;와 같은 ECMAScript 소스 텍스트 와 구별됩니다.
5.2.8 동일성
이 명세에서는 명세 값과 ECMAScript 언어 값 모두에 대해 동등성을 비교합니다. 동등성을 비교할 때 값은 두 범주 중 하나에 속합니다. 동일성이 없는 값 은 정수 의 크기나 시퀀스의 길이와 같은 모든 고유 특성이 같으면 다른 동일성이 없는 값과 동등합니다. 동일성이 없는 값은 그 특성을 완전히 기술함으로써 사전 참조 없이 나타낼 수 있습니다. 반면 각 동일성이 있는 값 은 고유하므로 자기 자신과만 동등합니다. 동일성이 있는 값은 동일성이 없는 값과 유사하지만, 동일성 이라는 추측할 수 없고 변경할 수 없으며 전역적으로 고유한 특성이 추가로 있습니다. 동일성 자체는 기술할 수 없으므로 기존의 동일성이 있는 값에 대한 참조는 단순히 해당 값을 기술하는 것만으로 나타낼 수 없습니다. 대신 이러한 값에 대한 참조를 한 곳에서 다른 곳으로 명시적으로 전달해야 합니다. 동일성이 있는 값 중 일부는 변경 가능하므로 동일성을 제외한 특성을 그 자리에서 변경할 수 있으며, 그 값을 보유한 모든 곳에서 새로운 특성을 관찰하게 됩니다. 동일성이 없는 값은 동일성이 있는 값과 결코 동등하지 않습니다.
이 명세의 관점에서 “이다”라는 말은 “만약 bool 이 true 이면, ...”와 같이 두 값의 동등성을 비교하는 데 사용되며, “포함한다”라는 말은 “만약 list 가 r .[[Foo]] 가 true 인 Record r 을 포함하면, ...”와 같이 동등성 비교를 사용하여 리스트 안에서 값을 찾는 데 사용됩니다. 값의 명세 동일성 은 이러한 비교의 결과를 결정하며, 이 명세에서 공리적으로 주어집니다.
ECMAScript 언어의 관점에서 언어 값의 동등성은 SameValue 추상 연산 과 이 연산이 전이적으로 호출하는 추상 연산 을 사용하여 비교합니다. 이러한 비교 추상 연산 의 알고리즘은 ECMAScript 언어 값 의 언어 동일성 을 결정합니다.
명세 값 중 명세 동일성이 없는 값의 예에는 수학적 값 과 확장된 수학적 값 ; ECMAScript 소스 텍스트 , 서로게이트 쌍 , 지시문 프롤로그 등; UTF-16 코드 단위; 유니코드 코드 포인트; 열거 값; 구문 지향 연산 과 호스트 훅 등을 포함하는 추상 연산 ; 순서쌍이 있으며, 이에 한정되지 않습니다. 명세 동일성이 있는 명세 값의 예에는 Property Descriptor , PrivateElement 등을 포함하는 모든 종류의 Record ; 파스 노드 ; List ; Set 과 Relation ; Abstract Closure ; Data Block ; Private Name ; 실행 컨텍스트 와 실행 컨텍스트 스택 ; 에이전트 식별자 ; WaiterList Record 가 있으며, 이에 한정되지 않습니다.
Symbol.for 로 생성한 Symbol 값을 제외한 모든 ECMAScript 언어 값 에서 명세 동일성과 언어 동일성은 일치합니다. 명세 동일성과 언어 동일성이 모두 없는 ECMAScript 언어 값 은 undefined , null , Boolean , String , Number 및 BigInt 입니다. 명세 동일성과 언어 동일성이 모두 있는 ECMAScript 언어 값 은 Symbol 중 Symbol.for 로 생성하지 않은 값과 Object 입니다. Symbol.for 로 생성한 Symbol 값에는 명세 동일성이 있지만 언어 동일성은 없습니다.
6 ECMAScript 데이터 타입과 값
이 명세의 알고리즘은 각각 연관된 타입이 있는 값을 조작합니다. 가능한 값 타입은 정확히 이 절에 정의된 타입입니다. 타입은 다시 ECMAScript 언어 타입 과 명세 타입으로 분류됩니다.
6.1 ECMAScript 언어 타입
ECMAScript 언어 타입 은 ECMAScript 프로그래머가 ECMAScript 언어를 사용하여 직접 조작하는 값에 대응합니다. ECMAScript 언어 타입은 Undefined, Null, Boolean, String, Symbol, Number, BigInt 및 Object입니다. ECMAScript 언어 값 은 ECMAScript 언어 타입으로 특징지어지는 값입니다.
6.1.1 Undefined 타입
Undefined 타입에는 undefined 라고 하는 값이 정확히 하나 있습니다. 값이 할당되지 않은 모든 변수는 undefined 값을 갖습니다.
6.1.2 Null 타입
Null 타입에는 null 이라고 하는 값이 정확히 하나 있습니다.
6.1.3 Boolean 타입
Boolean 타입 은 true 와 false 라고 하는 두 값을 갖는 논리적 개체를 나타냅니다.
6.1.4 String 타입
String 타입 은 0개 이상의 16비트 부호 없는 정숫값(“요소”)으로 이루어진 모든 순서 있는 시퀀스의 집합이며, 최대 길이는 253 - 1개 요소입니다. String 타입은 일반적으로 실행 중인 ECMAScript 프로그램의 텍스트 데이터를 나타내는 데 사용되며, 이 경우 String의 각 요소는 UTF-16 코드 단위 값으로 취급됩니다. 각 요소는 시퀀스 내의 한 위치를 차지하는 것으로 간주됩니다. 이러한 위치는 음이 아닌 정수 로 인덱싱됩니다. 첫 번째 요소가 있으면 인덱스 0에 있고, 다음 요소가 있으면 인덱스 1에 있으며, 이후에도 같은 방식으로 이어집니다. String의 길이는 그 안에 포함된 요소(즉, 16비트 값)의 개수입니다. 빈 String의 길이는 0이므로 요소를 포함하지 않습니다.
String 내용을 해석하지 않는 ECMAScript 연산은 추가적인 의미론을 적용하지 않습니다. String 값을 해석하는 연산은 각 요소를 하나의 UTF-16 코드 단위로 취급합니다. 그러나 ECMAScript는 이러한 코드 단위의 값이나 코드 단위 사이의 관계를 제한하지 않으므로, String 내용을 UTF-16으로 인코딩된 유니코드 코드 포인트 시퀀스로 추가 해석하는 연산은 올바르지 않은 부분 시퀀스를 고려해야 합니다. 이러한 연산은 숫자 값이 0xD800부터 0xDBFF까지의 닫힌 구간 에 있는 모든 코드 단위(유니코드 표준에서 선행 서로게이트 , 더 공식적으로는 상위 서로게이트 코드 단위 로 정의됨)와 숫자 값이 0xDC00부터 0xDFFF까지의 닫힌 구간 에 있는 모든 코드 단위(후행 서로게이트 , 더 공식적으로는 하위 서로게이트 코드 단위 로 정의됨)를 다음 규칙에 따라 특별하게 취급합니다:
String.prototype.normalize 함수(22.1.3.15 참조)를 사용하여 String 값을 명시적으로 정규화할 수 있습니다. String.prototype.localeCompare(22.1.3.12 참조)는 내부적으로 String 값을 정규화하지만, 다른 어떤 연산도 자신이 처리하는 String을 암묵적으로 정규화하지 않습니다. 달리 명시되지 않는 한 연산 결과는 언어 및/또는 로케일에 민감하지 않습니다.
참고
이 설계의 근거는 String의 구현을 가능한 한 단순하고 고성능으로 유지하기 위한 것입니다. ECMAScript 소스 텍스트 가 정규화 형식 C인 경우, 문자열 리터럴에 유니코드 이스케이프 시퀀스가 포함되지 않는 한 문자열 리터럴도 정규화되어 있음이 보장됩니다.
이 명세에서 “A , B , ...의 문자열 연결 ”이라는 문구(각 인수는 String 값, 코드 단위 또는 코드 단위 시퀀스입니다)는 각 인수의 코드 단위를 인수 순서대로 연결한 코드 단위 시퀀스를 갖는 String 값을 나타냅니다.
“string 의 inclusiveStart 부터 exclusiveEnd 까지의 부분 문자열 ”이라는 문구(string 은 String 값 또는 코드 단위 시퀀스이고 inclusiveStart 와 exclusiveEnd 는 정수 입니다)는 string 에서 인덱스 inclusiveStart 로 시작하여 인덱스 exclusiveEnd 바로 앞에서 끝나는 연속 코드 단위로 구성된 String 값을 나타냅니다(inclusiveStart = exclusiveEnd 이면 빈 String입니다). “to” 접미사가 생략되면 string 의 길이가 exclusiveEnd 값으로 사용됩니다.
“ASCII 단어 문자 ”라는 문구는 유니코드 기본 라틴 블록의 모든 문자와 숫자 및 U+005F (LOW LINE)만으로 구성된 다음 String 값을 나타냅니다:
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_" .
역사적인 이유로 이는 여러 알고리즘에서 중요한 의미를 갖습니다.
6.1.4.1 StringIndexOf ( string , searchValue , fromIndex )
추상 연산 StringIndexOf. 인수 string (String), searchValue (String) 및 fromIndex (음이 아닌 정수 ). 반환값: 음이 아닌 정수 또는 not-found . 호출되면 다음 단계를 수행한다.
length 를 string 의 길이로 둡니다.searchValue 가 빈 String이고 fromIndex ≤ length 이면, fromIndex 를 반환합니다.searchLength 를 searchValue 의 길이로 둡니다.fromIndex ≤ i ≤ length - searchLength 를 만족하는 각 정수 i 에 대해 오름차순으로 다음을 수행합니다.candidate 를 string 의 i 부터 i + searchLength 까지의 부분 문자열 로 둡니다.candidate 가 searchValue 이면, i 를 반환합니다.not-found 를 반환합니다.
참고 1
searchValue 가 빈 String이고 fromIndex ≤ string 의 길이이면, 이 알고리즘은 fromIndex 를 반환합니다. 빈 String은 마지막 코드 단위 뒤를 포함하여 문자열 내의 모든 위치에서 사실상 발견됩니다.
참고 2
fromIndex + searchValue 의 길이 > string 의 길이이면 이 알고리즘은 항상 not-found 를 반환합니다.
6.1.4.2 StringLastIndexOf ( string , searchValue , fromIndex )
추상 연산 StringLastIndexOf. 인수 string (String), searchValue (String) 및 fromIndex (음이 아닌 정수 ). 반환값: 음이 아닌 정수 또는 not-found . 호출되면 다음 단계를 수행한다.
length 를 string 의 길이로 둡니다.searchLength 를 searchValue 의 길이로 둡니다.단언 : fromIndex + searchLength ≤ length 입니다.0 ≤ i ≤ fromIndex 를 만족하는 각 정수 i 에 대해 내림차순으로 다음을 수행합니다.candidate 를 string 의 i 부터 i + searchLength 까지의 부분 문자열 로 둡니다.candidate 가 searchValue 이면, i 를 반환합니다. not-found 를 반환합니다.
참고
searchValue 가 빈 String이면 이 알고리즘은 fromIndex 를 반환합니다. 빈 String은 마지막 코드 단위 뒤를 포함하여 문자열 내의 모든 위치에서 사실상 발견됩니다.
6.1.5 Symbol 타입
Symbol 타입 은 Object 프로퍼티의 키로 사용할 수 있는 모든 String이 아닌 값의 집합입니다(6.1.7 ).
각 Symbol은 고유하며 변경할 수 없습니다.
각 Symbol에는 값이 String 또는 undefined 인 변경 불가능한 [[Description]] 내부 슬롯이 있습니다.
6.1.5.1 잘 알려진 Symbol
잘 알려진 Symbol은 이 명세의 알고리즘에서 명시적으로 참조하는 내장 Symbol 값입니다. 일반적으로 명세 알고리즘의 확장 지점 역할을 하는 값을 가진 프로퍼티의 키로 사용됩니다. 달리 명시되지 않는 한 잘 알려진 Symbol 값은 모든 realm 에서 공유됩니다(9.3 ).
이 명세에서 잘 알려진 Symbol은 표준 내재 표기법 을 사용하여 참조하며, 여기에서 내재 객체는 표 1 에 나열된 값 중 하나입니다.
참고 이 명세의 이전 판에서는 현재 판에서 %Symbol.name%을 사용하는 곳에 @@name 형식의 표기법을 사용했습니다. 구체적으로 다음 이름이 사용되었습니다: @@asyncIterator, @@hasInstance, @@isConcatSpreadable, @@iterator , @@match, @@matchAll, @@replace, @@search, @@species, @@split, @@toPrimitive, @@toStringTag 및 @@unscopables.
표 1: 잘 알려진 Symbol
명세 이름
[[Description]]
값과 목적
%Symbol.asyncDispose%
"Symbol.asyncDispose"
객체에서 리소스 정리를 비동기적으로 수행하는 메서드입니다. 포함하는 스코프의 평가가 완료될 때 AsyncDisposableStack 객체와 await using 선언에서 호출됩니다.
%Symbol.asyncIterator%
"Symbol.asyncIterator"
객체의 기본 비동기 이터레이터를 반환하는 메서드입니다. for-await-of 문의 의미론에서 호출됩니다.
%Symbol.dispose%
"Symbol.dispose"
객체에서 명시적인 리소스 정리를 수행하는 메서드입니다. 포함하는 스코프의 평가가 완료될 때 DisposableStack 객체, AsyncDisposableStack 객체 및 using 선언에서 호출됩니다.
%Symbol.hasInstance%
"Symbol.hasInstance"
생성자 객체가 어떤 객체를 해당 생성자 의 인스턴스 중 하나로 인식하는지 결정하는 메서드입니다. instanceof 연산자의 의미론에서 호출됩니다.
%Symbol.isConcatSpreadable%
"Symbol.isConcatSpreadable"
값이 true이면 Array.prototype.concat 에 의해 객체가 배열 요소로 평탄화되어야 함을 나타내는 Boolean 값 프로퍼티입니다.
%Symbol.iterator%
"Symbol.iterator"
객체의 기본 이터레이터를 반환하는 메서드입니다. for-of 문의 의미론에서 호출됩니다.
%Symbol.match%
"Symbol.match"
정규 표현식을 문자열과 일치시키는 정규 표현식 메서드입니다. String.prototype.match 메서드에서 호출됩니다.
%Symbol.matchAll%
"Symbol.matchAll"
문자열에 대한 정규 표현식의 일치 결과를 생성하는 이터레이터를 반환하는 정규 표현식 메서드입니다. String.prototype.matchAll 메서드에서 호출됩니다.
%Symbol.replace%
"Symbol.replace"
문자열에서 일치한 부분 문자열 을 치환하는 정규 표현식 메서드입니다. String.prototype.replace 메서드에서 호출됩니다.
%Symbol.search%
"Symbol.search"
문자열에서 정규 표현식과 일치하는 인덱스를 반환하는 정규 표현식 메서드입니다. String.prototype.search 메서드에서 호출됩니다.
%Symbol.species%
"Symbol.species"
파생 객체를 생성하는 데 사용되는 생성자 함수인 함수 값 프로퍼티입니다.
%Symbol.split%
"Symbol.split"
정규 표현식과 일치하는 인덱스에서 문자열을 분할하는 정규 표현식 메서드입니다. String.prototype.split 메서드에서 호출됩니다.
%Symbol.toPrimitive%
"Symbol.toPrimitive"
객체를 대응하는 원시값으로 변환하는 메서드입니다. ToPrimitive 추상 연산 에서 호출됩니다.
%Symbol.toStringTag%
"Symbol.toStringTag"
객체의 기본 문자열 설명을 생성하는 데 사용되는 String 값 프로퍼티입니다. 내장 메서드 Object.prototype.toString 에서 접근합니다.
%Symbol.unscopables%
"Symbol.unscopables"
자체 프로퍼티 이름 과 상속된 프로퍼티 이름 이 연결된 객체의 with 환경 바인딩에서 제외되는 프로퍼티 이름 인 객체 값 프로퍼티입니다.
6.1.6 숫자 타입
ECMAScript에는 Number와 BigInt라는 두 개의 내장 숫자 타입이 있습니다. 다음 추상 연산 은 이러한 숫자 타입에 대해 정의됩니다. “결과” 열에는 반환 타입과 함께 연산의 일부 호출이 비정상 완료 를 반환할 가능성이 있는지를 표시합니다.
표 2: 숫자 타입 연산
연산
예제 소스
...의 Evaluation 의미론에서 호출
결과
Number::unaryMinus
-x
단항 - 연산자
Number
BigInt::unaryMinus
BigInt
Number::bitwiseNOT
~x
비트 NOT 연산자 ( ~ )
Number
BigInt::bitwiseNOT
BigInt
Number::exponentiate
x ** y
지수 연산자
및 Math.pow ( base , exponent )
Number
BigInt::exponentiate
BigInt를 포함하는 정상 완료 또는 던지기 완료
Number::multiply
x * y
곱셈 연산자
Number
BigInt::multiply
BigInt
Number::divide
x / y
곱셈 연산자
Number
BigInt::divide
BigInt를 포함하는 정상 완료 또는 던지기 완료
Number::remainder
x % y
곱셈 연산자
Number
BigInt::remainder
BigInt를 포함하는 정상 완료 또는 던지기 완료
Number::add
x ++
++ x
x + y
후위 증가 연산자 ,
전위 증가 연산자 ,
및 덧셈 연산자 ( + )
Number
BigInt::add
BigInt
Number::subtract
x --
-- x
x - y
후위 감소 연산자 ,
전위 감소 연산자 ,
및 뺄셈 연산자 ( - )
Number
BigInt::subtract
BigInt
Number::leftShift
x << y
왼쪽 시프트 연산자 ( << )
Number
BigInt::leftShift
BigInt
Number::signedRightShift
x >> y
부호 있는 오른쪽 시프트 연산자 ( >> )
Number
BigInt::signedRightShift
BigInt
Number::unsignedRightShift
x >>> y
부호 없는 오른쪽 시프트 연산자 ( >>> )
Number
BigInt::unsignedRightShift
던지기 완료
Number::lessThan
x < y
x > y
x <= y
x >= y
관계 연산자 ,
IsLessThan ( x , y , leftFirst ) 를 통해
Boolean 또는 undefined (순서가 없는 입력의 경우)
BigInt::lessThan
Boolean
Number::equal
x == y
x != y
x === y
x !== y
동등 연산자 ,
IsStrictlyEqual ( x , y ) 를 통해
Boolean
BigInt::equal
Number::sameValue
Object.is(x, y)
Object 내부 메서드에서,
SameValue ( x , y ) 를 통해,
정확한 값 동등성을 검사하기 위해 사용
Boolean
Number::sameValueZero
[x].includes(y)
SameValueZero ( x , y ) 를 통해,
Array, Map 및 Set 메서드에서처럼 +0 𝔽 과 -0 𝔽 의 차이를 무시하여 값 동등성을 검사하기 위해 사용
Boolean
Number::bitwiseAND
x & y
이항 비트 연산자
Number
BigInt::bitwiseAND
BigInt
Number::bitwiseXOR
x ^ y
Number
BigInt::bitwiseXOR
BigInt
Number::bitwiseOR
x | y
Number
BigInt::bitwiseOR
BigInt
Number::toString
String(x)
많은 표현식과 내장 함수에서 ToString ( arg ) 를 통해 호출
String
BigInt::toString
숫자 타입은 일반적으로 정밀도 손실이나 잘림 없이 서로 변환할 수 없으므로 ECMAScript 언어는 이러한 타입 사이에 암묵적 변환을 제공하지 않습니다. 다른 타입을 요구하는 함수를 호출할 때 타입을 변환하려면 프로그래머가 Number 및 BigInt 함수를 명시적으로 호출해야 합니다.
참고
ECMAScript 초판과 이후 판에서는 특정 연산자에 대해 정밀도 손실이나 잘림이 발생할 수 있는 암묵적 숫자 변환을 제공해 왔습니다. 이러한 레거시 암묵적 변환은 하위 호환성을 위해 유지되지만, 프로그래머 오류의 가능성을 최소화하고 향후 판에서 일반화된 값 타입 을 도입할 가능성을 열어 두기 위해 BigInt에는 제공되지 않습니다.
6.1.6.1 Number 타입
Number 타입 은 정확히 18,437,736,874,454,810,627개(즉, 264 - 253 + 3 )의 값을 가지며, IEEE 부동 소수점 산술 표준에 명시된 배정밀도 부동 소수점 IEEE 754-2019 binary64 값을 나타냅니다. 단, IEEE 표준의 서로 구별되는 9,007,199,254,740,990개(즉, 253 - 2 )의 NaN 값은 ECMAScript에서 하나의 특수한 NaN 값으로 나타냅니다. (NaN 값은 프로그램 표현식 NaN에 의해 생성된다는 점에 유의하십시오.) 일부 구현에서는 외부 코드가 다양한 NaN 값 간의 차이를 감지할 수 있지만, 이러한 동작은 구현 정의입니다. ECMAScript 코드에서는 모든 NaN 값을 서로 구별할 수 없습니다.
참고
Number 값 이 ArrayBuffer(25.1 참조) 또는 SharedArrayBuffer(25.2 참조)에 저장된 후 관찰될 수 있는 비트 패턴은 ECMAScript 구현에서 사용하는 해당 Number 값 의 내부 표현과 반드시 동일하지는 않습니다.
양의 무한대 와 음의 무한대 라고 하는 두 개의 다른 특수 값이 있습니다. 간결하게 설명하기 위해 이러한 값은 각각 기호 +∞ 𝔽 와 -∞ 𝔽 로도 지칭합니다. (이 두 무한 Number 값 은 프로그램 표현식 +Infinity(또는 단순히 Infinity)와 -Infinity에 의해 생성된다는 점에 유의하십시오.)
나머지 18,437,736,874,454,810,624개(즉, 264 - 253 )의 각 값은 유한 Number 입니다. 이 중 절반은 양수이고 절반은 음수입니다. 모든 양의 유한 Number 에는 크기가 같은 대응하는 음의 Number가 있습니다.
양의 0 과 음의 0 이 모두 존재한다는 점에 유의하십시오. 간결하게 설명하기 위해 이러한 값은 각각 기호 +0 𝔽 와 -0 𝔽 로도 지칭합니다. (이 두 개의 서로 다른 0 Number 값 은 프로그램 표현식 +0(또는 단순히 0)과 -0에 의해 생성된다는 점에 유의하십시오.)
18,437,736,874,454,810,622개(즉, 264 - 253 - 2 )의 유한한 0이 아닌 값은 두 종류입니다.
그중 18,428,729,675,200,069,632개(즉, 264 - 254 )는 정규화된 값이며, 다음 형식을 가집니다.
s × m × 2e
여기서 s 는 1 또는 -1이고, m 은 252 (포함)부터 253 (제외)까지의 구간 에 있는 정수 이며, e 는 -1074부터 971까지의 양 끝을 포함하는 구간 에 있는 정수 입니다.
나머지 9,007,199,254,740,990개(즉, 253 - 2 )의 값은 비정규화된 값이며, 다음 형식을 가집니다.
s × m × 2e
여기서 s 는 1 또는 -1이고, m 은 0(제외)부터 252 (제외)까지의 구간 에 있는 정수 이며, e 는 -1074입니다.
크기가 253 이하인 모든 양의 정수 와 음의 정수 는 Number 타입으로 표현할 수 있다는 점에 유의하십시오. 정수 0은 Number 타입에서 두 가지 표현, 즉 +0 𝔽 와 -0 𝔽 를 가집니다.
유한 Number 가 0이 아니고 이를 표현하는 데 사용되는 정수 m (위에 표시된 두 형식 중 하나에서)가 홀수이면 홀수 유효숫자 를 가집니다. 그렇지 않으면 짝수 유효숫자 를 가집니다.
이 명세에서 x 가 정확한 실수의 수학적 양(π와 같은 무리수일 수도 있음)을 나타낼 때 “x 에 대한 Number 값 ”이라는 구문은 다음 방식으로 선택된 Number 값 을 의미합니다. -0 𝔽 를 제외한 모든 유한 Number 의 합집합에 Number 타입으로 표현할 수 없는 두 개의 추가 값, 즉 21024 (이는 +1 × 253 × 2971 )와 -21024 (이는 -1 × 253 × 2971 )를 더한 집합을 고려합니다. 이 집합에서 값이 x 에 가장 가까운 원소를 선택합니다. 집합의 두 값이 동일하게 가깝다면 짝수 유효숫자를 가진 값을 선택합니다. 이를 위해 두 추가 값 21024 와 -21024 는 짝수 유효숫자를 가진 것으로 간주합니다. 마지막으로 21024 가 선택된 경우 이를 +∞ 𝔽 로 바꾸고, -21024 가 선택된 경우 이를 -∞ 𝔽 로 바꾸며, +0 𝔽 가 선택된 경우 x < 0인 경우에만 이를 -0 𝔽 로 바꿉니다. 그 밖의 선택된 값은 변경하지 않고 사용합니다. 그 결과가 x 에 대한 Number 값 입니다. (이 절차는 IEEE 754-2019 roundTiesToEven 모드의 동작과 정확히 일치합니다.)
+∞에 대한 Number 값 은 +∞ 𝔽 이고, -∞에 대한 Number 값 은 -∞ 𝔽 입니다.
일부 ECMAScript 연산자는 -231 부터 231 - 1 까지의 양 끝을 포함하는 구간 이나 0부터 216 - 1 까지의 양 끝을 포함하는 구간 과 같은 특정 범위의 정수 만 처리합니다. 이러한 연산자는 Number 타입의 모든 값을 허용하지만, 먼저 각 값을 예상 범위의 정수 값으로 변환합니다. 7.1 의 숫자 변환 연산에 대한 설명을 참조하십시오.
6.1.6.1.1 Number::unaryMinus ( number )
추상 연산 Number::unaryMinus. 인수 number (Number). 반환값: Number. 호출되면 다음 단계를 수행한다.
number 가 NaN 이면, NaN 을 반환합니다.number 의 부정값, 즉 크기는 같지만 부호가 반대인 Number를 계산하여 반환합니다.
6.1.6.1.2 Number::bitwiseNOT ( number )
추상 연산 Number::bitwiseNOT. 인수 number (Number). 반환값: 정수인 Number . 호출되면 다음 단계를 수행한다.
oldValue 를 ! ToInt32 (number )로 둡니다.oldValue 의 비트 보수를 반환합니다. 결과의 수학적 값 은 32비트 2의 보수 비트 문자열로 정확하게 표현할 수 있습니다.
6.1.6.1.3 Number::exponentiate ( base , exponent )
추상 연산 Number::exponentiate. 인수 base (Number) 및 exponent (Number). 반환값: Number. base 를 exponent 제곱한 결과를 나타내는 구현체 근사 값을 반환합니다. 호출되면 다음 단계를 수행한다.
exponent 가 NaN 이면 NaN 을 반환합니다.exponent 가 +0 𝔽 또는 -0 𝔽 중 하나이면 1 𝔽 을 반환합니다.base 가 NaN 이면 NaN 을 반환합니다.base 가 +∞ 𝔽 이면 다음을 수행합니다.exponent > +0 𝔽 이면 +∞ 𝔽 을 반환합니다.+0 𝔽 을 반환합니다.base 가 -∞ 𝔽 이면 다음을 수행합니다.exponent > +0 𝔽 이면 다음을 수행합니다.exponent 가 홀수인 정수 Number이면 -∞ 𝔽 을 반환합니다.+∞ 𝔽 을 반환합니다.exponent 가 홀수인 정수 Number이면 -0 𝔽 을 반환합니다.+0 𝔽 을 반환합니다.base 가 +0 𝔽 이면 다음을 수행합니다.exponent > +0 𝔽 이면 +0 𝔽 을 반환합니다.+∞ 𝔽 을 반환합니다.base 가 -0 𝔽 이면 다음을 수행합니다.exponent > +0 𝔽 이면 다음을 수행합니다.exponent 가 홀수인 정수 Number이면 -0 𝔽 을 반환합니다.+0 𝔽 을 반환합니다.exponent 가 홀수인 정수 Number이면 -∞ 𝔽 을 반환합니다.+∞ 𝔽 을 반환합니다.단언 : base 는 유한 Number 이며 +0 𝔽 도 -0 𝔽 도 아닙니다.exponent 가 +∞ 𝔽 이면 다음을 수행합니다.abs (ℝ (base )) > 1이면 +∞ 𝔽 을 반환합니다.abs (ℝ (base )) = 1이면 NaN 을 반환합니다.+0 𝔽 을 반환합니다.exponent 가 -∞ 𝔽 이면 다음을 수행합니다.abs (ℝ (base )) > 1이면 +0 𝔽 을 반환합니다.abs (ℝ (base )) = 1이면 NaN 을 반환합니다.+∞ 𝔽 을 반환합니다.단언 : exponent 는 유한 Number 이며 +0 𝔽 도 -0 𝔽 도 아닙니다.base < -0 𝔽 이고 exponent 가 정수 Number가 아니면 NaN 을 반환합니다.ℝ (base )를 ℝ (exponent ) 제곱한 결과를 나타내는 구현에서 근사한 Number 값 을 반환합니다.
참고
base 가 1 𝔽 또는 -1 𝔽 이고 exponent 가 +∞ 𝔽 또는 -∞ 𝔽 인 경우, 또는 base 가 1 𝔽 이고 exponent 가 NaN 인 경우의 base ** exponent 결과는 IEEE 754-2019 와 다릅니다. ECMAScript 초판은 이 연산의 결과를 NaN 으로 명시했지만, 이후 IEEE 754 개정판은 1 𝔽 을 명시했습니다. 호환성을 위해 역사적인 ECMAScript 동작을 유지합니다.
6.1.6.1.4 Number::multiply ( x , y )
추상 연산 Number::multiply. 인수 x (Number) 및 y (Number). 반환값: Number. IEEE 754-2019 이진 배정밀도 산술 규칙에 따라 곱셈을 수행하여 x 와 y 의 곱을 생성합니다. 호출되면 다음 단계를 수행한다.
x 가 NaN 이거나 y 가 NaN 이면, NaN 을 반환합니다.x 가 +∞ 𝔽 또는 -∞ 𝔽 이면, 다음을 수행합니다.y 가 +0 𝔽 또는 -0 𝔽 이면, NaN 을 반환합니다.y > +0 𝔽 이면, x 를 반환합니다.-x 를 반환합니다. y 가 +∞ 𝔽 또는 -∞ 𝔽 이면, 다음을 수행합니다.x 가 +0 𝔽 또는 -0 𝔽 이면, NaN 을 반환합니다.x > +0 𝔽 이면, y 를 반환합니다.-y 를 반환합니다. x 가 -0 𝔽 이면, 다음을 수행합니다.y 가 -0 𝔽 이거나 y < -0 𝔽 이면, +0 𝔽 을 반환합니다.-0 𝔽 을 반환합니다.y 가 -0 𝔽 이면, 다음을 수행합니다.x < -0 𝔽 이면, +0 𝔽 을 반환합니다.-0 𝔽 을 반환합니다.𝔽 (ℝ (x ) × ℝ (y ))를 반환합니다.
참고
유한 정밀도 곱셈은 교환법칙을 만족하지만 항상 결합법칙을 만족하는 것은 아닙니다.
6.1.6.1.5 Number::divide ( x , y )
추상 연산 Number::divide. 인수 x (Number) 및 y (Number). 반환값: Number. IEEE 754-2019 이진 배정밀도 산술 규칙에 따라 나눗셈을 수행하며, x 가 피제수이고 y 가 제수인 x 와 y 의 몫을 생성합니다. 호출되면 다음 단계를 수행한다.
x 가 NaN 이거나 y 가 NaN 이면, NaN 을 반환합니다.x 가 +∞ 𝔽 또는 -∞ 𝔽 이면, 다음을 수행합니다.y 가 +∞ 𝔽 또는 -∞ 𝔽 이면, NaN 을 반환합니다.y 가 +0 𝔽 이거나 y > +0 𝔽 이면, x 를 반환합니다.-x 를 반환합니다. y 가 +∞ 𝔽 이면, 다음을 수행합니다.x 가 +0 𝔽 이거나 x > +0 𝔽 이면, +0 𝔽 을 반환합니다.-0 𝔽 을 반환합니다.y 가 -∞ 𝔽 이면, 다음을 수행합니다.x 가 +0 𝔽 이거나 x > +0 𝔽 이면, -0 𝔽 을 반환합니다.+0 𝔽 을 반환합니다.x 가 +0 𝔽 또는 -0 𝔽 이면, 다음을 수행합니다.y 가 +0 𝔽 또는 -0 𝔽 이면, NaN 을 반환합니다.y > +0 𝔽 이면, x 를 반환합니다.-x 를 반환합니다. y 가 +0 𝔽 이면, 다음을 수행합니다.x > +0 𝔽 이면, +∞ 𝔽 을 반환합니다.-∞ 𝔽 을 반환합니다.y 가 -0 𝔽 이면, 다음을 수행합니다.x > +0 𝔽 이면, -∞ 𝔽 을 반환합니다.+∞ 𝔽 을 반환합니다.𝔽 (ℝ (x ) / ℝ (y ))를 반환합니다.
6.1.6.1.6 Number::remainder ( numerator , denominator )
추상 연산 Number::remainder. 인수 numerator (Number) 및 denominator (Number). 반환값: Number. 피연산자의 암묵적인 나눗셈에서 나머지를 생성하며, 여기에서 numerator 는 피제수이고 denominator 는 제수입니다. 호출되면 다음 단계를 수행한다.
numerator 가 NaN 이거나 denominator 가 NaN 이면 NaN 을 반환합니다.numerator 가 +∞ 𝔽 또는 -∞ 𝔽 중 하나이면 NaN 을 반환합니다.denominator 가 +∞ 𝔽 또는 -∞ 𝔽 중 하나이면 numerator 를 반환합니다.denominator 가 +0 𝔽 또는 -0 𝔽 중 하나이면 NaN 을 반환합니다.numerator 가 +0 𝔽 또는 -0 𝔽 중 하나이면 numerator 를 반환합니다.단언 : numerator 는 유한 Number 이며 +0 𝔽 도 -0 𝔽 도 아닙니다.단언 : denominator 는 유한 Number 이며 +0 𝔽 도 -0 𝔽 도 아닙니다.quotient 를 ℝ (numerator ) / ℝ (denominator )로 둡니다.truncatedQuotient 를 truncate (quotient )로 둡니다.remainder 를 ℝ (numerator ) - (ℝ (denominator ) × truncatedQuotient )로 둡니다.remainder = 0이고 numerator < -0 𝔽 이면 -0 𝔽 을 반환합니다.𝔽 (remainder )를 반환합니다.
참고 1
C와 C++에서 나머지 연산자는 정수 피연산자만 허용하지만, ECMAScript에서는 부동소수점 피연산자도 허용합니다.
참고 2 % 연산자가 계산하는 부동소수점 나머지 연산의 결과는
IEEE 754-2019 에서 정의한 “나머지” 연산과 같지 않습니다.
IEEE 754-2019 의 “나머지” 연산은 절삭 나눗셈이 아니라 반올림 나눗셈에서 나머지를 계산하므로 일반적인
정수 나머지 연산자의 동작과 유사하지 않습니다. 대신 ECMAScript 언어는 부동소수점 연산에 대한
%가 Java의
정수 나머지 연산자와 유사하게 동작하도록 정의합니다. 이는 C 라이브러리 함수 fmod와 비교할 수 있습니다.
6.1.6.1.7 Number::add ( x , y )
추상 연산 Number::add. 인수 x (Number) 및 y (Number). 반환값: Number. IEEE 754-2019 이진 배정밀도 산술 규칙에 따라 덧셈을 수행하여 인수의 합을 생성합니다. 호출되면 다음 단계를 수행한다.
x 가 NaN 이거나 y 가 NaN 이면 NaN 을 반환합니다.x 가 +∞ 𝔽 이고 y 가 -∞ 𝔽 이면 NaN 을 반환합니다.x 가 -∞ 𝔽 이고 y 가 +∞ 𝔽 이면 NaN 을 반환합니다.x 가 +∞ 𝔽 또는 -∞ 𝔽 중 하나이면 x 를 반환합니다.y 가 +∞ 𝔽 또는 -∞ 𝔽 중 하나이면 y 를 반환합니다.단언 : x 와 y 는 유한 Number 입니다.x 가 -0 𝔽 이고 y 가 -0 𝔽 이면 -0 𝔽 을 반환합니다.𝔽 (ℝ (x ) + ℝ (y ))를 반환합니다.
참고
유한 정밀도 덧셈은 교환법칙을 만족하지만 항상 결합법칙을 만족하는 것은 아닙니다.
6.1.6.1.8 Number::subtract ( x , y )
추상 연산 Number::subtract. 인수 x (Number) 및 y (Number). 반환값: Number. 뺄셈을 수행하여 피연산자의 차를 생성합니다. x 는 피감수이고 y 는 감수입니다. 호출되면 다음 단계를 수행한다.
Number::add (x , Number::unaryMinus (y ))를 반환합니다.
참고
x - y는 항상 x + (-y)와 같은 결과를 생성합니다.
6.1.6.1.9 Number::leftShift ( x , y )
추상 연산 Number::leftShift. 인수 x (Number) 및 y (Number). 반환값: 정수인 Number . 호출되면 다음 단계를 수행한다.
leftNumber 를 ! ToInt32 (x )로 둡니다.rightNumber 를 ! ToUint32 (y )로 둡니다.shiftCount 를 ℝ (rightNumber ) modulo 32로 둡니다.leftNumber 를 shiftCount 비트만큼 왼쪽으로 시프트한 결과를 반환합니다. 결과의 수학적 값 은 32비트 2의 보수 비트 문자열로 정확하게 표현할 수 있습니다.
6.1.6.1.10 Number::signedRightShift ( x , y )
추상 연산 Number::signedRightShift. 인수 x (Number) 및 y (Number). 반환값: 정수인 Number . 호출되면 다음 단계를 수행한다.
leftNumber 를 ! ToInt32 (x )로 둡니다.rightNumber 를 ! ToUint32 (y )로 둡니다.shiftCount 를 ℝ (rightNumber ) modulo 32로 둡니다.leftNumber 를 shiftCount 비트만큼 부호 확장 오른쪽 시프트한 결과를 반환합니다. 최상위 비트가 전파됩니다. 결과의 수학적 값 은 32비트 2의 보수 비트 문자열로 정확하게 표현할 수 있습니다.
6.1.6.1.11 Number::unsignedRightShift ( x , y )
추상 연산 Number::unsignedRightShift. 인수 x (Number) 및 y (Number). 반환값: 정수인 Number . 호출되면 다음 단계를 수행한다.
leftNumber 를 ! ToUint32 (x )로 둡니다.rightNumber 를 ! ToUint32 (y )로 둡니다.shiftCount 를 ℝ (rightNumber ) modulo 32로 둡니다.leftNumber 를 shiftCount 비트만큼 0 채움 오른쪽 시프트한 결과를 반환합니다. 비워진 비트는 0으로 채워집니다. 결과의 수학적 값 은 32비트 부호 없는 비트 문자열로 정확하게 표현할 수 있습니다.
6.1.6.1.12 Number::lessThan ( x , y )
추상 연산 Number::lessThan. 인수 x (Number) 및 y (Number). 반환값: Boolean 또는 undefined . 호출되면 다음 단계를 수행한다.
x 가 NaN 이면 undefined 를 반환합니다.y 가 NaN 이면 undefined 를 반환합니다.x 가 y 이면 false 를 반환합니다.x 가 +0 𝔽 이고 y 가 -0 𝔽 이면 false 를 반환합니다.x 가 -0 𝔽 이고 y 가 +0 𝔽 이면 false 를 반환합니다.x 가 +∞ 𝔽 이면 false 를 반환합니다.y 가 +∞ 𝔽 이면 true 를 반환합니다.y 가 -∞ 𝔽 이면 false 를 반환합니다.x 가 -∞ 𝔽 이면 true 를 반환합니다.단언 : x 와 y 는 유한 Number 입니다.ℝ (x ) < ℝ (y )이면 true 를 반환합니다.false 를 반환합니다.
6.1.6.1.13 Number::equal ( x , y )
추상 연산 Number::equal. 인수 x (Number) 및 y (Number). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
x 가 NaN 이면, false 를 반환합니다.y 가 NaN 이면, false 를 반환합니다.x 가 y 이면, true 를 반환합니다.x 가 +0 𝔽 이고 y 가 -0 𝔽 이면, true 를 반환합니다.x 가 -0 𝔽 이고 y 가 +0 𝔽 이면, true 를 반환합니다.false 를 반환합니다.
6.1.6.1.14 Number::sameValue ( x , y )
추상 연산 Number::sameValue. 인수 x (Number) 및 y (Number). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
x 가 NaN 이고 y 가 NaN 이면, true 를 반환합니다.x 가 +0 𝔽 이고 y 가 -0 𝔽 이면, false 를 반환합니다.x 가 -0 𝔽 이고 y 가 +0 𝔽 이면, false 를 반환합니다.x 가 y 이면, true 를 반환합니다.false 를 반환합니다.
6.1.6.1.15 Number::sameValueZero ( x , y )
추상 연산 Number::sameValueZero. 인수 x (Number) 및 y (Number). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
x 가 NaN 이고 y 가 NaN 이면, true 를 반환합니다.x 가 +0 𝔽 이고 y 가 -0 𝔽 이면, true 를 반환합니다.x 가 -0 𝔽 이고 y 가 +0 𝔽 이면, true 를 반환합니다.x 가 y 이면, true 를 반환합니다.false 를 반환합니다.
6.1.6.1.16 NumberBitwiseOp ( op , x , y )
추상 연산 NumberBitwiseOp. 인수 op ((&, ^ 또는 |)), x (Number) 및 y (Number). 반환값: 정수인 Number . 호출되면 다음 단계를 수행한다.
leftNumber 를 ! ToInt32 (x )로 둡니다.rightNumber 를 ! ToInt32 (y )로 둡니다.leftBits 를 ℝ (leftNumber )를 나타내는 32비트 2의 보수 비트 문자열로 둡니다.rightBits 를 ℝ (rightNumber )를 나타내는 32비트 2의 보수 비트 문자열로 둡니다.op 가 &이면,result 를 leftBits 와 rightBits 에 비트 단위 AND 연산을 적용한 결과로 둡니다.그렇지 않고 op 가 ^이면,result 를 leftBits 와 rightBits 에 비트 단위 XOR(배타적 OR) 연산을 적용한 결과로 둡니다. 그렇지 않으면,단언 : op 는 |입니다.result 를 leftBits 와 rightBits 에 비트 단위 OR(포괄적 OR) 연산을 적용한 결과로 둡니다. 32비트 2의 보수 비트 문자열 result 가 나타내는 정수 에 해당하는 Number 값 을 반환합니다.
6.1.6.1.17 Number::bitwiseAND ( x , y )
추상 연산 Number::bitwiseAND. 인수 x (Number) 및 y (Number). 반환값: 정수인 Number . 호출되면 다음 단계를 수행한다.
NumberBitwiseOp (&, x , y )를 반환합니다.
6.1.6.1.18 Number::bitwiseXOR ( x , y )
추상 연산 Number::bitwiseXOR. 인수 x (Number) 및 y (Number). 반환값: 정수인 Number . 호출되면 다음 단계를 수행한다.
NumberBitwiseOp (^, x , y )를 반환합니다.
6.1.6.1.19 Number::bitwiseOR ( x , y )
추상 연산 Number::bitwiseOR. 인수 x (Number) 및 y (Number). 반환값: 정수인 Number . 호출되면 다음 단계를 수행한다.
NumberBitwiseOp (|, x , y )를 반환합니다.
6.1.6.1.20 Number::toString ( x , radix )
추상 연산 Number::toString. 인수 x (Number) 및 radix (an integer within the closed interval from 2 to 36). 반환값: String. 기수가 radix 인 위치 기수법을 사용하여 x 를 String으로 나타냅니다. 기수 r 을 사용한 수의 표현에 사용되는 숫자는 "0123456789abcdefghijklmnopqrstuvwxyz" 의 처음 r 개 코드 단위에서 순서대로 가져옵니다. 크기가 1 𝔽 이상인 수의 표현에는 선행 0이 포함되지 않습니다. 호출되면 다음 단계를 수행한다.
x 가 NaN 이면, "NaN" 을 반환합니다.x 가 +0 𝔽 또는 -0 𝔽 이면, "0" 을 반환합니다.x < -0 𝔽 이면, "-" 와 Number::toString (-x , radix )의 문자열 연결 을 반환합니다.x 가 +∞ 𝔽 이면, "Infinity" 를 반환합니다.k ≥ 1이고, radix k - 1 ≤ s < radix k 이며, 𝔽 (s × radix n - k )가 x 이고, k 가 가능한 한 작은 정수 n , k 및 s 를 둡니다. k 는 기수 radix 를 사용한 s 표현의 자릿수이고, s 는 radix 로 나누어떨어지지 않으며, 이러한 기준만으로 s 의 최하위 자릿수가 반드시 고유하게 결정되는 것은 아니라는 점에 유의하시기 바랍니다.radix ≠ 10이거나 n 이 -5부터 21까지의 닫힌 구간 에 있으면, 다음을 수행합니다.n ≥ k 이면, 다음을 수행합니다.다음의 문자열 연결 을 반환합니다:기수 radix 를 사용한 s 표현의 k 개 숫자의 코드 단위 코드 단위 0x0030 (DIGIT ZERO)의 n - k 개 발생 n > 0이면, 다음을 수행합니다.다음의 문자열 연결 을 반환합니다:기수 radix 를 사용한 s 표현의 최상위 n 개 숫자의 코드 단위 코드 단위 0x002E (FULL STOP) 기수 radix 를 사용한 s 표현의 나머지 k - n 개 숫자의 코드 단위 단언 : n ≤ 0입니다.다음의 문자열 연결 을 반환합니다:코드 단위 0x0030 (DIGIT ZERO) 코드 단위 0x002E (FULL STOP) 코드 단위 0x0030 (DIGIT ZERO)의 -n 개 발생 기수 radix 를 사용한 s 표현의 k 개 숫자의 코드 단위 참고 : 이 경우 입력은 1.2e+3과 같은 과학적 E 표기법을 사용하여 표현됩니다.단언 : radix 는 10입니다.n < 0이면, 다음을 수행합니다.exponentSign 을 코드 단위 0x002D (HYPHEN-MINUS)로 둡니다.그렇지 않으면,exponentSign 을 코드 단위 0x002B (PLUS SIGN)로 둡니다. k = 1이면, 다음을 수행합니다.다음의 문자열 연결 을 반환합니다:s 의 단일 숫자의 코드 단위코드 단위 0x0065 (LATIN SMALL LETTER E) exponentSign abs (n - 1)의 십진 표현의 코드 단위 다음의 문자열 연결 을 반환합니다:s 의 십진 표현에서 최상위 숫자의 코드 단위코드 단위 0x002E (FULL STOP) s 의 십진 표현에서 나머지 k - 1개 숫자의 코드 단위코드 단위 0x0065 (LATIN SMALL LETTER E) exponentSign abs (n - 1)의 십진 표현의 코드 단위
참고 1
다음 관찰 사항은 구현체를 위한 지침으로 유용할 수 있지만 이 표준의 규범적 요구 사항에 포함되지는 않습니다:
참고 2
위 규칙에서 요구하는 것보다 더 정확한 변환을 제공하는 구현체에는 다음과 같은 5 단계의 대체 버전을 지침으로 사용할 것을 권장합니다:
k ≥ 1이고, radix k - 1 ≤ s < radix k 이며, 𝔽 (s × radix n - k )가 x 이고, k 가 가능한 한 작은 정수 n , k 및 s 를 둡니다. s 에 여러 가능성이 있으면 s × radix n - k 가 ℝ (x )에 가장 가까워지는 s 를 선택합니다. 그러한 가능한 s 값이 두 개이면 짝수인 값을 선택합니다. k 는 기수 radix 를 사용한 s 표현의 자릿수이고 s 는 radix 로 나누어떨어지지 않는다는 점에 유의하시기 바랍니다.
참고 3
ECMAScript 구현자는 부동소수점 수의 이진-십진 변환을 위해 David M. Gay가 작성한 다음 논문과 코드를 유용하게 활용할 수 있습니다:
Gay, David M. 정확하게 반올림된 이진-십진 및 십진-이진 변환. Numerical Analysis, Manuscript 90-10. AT&T Bell Laboratories (Murray Hill, New Jersey). 30 November 1990. 다음에서 이용할 수 있습니다
https://ampl.com/_archive/first-website/REFS/rounding.pdf . 관련 코드는 다음에서 이용할 수 있습니다
http://netlib.sandia.gov/fp/dtoa.c 및
http://netlib.sandia.gov/fp/g_fmt.c 이며 다양한 netlib 미러 사이트에서도 찾을 수 있습니다.
6.1.6.2 BigInt 타입
BigInt 타입 은 정숫값을 나타냅니다. 값의 크기는 임의적일 수 있으며 특정 비트 너비로 제한되지 않습니다. 일반적으로 달리 명시되지 않는 한 연산은 수학적으로 정확한 결과를 반환하도록 설계됩니다. 이항 연산에서 BigInt는 2의 보수 이진 문자열처럼 동작하며, 음수는 왼쪽으로 무한히 비트가 설정된 것으로 취급됩니다.
6.1.6.2.1 BigInt::unaryMinus ( bigint )
추상 연산 BigInt::unaryMinus. 인수 bigint (BigInt). 반환값: BigInt. 호출되면 다음 단계를 수행한다.
bigint = 0 ℤ 이면, 0 ℤ 을 반환합니다.-bigint 를 반환합니다.
6.1.6.2.2 BigInt::bitwiseNOT ( bigint )
추상 연산 BigInt::bitwiseNOT. 인수 bigint (BigInt). 반환값: BigInt. bigint 의 1의 보수를 반환합니다. 호출되면 다음 단계를 수행한다.
-bigint - 1 ℤ 을 반환합니다.
6.1.6.2.3 BigInt::exponentiate ( base , exponent )
추상 연산 BigInt::exponentiate. 인수 base (BigInt) 및 exponent (BigInt). 반환값: BigInt를 포함하는 정상 완료 또는 던지기 완료. 호출되면 다음 단계를 수행한다.
exponent < 0 ℤ 이면, RangeError 예외를 던집니다.base = 0 ℤ 이고 exponent = 0 ℤ 이면, 1 ℤ 을 반환합니다.base 를 exponent 제곱한 값을 반환합니다.
6.1.6.2.4 BigInt::multiply ( x , y )
추상 연산 BigInt::multiply. 인수 x (BigInt) 및 y (BigInt). 반환값: BigInt. 호출되면 다음 단계를 수행한다.
x × y 를 반환합니다.
참고 결과의 비트 너비가 입력보다 훨씬 크더라도 정확한 수학적 결과가 제공됩니다.
6.1.6.2.5 BigInt::divide ( x , y )
추상 연산 BigInt::divide. 인수 x (BigInt) 및 y (BigInt). 반환값: BigInt를 포함하는 정상 완료 또는 던지기 완료. 호출되면 다음 단계를 수행한다.
y = 0 ℤ 이면, RangeError 예외를 던집니다.quotient 를 ℝ (x ) / ℝ (y )로 둡니다.ℤ (truncate (quotient ))를 반환합니다.
6.1.6.2.6 BigInt::remainder ( numerator , denominator )
추상 연산 BigInt::remainder. 인수 numerator (BigInt) 및 denominator (BigInt). 반환값: BigInt를 포함하는 정상 완료 또는 던지기 완료. 호출되면 다음 단계를 수행한다.
denominator = 0 ℤ 이면, RangeError 예외를 던집니다.numerator = 0 ℤ 이면, 0 ℤ 을 반환합니다.quotient 를 ℝ (numerator ) / ℝ (denominator )로 둡니다.truncatedQuotient 를 ℤ (truncate (quotient ))로 둡니다.numerator - (denominator × truncatedQuotient )를 반환합니다.
참고 결과의 부호는 피제수의 부호입니다.
6.1.6.2.7 BigInt::add ( x , y )
추상 연산 BigInt::add. 인수 x (BigInt) 및 y (BigInt). 반환값: BigInt. 호출되면 다음 단계를 수행한다.
x + y 를 반환합니다.
6.1.6.2.8 BigInt::subtract ( x , y )
추상 연산 BigInt::subtract. 인수 x (BigInt) 및 y (BigInt). 반환값: BigInt. 호출되면 다음 단계를 수행한다.
x - y 를 반환합니다.
6.1.6.2.9 BigInt::leftShift ( x , y )
추상 연산 BigInt::leftShift. 인수 x (BigInt) 및 y (BigInt). 반환값: BigInt. 호출되면 다음 단계를 수행한다.
y < 0 ℤ 이면, 다음을 수행합니다.ℤ (floor (ℝ (x ) / 2-ℝ (y ) ))를 반환합니다.x × 2 ℤ y 를 반환합니다.
참고 여기에서의 의미론은 BigInt를 길이가 무한한 이진 2의 보수 숫자 문자열로 취급하는 비트 시프트와 동등해야 합니다.
6.1.6.2.10 BigInt::signedRightShift ( x , y )
추상 연산 BigInt::signedRightShift. 인수 x (BigInt) 및 y (BigInt). 반환값: BigInt. 호출되면 다음 단계를 수행한다.
BigInt::leftShift (x , -y )를 반환합니다.
6.1.6.2.11 BigInt::unsignedRightShift ( x , y )
추상 연산 BigInt::unsignedRightShift. 인수 x (BigInt) 및 y (BigInt). 반환값: 던지기 완료. 호출되면 다음 단계를 수행한다.
TypeError 예외를 던집니다.
6.1.6.2.12 BigInt::lessThan ( x , y )
추상 연산 BigInt::lessThan. 인수 x (BigInt) 및 y (BigInt). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
ℝ (x ) < ℝ (y )이면, true 를 반환합니다.false 를 반환합니다.
6.1.6.2.13 BigInt::equal ( x , y )
추상 연산 BigInt::equal. 인수 x (BigInt) 및 y (BigInt). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
ℝ (x ) = ℝ (y )이면, true 를 반환합니다.false 를 반환합니다.
6.1.6.2.14 BigIntBitwiseOp ( op , x , y )
추상 연산 BigIntBitwiseOp. 인수 op ((&, ^ 또는 |)), x (BigInt) 및 y (BigInt). 반환값: BigInt. 호출되면 다음 단계를 수행한다.
x 를 ℝ (x )로 설정합니다.y 를 ℝ (y )로 설정합니다.result 를 0으로 둡니다.shift 를 0으로 둡니다.(x = 0 또는 x = -1)이고 (y = 0 또는 y = -1)이 될 때까지 다음을 반복합니다,xBit 를 x modulo 2로 둡니다.yBit 를 y modulo 2로 둡니다.op 가 &이면,resultBit 를 xBit 와 yBit 에 단일 비트 AND 연산을 적용한 결과로 둡니다.그렇지 않고 op 가 ^이면,resultBit 를 xBit 와 yBit 에 단일 비트 XOR(배타적 OR) 연산을 적용한 결과로 둡니다. 그렇지 않으면,단언 : op 는 |입니다.resultBit 를 xBit 와 yBit 에 단일 비트 OR(포괄적 OR) 연산을 적용한 결과로 둡니다. result 를 result + 2shift × resultBit 로 설정합니다.shift 를 shift + 1로 설정합니다.x 를 (x - xBit ) / 2로 설정합니다.y 를 (y - yBit ) / 2로 설정합니다. op 가 &이면,signBit 를 (x modulo 2)와 (y modulo 2)에 단일 비트 AND 연산을 적용한 결과로 둡니다.그렇지 않고 op 가 ^이면,signBit 를 (x modulo 2)와 (y modulo 2)에 단일 비트 XOR(배타적 OR) 연산을 적용한 결과로 둡니다. 그렇지 않으면,단언 : op 는 |입니다.signBit 를 (x modulo 2)와 (y modulo 2)에 단일 비트 OR(포괄적 OR) 연산을 적용한 결과로 둡니다. signBit ≠ 0이면,result 를 result - 2shift 로 설정합니다.참고 : 이는 부호를 확장합니다.result 에 해당하는 BigInt 값 을 반환합니다.
6.1.6.2.15 BigInt::bitwiseAND ( x , y )
추상 연산 BigInt::bitwiseAND. 인수 x (BigInt) 및 y (BigInt). 반환값: BigInt. 호출되면 다음 단계를 수행한다.
BigIntBitwiseOp (&, x , y )를 반환합니다.
6.1.6.2.16 BigInt::bitwiseXOR ( x , y )
추상 연산 BigInt::bitwiseXOR. 인수 x (BigInt) 및 y (BigInt). 반환값: BigInt. 호출되면 다음 단계를 수행한다.
BigIntBitwiseOp (^, x , y )를 반환합니다.
6.1.6.2.17 BigInt::bitwiseOR ( x , y )
추상 연산 BigInt::bitwiseOR. 인수 x (BigInt) 및 y (BigInt). 반환값: BigInt. 호출되면 다음 단계를 수행한다.
BigIntBitwiseOp (|, x , y )를 반환합니다.
6.1.6.2.18 BigInt::toString ( x , radix )
추상 연산 BigInt::toString. 인수 x (BigInt) 및 radix (2부터 36까지의 닫힌 구간 에 있는 정수 ). 반환값: String. 기수가 radix 인 위치 기수법을 사용하여 x 를 String으로 나타냅니다. 기수 r 을 사용한 BigInt 표현에 사용되는 숫자는 "0123456789abcdefghijklmnopqrstuvwxyz" 의 처음 r 개 코드 단위에서 순서대로 가져옵니다. 0 ℤ 이외의 BigInt 표현에는 선행 0이 포함되지 않습니다. 호출되면 다음 단계를 수행한다.
x < 0 ℤ 이면, "-" 와 BigInt::toString (-x , radix )의 문자열 연결 을 반환합니다.기수 radix 를 사용한 x 의 표현으로 구성된 String 값을 반환합니다.
6.1.7 Object 타입
간단히 “Object”라고도 하는 Object 타입 의 각 인스턴스는 프로퍼티의 컬렉션을 나타냅니다. 각 프로퍼티는 데이터 프로퍼티 또는 접근자 프로퍼티입니다:
데이터 프로퍼티 는 키 값을 ECMAScript 언어 값 및 Boolean 속성 집합과 연결합니다.
접근자 프로퍼티 는 키 값을 하나 또는 두 개의 접근자 함수 및 Boolean 속성 집합과 연결합니다. 접근자 함수는 프로퍼티와 연결된 ECMAScript 언어 값 을 저장하거나 가져오는 데 사용됩니다.
객체의 프로퍼티는 프로퍼티 키 를 사용하여 고유하게 식별됩니다. 프로퍼티 키 는 String 또는 Symbol입니다. 빈 String을 포함하여 모든 String과 Symbol은 유효한 프로퍼티 키 입니다. 프로퍼티 이름 은 String인 프로퍼티 키 입니다.
정수 인덱스 는 CanonicalNumericIndexString (n )이 +0 𝔽 부터 𝔽 (253 - 1)까지의 닫힌 구간 에 있는 정수인 Number 를 반환하는 프로퍼티 이름 n 입니다. 배열 인덱스 는 CanonicalNumericIndexString (n )이 +0 𝔽 부터 𝔽 (232 - 2)까지의 닫힌 구간 에 있는 정수인 Number 를 반환하는 정수 인덱스 n 입니다.
참고
모든 음이 아닌 안전한 정수 에는 대응하는 정수 인덱스 가 있습니다. 232 - 1 을 제외한 모든 32비트 부호 없는 정수 에는 대응하는 배열 인덱스 가 있습니다. "-0" 은 정수 인덱스 도 배열 인덱스 도 아닙니다.
프로퍼티 키 는 프로퍼티와 그 값에 접근하는 데 사용됩니다. 프로퍼티 접근에는 값의 검색과 할당에 각각 대응하는 get 과 set 이라는 두 종류가 있습니다. get 및 set 접근을 통해 접근할 수 있는 프로퍼티에는 객체의 직접적인 일부인 자체 프로퍼티 와 프로퍼티 상속 관계를 통해 연결된 다른 객체가 제공하는 상속된 프로퍼티 가 모두 포함됩니다. 상속된 프로퍼티는 연결된 객체의 자체 프로퍼티 또는 상속된 프로퍼티일 수 있습니다. 객체의 각 자체 프로퍼티는 해당 객체의 다른 자체 프로퍼티 키 값과 구별되는 키 값을 가져야 합니다.
논리적으로 모든 객체는 프로퍼티의 컬렉션이지만, 프로퍼티에 접근하고 조작하는 의미론이 서로 다른 여러 형태의 객체가 있습니다. 여러 형태의 객체에 대한 정의는 6.1.7.2 를 참조하시기 바랍니다.
또한 일부 객체는 호출할 수 있습니다. 이러한 객체를 함수 또는 함수 객체 라고 하며 아래에서 더 자세히 설명합니다. ECMAScript의 모든 함수는 Object 타입의 구성원입니다.
6.1.7.1 프로퍼티 속성
속성은 표 3 에 설명된 대로 이 명세에서 Object 프로퍼티의 상태를 정의하고 설명하는 데 사용됩니다. 명시적으로 지정되지 않는 한 각 속성의 초기값은 해당 기본값입니다.
표 3: Object 프로퍼티의 속성
속성 이름
이 속성이 존재하는 프로퍼티 타입
값 영역
기본값
설명
[[Value]]
데이터 프로퍼티
ECMAScript 언어 값
undefined
프로퍼티에 get 접근하여 가져오는 값입니다.
[[Writable]]
데이터 프로퍼티
Boolean
false
false 이면 ECMAScript 코드가 [[Set]] 을 사용하여 프로퍼티의 [[Value]] 속성을 변경하려는 시도는 성공하지 않습니다.
[[Getter]]
접근자 프로퍼티
함수 객체 또는 undefined
undefined
값이 undefined 가 아니면 프로퍼티에 get 접근을 수행할 때마다 프로퍼티 값을 가져오기 위해 빈 인수 목록으로 해당 [[Call]] 내부 메서드(표 5 )를 호출합니다.
[[Setter]]
접근자 프로퍼티
함수 객체 또는 undefined
undefined
값이 undefined 가 아니면 프로퍼티에 set 접근을 수행할 때마다 할당된 값을 유일한 인수로 포함하는 인수 목록으로 해당 [[Call]] 내부 메서드(표 5 )를 호출합니다. 프로퍼티의 [[Setter]] 내부 메서드 효과는 이후 해당 프로퍼티의 [[Getter]] 내부 메서드 호출이 반환하는 값에 영향을 줄 수 있지만 반드시 영향을 주어야 하는 것은 아닙니다.
[[Enumerable]]
데이터 프로퍼티 또는 접근자 프로퍼티
Boolean
false
true 이면 프로퍼티가 for-in 열거(14.7.5 참조)에 포함됩니다. 그렇지 않으면 프로퍼티를 열거할 수 없다고 합니다.
[[Configurable]]
데이터 프로퍼티 또는 접근자 프로퍼티
Boolean
false
false 이면 프로퍼티를 삭제하거나, 데이터 프로퍼티 를 접근자 프로퍼티 로 또는 접근자 프로퍼티 를 데이터 프로퍼티 로 변경하거나, 기존 [[Value]] 를 교체하거나 [[Writable]] 을 false 로 설정하는 경우를 제외하고 속성을 변경하려는 시도는 실패합니다.
6.1.7.2 Object 내부 메서드와 내부 슬롯
ECMAScript에서 객체의 실제 의미론은 내부 메서드 라고 하는 알고리즘을 통해 명시됩니다. ECMAScript 엔진의 각 객체에는 해당 객체의 런타임 동작을 정의하는 내부 메서드 집합이 연결되어 있습니다. 이러한 내부 메서드는 ECMAScript 언어의 일부가 아닙니다. 이 명세에서는 오직 설명을 목적으로 정의합니다. 그러나 ECMAScript 구현체의 각 객체는 해당 객체와 연결된 내부 메서드가 명시하는 대로 동작해야 합니다. 이를 정확히 어떤 방식으로 달성하는지는 구현체가 결정합니다.
내부 메서드 이름은 다형적입니다. 이는 공통 내부 메서드 이름을 서로 다른 객체 값에 대해 호출할 때 서로 다른 알고리즘을 수행할 수 있음을 의미합니다. 내부 메서드가 호출되는 실제 객체를 호출의 “대상”이라고 합니다. 런타임에 알고리즘 구현이 객체가 지원하지 않는 내부 메서드를 사용하려 하면 TypeError 예외가 던져집니다.
내부 슬롯은 객체, Symbol 또는 Private Name 과 연결되고 여러 ECMAScript 명세 알고리즘에서 사용하는 내부 상태에 해당합니다. 내부 슬롯은 객체 프로퍼티가 아니며 상속되지 않습니다. 특정 내부 슬롯 명세에 따라 이러한 상태는 임의의 ECMAScript 언어 타입 값 또는 특정 ECMAScript 명세 타입 값으로 구성될 수 있습니다. 명시적으로 달리 지정되지 않는 한 내부 슬롯은 객체, Symbol 또는 Private Name 을 생성하는 과정의 일부로 할당되며 동적으로 추가할 수 없습니다. 달리 명시되지 않는 한 내부 슬롯의 초기값은 undefined 입니다. 이 명세의 여러 알고리즘은 내부 슬롯을 갖는 값을 생성합니다. 그러나 ECMAScript 언어는 내부 슬롯을 직접 조작할 방법을 제공하지 않습니다.
모든 객체에는 PrivateElements 의 List 인 [[PrivateElements]] 라는 내부 슬롯이 있습니다. 이 List 는 객체의 비공개 필드, 메서드 및 접근자의 값을 나타냅니다. 처음에는 빈 List 입니다.
이 명세에서 내부 메서드와 내부 슬롯은 이중 대괄호 [[ ]]로 둘러싼 이름으로 식별됩니다.
표 4 에는 ECMAScript 코드가 생성하거나 조작하는 모든 객체에 적용되는 이 명세의 필수 내부 메서드 가 요약되어 있습니다. 모든 객체에는 모든 필수 내부 메서드에 대한 알고리즘이 있어야 합니다. 그러나 모든 객체가 이러한 메서드에 동일한 알고리즘을 사용하는 것은 아닙니다.
일반 객체 는 다음 기준을 모두 만족하는 객체입니다:
표 4 에 나열된 내부 메서드에 대해 객체는 10.1 에 정의된 메서드를 사용합니다.
객체에 [[Call]] 내부 메서드가 있으면 10.2.1 에 정의된 메서드 또는 10.3.1 에 정의된 메서드를 사용합니다.
객체에 [[Construct]] 내부 메서드가 있으면 10.2.2 에 정의된 메서드 또는 10.3.2 에 정의된 메서드를 사용합니다.
특수 객체 는 일반 객체 가 아닌 객체입니다.
이 명세는 객체의 내부 메서드를 기준으로 서로 다른 종류의 특수 객체 를 인식합니다. 특정 종류의 특수 객체 (예: Array 특수 객체 또는 바인딩된 함수 특수 객체 )와 동작상 동등하지만 해당 종류에 명시된 것과 동일한 내부 메서드 집합을 갖지 않는 객체는 그 종류의 특수 객체 로 인식되지 않습니다.
표 4 와 기타 유사한 표는 각 내부 메서드의 호출 패턴을 설명합니다. 호출 패턴에는 항상 괄호로 둘러싼 설명적 매개변수 이름 목록이 포함됩니다.
내부 메서드는 매개변수 외에도 항상 메서드 호출의 대상인 객체에 접근할 수 있습니다.
내부 메서드는 암묵적으로 Completion Record 를 반환하며, 호출 패턴에 표시된 반환 타입의 값을 감싸는 정상 완료 또는 던지기 완료 중 하나입니다.
표 4: 필수 내부 메서드
내부 메서드
설명
정의
[[GetPrototypeOf]] ( )
내부 메서드 [[GetPrototypeOf]] . 인수 없음. 반환값: Object 또는 null 을 포함하는 정상 완료 또는 던지기 완료.
이 객체에 상속된 프로퍼티를 제공하는 객체를 결정합니다. null 값은 그러한 객체가 없음을 나타냅니다.
이 명세에서는 다음 타입에 정의되어 있으며, 호스트 는 자체 정의를 갖는 추가 타입을 제공할 수 있습니다:
[[SetPrototypeOf]] ( proto )
내부 메서드 [[SetPrototypeOf]] . 인수 proto ((Object 또는 null )). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ).
이 객체를 상속된 프로퍼티를 제공하는 다른 객체와 연결합니다. null 을 전달하면 상속된 프로퍼티를 제공하는 객체가 없음을 나타냅니다. 연산이 성공적으로 완료되었음을 나타내는 true 또는 연산이 성공하지 못했음을 나타내는 false 를 반환합니다.
이 명세에서는 다음 타입에 정의되어 있으며, 호스트 는 자체 정의를 갖는 추가 타입을 제공할 수 있습니다:
[[IsExtensible]] ( )
내부 메서드 [[IsExtensible]] . 인수 없음. 반환값: Boolean을 포함하는 정상 완료 또는 던지기 완료.
이 객체에 추가 프로퍼티를 추가하는 것이 허용되는지 결정합니다.
이 명세에서는 다음 타입에 정의되어 있으며, 호스트 는 자체 정의를 갖는 추가 타입을 제공할 수 있습니다:
[[PreventExtensions]] ( )
내부 메서드 [[PreventExtensions]] . 인수 없음. 반환값: Boolean을 포함하는 정상 완료 또는 던지기 완료.
이 객체에 새 프로퍼티를 추가할 수 있는지 제어합니다. 연산이 성공하면 true 를 반환하고 성공하지 못하면 false 를 반환합니다.
이 명세에서는 다음 타입에 정의되어 있으며, 호스트 는 자체 정의를 갖는 추가 타입을 제공할 수 있습니다:
[[GetOwnProperty]] ( propertyKey )
내부 메서드 [[GetOwnProperty]] . 인수 propertyKey (프로퍼티 키 ). 반환값: Property Descriptor 또는 undefined 를 포함하는 정상 완료 또는 던지기 완료.
키가 propertyKey 인 이 객체의 자체 프로퍼티에 대한 Property Descriptor 를 반환하고, 그러한 프로퍼티가 없으면 undefined 를 반환합니다.
이 명세에서는 다음 타입에 정의되어 있으며, 호스트 는 자체 정의를 갖는 추가 타입을 제공할 수 있습니다:
[[DefineOwnProperty]] ( propertyKey , propertyDesc )
내부 메서드 [[DefineOwnProperty]] . 인수 propertyKey (프로퍼티 키 ) 및 propertyDesc (프로퍼티 서술자 ). 반환값: Boolean을 포함하는 정상 완료 또는 던지기 완료.
키가 propertyKey 인 자체 프로퍼티를 생성하거나 변경하여 propertyDesc 가 설명하는 상태를 갖게 합니다. 연산이 성공하면 true 를 반환하고 프로퍼티를 생성하거나 갱신할 수 없으면 false 를 반환합니다.
이 명세에서는 다음 타입에 정의되어 있으며, 호스트 는 자체 정의를 갖는 추가 타입을 제공할 수 있습니다:
[[HasProperty]] ( propertyKey )
내부 메서드 [[HasProperty]] . 인수 propertyKey (프로퍼티 키 ). 반환값: Boolean을 포함하는 정상 완료 또는 던지기 완료.
이 객체에 키가 propertyKey 인 자체 프로퍼티 또는 상속된 프로퍼티가 이미 있는지를 나타내는 Boolean을 반환합니다.
이 명세에서는 다음 타입에 정의되어 있으며, 호스트 는 자체 정의를 갖는 추가 타입을 제공할 수 있습니다:
[[Get]] ( propertyKey , receiver )
내부 메서드 [[Get]] . 인수 propertyKey (프로퍼티 키 ) 및 receiver (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 throw 완료 ).
이 객체에서 키가 propertyKey 인 프로퍼티의 값을 반환합니다. 프로퍼티 값을 가져오기 위해 ECMAScript 코드를 실행해야 하는 경우 코드를 평가할 때 receiver 를 this 값으로 사용합니다.
이 명세에서는 다음 타입에 정의되어 있으며, 호스트 는 자체 정의를 갖는 추가 타입을 제공할 수 있습니다:
[[Set]] ( propertyKey , value , receiver )
내부 메서드 [[Set]] . 인수 propertyKey (프로퍼티 키 ), value (ECMAScript 언어 값 ) 및 receiver (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ).
키가 propertyKey 인 프로퍼티의 값을 value 로 설정합니다. 프로퍼티 값을 설정하기 위해 ECMAScript 코드를 실행해야 하는 경우 코드를 평가할 때 receiver 를 this 값으로 사용합니다. 프로퍼티 값이 설정되었으면 true 를 반환하고 설정할 수 없으면 false 를 반환합니다.
이 명세에서는 다음 타입에 정의되어 있으며, 호스트 는 자체 정의를 갖는 추가 타입을 제공할 수 있습니다:
[[Delete]] ( propertyKey )
내부 메서드 [[Delete]] . 인수 propertyKey (프로퍼티 키 ). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ).
이 객체에서 키가 propertyKey 인 자체 프로퍼티를 제거합니다. 프로퍼티가 삭제되지 않아 여전히 존재하면 false 를 반환합니다. 프로퍼티가 삭제되었거나 존재하지 않으면 true 를 반환합니다.
이 명세에서는 다음 타입에 정의되어 있으며, 호스트 는 자체 정의를 갖는 추가 타입을 제공할 수 있습니다:
[[OwnPropertyKeys]] ( )
내부 메서드 [[OwnPropertyKeys]] . 인수 없음. 반환값: (정상 완료 (값: 리스트 (요소: 프로퍼티 키 )) 또는 throw 완료 ).
객체의 모든 자체 프로퍼티 키 를 요소로 갖는 List 를 반환합니다.
이 명세에서는 다음 타입에 정의되어 있으며, 호스트 는 자체 정의를 갖는 추가 타입을 제공할 수 있습니다:
표 5 에는 함수로 호출될 수 있는 객체가 지원하는 추가 필수 내부 메서드가 요약되어 있습니다. 함수 객체 는 [[Call]] 내부 메서드를 지원하는 객체입니다. 생성자 는 [[Construct]] 내부 메서드를 지원하는 객체입니다. [[Construct]] 를 지원하는 모든 객체는 [[Call]] 도 지원해야 합니다. 즉, 모든 생성자 는 함수 객체 여야 합니다. 따라서 생성자 는 생성자 함수 또는 생성자 함수 객체 라고도 할 수 있습니다.
표 5: 함수 객체 의 추가 필수 내부 메서드
내부 메서드
설명
정의
[[Call]] ( thisArg , argList )
내부 메서드 [[Call]] . 인수 thisArg (ECMAScript 언어 값 ) 및 argList (리스트 (요소: ECMAScript 언어 값 )). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 throw 완료 ).
이 객체와 연결된 코드를 실행합니다. 함수 호출 표현식을 통해 호출됩니다. 내부 메서드의 인수는 this 값과, 호출 표현식이 함수에 전달한 인수를 요소로 갖는 List 입니다. 이 내부 메서드를 구현하는 객체는 호출 가능 합니다.
이 명세에서는 다음 타입에 정의되어 있으며, 호스트 는 자체 정의를 갖는 추가 타입을 제공할 수 있습니다:
[[Construct]] ( argList , newTarget )
내부 메서드 [[Construct]] . 인수 argList (리스트 (요소: ECMAScript 언어 값 )) 및 newTarget (생성자 ). 반환값: (정상 완료 (값: Object) 또는 throw 완료 ).
객체를 생성합니다. new 연산자 또는 super 호출을 통해 호출됩니다. 내부 메서드의 첫 번째 인수는 생성자 호출 또는 super 호출의 인수를 요소로 갖는 List 입니다. 두 번째 인수는 처음에 new 연산자가 적용된 객체입니다. 이 내부 메서드를 구현하는 객체를 생성자 라고 합니다. 함수 객체 가 반드시 생성자 인 것은 아니며, 이러한 생성자 가 아닌 함수 객체 에는 [[Construct]] 내부 메서드가 없습니다.
이 명세에서는 다음 타입에 정의되어 있으며, 호스트 는 자체 정의를 갖는 추가 타입을 제공할 수 있습니다:
일반 객체 와 표준 특수 객체 의 필수 내부 메서드 의미론은 10 절에 명시되어 있습니다. 특수 객체 의 내부 메서드를 명시된 방식으로 사용하는 것을 구현체가 지원하지 않는 경우, 해당 사용을 시도하면 TypeError 예외를 던져야 합니다.
6.1.7.3 필수 내부 메서드의 불변 조건
ECMAScript 엔진의 Object 내부 메서드는 아래에 명시된 불변 조건 목록을 준수해야 합니다. 일반 ECMAScript Object와 이 명세의 모든 표준 특수 객체 는 이러한 불변 조건을 유지합니다. ECMAScript Proxy 객체는 [[ProxyHandler]] 객체에서 호출된 트랩의 결과에 대한 런타임 검사를 통해 이러한 불변 조건을 유지합니다.
구현체가 제공하는 모든 특수 객체 도 해당 객체에 대해 이러한 불변 조건을 유지해야 합니다. 이러한 불변 조건을 위반하면 ECMAScript 코드가 예측할 수 없는 동작을 하거나 보안 문제를 일으킬 수 있습니다. 그러나 이러한 불변 조건의 위반으로 구현체의 메모리 안전성이 손상되어서는 안 됩니다.
구현체는 불변 조건을 강제하지 않은 채 필수 내부 메서드의 기능을 구현하는 대체 인터페이스를 제공하는 등의 방법으로 이러한 불변 조건을 우회할 수 있게 해서는 안 됩니다.
정의:
내부 메서드의 대상 은 해당 내부 메서드가 호출되는 객체입니다.
[[IsExtensible]] 내부 메서드에서 false 를 반환한 것이 관찰되었거나 [[PreventExtensions]] 내부 메서드에서 true 를 반환한 것이 관찰된 대상은 확장 불가능 합니다.
존재하지 않는 프로퍼티는 확장 불가능한 대상에 자체 프로퍼티로 존재하지 않는 프로퍼티입니다.
SameValue 에 대한 모든 참조는 SameValue 알고리즘의 정의를 따릅니다.
반환값:
모든 내부 메서드가 반환하는 값은 다음 중 하나인 Completion Record 여야 합니다:
[[Type]] = normal , [[Target]] = empty , 그리고 [[Value]] = 해당 내부 메서드에 대해 아래에 표시된 “정상 반환 타입”의 값, 또는
[[Type]] = throw , [[Target]] = empty , 그리고 [[Value]] = 임의의 ECMAScript 언어 값 .
참고 1
내부 메서드는 continue 완료 , break 완료 또는 return 완료 를 반환해서는 안 됩니다.
[[GetPrototypeOf]] ( )
정상 반환 타입은 Object 또는 Null입니다.
대상이 확장 불가능하고 [[GetPrototypeOf]] 가 값 proto 를 반환하면, 이후 [[GetPrototypeOf]] 의 모든 호출은 proto 와 SameValue 인 값을 반환해야 합니다.
참고 2
객체의 프로토타입 체인은 유한한 길이를 가져야 합니다(즉, 임의의 객체에서 시작하여 [[GetPrototypeOf]] 내부 메서드를 그 결과에 재귀적으로 적용하면 결국 null 값에 도달해야 합니다). 그러나 프로토타입 체인에 [[GetPrototypeOf]] 의 일반 객체 정의를 사용하지 않는 특수 객체 가 포함되어 있으면 이 요구 사항을 객체 수준의 불변 조건으로 강제할 수 없습니다. 이러한 순환 프로토타입 체인은 객체 프로퍼티에 접근할 때 무한 루프를 일으킬 수 있습니다.
[[SetPrototypeOf]] ( proto )
정상 반환 타입은 Boolean입니다.
대상이 확장 불가능하면 proto 가 대상에서 관찰된 [[GetPrototypeOf]] 값과 SameValue 인 경우를 제외하고 [[SetPrototypeOf]] 는 false 를 반환해야 합니다.
[[IsExtensible]] ( )
정상 반환 타입은 Boolean입니다.
[[IsExtensible]] 이 false 를 반환하면 이후 대상에 대한 모든 [[IsExtensible]] 호출도 false 를 반환해야 합니다.
[[PreventExtensions]] ( )
정상 반환 타입은 Boolean입니다.
[[PreventExtensions]] 가 true 를 반환하면 이후 대상에 대한 모든 [[IsExtensible]] 호출은 false 를 반환해야 하며, 이제 대상은 확장 불가능한 것으로 간주됩니다.
[[GetOwnProperty]] ( propertyKey )
정상 반환 타입은 Property Descriptor 또는 Undefined입니다.
반환값이 Property Descriptor 이면 모든 필드가 채워진 Property Descriptor 여야 합니다.
propertyKey 가 구성 불가능하고 쓰기 불가능한 자체 데이터 프로퍼티 로 기술되었으면 이후 [[GetOwnProperty]] ( propertyKey )의 모든 호출은 [[Value]] 가 propertyKey 의 [[Value]] 속성과 SameValue 인 Property Descriptor 를 반환해야 합니다.
[[Writable]] 과 [[Value]] 이외의 propertyKey 속성이 시간에 따라 변경될 수 있거나 프로퍼티가 삭제될 수 있다면 propertyKey 의 [[Configurable]] 속성은 true 여야 합니다.
[[Writable]] 속성이 false 에서 true 로 변경될 수 있다면 [[Configurable]] 속성은 true 여야 합니다.
대상이 확장 불가능하고 propertyKey 가 존재하지 않으면 이후 대상에 대한 모든 [[GetOwnProperty]] (propertyKey ) 호출은 propertyKey 가 존재하지 않는 것으로 기술해야 합니다(즉, [[GetOwnProperty]] (propertyKey )는 undefined 를 반환해야 합니다).
참고 3
세 번째 불변 조건의 결과로, 프로퍼티가 데이터 프로퍼티 로 기술되고 시간에 따라 서로 다른 값을 반환할 수 있다면 다른 필수 내부 메서드를 통해 값을 변경하는 메커니즘이 노출되지 않더라도 [[Writable]] 과 [[Configurable]] 속성 중 하나 또는 둘 모두가 true 여야 합니다.
[[DefineOwnProperty]] ( propertyKey , propertyDesc )
정상 반환 타입은 Boolean입니다.
propertyKey 가 이전에 대상의 구성 불가능한 자체 프로퍼티로 관찰되었으면 다음 중 하나에 해당하지 않는 한 [[DefineOwnProperty]] 는 false 를 반환해야 합니다:
propertyKey 가 쓰기 가능한 데이터 프로퍼티 입니다. 구성 불가능하면서 쓰기 가능한 데이터 프로퍼티 는 구성 불가능하면서 쓰기 불가능한 데이터 프로퍼티 로 변경할 수 있습니다.
propertyDesc 의 모든 속성이 propertyKey 의 속성과 SameValue 입니다.
대상이 확장 불가능하고 propertyKey 가 존재하지 않는 자체 프로퍼티이면 [[DefineOwnProperty]] (propertyKey , propertyDesc )는 false 를 반환해야 합니다. 즉, 확장 불가능한 대상 객체는 새 프로퍼티로 확장할 수 없습니다.
[[HasProperty]] ( propertyKey )
정상 반환 타입은 Boolean입니다.
propertyKey 가 이전에 대상의 구성 불가능한 자체 데이터 프로퍼티 또는 접근자 프로퍼티 로 관찰되었으면 [[HasProperty]] 는 true 를 반환해야 합니다.
[[Get]] ( propertyKey , receiver )
정상 반환 타입은 임의의 ECMAScript 언어 타입 입니다.
propertyKey 가 이전에 값 value 를 갖는 대상의 구성 불가능하고 쓰기 불가능한 자체 데이터 프로퍼티 로 관찰되었으면 [[Get]] 은 value 와 SameValue 인 값을 반환해야 합니다.
propertyKey 가 이전에 [[Getter]] 속성이 undefined 인 대상의 구성 불가능한 자체 접근자 프로퍼티 로 관찰되었으면 [[Get]] 연산은 undefined 를 반환해야 합니다.
[[Set]] ( propertyKey , value , receiver )
정상 반환 타입은 Boolean입니다.
propertyKey 가 이전에 대상의 구성 불가능하고 쓰기 불가능한 자체 데이터 프로퍼티 로 관찰되었으면 value 가 propertyKey 의 [[Value]] 속성과 SameValue 인 경우를 제외하고 [[Set]] 은 false 를 반환해야 합니다.
propertyKey 가 이전에 [[Setter]] 속성이 undefined 인 대상의 구성 불가능한 자체 접근자 프로퍼티 로 관찰되었으면 [[Set]] 연산은 false 를 반환해야 합니다.
[[Delete]] ( propertyKey )
정상 반환 타입은 Boolean입니다.
propertyKey 가 이전에 대상의 구성 불가능한 자체 데이터 프로퍼티 또는 접근자 프로퍼티 로 관찰되었으면 [[Delete]] 는 false 를 반환해야 합니다.
[[OwnPropertyKeys]] ( )
정상 반환 타입은 List 입니다.
반환된 List 에는 중복 항목이 포함되어서는 안 됩니다.
반환된 List 의 각 요소는 프로퍼티 키 여야 합니다.
반환된 List 에는 이전에 관찰된 모든 구성 불가능한 자체 프로퍼티의 키가 적어도 포함되어야 합니다.
대상이 확장 불가능하면 반환된 List 에는 [[GetOwnProperty]] 를 사용하여 관찰할 수 있는 대상의 모든 자체 프로퍼티 키 만 포함되어야 합니다.
[[Call]] ( )
[[Construct]] ( )
정상 반환 타입은 Object입니다.
대상에는 [[Call]] 내부 메서드도 있어야 합니다.
6.1.7.4 잘 알려진 내재 객체
잘 알려진 내재 객체는 이 명세의 알고리즘에서 명시적으로 참조되며 일반적으로 realm 별 고유한 동일성을 갖는 내장 객체입니다. 달리 명시되지 않는 한 각 내재 객체는 실제로 realm 마다 하나씩 존재하는 유사한 객체의 집합에 대응합니다.
이 명세에서 %name%과 같은 참조는 현재 realm 과 연관되고 해당 이름에 대응하는 내재 객체를 의미합니다. %name.a.b%와 같은 참조는 ECMAScript 코드가 평가되기 전에 내재 객체 %name%의 "a" 프로퍼티 값의 "b" 프로퍼티에 접근한 것과 같은 의미입니다. 현재 realm 과 그 내재 객체를 결정하는 방법은 9.4 에 설명되어 있습니다. 잘 알려진 내재 객체는 표 6 에 나열되어 있습니다.
표 6: 잘 알려진 내재 객체
참고
6.2 ECMAScript 명세 타입
명세 타입은 ECMAScript 언어 구성 요소와 ECMAScript 언어 타입 의 의미론을 설명하기 위해 알고리즘 내에서 사용하는 메타 값에 대응합니다. 명세 타입에는 Reference Record , List , Completion Record , Property Descriptor , Environment Record , Abstract Closure 및 Data Block 이 포함됩니다. 명세 타입 값은 ECMAScript 구현체 내의 특정 개체와 반드시 대응하지는 않는 명세상의 구성 요소입니다. 명세 타입 값은 ECMAScript 표현식 평가의 중간 결과를 설명하는 데 사용할 수 있지만, 이러한 값은 객체의 프로퍼티나 ECMAScript 언어 변수의 값으로 저장할 수 없습니다.
6.2.1 Enum 명세 타입
Enum 은 명세 내부에서 사용되며 ECMAScript 코드에서 직접 관찰할 수 없는 값입니다. Enum은 산세리프체 를 사용하여 대문자 케밥 표기법으로 나타냅니다. 예를 들어 Completion Record 의 [[Type]] 필드는 normal , return 또는 throw 와 같은 값을 가집니다. Enum에는 이름 이외의 특성이 없습니다. Enum의 이름은 다른 Enum과 구별하는 것 이외의 목적은 없으며, 문맥에서의 용도나 의미에 대해서는 아무것도 암시하지 않습니다.
6.2.2 List 및 Record 명세 타입
List 타입은 new 표현식, 함수 호출 및 단순한 순서 있는 값 목록이 필요한 기타 알고리즘에서 인수 목록의 평가(13.3.8 참조)를 설명하는 데 사용됩니다. List 타입의 값은 개별 값을 포함하는 목록 요소의 단순한 순서 있는 시퀀스입니다. 이러한 시퀀스는 임의의 길이를 가질 수 있습니다. 목록의 요소는 0부터 시작하는 인덱스를 사용하여 임의 접근할 수 있습니다. 표기상의 편의를 위해 배열과 유사한 구문을 사용하여 List 요소에 접근할 수 있습니다. 예를 들어 args [2]는 List args 의 3번째 요소를 나타내는 축약 표현입니다.
알고리즘이 순서를 지정하지 않고 List의 요소를 반복 처리하는 경우, List 내의 요소 순서를 사용합니다.
이 명세에서는 표기상의 편의를 위해 리터럴 구문을 사용하여 새로운 List 값을 표현할 수 있습니다. 예를 들어 « 1, 2 »는 각각 특정 값으로 초기화된 두 개의 요소를 갖는 List 값을 정의합니다. 새로운 빈 List는 « »로 표현할 수 있습니다.
이 명세에서 “A , B , ...의 목록 연결 ”이라는 문구(각 인수는 비어 있을 수도 있는 List입니다)는 각 인수의 요소를 인수 순서대로 연결한 요소를 갖는 새로운 List 값을 나타냅니다.
String의 List에 적용할 때 “사전식 코드 단위 순서 에 따라 정렬”이라는 문구는 더 짧은 문자열의 길이까지 각 코드 단위의 숫자 값으로 정렬하고, 모든 값이 같으면 더 짧은 문자열을 더 긴 문자열보다 앞에 정렬하는 것을 의미하며, 이는 추상 연산 IsLessThan 에 설명되어 있습니다.
Record 타입은 이 명세의 알고리즘 내에서 데이터 집합을 설명하는 데 사용됩니다. Record 타입 값은 하나 이상의 이름 있는 필드로 구성됩니다. 각 필드의 값은 ECMAScript 언어 값 또는 명세 값입니다. 필드 이름은 항상 이중 대괄호로 둘러싸며, 예를 들어 [[Value]] 와 같습니다.
이 명세에서는 표기상의 편의를 위해 객체 리터럴과 유사한 구문을 사용하여 Record를 표현할 수 있습니다. 예를 들어 { [[Field1]] : 42, [[Field2]] : false , [[Field3]] : empty }는 각각 특정 값으로 초기화된 세 개의 필드를 갖는 Record를 정의합니다. 필드 이름의 순서는 중요하지 않습니다. 명시적으로 나열되지 않은 모든 필드는 존재하지 않는 것으로 간주됩니다.
명세 텍스트와 알고리즘에서는 점 표기법을 사용하여 Record의 특정 필드를 참조할 수 있습니다. 예를 들어 R이 이전 단락에 표시된 Record라면 R.[[Field2]] 는 “이름이 [[Field2]] 인 R의 필드”를 나타내는 축약 표현입니다.
자주 사용되는 Record 필드 조합의 스키마에는 이름을 지정할 수 있으며, 해당 이름을 리터럴 Record의 접두사로 사용하여 설명 중인 특정 종류의 집합을 식별할 수 있습니다. 예: PropertyDescriptor { [[Value]] : 42, [[Writable]] : false , [[Configurable]] : true }.
6.2.3 Set 및 Relation 명세 타입
Set 타입은 메모리 모델 에서 사용하는 순서 없는 요소의 컬렉션을 설명하는 데 사용됩니다. 이는 같은 이름의 ECMAScript 컬렉션 타입과 구별됩니다. 모호함을 피하기 위해 이 명세에서는 ECMAScript 컬렉션의 인스턴스를 일관되게 “Set 객체 ”라고 합니다. Set 타입의 값은 요소의 단순한 컬렉션이며, 동일한 요소가 두 번 이상 나타나지 않습니다. Set에 요소를 추가하거나 제거할 수 있습니다. Set은 서로 합집합, 교집합 또는 차집합을 구할 수 있습니다.
Relation 타입은 Set에 대한 제약 조건을 설명하는 데 사용됩니다. Relation 타입의 값은 해당 값 영역의 값들로 이루어진 순서쌍의 Set입니다. 예를 들어 Memory 이벤트 에 대한 Relation은 Memory 이벤트 의 순서쌍으로 이루어진 집합입니다. Relation R 과 R 의 값 영역에 있는 두 값 a 와 b 에 대해 a R b 는 순서쌍 (a , b )가 R 의 구성원임을 나타내는 축약 표현입니다. 어떤 조건에 대해 Relation이 해당 조건을 만족하는 가장 작은 Relation이면 이를 최소 Relation 이라고 합니다.
엄격 부분 순서 는 다음을 만족하는 Relation 값 R 입니다.
참고 1
위의 두 특성을 각각 비반사성과 추이성이라고 합니다.
엄격 전순서 는 다음을 만족하는 Relation 값 R 입니다.
참고 2
위의 세 특성을 각각 전성, 비반사성 및 추이성이라고 합니다.
6.2.4 Completion Record 명세 타입
Completion Record 명세 타입은 비국소적인 제어 이전을 수행하는 문(break, continue, return 및 throw)의 동작과 같은 값 및 제어 흐름의 런타임 전파를 설명하는 데 사용됩니다.
Completion Record에는 표 7 에 정의된 필드가 있습니다.
표 7: Completion Record 필드
필드 이름
값
의미
[[Type]]
normal , break , continue , return 또는 throw
발생한 완료의 타입입니다.
[[Value]]
Completion Record 를 제외한 임의의 값
생성된 값입니다.
[[Target]]
String 또는 empty
지시된 제어 이전의 대상 레이블입니다.
Completion Record를 참조하기 위해 다음 축약 용어를 사용하는 경우가 있습니다.
정상 완료 는 [[Type]] 값이 normal 인 모든 Completion Record를 가리킵니다.
break 완료 는 [[Type]] 값이 break 인 모든 Completion Record를 가리킵니다.
continue 완료 는 [[Type]] 값이 continue 인 모든 Completion Record를 가리킵니다.
return 완료 는 [[Type]] 값이 return 인 모든 Completion Record를 가리킵니다.
throw 완료 는 [[Type]] 값이 throw 인 모든 Completion Record를 가리킵니다.
비정상 완료 는 [[Type]] 값이 normal 이 아닌 모든 Completion Record를 가리킵니다.
어떤 타입의 값을 포함하는 정상 완료 는 [[Value]] 필드에 해당 타입의 값을 갖는 정상 완료를 가리킵니다.
이 명세에서 정의한 호출 가능 객체는 정상 완료 또는 throw 완료만 반환합니다. 그 밖의 종류의 Completion Record를 반환하는 것은 편집 오류로 간주됩니다.
구현체 정의 호출 가능 객체는 정상 완료 또는 throw 완료 중 하나를 반환해야 합니다.
6.2.4.1 NormalCompletion ( value )
추상 연산 NormalCompletion. 인수 value (Completion Record 를 제외한 임의의 값). 반환값: 정상 완료 . 호출되면 다음 단계를 수행한다.
Completion Record { [[Type]] : normal , [[Value]] : value , [[Target]] : empty }를 반환합니다.
6.2.4.2 ThrowCompletion ( value )
추상 연산 ThrowCompletion. 인수 value (ECMAScript 언어 값 ). 반환값: throw 완료 . 호출되면 다음 단계를 수행한다.
Completion Record { [[Type]] : throw , [[Value]] : value , [[Target]] : empty }를 반환합니다.
6.2.4.3 ReturnCompletion ( value )
추상 연산 ReturnCompletion. 인수 value (ECMAScript 언어 값 ). 반환값: return 완료 . 호출되면 다음 단계를 수행한다.
Completion Record { [[Type]] : return , [[Value]] : value , [[Target]] : empty }를 반환합니다.
6.2.4.4 UpdateEmpty ( completionRecord , value )
추상 연산 UpdateEmpty. 인수 completionRecord (Completion 레코드 ) 및 value (Completion Record 를 제외한 임의의 값). 반환값: Completion 레코드 . 호출되면 다음 단계를 수행한다.
단언 : completionRecord 가 return 완료 또는 throw 완료 이면, completionRecord .[[Value]] 는 empty 가 아닙니다.completionRecord .[[Value]] 가 empty 가 아니면, ? completionRecord 를 반환합니다.Completion Record { [[Type]] : completionRecord .[[Type]] , [[Value]] : value , [[Target]] : completionRecord .[[Target]] }를 반환합니다.
6.2.5 Reference Record 명세 타입
Reference Record 타입은 delete, typeof, 할당 연산자, super 키워드 및 기타 언어 기능과 같은 연산자의 동작을 설명하는 데 사용됩니다. 예를 들어 할당의 왼쪽 피연산자는 Reference Record를 생성할 것으로 예상됩니다.
Reference Record는 해석된 이름 또는 (아직 해석되지 않았을 수도 있는) 프로퍼티 바인딩이며, 해당 필드는 표 8 에 정의되어 있습니다.
표 8: Reference Record 필드
이 명세에서는 Reference Record에 대해 연산하기 위해 다음 추상 연산 을 사용합니다:
6.2.5.1 IsPropertyReference ( refRecord )
추상 연산 IsPropertyReference. 인수 refRecord (Reference 레코드 ). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
refRecord .[[Base]] 가 unresolvable 이면, false 를 반환합니다.refRecord .[[Base]] 가 Environment Record 이면, false 를 반환합니다.true 를 반환합니다.
6.2.5.2 IsUnresolvableReference ( refRecord )
추상 연산 IsUnresolvableReference. 인수 refRecord (Reference 레코드 ). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
refRecord .[[Base]] 가 unresolvable 이면, true 를 반환합니다.false 를 반환합니다.
6.2.5.3 IsSuperReference ( refRecord )
추상 연산 IsSuperReference. 인수 refRecord (Reference 레코드 ). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
refRecord .[[ThisValue]] 가 empty 이면, false 를 반환합니다.true 를 반환합니다.
6.2.5.4 IsPrivateReference ( refRecord )
추상 연산 IsPrivateReference. 인수 refRecord (Reference 레코드 ). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
refRecord .[[ReferencedName]] 이 Private Name 이면, true 를 반환합니다.false 를 반환합니다.
6.2.5.5 GetValue ( refRecord )
추상 연산 GetValue. 인수 refRecord (Reference Record 또는 ECMAScript 언어 값 ). 반환값: ECMAScript 언어 값 을 포함하는 정상 완료 또는 비정상 완료 . 호출되면 다음 단계를 수행한다.
refRecord 가 Reference Record 가 아니면, refRecord 를 반환합니다.IsUnresolvableReference (refRecord )가 true 이면, ReferenceError 예외를 던집니다.IsPropertyReference (refRecord )가 true 이면, 다음을 수행합니다.baseObj 를 ? ToObject (refRecord .[[Base]] )로 둡니다.IsPrivateReference (refRecord )가 true 이면, 다음을 수행합니다.? PrivateGet (baseObj , refRecord .[[ReferencedName]] )을 반환합니다. refRecord .[[ReferencedName]] 이 프로퍼티 키 가 아니면, 다음을 수행합니다.refRecord .[[ReferencedName]] 을 ? ToPropertyKey (refRecord .[[ReferencedName]] )로 설정합니다.? baseObj .[[Get]] (refRecord .[[ReferencedName]] , GetThisValue (refRecord )) 를 반환합니다. base 를 refRecord .[[Base]] 로 둡니다.단언 : base 는 Environment Record 입니다.? base .GetBindingValue (refRecord .[[ReferencedName]] , refRecord .[[Strict]] ) 를 반환합니다(9.1 참조).
참고
3.a 단계에서 생성될 수 있는 객체에는 위 추상 연산 과 일반 객체 [[Get]] 내부 메서드 외부에서 접근할 수 없습니다. 구현체는 실제 객체 생성을 피하도록 선택할 수도 있습니다.
6.2.5.6 PutValue ( refRecord , value )
추상 연산 PutValue. 인수 refRecord (Reference Record 또는 ECMAScript 언어 값 ) 및 value (ECMAScript 언어 값 ). 반환값: unused 를 포함하는 정상 완료 또는 비정상 완료 . 호출되면 다음 단계를 수행한다.
refRecord 가 Reference Record 가 아니면, ReferenceError 예외를 던집니다.IsUnresolvableReference (refRecord )가 true 이면, 다음을 수행합니다.refRecord .[[Strict]] 가 true 이면, ReferenceError 예외를 던집니다.globalObj 를 GetGlobalObject ()로 둡니다.? Set (globalObj , refRecord .[[ReferencedName]] , value , false )를 수행합니다. unused 를 반환합니다.IsPropertyReference (refRecord )가 true 이면, 다음을 수행합니다.baseObj 를 ? ToObject (refRecord .[[Base]] )로 둡니다.IsPrivateReference (refRecord )가 true 이면, 다음을 수행합니다.? PrivateSet (baseObj , refRecord .[[ReferencedName]] , value )를 반환합니다. refRecord .[[ReferencedName]] 이 프로퍼티 키 가 아니면, 다음을 수행합니다.refRecord .[[ReferencedName]] 을 ? ToPropertyKey (refRecord .[[ReferencedName]] )로 설정합니다.succeeded 를 ? baseObj .[[Set]] (refRecord .[[ReferencedName]] , value , GetThisValue (refRecord )) 로 둡니다.succeeded 가 false 이고 refRecord .[[Strict]] 가 true 이면, TypeError 예외를 던집니다.unused 를 반환합니다.base 를 refRecord .[[Base]] 로 둡니다.단언 : base 는 Environment Record 입니다.? base .SetMutableBinding (refRecord .[[ReferencedName]] , value , refRecord .[[Strict]] ) 를 반환합니다(9.1 참조).
참고
3.a 단계에서 생성될 수 있는 객체에는 위 추상 연산 과 일반 객체 [[Set]] 내부 메서드 외부에서 접근할 수 없습니다. 구현체는 해당 객체의 실제 생성을 피하도록 선택할 수도 있습니다.
6.2.5.7 GetThisValue ( refRecord )
추상 연산 GetThisValue. 인수 refRecord (Reference 레코드 ). 반환값: ECMAScript 언어 값 . 호출되면 다음 단계를 수행한다.
단언 : IsPropertyReference (refRecord )는 true 입니다.IsSuperReference (refRecord )가 true 이면, refRecord .[[ThisValue]] 를 반환합니다.refRecord .[[Base]] 를 반환합니다.
6.2.5.8 InitializeReferencedBinding ( refRecord , value )
추상 연산 InitializeReferencedBinding. 인수 refRecord (Reference 레코드 ) 및 value (ECMAScript 언어 값 ). 반환값: unused 를 포함하는 정상 완료 또는 비정상 완료 . 호출되면 다음 단계를 수행한다.
단언 : IsUnresolvableReference (refRecord )는 false 입니다.base 를 refRecord .[[Base]] 로 둡니다.단언 : base 는 Environment Record 입니다.? base .InitializeBinding (refRecord .[[ReferencedName]] , value )을 반환합니다.
6.2.5.9 MakePrivateReference ( baseValue , privateIdentifier )
추상 연산 MakePrivateReference. 인수 baseValue (ECMAScript 언어 값 ) 및 privateIdentifier (String). 반환값: Reference 레코드 . 호출되면 다음 단계를 수행한다.
privateEnv 를 실행 중인 실행 컨텍스트 의 PrivateEnvironment로 둡니다.단언 : privateEnv 는 null 이 아닙니다.privateName 을 ResolvePrivateIdentifier (privateEnv , privateIdentifier )로 둡니다.Reference Record { [[Base]] : baseValue , [[ReferencedName]] : privateName , [[Strict]] : true , [[ThisValue]] : empty }를 반환합니다.
6.2.6 Property Descriptor 명세 타입
Property Descriptor 타입은 Object 프로퍼티 속성의 조작과 구체화를 설명하는 데 사용됩니다. Property Descriptor는 0개 이상의 필드를 갖는 Record 이며, 각 필드의 이름은 속성 이름이고 값은 6.1.7.1 에 명시된 대응하는 속성 값입니다. 이 명세에서 Property Descriptor Record 의 리터럴 설명에 태그를 지정하는 데 사용하는 스키마 이름은 “PropertyDescriptor”입니다.
Property Descriptor 값은 특정 필드의 존재 여부 또는 사용에 따라 데이터 Property Descriptor와 접근자 Property Descriptor로 더 분류할 수 있습니다. 데이터 Property Descriptor는 [[Value]] 또는 [[Writable]] 이라는 이름의 필드를 하나라도 포함하는 Property Descriptor입니다. 접근자 Property Descriptor는 [[Getter]] 또는 [[Setter]] 라는 이름의 필드를 하나라도 포함하는 Property Descriptor입니다. 모든 Property Descriptor에는 [[Enumerable]] 및 [[Configurable]] 이라는 이름의 필드가 있을 수 있습니다. Property Descriptor 값은 데이터 Property Descriptor이면서 동시에 접근자 Property Descriptor일 수 없습니다. 그러나 둘 다 아닐 수는 있습니다(이 경우 일반 Property Descriptor입니다). 모든 필드가 채워진 Property Descriptor 는 접근자 Property Descriptor 또는 데이터 Property Descriptor 중 하나이면서 표 3 에 정의된 해당 필드를 모두 갖는 Property Descriptor입니다.
이 명세에서는 Property Descriptor 값에 대해 연산하기 위해 다음 추상 연산 을 사용합니다:
6.2.6.1 IsAccessorDescriptor ( propertyDesc )
추상 연산 IsAccessorDescriptor. 인수 propertyDesc (프로퍼티 서술자 ). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
propertyDesc 에 [[Getter]] 필드가 있으면, true 를 반환합니다.propertyDesc 에 [[Setter]] 필드가 있으면, true 를 반환합니다.false 를 반환합니다.
6.2.6.2 IsDataDescriptor ( propertyDesc )
추상 연산 IsDataDescriptor. 인수 propertyDesc (프로퍼티 서술자 ). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
propertyDesc 에 [[Value]] 필드가 있으면, true 를 반환합니다.propertyDesc 에 [[Writable]] 필드가 있으면, true 를 반환합니다.false 를 반환합니다.
6.2.6.3 IsGenericDescriptor ( propertyDesc )
추상 연산 IsGenericDescriptor. 인수 propertyDesc (프로퍼티 서술자 ). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
IsAccessorDescriptor (propertyDesc )가 true 이면, false 를 반환합니다.IsDataDescriptor (propertyDesc )가 true 이면, false 를 반환합니다.true 를 반환합니다.
6.2.6.4 FromPropertyDescriptor ( propertyDesc )
추상 연산 FromPropertyDescriptor. 인수 propertyDesc (Property Descriptor 또는 undefined ). 반환값: Object 또는 undefined . 호출되면 다음 단계를 수행한다.
propertyDesc 가 undefined 이면, undefined 를 반환합니다.obj 를 OrdinaryObjectCreate (%Object.prototype% )로 둡니다.단언 : obj 는 자체 프로퍼티가 없는 확장 가능한 일반 객체 입니다.propertyDesc 에 [[Value]] 필드가 있으면, 다음을 수행합니다.! CreateDataPropertyOrThrow (obj , "value" , propertyDesc .[[Value]] )를 수행합니다. propertyDesc 에 [[Writable]] 필드가 있으면, 다음을 수행합니다.! CreateDataPropertyOrThrow (obj , "writable" , propertyDesc .[[Writable]] )를 수행합니다. propertyDesc 에 [[Getter]] 필드가 있으면, 다음을 수행합니다.! CreateDataPropertyOrThrow (obj , "get" , propertyDesc .[[Getter]] )를 수행합니다. propertyDesc 에 [[Setter]] 필드가 있으면, 다음을 수행합니다.! CreateDataPropertyOrThrow (obj , "set" , propertyDesc .[[Setter]] )를 수행합니다. propertyDesc 에 [[Enumerable]] 필드가 있으면, 다음을 수행합니다.! CreateDataPropertyOrThrow (obj , "enumerable" , propertyDesc .[[Enumerable]] )를 수행합니다. propertyDesc 에 [[Configurable]] 필드가 있으면, 다음을 수행합니다.! CreateDataPropertyOrThrow (obj , "configurable" , propertyDesc .[[Configurable]] )를 수행합니다. obj 를 반환합니다.
6.2.6.5 ToPropertyDescriptor ( obj )
추상 연산 ToPropertyDescriptor. 인수 obj (ECMAScript 언어 값 ). 반환값: Property Descriptor 를 포함하는 정상 완료 또는 throw 완료 . 호출되면 다음 단계를 수행한다.
obj 가 Object가 아니면, TypeError 예외를 던집니다.propertyDesc 를 처음에는 필드가 없는 새로운 Property Descriptor 로 둡니다.hasEnumerable 을 ? HasProperty (obj , "enumerable" )로 둡니다.hasEnumerable 이 true 이면, 다음을 수행합니다.enumerable 을 ToBoolean (? Get (obj , "enumerable" ))로 둡니다.propertyDesc .[[Enumerable]] 을 enumerable 로 설정합니다.hasConfigurable 을 ? HasProperty (obj , "configurable" )로 둡니다.hasConfigurable 이 true 이면, 다음을 수행합니다.configurable 을 ToBoolean (? Get (obj , "configurable" ))로 둡니다.propertyDesc .[[Configurable]] 을 configurable 로 설정합니다.hasValue 를 ? HasProperty (obj , "value" )로 둡니다.hasValue 가 true 이면, 다음을 수행합니다.value 를 ? Get (obj , "value" )로 둡니다.propertyDesc .[[Value]] 를 value 로 설정합니다.hasWritable 을 ? HasProperty (obj , "writable" )로 둡니다.hasWritable 이 true 이면, 다음을 수행합니다.writable 을 ToBoolean (? Get (obj , "writable" ))로 둡니다.propertyDesc .[[Writable]] 을 writable 로 설정합니다.hasGet 을 ? HasProperty (obj , "get" )로 둡니다.hasGet 이 true 이면, 다음을 수행합니다.getter 를 ? Get (obj , "get" )로 둡니다.IsCallable (getter )이 false 이고 getter 가 undefined 가 아니면, TypeError 예외를 던집니다.propertyDesc .[[Getter]] 를 getter 로 설정합니다.hasSet 을 ? HasProperty (obj , "set" )로 둡니다.hasSet 이 true 이면, 다음을 수행합니다.setter 를 ? Get (obj , "set" )로 둡니다.IsCallable (setter )이 false 이고 setter 가 undefined 가 아니면, TypeError 예외를 던집니다.propertyDesc .[[Setter]] 를 setter 로 설정합니다.propertyDesc 에 [[Getter]] 필드가 있거나 propertyDesc 에 [[Setter]] 필드가 있으면, 다음을 수행합니다.propertyDesc 에 [[Value]] 필드가 있거나 propertyDesc 에 [[Writable]] 필드가 있으면, TypeError 예외를 던집니다.propertyDesc 를 반환합니다.
6.2.6.6 CompletePropertyDescriptor ( propertyDesc )
추상 연산 CompletePropertyDescriptor. 인수 propertyDesc (프로퍼티 서술자 ). 반환값: unused . 호출되면 다음 단계를 수행한다.
like 를 Record { [[Value]] : undefined , [[Writable]] : false , [[Getter]] : undefined , [[Setter]] : undefined , [[Enumerable]] : false , [[Configurable]] : false }로 둡니다.IsGenericDescriptor (propertyDesc )가 true 이거나 IsDataDescriptor (propertyDesc )가 true 이면, 다음을 수행합니다.propertyDesc 에 [[Value]] 필드가 없으면, propertyDesc .[[Value]] 를 like .[[Value]] 로 설정합니다.propertyDesc 에 [[Writable]] 필드가 없으면, propertyDesc .[[Writable]] 을 like .[[Writable]] 로 설정합니다.그렇지 않으면,propertyDesc 에 [[Getter]] 필드가 없으면, propertyDesc .[[Getter]] 를 like .[[Getter]] 로 설정합니다.propertyDesc 에 [[Setter]] 필드가 없으면, propertyDesc .[[Setter]] 를 like .[[Setter]] 로 설정합니다. propertyDesc 에 [[Enumerable]] 필드가 없으면, propertyDesc .[[Enumerable]] 을 like .[[Enumerable]] 로 설정합니다.propertyDesc 에 [[Configurable]] 필드가 없으면, propertyDesc .[[Configurable]] 을 like .[[Configurable]] 로 설정합니다.unused 를 반환합니다.
6.2.7 Environment Record 명세 타입
Environment Record 타입은 중첩 함수와 블록에서 이름 해석의 동작을 설명하는 데 사용됩니다. 이 타입과 이에 대한 연산은 9.1 에 정의되어 있습니다.
6.2.8 Abstract Closure 명세 타입
Abstract Closure 명세 타입은 알고리즘 단계와 값의 컬렉션을 함께 참조하는 데 사용됩니다. Abstract Closure는 메타 값이며 closure (arg1 , arg2 )와 같은 함수 적용 형식을 사용하여 호출합니다. 추상 연산 과 마찬가지로 호출하면 Abstract Closure에 기술된 알고리즘 단계를 수행합니다.
Abstract Closure를 생성하는 알고리즘 단계에서는 “capture” 동사 뒤에 별칭 목록을 사용하여 값을 캡처합니다. Abstract Closure가 생성되면 해당 시점에 각 별칭과 연결된 값을 캡처합니다. Abstract Closure가 호출될 때 수행할 알고리즘을 명시하는 단계에서는 캡처된 각 값을 캡처할 때 사용한 별칭으로 참조합니다.
Abstract Closure가 Completion Record 를 반환하는 경우, 해당 Completion Record 는 정상 완료 또는 throw 완료 중 하나여야 합니다.
Abstract Closure는 다음 예에 표시된 것처럼 다른 알고리즘의 일부로 인라인 생성됩니다.
addend 를 41로 둡니다.closure 를 매개변수 (x )를 갖고 addend 를 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:x + addend 를 반환합니다.value 를 closure (1)로 둡니다.단언 : value 는 42입니다.
6.2.9 데이터 블록
Data Block 명세 타입은 바이트 크기(8비트)의 숫자 값으로 이루어진 독립적이고 변경 가능한 시퀀스를 설명하는 데 사용됩니다. 바이트 값 은 0부터 255까지의 닫힌 구간 에 있는 정수 입니다. Data Block 값은 고정된 개수의 바이트로 생성되며 각 바이트의 초기값은 0입니다.
이 명세에서는 표기상의 편의를 위해 배열과 유사한 구문을 사용하여 Data Block 값의 개별 바이트에 접근할 수 있습니다. 이 표기법은 Data Block 값을 0부터 시작하는 바이트의 정수 인덱스 시퀀스로 나타냅니다. 예를 들어 dataBlock 이 5바이트 Data Block 값이면 dataBlock [2]를 사용하여 세 번째 바이트에 접근할 수 있습니다.
여러 에이전트 가 동시에 참조할 수 있는 메모리에 존재하는 데이터 블록을 Shared Data Block 이라고 합니다. Shared Data Block에는 Shared Data Block 값의 동등성 검사에 사용되는 주소 독립적 동일성이 있습니다. 즉, 블록이 어떤 프로세스에서 매핑되는 가상 주소에 연결되는 것이 아니라 블록이 나타내는 메모리 위치의 집합에 연결됩니다. 두 데이터 블록은 포함하는 위치 집합이 같을 때만 서로 같으며, 그렇지 않으면 서로 같지 않고 각 블록이 포함하는 위치 집합의 교집합은 비어 있습니다. 마지막으로 Shared Data Block은 Data Block과 구별할 수 있습니다.
Shared Data Block의 의미론은 메모리 모델 에서 Shared Data Block 이벤트 를 사용하여 정의됩니다. 아래의 추상 연산 은 Shared Data Block 이벤트 를 도입하고 평가 의미론과 메모리 모델 의 이벤트 의미론 사이의 인터페이스 역할을 합니다. 이벤트는 후보 실행 을 형성하며, 메모리 모델 은 이를 필터로 처리합니다. 전체 의미론은 메모리 모델 을 참조하시기 바랍니다.
Shared Data Block 이벤트 는 메모리 모델 에 정의된 Record 로 모델링됩니다.
이 명세에서는 Data Block 값에 대해 연산하기 위해 다음 추상 연산 을 사용합니다:
6.2.9.1 CreateByteDataBlock ( size )
추상 연산 CreateByteDataBlock. 인수 size (음이 아닌 정수 ). 반환값: Data Block 을 포함하는 정상 완료 또는 throw 완료 . 호출되면 다음 단계를 수행한다.
size > 253 - 1이면, RangeError 예외를 던집니다.dataBlock 을 size 바이트로 구성된 새로운 Data Block 값으로 둡니다. 그러한 Data Block 을 생성할 수 없으면 RangeError 예외를 던집니다.dataBlock 의 모든 바이트를 0으로 설정합니다.dataBlock 을 반환합니다.
6.2.9.2 CreateSharedByteDataBlock ( size )
추상 연산 CreateSharedByteDataBlock. 인수 size (음이 아닌 정수 ). 반환값: Shared Data Block 을 포함하는 정상 완료 또는 throw 완료 . 호출되면 다음 단계를 수행한다.
dataBlock 을 size 바이트로 구성된 새로운 Shared Data Block 값으로 둡니다. 그러한 Shared Data Block 을 생성할 수 없으면 RangeError 예외를 던집니다.agentRecord 를 주변 에이전트 의 Agent Record 로 둡니다.execution 을 agentRecord .[[CandidateExecution]] 으로 둡니다.eventsRecord 를 [[AgentSignifier]] 가 AgentSignifier ()인 execution .[[EventsRecords]] 의 Agent Events Record 로 둡니다.zero 를 « 0 »으로 둡니다.dataBlock 의 각 인덱스 index 에 대해 다음을 수행합니다.WriteSharedMemory { [[Order]] : init , [[NoTear]] : true , [[Block]] : dataBlock , [[ByteIndex]] : index , [[ElementSize]] : 1, [[Payload]] : zero }를 eventsRecord .[[EventList]] 에 추가합니다.dataBlock 을 반환합니다.
6.2.9.3 CopyDataBlockBytes ( toBlock , toIndex , fromBlock , fromIndex , count )
추상 연산 CopyDataBlockBytes. 인수 toBlock (Data Block 또는 Shared Data Block ), toIndex (음이 아닌 정수 ), fromBlock (Data Block 또는 Shared Data Block ), fromIndex (음이 아닌 정수 ) 및 count (음이 아닌 정수 ). 반환값: unused . 호출되면 다음 단계를 수행한다.
단언 : fromBlock 과 toBlock 은 서로 다른 값입니다.fromSize 를 fromBlock 의 바이트 수로 둡니다.단언 : fromIndex + count ≤ fromSize 입니다.toSize 를 toBlock 의 바이트 수로 둡니다.단언 : toIndex + count ≤ toSize 입니다.count > 0인 동안 다음을 반복합니다.fromBlock 이 Shared Data Block 이면, 다음을 수행합니다.agentRecord 를 주변 에이전트 의 Agent Record 로 둡니다.execution 을 agentRecord .[[CandidateExecution]] 으로 둡니다.eventsRecord 를 [[AgentSignifier]] 가 AgentSignifier ()인 execution .[[EventsRecords]] 의 Agent Events Record 로 둡니다.bytes 를 비결정적으로 선택한 하나의 바이트 값 만을 요소로 갖는 List 로 둡니다.참고 : 구현체에서 bytes 는 기반 하드웨어의 비원자적 읽기 명령 결과입니다. 비결정성은 약한 일관성을 가진 하드웨어에서 관찰 가능한 동작을 설명하기 위한 메모리 모델 의 의미론적 규정입니다.readEvent 를 ReadSharedMemory { [[Order]] : unordered , [[NoTear]] : true , [[Block]] : fromBlock , [[ByteIndex]] : fromIndex , [[ElementSize]] : 1 }로 둡니다.readEvent 를 eventsRecord .[[EventList]] 에 추가합니다.Chosen Value Record { [[Event]] : readEvent , [[ChosenValue]] : bytes }를 execution .[[ChosenValues]] 에 추가합니다.toBlock 이 Shared Data Block 이면, 다음을 수행합니다.WriteSharedMemory { [[Order]] : unordered , [[NoTear]] : true , [[Block]] : toBlock , [[ByteIndex]] : toIndex , [[ElementSize]] : 1, [[Payload]] : bytes }를 eventsRecord .[[EventList]] 에 추가합니다.그렇지 않으면,toBlock [toIndex ]를 bytes [0]으로 설정합니다. 그렇지 않으면,단언 : toBlock 은 Shared Data Block 이 아닙니다.toBlock [toIndex ]를 fromBlock [fromIndex ]로 설정합니다. toIndex 를 toIndex + 1로 설정합니다.fromIndex 를 fromIndex + 1로 설정합니다.count 를 count - 1로 설정합니다.unused 를 반환합니다.
6.2.10 PrivateElement 명세 타입
PrivateElement 타입은 private 클래스 필드, 메서드 및 접근자의 명세에서 사용되는 Record 입니다. private 요소는 Property Descriptor 와 연결되지 않고 프로퍼티도 아니지만, 이를 참조하는 표현식의 런타임 의미론 은 몇 가지 측면에서 구성 불가능한 프로퍼티의 런타임 의미론 과 유사합니다(private 필드는 쓰기 가능한 데이터 프로퍼티 와 유사하고, private 메서드는 쓰기 불가능한 데이터 프로퍼티 와 유사하며, private 접근자는 접근자 프로퍼티 와 유사합니다). 또한 대응하는 Record 필드는 유사한 목적으로 사용됩니다.
PrivateElement 타입의 값은 표 9 에 의해 필드가 정의되는 Record 입니다. 이러한 값을 PrivateElements 라고 합니다.
표 9: PrivateElement 필드
필드 이름
이 필드가 존재하는 [[Kind]] 필드의 값
값
의미
[[Key]]
전체
Private Name
필드, 메서드 또는 접근자의 이름입니다.
[[Kind]]
전체
field , method 또는 accessor
요소의 종류입니다.
[[Value]]
field 및 method
ECMAScript 언어 값
필드의 값입니다.
[[Getter]]
accessor
함수 객체 또는 undefined
비공개 접근자의 getter입니다.
[[Setter]]
accessor
함수 객체 또는 undefined
비공개 접근자의 setter입니다.
6.2.11 ClassFieldDefinition Record 명세 타입
ClassFieldDefinition 타입은 클래스 필드의 명세에서 사용하는 Record 입니다.
ClassFieldDefinition 타입의 값은 표 10 에 의해 필드가 정의되는 Record 입니다. 이러한 값을 ClassFieldDefinition Records 라고 합니다.
표 10: ClassFieldDefinition Record 필드
필드 이름
값
의미
[[Name]]
Private Name , String 또는 Symbol
필드의 이름입니다.
[[Initializer]]
ECMAScript 함수 객체 또는 empty
필드의 이니셜라이저가 있는 경우 해당 이니셜라이저입니다.
6.2.12 Private Name
Private Name 명세 타입은 비공개 클래스 요소(필드, 메서드 또는 접근자)의 키를 나타내는 전역적으로 고유한 값(그 밖의 면에서 구별할 수 없더라도 다른 모든 Private Name과 서로 다른 값)을 설명하는 데 사용됩니다. 각 Private Name에는 String인 변경 불가능한 [[Description]] 내부 슬롯이 있습니다. Private Name은 PrivateFieldAdd 또는 PrivateMethodOrAccessorAdd 를 사용하여 임의의 ECMAScript 객체에 설치할 수 있으며, 이후 PrivateGet 과 PrivateSet 을 사용하여 읽거나 쓸 수 있습니다.
6.2.13 ClassStaticBlockDefinition Record 명세 타입
ClassStaticBlockDefinition Record 는 클래스 정적 초기화 블록의 실행 가능한 코드를 캡슐화하는 데 사용하는 Record 입니다.
ClassStaticBlockDefinition Record에는 표 11 에 나열된 필드가 있습니다.
표 11: ClassStaticBlockDefinition Record 필드
필드 이름
값
의미
[[BodyFunction]]
ECMAScript 함수 객체
클래스의 정적 초기화 중에 호출할 함수 객체 입니다.
7 추상 연산
이러한 연산은 ECMAScript 언어의 일부가 아닙니다. ECMAScript 언어의 의미론을 명시하는 데 도움을 주기 위해서만 여기에서 정의합니다. 그 밖의 보다 특수한 추상 연산 은 이 명세 전반에 걸쳐 정의되어 있습니다.
7.1 타입 변환
ECMAScript 언어는 필요에 따라 자동 타입 변환을 암묵적으로 수행합니다. 특정 구성 요소의 의미론을 명확히 하기 위해 변환 추상 연산 의 집합을 정의하는 것이 유용합니다. 변환 추상 연산 은 다형적이며 모든 ECMAScript 언어 타입 의 값을 받을 수 있습니다. 그러나 이러한 연산에는 다른 명세 타입을 사용하지 않습니다.
BigInt 타입 에는 ECMAScript 언어의 암묵적 변환이 없습니다. 프로그래머는 다른 타입의 값을 변환하려면 BigInt를 명시적으로 호출해야 합니다.
7.1.1 ToPrimitive ( input [ , preferredType ] )
추상 연산 ToPrimitive. 인수 input (ECMAScript 언어 값 ) 및 선택적 인수 preferredType ((string 또는 number )). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 throw 완료 ). input 인수를 Object가 아닌 타입으로 변환합니다. 객체가 둘 이상의 원시 타입으로 변환될 수 있는 경우, 선택적 힌트 preferredType 을 사용하여 해당 타입을 우선할 수 있습니다. 호출되면 다음 단계를 수행한다.
input 이 Object이면, 다음을 수행합니다.exoticToPrimitive 를 ? GetMethod (input , %Symbol.toPrimitive% )로 둡니다.exoticToPrimitive 가 undefined 가 아니면, 다음을 수행합니다.preferredType 이 존재하지 않으면, 다음을 수행합니다.hint 를 "default" 로 둡니다.그렇지 않고 preferredType 이 string 이면, 다음을 수행합니다.hint 를 "string" 으로 둡니다. 그렇지 않으면,단언 : preferredType 은 number 입니다.hint 를 "number" 로 둡니다. result 를 ? Call (exoticToPrimitive , input , « hint »)로 둡니다.result 가 Object가 아니면, result 를 반환합니다.TypeError 예외를 던집니다.preferredType 이 존재하지 않으면, preferredType 을 number 로 설정합니다.? OrdinaryToPrimitive (input , preferredType )를 반환합니다. input 을 반환합니다.
참고
힌트 없이 ToPrimitive를 호출하면 일반적으로 힌트가 number 인 것처럼 동작합니다. 그러나 객체는 %Symbol.toPrimitive% 메서드를 정의하여 이 동작을 재정의할 수 있습니다. 이 명세에 정의된 객체 중 기본 ToPrimitive 동작을 재정의하는 것은 Date(21.4.4.45 참조)와 Symbol 객체(20.4.3.5 참조)뿐입니다. Date는 힌트가 없는 경우를 힌트가 string 인 것처럼 취급합니다.
7.1.1.1 OrdinaryToPrimitive ( obj , hint )
추상 연산 OrdinaryToPrimitive. 인수 obj (Object) 및 hint (string 또는 number ). 반환값: ECMAScript 언어 값 을 포함하는 정상 완료 또는 throw 완료 . 호출되면 다음 단계를 수행한다.
hint 가 string 이면, 다음을 수행합니다.methodNames 를 « "toString" , "valueOf" »로 둡니다.그렇지 않으면,methodNames 를 « "valueOf" , "toString" »로 둡니다. methodNames 의 각 요소 name 에 대해 다음을 수행합니다.method 를 ? Get (obj , name )으로 둡니다.IsCallable (method )이 true 이면, 다음을 수행합니다.result 를 ? Call (method , obj )로 둡니다.result 가 Object가 아니면, result 를 반환합니다.TypeError 예외를 던집니다.
7.1.2 ToBoolean ( arg )
추상 연산 ToBoolean. 인수 arg (ECMAScript 언어 값 ). 반환값: Boolean. arg 를 Boolean 타입 의 값으로 변환합니다. 호출되면 다음 단계를 수행한다.
arg 가 Boolean이면, arg 를 반환합니다.arg 가 undefined , null , +0 𝔽 , -0 𝔽 , NaN , 0 ℤ 또는 빈 String 중 하나이면, false 를 반환합니다.Normative Optional
호스트 가 웹 브라우저이거나 그 밖의 방식으로 [[IsHTMLDDA]] 내부 슬롯 을 지원하면, 다음을 수행합니다.arg 가 Object이고 arg 에 [[IsHTMLDDA]] 내부 슬롯이 있으면, false 를 반환합니다.true 를 반환합니다.
7.1.3 ToNumeric ( arg )
추상 연산 ToNumeric. 인수 arg (ECMAScript 언어 값 ). 반환값: Number 또는 BigInt를 포함하는 정상 완료 또는 throw 완료 . arg 를 Number 또는 BigInt로 변환하여 반환합니다. 호출되면 다음 단계를 수행한다.
primitiveValue 를 ? ToPrimitive (arg , number )로 둡니다.primitiveValue 가 BigInt이면, primitiveValue 를 반환합니다.? ToNumber (primitiveValue )를 반환합니다.
7.1.4 ToNumber ( arg )
추상 연산 ToNumber. 인수 arg (ECMAScript 언어 값 ). 반환값: Number를 포함하는 정상 완료 또는 throw 완료 . arg 를 Number 타입 의 값으로 변환합니다. 호출되면 다음 단계를 수행한다.
arg 가 Number이면, arg 를 반환합니다.arg 가 Symbol 또는 BigInt이면, TypeError 예외를 던집니다.arg 가 undefined 이면, NaN 을 반환합니다.arg 가 null 또는 false 이면, +0 𝔽 을 반환합니다.arg 가 true 이면, 1 𝔽 을 반환합니다.arg 가 String이면, StringToNumber (arg )를 반환합니다.단언 : arg 는 Object입니다.primitiveValue 를 ? ToPrimitive (arg , number )로 둡니다.단언 : primitiveValue 는 Object가 아닙니다.? ToNumber (primitiveValue )를 반환합니다.
7.1.4.1 String 타입에 적용되는 ToNumber
추상 연산 StringToNumber 는 다음 문법을 사용하여 String 값을 Number 값 으로 변환하는 방법을 명시합니다.
구문
StringNumericLiteral :::
StrWhiteSpace opt
StrWhiteSpace opt
StrNumericLiteral
StrWhiteSpace opt
StrWhiteSpace :::
StrWhiteSpaceChar
StrWhiteSpace opt
StrWhiteSpaceChar :::
WhiteSpace
LineTerminator
StrNumericLiteral :::
StrDecimalLiteral
NonDecimalIntegerLiteral [~Sep]
StrDecimalLiteral :::
StrUnsignedDecimalLiteral
+
StrUnsignedDecimalLiteral
-
StrUnsignedDecimalLiteral
StrUnsignedDecimalLiteral :::
Infinity
DecimalDigits [~Sep]
.
DecimalDigits [~Sep] opt
ExponentPart [~Sep] opt
.
DecimalDigits [~Sep]
ExponentPart [~Sep] opt
DecimalDigits [~Sep]
ExponentPart [~Sep] opt
위에서 명시적으로 정의되지 않은 모든 문법 기호에는 숫자 리터럴의 어휘 문법(12.9.3 )에서 사용하는 정의가 적용됩니다.
참고
StringNumericLiteral 과 NumericLiteral 의 구문에는 다음과 같은 몇 가지 차이가 있음을 유의하시기 바랍니다:
7.1.4.1.1 StringToNumber ( string )
추상 연산 StringToNumber. 인수 string (String). 반환값: Number. 호출되면 다음 단계를 수행한다.
literal 을 ParseText (string , StringNumericLiteral )로 둡니다.literal 이 오류의 List 이면, NaN 을 반환합니다.literal 의 StringNumericValue 를 반환합니다.
7.1.4.1.2 Runtime Semantics: StringNumericValue
구문 지향 연산 StringNumericValue. 인수 없음. 반환값: Number.
참고
다음 생성 규칙별로 정의된다.
StringNumericLiteral ::: StrWhiteSpace opt
+0 𝔽 을 반환합니다.
StringNumericLiteral :::
StrWhiteSpace opt
StrNumericLiteral
StrWhiteSpace opt
StrNumericLiteral 의 StringNumericValue 를 반환합니다.
StrNumericLiteral ::: NonDecimalIntegerLiteral
𝔽 (NonDecimalIntegerLiteral 의 MV)를 반환합니다.
StrDecimalLiteral :::
-
StrUnsignedDecimalLiteral
a 를 StrUnsignedDecimalLiteral 의 StringNumericValue 로 둡니다.a 가 +0 𝔽 이면, -0 𝔽 을 반환합니다.-a 를 반환합니다.
StrUnsignedDecimalLiteral ::: Infinity
+∞ 𝔽 을 반환합니다.
StrUnsignedDecimalLiteral :::
DecimalDigits
.
DecimalDigits opt
ExponentPart opt
a 를 첫 번째 DecimalDigits 의 MV로 둡니다.두 번째 DecimalDigits 가 존재하면, 다음을 수행합니다.b 를 두 번째 DecimalDigits 의 MV로 둡니다.n 을 두 번째 DecimalDigits 의 코드 포인트 수로 둡니다. 그렇지 않으면,b 를 0으로 둡니다.n 을 0으로 둡니다. ExponentPart 가 존재하면 e 를 ExponentPart 의 MV로 둡니다. 그렇지 않으면 e 를 0으로 둡니다.RoundMVResult ((a + (b × 10-n )) × 10e )를 반환합니다.
StrUnsignedDecimalLiteral :::
.
DecimalDigits
ExponentPart opt
b 를 DecimalDigits 의 MV로 둡니다.ExponentPart 가 존재하면 e 를 ExponentPart 의 MV로 둡니다. 그렇지 않으면 e 를 0으로 둡니다.n 을 DecimalDigits 의 코드 포인트 수로 둡니다.RoundMVResult (b × 10e - n )를 반환합니다.
StrUnsignedDecimalLiteral :::
DecimalDigits
ExponentPart opt
a 를 DecimalDigits 의 MV로 둡니다.ExponentPart 가 존재하면 e 를 ExponentPart 의 MV로 둡니다. 그렇지 않으면 e 를 0으로 둡니다.RoundMVResult (a × 10e )를 반환합니다.
7.1.4.1.3 RoundMVResult ( n )
추상 연산 RoundMVResult. 인수 n (수학적 값 ). 반환값: Number. 구현체 정의 방식으로 n 을 Number로 변환합니다. 이 추상 연산 에서 숫자가 0이 아니거나, 그 왼쪽에 0이 아닌 숫자가 있고 오른쪽에도 0이 아닌 숫자가 있으면 해당 숫자는 유효한 것으로 간주됩니다. 이 추상 연산 에서 수학적 값 의 표현이 “나타내는 수학적 값 ”은 수학적 값 의 “십진 표현”의 역변환입니다. 호출되면 다음 단계를 수행한다.
n 의 십진 표현에 유효 숫자가 20개 이하이면, 𝔽 (n )을 반환합니다.option1 을 n 의 십진 표현에서 20번째 이후의 각 유효 숫자를 0 숫자로 바꾼 결과가 나타내는 수학적 값 으로 둡니다.option2 를 n 의 십진 표현에서 20번째 이후의 각 유효 숫자를 0 숫자로 바꾼 다음 20번째 위치의 값을 1 증가시킨 결과(필요한 경우 올림 포함)가 나타내는 수학적 값 으로 둡니다.chosen 을 option1 또는 option2 중 구현체 정의 방식으로 선택한 값으로 둡니다.𝔽 (chosen )을 반환합니다.
7.1.5 ToIntegerOrInfinity ( arg )
추상 연산 ToIntegerOrInfinity. 인수 arg (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: (정수 , +∞ 또는 -∞)) 또는 throw 완료 ). arg 를 소수 부분을 잘라낸 Number 값 을 나타내는 정수 로 변환하거나, 해당 Number 값 이 무한이면 +∞ 또는 -∞로 변환합니다. 호출되면 다음 단계를 수행한다.
number 를 ? ToNumber (arg )로 둡니다.number 가 NaN , +0 𝔽 또는 -0 𝔽 중 하나이면, 0을 반환합니다.number 가 +∞ 𝔽 이면, +∞를 반환합니다.number 가 -∞ 𝔽 이면, -∞를 반환합니다.truncate (ℝ (number ))를 반환합니다.
참고
𝔽 (ToIntegerOrInfinity(
x ))는
x 의 어떤 값에 대해서도
-0 𝔽 을 반환하지 않습니다. 소수 부분의 절삭은
x 를
수학적 값 으로 변환한 후 수행됩니다.
7.1.6 SnapToInteger ( arg , nonIntHandling [ , minimum [ , maximum ] ] )
추상 연산 SnapToInteger. 인수 arg (ECMAScript 언어 값 ) 및 nonIntHandling ((reject 또는 truncate )) 및 선택적 인수 minimum (정수 ) 및 maximum (정수 ). 반환값: (정상 완료 (값: 정수 ) 또는 throw 완료 ). arg 를 해당 Number 값 을 나타내는 정수 로 변환하며, 유한하지 않은 값을 거부하고 유한하지만 정수 가 아닌 값은 거부하거나 절삭하여 처리하며, 선택적으로 양 끝을 포함하는 제한 범위를 적용합니다. 호출되면 다음 단계를 수행한다.
number 를 ? ToNumber (arg )로 둡니다.number 가 NaN , +∞ 𝔽 또는 -∞ 𝔽 중 하나이면, RangeError 예외를 던집니다.mv 를 ℝ (number )로 둡니다.nonIntHandling 이 truncate 이면, mv 를 truncate (mv )로 설정합니다.mv 가 정수 가 아니면, RangeError 예외를 던집니다.minimum 이 존재하고 mv < minimum 이면, RangeError 예외를 던집니다.maximum 이 존재하고 mv > maximum 이면, RangeError 예외를 던집니다.mv 를 반환합니다.
7.1.7 ToFixedSizeInteger ( int , signed , bitWidth )
추상 연산 ToFixedSizeInteger. 인수 int ((정수 , +∞ 또는 -∞)), signed ((unsigned 또는 signed )) 및 bitWidth (양의 정수). 반환값: 정수 . int 를 2bitWidth 개의 정수 중 하나로 매핑합니다. signed 가 unsigned 이면 0부터 2bitWidth - 1까지의 닫힌 구간 에 있는 정수 로, signed 가 signed 이면 -2bitWidth - 1 부터 2bitWidth - 1 - 1까지의 닫힌 구간 에 있는 정수 로 매핑합니다. 호출되면 다음 단계를 수행한다.
int = +∞ 또는 int = -∞이면, 0을 반환합니다.fixedInt 를 int modulo 2bitWidth 로 둡니다.참고 : 다음 단계는 fixedInt 의 2의 보수 표현을 변경하지 않습니다.signed 가 signed 이고 fixedInt ≥ 2bitWidth - 1 이면, fixedInt 를 fixedInt - 2bitWidth 로 설정합니다.fixedInt 를 반환합니다.
참고
ToFixedSizeInteger는 멱등성을 가집니다. 즉, 임의의 ECMAScript 언어 값 x 에 대해 ToFixedSizeInteger(ToFixedSizeInteger(x , signed , bitWidth ), signed , bitWidth )는 ToFixedSizeInteger(x , signed , bitWidth )와 같습니다. 실제로 +∞와 -∞가 0으로 매핑되므로 이 불변 조건은 signed 를 반대로 바꾸더라도 유지됩니다(예: ToFixedSizeInteger(ToFixedSizeInteger(x , signed , 32), unsigned , 32)는 ToFixedSizeInteger(x , unsigned , 32)와 같습니다).
7.1.8 ToInt32 ( arg )
추상 연산 ToInt32. 인수 arg (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: 정수인 Number ) 또는 throw 완료 ). arg 를 𝔽 (-231 )부터 𝔽 (231 - 1)까지의 닫힌 구간 에 있는 232 개의 정수인 Number 값 중 하나로 변환하며, -0 𝔽 은 제외합니다. 호출되면 다음 단계를 수행한다.
int 를 ? ToIntegerOrInfinity (arg )로 둡니다.𝔽 (ToFixedSizeInteger (int , signed , 32))를 반환합니다.
7.1.9 ToUint32 ( arg )
추상 연산 ToUint32. 인수 arg (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: 정수인 Number ) 또는 throw 완료 ). arg 를 +0 𝔽 부터 𝔽 (232 - 1)까지의 닫힌 구간 에 있는 232 개의 정수인 Number 값 중 하나로 변환합니다. 호출되면 다음 단계를 수행한다.
int 를 ? ToIntegerOrInfinity (arg )로 둡니다.𝔽 (ToFixedSizeInteger (int , unsigned , 32))를 반환합니다.
7.1.10 ToInt16 ( arg )
추상 연산 ToInt16. 인수 arg (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: 정수인 Number ) 또는 throw 완료 ). arg 를 𝔽 (-215 )부터 𝔽 (215 - 1)까지의 닫힌 구간 에 있는 216 개의 정수인 Number 값 중 하나로 변환하며, -0 𝔽 은 제외합니다. 호출되면 다음 단계를 수행한다.
int 를 ? ToIntegerOrInfinity (arg )로 둡니다.𝔽 (ToFixedSizeInteger (int , signed , 16))를 반환합니다.
7.1.11 ToUint16 ( arg )
추상 연산 ToUint16. 인수 arg (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: 정수인 Number ) 또는 throw 완료 ). arg 를 +0 𝔽 부터 𝔽 (216 - 1)까지의 닫힌 구간 에 있는 216 개의 정수인 Number 값 중 하나로 변환합니다. 호출되면 다음 단계를 수행한다.
int 를 ? ToIntegerOrInfinity (arg )로 둡니다.𝔽 (ToFixedSizeInteger (int , unsigned , 16))를 반환합니다.
7.1.12 ToInt8 ( arg )
추상 연산 ToInt8. 인수 arg (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: 정수인 Number ) 또는 throw 완료 ). arg 를 -128 𝔽 부터 127 𝔽 까지의 닫힌 구간 에 있는 28 개의 정수인 Number 값 중 하나로 변환하며, -0 𝔽 은 제외합니다. 호출되면 다음 단계를 수행한다.
int 를 ? ToIntegerOrInfinity (arg )로 둡니다.𝔽 (ToFixedSizeInteger (int , signed , 8))를 반환합니다.
7.1.13 ToUint8 ( arg )
추상 연산 ToUint8. 인수 arg (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: 정수인 Number ) 또는 throw 완료 ). arg 를 +0 𝔽 부터 255 𝔽 까지의 닫힌 구간 에 있는 28 개의 정수인 Number 값 중 하나로 변환합니다. 호출되면 다음 단계를 수행한다.
int 를 ? ToIntegerOrInfinity (arg )로 둡니다.𝔽 (ToFixedSizeInteger (int , unsigned , 8))를 반환합니다.
7.1.14 ToUint8Clamp ( arg )
추상 연산 ToUint8Clamp. 인수 arg (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: 정수인 Number ) 또는 throw 완료 ). arg 를 제한하고 반올림하여 +0 𝔽 부터 255 𝔽 까지의 닫힌 구간 에 있는 28 개의 정수인 Number 값 중 하나로 변환합니다. 호출되면 다음 단계를 수행한다.
number 를 ? ToNumber (arg )로 둡니다.number 가 NaN 이면, +0 𝔽 을 반환합니다.mv 를 number 의 확장된 수학적 값 으로 둡니다.clamped 를 mv 를 0과 255 사이로 제한한 결과로 둡니다.f 를 floor (clamped )로 둡니다.clamped < f + 0.5이면, 𝔽 (f )를 반환합니다.clamped > f + 0.5이면, 𝔽 (f + 1)을 반환합니다.f 가 짝수이면, 𝔽 (f )를 반환합니다.𝔽 (f + 1)을 반환합니다.
참고
대부분의 다른 ECMAScript 정수 변환 연산과 달리 ToUint8Clamp는 정수 가 아닌 값을 절삭하지 않고 반올림합니다. 또한 “가장 가까운 짝수로 절반 반올림” 동률 결정 방식을 사용하며, 이는 Math.round 의 “절반 올림” 동률 결정 방식과 다릅니다.
7.1.15 ToBigInt ( arg )
추상 연산 ToBigInt. 인수 arg (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: BigInt) 또는 throw 완료 ). arg 를 BigInt 값 으로 변환하며, Number에서 암묵적 변환이 필요하면 예외를 던집니다. 호출되면 다음 단계를 수행한다.
primitive 를 ? ToPrimitive (arg , number )로 둡니다.표 12 에서 primitive 에 대응하는 값을 반환합니다.
표 12: BigInt 변환
인수 타입
결과
Undefined
TypeError 예외를 던집니다.
Null
TypeError 예외를 던집니다.
Boolean
primitive 가 true 이면 1n을 반환하고, primitive 가 false 이면 0n을 반환합니다.
BigInt
primitive 를 반환합니다.
Number
TypeError 예외를 던집니다.
String
n 을 StringToBigInt (primitive )로 둡니다.n 이 undefined 이면, SyntaxError 예외를 던집니다.n 을 반환합니다.
Symbol
TypeError 예외를 던집니다.
7.1.16 StringToBigInt ( string )
추상 연산 StringToBigInt. 인수 string (String). 반환값: (BigInt 또는 undefined ). 호출되면 다음 단계를 수행한다.
literal 을 ParseText (string , StringIntegerLiteral )로 둡니다.literal 이 오류의 List 이면, undefined 를 반환합니다.mv 를 literal 의 MV로 둡니다.단언 : mv 는 정수 입니다.ℤ (mv )를 반환합니다.
7.1.16.1 StringIntegerLiteral 문법
StringToBigInt 는 다음 문법을 사용합니다.
구문
StringIntegerLiteral :::
StrWhiteSpace opt
StrWhiteSpace opt
StrIntegerLiteral
StrWhiteSpace opt
StrIntegerLiteral :::
SignedInteger [~Sep]
NonDecimalIntegerLiteral [~Sep]
7.1.16.2 Runtime Semantics: MV
7.1.17 ToBigInt64 ( arg )
추상 연산 ToBigInt64. 인수 arg (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: BigInt) 또는 throw 완료 ). arg 를 ℤ (-263 )부터 ℤ (263 - 1)까지의 닫힌 구간 에 있는 264 개의 BigInt 값 중 하나로 변환합니다. 호출되면 다음 단계를 수행한다.
int 를 ℝ (? ToBigInt (arg ))로 둡니다.ℤ (ToFixedSizeInteger (int , signed , 64))를 반환합니다.
7.1.18 ToBigUint64 ( arg )
추상 연산 ToBigUint64. 인수 arg (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: BigInt) 또는 throw 완료 ). arg 를 0 ℤ 부터 ℤ (264 - 1)까지의 닫힌 구간 에 있는 264 개의 BigInt 값 중 하나로 변환합니다. 호출되면 다음 단계를 수행한다.
int 를 ℝ (? ToBigInt (arg ))로 둡니다.ℤ (ToFixedSizeInteger (int , unsigned , 64))를 반환합니다.
7.1.19 ToString ( arg )
추상 연산 ToString. 인수 arg (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: String) 또는 throw 완료 ). arg 를 String 타입 의 값으로 변환합니다. 호출되면 다음 단계를 수행한다.
arg 가 String이면, arg 를 반환합니다.arg 가 Symbol이면, TypeError 예외를 던집니다.arg 가 undefined 이면, "undefined" 를 반환합니다.arg 가 null 이면, "null" 을 반환합니다.arg 가 true 이면, "true" 를 반환합니다.arg 가 false 이면, "false" 를 반환합니다.arg 가 Number이면, Number::toString (arg , 10)을 반환합니다.arg 가 BigInt이면, BigInt::toString (arg , 10)을 반환합니다.단언 : arg 는 Object입니다.primitiveValue 를 ? ToPrimitive (arg , string )로 둡니다.단언 : primitiveValue 는 Object가 아닙니다.? ToString (primitiveValue )를 반환합니다.
7.1.20 ToObject ( arg )
추상 연산 ToObject. 인수 arg (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: Object) 또는 throw 완료 ). arg 를 Object 타입 의 값으로 변환합니다. 호출되면 다음 단계를 수행한다.
arg 가 undefined 또는 null 이면, TypeError 예외를 던집니다.arg 가 Boolean이면, [[BooleanData]] 내부 슬롯이 arg 로 설정된 새로운 Boolean 객체를 반환합니다. Boolean 객체에 대한 설명은 20.3 를 참조하시기 바랍니다.arg 가 Number이면, [[NumberData]] 내부 슬롯이 arg 로 설정된 새로운 Number 객체를 반환합니다. Number 객체에 대한 설명은 21.1 를 참조하시기 바랍니다.arg 가 String이면, [[StringData]] 내부 슬롯이 arg 로 설정된 새로운 String 객체를 반환합니다. String 객체에 대한 설명은 22.1 를 참조하시기 바랍니다.arg 가 Symbol이면, [[SymbolData]] 내부 슬롯이 arg 로 설정된 새로운 Symbol 객체를 반환합니다. Symbol 객체에 대한 설명은 20.4 를 참조하시기 바랍니다.arg 가 BigInt이면, [[BigIntData]] 내부 슬롯이 arg 로 설정된 새로운 BigInt 객체를 반환합니다. BigInt 객체에 대한 설명은 21.2 를 참조하시기 바랍니다.단언 : arg 는 Object입니다.arg 를 반환합니다.
7.1.21 ToPropertyKey ( arg )
추상 연산 ToPropertyKey. 인수 arg (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: 프로퍼티 키 ) 또는 throw 완료 ). arg 를 프로퍼티 키 로 사용할 수 있는 값으로 변환합니다. 호출되면 다음 단계를 수행한다.
key 를 ? ToPrimitive (arg , string )로 둡니다.key 가 Symbol이면, 다음을 수행합니다.key 를 반환합니다.! ToString (key )을 반환합니다.
7.1.22 ToLength ( arg )
추상 연산 ToLength. 인수 arg (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: 음이 아닌 정수인 Number) 또는 throw 완료 ). arg 를 제한하고 절삭하여 배열과 유사한 객체 의 길이로 사용하기에 적합한 음이 아닌 정수인 Number 로 변환합니다. 호출되면 다음 단계를 수행한다.
length 를 ? ToIntegerOrInfinity (arg )로 둡니다.clampedLength 를 length 를 0과 253 - 1 사이로 제한한 결과로 둡니다.𝔽 (clampedLength )를 반환합니다.
7.1.23 CanonicalNumericIndexString ( arg )
추상 연산 CanonicalNumericIndexString. 인수 arg (String). 반환값: (Number 또는 undefined ). arg 가 "-0" 이거나 어떤 Number 값 n 에 대한 ToString (n )과 정확히 일치하면 각각에 대응하는 Number 값 을 반환합니다. 그렇지 않으면 undefined 를 반환합니다. 호출되면 다음 단계를 수행한다.
arg 가 "-0" 이면, -0 𝔽 을 반환합니다.n 을 ! ToNumber (arg )로 둡니다.! ToString (n )이 arg 이면, n 을 반환합니다. undefined 를 반환합니다.
정규 숫자 문자열 은 CanonicalNumericIndexString 추상 연산 이 undefined 를 반환하지 않는 모든 String입니다.
7.1.24 ToIndex ( arg )
추상 연산 ToIndex. 인수 arg (ECMAScript 언어 값 ). 반환값: 음이 아닌 정수 를 포함하는 정상 완료 또는 throw 완료 . arg 를 정수 로 변환하고 해당 정수 가 음이 아니며 정수 인덱스 에 대응하면 그 정수 를 반환합니다. 그렇지 않으면 예외를 던집니다. 호출되면 다음 단계를 수행한다.
int 를 ? ToIntegerOrInfinity (arg )로 둡니다.int 가 0부터 253 - 1까지의 닫힌 구간 에 없으면, RangeError 예외를 던집니다.int 를 반환합니다.
7.1.25 ToAbsoluteIndex ( value , length )
추상 연산 ToAbsoluteIndex. 인수 value (ECMAScript 언어 값 ) 및 length (음이 아닌 정수). 반환값: (정상 완료 (값: (정수 , +∞ 또는 -∞)) 또는 throw 완료 ). value 를 정수 , +∞ 또는 -∞로 변환하며, 음수 값은 length 를 기준으로 상대적으로 해석합니다. 호출되면 다음 단계를 수행한다.
int 를 ? ToIntegerOrInfinity (value )로 둡니다.int 가 유한하고 int < 0이면, int 를 length + int 로 설정합니다.int 를 반환합니다.
7.1.26 ToClampedIndex ( value , length )
추상 연산 ToClampedIndex. 인수 value (ECMAScript 언어 값 ) 및 length (음이 아닌 정수). 반환값: (정상 완료 (값: 음이 아닌 정수) 또는 throw 완료 ). value 를 정수 로 변환하고(음수 값은 length 를 기준으로 상대적으로 해석), 그 결과를 0부터 length 까지의 닫힌 구간 으로 제한합니다. 호출되면 다음 단계를 수행한다.
index 를 ? ToAbsoluteIndex (value , length )로 둡니다.index 를 0과 length 사이로 제한한 결과를 반환합니다.
7.2 검사 및 비교 연산
7.2.1 RequireObjectCoercible ( arg )
추상 연산 RequireObjectCoercible. 인수 arg (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). arg 가 ToObject 를 사용하여 Object로 변환할 수 없는 값이면 오류를 던집니다. 호출되면 다음 단계를 수행한다.
arg 가 undefined 또는 null 이면, TypeError 예외를 던집니다.unused 를 반환합니다.
7.2.2 IsArray ( arg )
추상 연산 IsArray. 인수 arg (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
arg 가 Object가 아니면, false 를 반환합니다.arg 가 Array 특수 객체 이면, true 를 반환합니다.arg 가 Proxy 특수 객체 이면, 다음을 수행합니다.? ValidateNonRevokedProxy (arg )를 수행합니다. proxyTarget 을 arg .[[ProxyTarget]] 으로 둡니다.? IsArray (proxyTarget )를 반환합니다. false 를 반환합니다.
7.2.3 IsCallable ( arg )
추상 연산 IsCallable. 인수 arg (ECMAScript 언어 값 ). 반환값: Boolean. arg 가 [[Call]] 내부 메서드를 갖는 호출 가능한 함수인지 결정합니다. 호출되면 다음 단계를 수행한다.
arg 가 Object가 아니면, false 를 반환합니다.arg 에 [[Call]] 내부 메서드가 있으면, true 를 반환합니다.false 를 반환합니다.
7.2.4 IsConstructor ( arg )
추상 연산 IsConstructor. 인수 arg (ECMAScript 언어 값 ). 반환값: Boolean. arg 가 [[Construct]] 내부 메서드를 갖는 함수 객체 인지 결정합니다. 호출되면 다음 단계를 수행한다.
arg 가 Object가 아니면, false 를 반환합니다.arg 에 [[Construct]] 내부 메서드가 있으면, true 를 반환합니다.false 를 반환합니다.
7.2.5 IsExtensible ( obj )
추상 연산 IsExtensible. 인수 obj (Object). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). obj 에 추가 프로퍼티를 추가할 수 있는지 결정하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
? obj .[[IsExtensible]] () 를 반환합니다.
7.2.6 IsRegExp ( arg )
추상 연산 IsRegExp. 인수 arg (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
arg 가 Object가 아니면, false 를 반환합니다.matcher 를 ? Get (arg , %Symbol.match% )로 둡니다.matcher 가 undefined 가 아니면, ToBoolean (matcher )을 반환합니다.arg 에 [[RegExpMatcher]] 내부 슬롯이 있으면, true 를 반환합니다.false 를 반환합니다.
7.2.7 Static Semantics: IsStringWellFormedUnicode ( string )
추상 연산 IsStringWellFormedUnicode. 인수 string (String). 반환값: Boolean. 6.1.4 에 설명된 대로 string 을 UTF-16로 인코딩된 코드 포인트 시퀀스로 해석하고, 이것이 올바른 형식 의 UTF-16 시퀀스인지 결정합니다. 호출되면 다음 단계를 수행한다.
length 를 string 의 길이로 둡니다.k 를 0으로 둡니다.k < length 인 동안 다음을 반복합니다.codePoint 를 CodePointAt (string , k )으로 둡니다.codePoint .[[IsUnpairedSurrogate]] 가 true 이면, false 를 반환합니다.k 를 k + codePoint .[[CodeUnitCount]] 로 설정합니다.true 를 반환합니다.
7.2.8 SameType ( x , y )
추상 연산 SameType. 인수 x (ECMAScript 언어 값 ) 및 y (ECMAScript 언어 값 ). 반환값: Boolean. 두 인수가 같은 타입인지 결정합니다. 호출되면 다음 단계를 수행한다.
x 가 undefined 이고 y 가 undefined 이면, true 를 반환합니다.x 가 null 이고 y 가 null 이면, true 를 반환합니다.x 가 Boolean이고 y 가 Boolean이면, true 를 반환합니다.x 가 Number이고 y 가 Number이면, true 를 반환합니다.x 가 BigInt이고 y 가 BigInt이면, true 를 반환합니다.x 가 Symbol이고 y 가 Symbol이면, true 를 반환합니다.x 가 String이고 y 가 String이면, true 를 반환합니다.x 가 Object이고 y 가 Object이면, true 를 반환합니다.false 를 반환합니다.
7.2.9 SameValue ( x , y )
추상 연산 SameValue. 인수 x (ECMAScript 언어 값 ) 및 y (ECMAScript 언어 값 ). 반환값: Boolean. 두 인수가 같은 값인지 결정합니다. 호출되면 다음 단계를 수행한다.
SameType (x , y )이 false 이면, false 를 반환합니다.x 가 Number이면, 다음을 수행합니다.Number::sameValue (x , y )를 반환합니다.SameValueNonNumber (x , y )를 반환합니다.
참고
이 알고리즘은 모든 NaN 값을 동등하게 취급하고 +0 𝔽 과 -0 𝔽 을 구별한다는 점에서 IsStrictlyEqual 알고리즘과 다릅니다.
7.2.10 SameValueZero ( x , y )
추상 연산 SameValueZero. 인수 x (ECMAScript 언어 값 ) 및 y (ECMAScript 언어 값 ). 반환값: Boolean. 두 인수가 같은 값인지 결정합니다(+0 𝔽 과 -0 𝔽 의 차이는 무시합니다). 호출되면 다음 단계를 수행한다.
SameType (x , y )이 false 이면, false 를 반환합니다.x 가 Number이면, 다음을 수행합니다.Number::sameValueZero (x , y )를 반환합니다.SameValueNonNumber (x , y )를 반환합니다.
참고
SameValueZero는 +0 𝔽 과 -0 𝔽 을 동등하게 취급한다는 점에서만 SameValue 와 다릅니다.
7.2.11 SameValueNonNumber ( x , y )
추상 연산 SameValueNonNumber. 인수 x (Number가 아닌 ECMAScript 언어 값 ) 및 y (Number가 아닌 ECMAScript 언어 값 ). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
단언 : SameType (x , y )은 true 입니다.x 가 undefined 또는 null 이면, true 를 반환합니다.x 가 BigInt이면, 다음을 수행합니다.BigInt::equal (x , y )를 반환합니다.x 가 String이면, 다음을 수행합니다.x 와 y 의 길이가 같고 동일한 위치에 동일한 코드 단위가 있으면, true 를 반환합니다.false 를 반환합니다.x 가 Boolean이면, 다음을 수행합니다.x 가 true 이고 y 가 true 이면, true 를 반환합니다.x 가 false 이고 y 가 false 이면, true 를 반환합니다.false 를 반환합니다.참고 : 그 밖의 모든 ECMAScript 언어 값 은 동일성으로 비교됩니다.x 가 y 이면, true 를 반환합니다.false 를 반환합니다.
참고 1
설명을 위해 필요하지 않은 경우에도 일부 경우를 이 알고리즘 내에서 별도로 처리합니다.
참고 2
“
x 가
y 이다”가 구체적으로 무엇을 의미하는지는
5.2.8 에 자세히 설명되어 있습니다.
7.2.12 IsLessThan ( x , y , leftFirst )
추상 연산 IsLessThan. 인수 x (ECMAScript 언어 값 ), y (ECMAScript 언어 값 ) 및 leftFirst (Boolean). 반환값: Boolean 또는 undefined 를 포함하는 정상 완료 또는 throw 완료 . 비교 x < y 의 의미론을 제공하며, true , false 또는 undefined (피연산자를 동일한 숫자 타입의 비교 가능한 값으로 강제 변환할 수 없음을 나타냅니다)를 반환합니다. leftFirst 플래그는 x 와 y 에 대해 관찰 가능한 부작용이 있을 수 있는 연산을 수행하는 순서를 제어하는 데 사용됩니다. ECMAScript가 표현식의 왼쪽에서 오른쪽 평가를 명시하기 때문에 필요합니다. leftFirst 가 true 이면 x 매개변수는 y 매개변수에 대응하는 표현식보다 왼쪽에 나타나는 표현식에 대응합니다. leftFirst 가 false 이면 반대이며, x 보다 y 에 대한 연산을 먼저 수행해야 합니다. 호출되면 다음 단계를 수행한다.
leftFirst 가 true 이면, 다음을 수행합니다.px 를 ? ToPrimitive (x , number )로 둡니다.py 를 ? ToPrimitive (y , number )로 둡니다.그렇지 않으면,참고 : 왼쪽에서 오른쪽 평가를 유지하기 위해 평가 순서를 반대로 해야 합니다.py 를 ? ToPrimitive (y , number )로 둡니다.px 를 ? ToPrimitive (x , number )로 둡니다. px 가 String이고 py 가 String이면, 다음을 수행합니다.lx 를 px 의 길이로 둡니다.ly 를 py 의 길이로 둡니다.0 ≤ i < min (lx , ly )를 만족하는 각 정수 i 에 대해 오름차순으로 다음을 수행합니다.cx 를 px 내 인덱스 i 에 있는 코드 단위의 숫자 값으로 둡니다.cy 를 py 내 인덱스 i 에 있는 코드 단위의 숫자 값으로 둡니다.cx < cy 이면, true 를 반환합니다.cx > cy 이면, false 를 반환합니다. lx < ly 이면, true 를 반환합니다.false 를 반환합니다.px 가 BigInt이고 py 가 String이면, 다음을 수행합니다.ny 를 StringToBigInt (py )로 둡니다.ny 가 undefined 이면, undefined 를 반환합니다.BigInt::lessThan (px , ny )을 반환합니다.px 가 String이고 py 가 BigInt이면, 다음을 수행합니다.nx 를 StringToBigInt (px )로 둡니다.nx 가 undefined 이면, undefined 를 반환합니다.BigInt::lessThan (nx , py )을 반환합니다.참고 : px 와 py 는 원시값이므로 평가 순서는 중요하지 않습니다.nx 를 ? ToNumeric (px )로 둡니다.ny 를 ? ToNumeric (py )로 둡니다.SameType (nx , ny )이 true 이면, 다음을 수행합니다.nx 가 Number이면, Number::lessThan (nx , ny )을 반환합니다.단언 : nx 는 BigInt입니다.BigInt::lessThan (nx , ny )을 반환합니다.단언 : nx 가 BigInt이고 ny 가 Number이거나, nx 가 Number이고 ny 가 BigInt입니다.nx 가 NaN 이거나 ny 가 NaN 이면, undefined 를 반환합니다.nx 가 -∞ 𝔽 이거나 ny 가 +∞ 𝔽 이면, true 를 반환합니다.nx 가 +∞ 𝔽 이거나 ny 가 -∞ 𝔽 이면, false 를 반환합니다.ℝ (nx ) < ℝ (ny )이면, true 를 반환합니다.false 를 반환합니다.
참고 1
3 단계는 덧셈 연산자 +를 처리하는 알고리즘(13.15.3 )의 1.c 단계와 달리 논리 OR 연산 대신 논리 AND 연산을 사용합니다.
참고 2
String 비교에서는 UTF-16 코드 단위 값의 시퀀스에 대한 단순한 사전식 순서를 사용합니다. 유니코드 명세에 정의된 더 복잡하고 의미론 중심적인 문자 또는 문자열 동등성과 정렬 순서 정의를 사용하려는 시도는 하지 않습니다. 따라서 유니코드 표준에 따라 정규적으로 동등하지만 동일한 정규화 형식이 아닌 String 값은 서로 같지 않은 것으로 판정될 수 있습니다. 또한 서로게이트 쌍 을 포함하는 String의 경우 코드 단위 에 따른 사전식 순서는 코드 포인트 에 따른 순서와 다르다는 점에 유의하시기 바랍니다.
7.2.13 IsLooselyEqual ( x , y )
추상 연산 IsLooselyEqual. 인수 x (ECMAScript 언어 값 ) 및 y (ECMAScript 언어 값 ). 반환값: Boolean을 포함하는 정상 완료 또는 throw 완료 . == 연산자의 의미론을 제공합니다. 호출되면 다음 단계를 수행한다.
SameType (x , y )가 true 이면 다음을 수행합니다.IsStrictlyEqual (x , y )을 반환합니다.x 가 null 이고 y 가 undefined 이면 true 를 반환합니다.x 가 undefined 이고 y 가 null 이면 true 를 반환합니다.Normative Optional
호스트 가 웹 브라우저이거나 그 밖의 방식으로 [[IsHTMLDDA]] 내부 슬롯 을 지원하면 다음을 수행합니다.x 가 Object이고, x 에 [[IsHTMLDDA]] 내부 슬롯이 있으며, y 가 undefined 또는 null 중 하나이면 true 를 반환합니다.x 가 undefined 또는 null 중 하나이고, y 가 Object이며, y 에 [[IsHTMLDDA]] 내부 슬롯이 있으면 true 를 반환합니다.x 가 Number이고 y 가 String이면 ! IsLooselyEqual (x , ! ToNumber (y ))을 반환합니다.x 가 String이고 y 가 Number이면 ! IsLooselyEqual (! ToNumber (x ), y )를 반환합니다.x 가 BigInt이고 y 가 String이면 다음을 수행합니다.n 을 StringToBigInt (y )로 둡니다.n 이 undefined 이면 false 를 반환합니다.! IsLooselyEqual (x , n )을 반환합니다. x 가 String이고 y 가 BigInt이면 ! IsLooselyEqual (y , x )를 반환합니다.x 가 Boolean이면 ! IsLooselyEqual (! ToNumber (x ), y )를 반환합니다.y 가 Boolean이면 ! IsLooselyEqual (x , ! ToNumber (y ))을 반환합니다.x 가 String, Number, BigInt 또는 Symbol 중 하나이고 y 가 Object이면 ! IsLooselyEqual (x , ? ToPrimitive (y ))을 반환합니다.x 가 Object이고 y 가 String, Number, BigInt 또는 Symbol 중 하나이면 ! IsLooselyEqual (? ToPrimitive (x ), y )를 반환합니다.x 가 BigInt이고 y 가 유한 Number 이거나, x 가 유한 Number 이고 y 가 BigInt이면 다음을 수행합니다.ℝ (x ) = ℝ (y )이면 true 를 반환합니다.false 를 반환합니다.false 를 반환합니다.
7.2.14 IsStrictlyEqual ( x , y )
추상 연산 IsStrictlyEqual. 인수 x (ECMAScript 언어 값 ) 및 y (ECMAScript 언어 값 ). 반환값: Boolean. === 연산자의 의미론을 제공합니다. 호출되면 다음 단계를 수행한다.
SameType (x , y )이 false 이면, false 를 반환합니다.x 가 Number이면, 다음을 수행합니다.Number::equal (x , y )을 반환합니다.SameValueNonNumber (x , y )을 반환합니다.
참고
이 알고리즘은 부호가 있는 0과 NaN을 처리하는 방식에서 SameValue 알고리즘과 다릅니다.
7.3 객체에 대한 연산
7.3.1 MakeBasicObject ( internalSlotsList )
추상 연산 MakeBasicObject. 인수 internalSlotsList (내부 슬롯 이름의 List ). 반환값: Object. 일반 객체 와 특수 객체 를 모두 포함하여 알고리즘으로 생성되는 모든 ECMAScript 객체의 출처입니다. 모든 객체 생성에 공통으로 사용하는 단계를 분리하고 객체 생성을 중앙화합니다. 호출되면 다음 단계를 수행한다.
internalSlotsList 를 internalSlotsList 와 « [[PrivateElements]] »의 목록 연결 로 설정합니다.obj 를 internalSlotsList 의 각 이름에 대한 내부 슬롯을 갖는 새로 생성된 객체로 둡니다.참고 : Object 내부 메서드와 내부 슬롯 에 설명된 대로 달리 명시되지 않는 한 이러한 각 내부 슬롯의 초기값은 undefined 입니다.obj .[[PrivateElements]] 를 새로운 빈 List 로 설정합니다.obj 의 필수 내부 메서드를 10.1 에 명시된 기본 일반 객체 정의로 설정합니다.단언 : 호출자가 obj 의 [[GetPrototypeOf]] 및 [[SetPrototypeOf]] 필수 내부 메서드를 모두 재정의하지 않을 예정이면, internalSlotsList 에는 [[Prototype]] 이 포함됩니다.단언 : 호출자가 obj 의 [[SetPrototypeOf]] , [[IsExtensible]] 및 [[PreventExtensions]] 필수 내부 메서드를 모두 재정의하지 않을 예정이면, internalSlotsList 에는 [[Extensible]] 이 포함됩니다.internalSlotsList 에 [[Extensible]] 이 포함되어 있으면, obj .[[Extensible]] 을 true 로 설정합니다.obj 를 반환합니다.
참고
이 명세에서 특수 객체 는 ArrayCreate 및 BoundFunctionCreate 와 같은 추상 연산 에서 먼저 MakeBasicObject를 호출하여 기본적인 기반 객체를 얻은 다음, 해당 객체의 일부 또는 모든 내부 메서드를 재정의하여 생성합니다. 특수 객체 생성을 캡슐화하기 위해 객체의 필수 내부 메서드는 이러한 연산 외부에서는 절대로 수정하지 않습니다.
7.3.2 Get ( obj , propertyKey )
추상 연산 Get. 인수 obj (Object) 및 propertyKey (프로퍼티 키 ). 반환값: ECMAScript 언어 값 을 포함하는 정상 완료 또는 throw 완료 . 객체의 특정 프로퍼티 값을 가져오는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
? obj .[[Get]] (propertyKey , obj ) 를 반환합니다.
7.3.3 GetV ( value , propertyKey )
추상 연산 GetV. 인수 value (ECMAScript 언어 값 ) 및 propertyKey (프로퍼티 키 ). 반환값: ECMAScript 언어 값 을 포함하는 정상 완료 또는 throw 완료 . ECMAScript 언어 값 의 특정 프로퍼티 값을 가져오는 데 사용됩니다. 값이 객체가 아닌 경우 해당 값 타입에 적합한 래퍼 객체를 사용하여 프로퍼티 조회를 수행합니다. 호출되면 다음 단계를 수행한다.
obj 를 ? ToObject (value )로 둡니다.? obj .[[Get]] (propertyKey , value ) 를 반환합니다.
7.3.4 Set ( obj , propertyKey , value , throw )
추상 연산 Set. 인수 obj (Object), propertyKey (프로퍼티 키 ), value (ECMAScript 언어 값 ) 및 throw (Boolean). 반환값: unused 를 포함하는 정상 완료 또는 throw 완료 . 객체의 특정 프로퍼티 값을 설정하는 데 사용됩니다. value 는 프로퍼티의 새 값입니다. 호출되면 다음 단계를 수행한다.
success 를 ? obj .[[Set]] (propertyKey , value , obj ) 로 둡니다.success 가 false 이고 throw 가 true 이면, TypeError 예외를 던집니다.unused 를 반환합니다.
7.3.5 CreateDataProperty ( obj , propertyKey , value )
추상 연산 CreateDataProperty. 인수 obj (Object), propertyKey (프로퍼티 키 ) 및 value (ECMAScript 언어 값 ). 반환값: Boolean을 포함하는 정상 완료 또는 throw 완료 . 객체에 새로운 자체 프로퍼티를 생성하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
newDesc 를 PropertyDescriptor { [[Value]] : value , [[Writable]] : true , [[Enumerable]] : true , [[Configurable]] : true }로 둡니다.? obj .[[DefineOwnProperty]] (propertyKey , newDesc ) 를 반환합니다.
참고
이 추상 연산 은 ECMAScript 언어의 할당 연산자가 생성하는 프로퍼티에 사용되는 기본값과 동일하게 속성이 설정된 프로퍼티를 생성합니다. 일반적으로 해당 프로퍼티는 이미 존재하지 않습니다. 이미 존재하면서 구성 가능하지 않거나 obj 가 확장 가능하지 않으면 [[DefineOwnProperty]] 는 false 를 반환합니다.
7.3.6 CreateDataPropertyOrThrow ( obj , propertyKey , value )
추상 연산 CreateDataPropertyOrThrow. 인수 obj (Object), propertyKey (프로퍼티 키 ) 및 value (ECMAScript 언어 값 ). 반환값: unused 를 포함하는 정상 완료 또는 throw 완료 . 객체에 새로운 자체 프로퍼티를 생성하는 데 사용됩니다. 요청한 프로퍼티 갱신을 수행할 수 없으면 TypeError 예외를 던집니다. 호출되면 다음 단계를 수행한다.
success 를 ? CreateDataProperty (obj , propertyKey , value )로 둡니다.success 가 false 이면, TypeError 예외를 던집니다.unused 를 반환합니다.
참고
이 추상 연산 은 ECMAScript 언어의 할당 연산자가 생성하는 프로퍼티에 사용되는 기본값과 동일하게 속성이 설정된 프로퍼티를 생성합니다. 일반적으로 해당 프로퍼티는 이미 존재하지 않습니다. 이미 존재하면서 구성 가능하지 않거나 obj 가 확장 가능하지 않으면 [[DefineOwnProperty]] 는 false 를 반환하여 이 연산이 TypeError 예외를 던지게 합니다.
7.3.7 CreateNonEnumerableDataPropertyOrThrow ( obj , propertyKey , value )
추상 연산 CreateNonEnumerableDataPropertyOrThrow. 인수 obj (Object), propertyKey (프로퍼티 키 ) 및 value (ECMAScript 언어 값 ). 반환값: unused . 일반 객체 에 열거할 수 없는 새로운 자체 프로퍼티를 생성하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
단언 : obj 는 구성 불가능한 프로퍼티가 없는 일반 확장 가능 객체입니다.newDesc 를 PropertyDescriptor { [[Value]] : value , [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : true }로 둡니다.! DefinePropertyOrThrow (obj , propertyKey , newDesc )를 수행합니다. unused 를 반환합니다.
참고
이 추상 연산 은 열거 가능하지 않다는 점을 제외하면 ECMAScript 언어의 할당 연산자가 생성하는 프로퍼티에 사용되는 기본값과 동일하게 속성이 설정된 프로퍼티를 생성합니다. 일반적으로 해당 프로퍼티는 이미 존재하지 않습니다. 이미 존재하더라도 DefinePropertyOrThrow 는 정상적으로 완료됨이 보장됩니다.
7.3.8 DefinePropertyOrThrow ( obj , propertyKey , propertyDesc )
추상 연산 DefinePropertyOrThrow. 인수 obj (Object), propertyKey (프로퍼티 키 ) 및 propertyDesc (프로퍼티 서술자 ). 반환값: unused 를 포함하는 정상 완료 또는 throw 완료 . 요청한 프로퍼티 갱신을 수행할 수 없는 경우 TypeError 예외를 던지는 방식으로 객체의 [[DefineOwnProperty]] 내부 메서드를 호출하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
success 를 ? obj .[[DefineOwnProperty]] (propertyKey , propertyDesc ) 로 둡니다.success 가 false 이면, TypeError 예외를 던집니다.unused 를 반환합니다.
7.3.9 DeletePropertyOrThrow ( obj , propertyKey )
추상 연산 DeletePropertyOrThrow. 인수 obj (Object) 및 propertyKey (프로퍼티 키 ). 반환값: unused 를 포함하는 정상 완료 또는 throw 완료 . 객체의 특정 자체 프로퍼티를 제거하는 데 사용됩니다. 프로퍼티가 구성 가능하지 않으면 예외를 던집니다. 호출되면 다음 단계를 수행한다.
success 를 ? obj .[[Delete]] (propertyKey ) 로 둡니다.success 가 false 이면, TypeError 예외를 던집니다.unused 를 반환합니다.
7.3.10 GetMethod ( value , propertyKey )
추상 연산 GetMethod. 인수 value (ECMAScript 언어 값 ) 및 propertyKey (프로퍼티 키 ). 반환값: 함수 객체 또는 undefined 를 포함하는 정상 완료 또는 throw 완료 . 프로퍼티의 값이 함수일 것으로 예상되는 경우 ECMAScript 언어 값 의 특정 프로퍼티 값을 가져오는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
func 를 ? GetV (value , propertyKey )로 둡니다.func 가 undefined 또는 null 이면, undefined 를 반환합니다.IsCallable (func )이 false 이면, TypeError 예외를 던집니다.func 를 반환합니다.
7.3.11 HasProperty ( obj , propertyKey )
추상 연산 HasProperty. 인수 obj (Object) 및 propertyKey (프로퍼티 키 ). 반환값: Boolean을 포함하는 정상 완료 또는 throw 완료 . 객체가 지정된 프로퍼티 키 를 갖는 프로퍼티를 보유하는지 결정하는 데 사용됩니다. 프로퍼티는 자체 프로퍼티 또는 상속된 프로퍼티일 수 있습니다. 호출되면 다음 단계를 수행한다.
? obj .[[HasProperty]] (propertyKey ) 를 반환합니다.
7.3.12 HasOwnProperty ( obj , propertyKey )
추상 연산 HasOwnProperty. 인수 obj (Object) 및 propertyKey (프로퍼티 키 ). 반환값: Boolean을 포함하는 정상 완료 또는 throw 완료 . 객체가 지정된 프로퍼티 키 를 갖는 자체 프로퍼티를 보유하는지 결정하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
propertyDesc 를 ? obj .[[GetOwnProperty]] (propertyKey ) 로 둡니다.propertyDesc 가 undefined 이면, false 를 반환합니다.true 를 반환합니다.
7.3.13 Call ( func , thisValue [ , argList ] )
추상 연산 Call. 인수 func (ECMAScript 언어 값 ) 및 thisValue (ECMAScript 언어 값 ) 및 선택적 인수 argList (리스트 (요소: ECMAScript 언어 값 )). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 throw 완료 ). 함수 객체 의 [[Call]] 내부 메서드를 호출하는 데 사용됩니다. func 는 함수 객체 이고, thisValue 는 [[Call]] 의 this 값인 ECMAScript 언어 값 이며, argList 는 내부 메서드의 대응하는 인수에 전달되는 값입니다. argList 가 존재하지 않으면 새로운 빈 List 를 값으로 사용합니다. 호출되면 다음 단계를 수행한다.
argList 가 존재하지 않으면, argList 를 새로운 빈 List 로 설정합니다.IsCallable (func )이 false 이면, TypeError 예외를 던집니다.? func .[[Call]] (thisValue , argList ) 를 반환합니다.
7.3.14 Construct ( ctor [ , argList [ , newTarget ] ] )
추상 연산 Construct. 인수 ctor (생성자 ) 및 선택적 인수 argList (리스트 (요소: ECMAScript 언어 값 )) 및 newTarget (생성자 ). 반환값: (정상 완료 (값: Object) 또는 throw 완료 ). 함수 객체 의 [[Construct]] 내부 메서드를 호출하는 데 사용됩니다. argList 와 newTarget 은 내부 메서드의 대응하는 인수로 전달되는 값입니다. argList 가 존재하지 않으면 새로운 빈 List 를 값으로 사용합니다. newTarget 이 존재하지 않으면 ctor 를 값으로 사용합니다. 호출되면 다음 단계를 수행한다.
newTarget 이 존재하지 않으면, newTarget 을 ctor 로 설정합니다.argList 가 존재하지 않으면, argList 를 새로운 빈 List 로 설정합니다.? ctor .[[Construct]] (argList , newTarget ) 를 반환합니다.
참고
newTarget 이 존재하지 않으면 이 연산은 new F(...argumentsList)와 동등합니다.
7.3.15 SetIntegrityLevel ( obj , level )
추상 연산 SetIntegrityLevel. 인수 obj (Object) 및 level ((sealed 또는 frozen )). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 객체의 자체 프로퍼티 집합을 고정하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
status 를 ? obj .[[PreventExtensions]] ()로 둡니다.status 가 false 이면, false 를 반환합니다.keys 를 ? obj .[[OwnPropertyKeys]] ()로 둡니다.level 이 sealed 이면, 다음을 수행합니다.keys 의 각 요소 key 에 대해 다음을 수행합니다.? DefinePropertyOrThrow (obj , key , PropertyDescriptor { [[Configurable]] : false })를 수행합니다. 그렇지 않으면,단언 : level 은 frozen 입니다.keys 의 각 요소 key 에 대해 다음을 수행합니다.currentDesc 를 ? obj .[[GetOwnProperty]] (key ) 로 둡니다.currentDesc 가 undefined 가 아니면, 다음을 수행합니다.IsAccessorDescriptor (currentDesc )가 true 이면, 다음을 수행합니다.propertyDesc 를 PropertyDescriptor { [[Configurable]] : false }로 둡니다.그렇지 않으면,propertyDesc 를 PropertyDescriptor { [[Configurable]] : false , [[Writable]] : false }로 둡니다. ? DefinePropertyOrThrow (obj , key , propertyDesc )를 수행합니다. true 를 반환합니다.
7.3.16 TestIntegrityLevel ( obj , level )
추상 연산 TestIntegrityLevel. 인수 obj (Object) 및 level ((sealed 또는 frozen )). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 객체의 자체 프로퍼티 집합이 고정되어 있는지 결정하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
extensible 을 ? IsExtensible (obj )로 둡니다.extensible 이 true 이면, false 를 반환합니다.참고 : 객체가 확장 가능하면 해당 객체의 프로퍼티는 검사하지 않습니다.keys 를 ? obj .[[OwnPropertyKeys]] ()로 둡니다.keys 의 각 요소 key 에 대해 다음을 수행합니다.currentDesc 를 ? obj .[[GetOwnProperty]] (key ) 로 둡니다.currentDesc 가 undefined 가 아니면, 다음을 수행합니다.currentDesc .[[Configurable]] 이 true 이면, false 를 반환합니다.level 이 frozen 이고 IsDataDescriptor (currentDesc )가 true 이면, 다음을 수행합니다.currentDesc .[[Writable]] 이 true 이면, false 를 반환합니다.true 를 반환합니다.
7.3.17 CreateArrayFromList ( elements )
추상 연산 CreateArrayFromList. 인수 elements (리스트 (요소: ECMAScript 언어 값 )). 반환값: Array. elements 가 제공하는 요소를 갖는 Array를 생성하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
array 를 ! ArrayCreate (0)으로 둡니다.n 을 0으로 둡니다.elements 의 각 요소 element 에 대해 다음을 수행합니다.! CreateDataPropertyOrThrow (array , ! ToString (𝔽 (n )), element )를 수행합니다. n 을 n + 1로 설정합니다.array 를 반환합니다.
7.3.18 LengthOfArrayLike ( obj )
추상 연산 LengthOfArrayLike. 인수 obj (Object). 반환값: (정상 완료 (값: 음이 아닌 정수) 또는 throw 완료 ). 배열과 유사한 객체의 "length" 프로퍼티 값을 반환합니다. 호출되면 다음 단계를 수행한다.
ℝ (? ToLength (? Get (obj , "length" )))를 반환합니다.
배열과 유사한 객체 는 이 연산이 정상 완료 를 반환하는 모든 객체입니다.
참고 1
일반적으로 배열과 유사한 객체에는
정수 인덱스 이름을 갖는 프로퍼티도 일부 있을 수 있습니다. 그러나 이는 이 정의의 요구 사항은 아닙니다.
참고 2
Array와 String 객체는 배열과 유사한 객체의 예입니다.
7.3.19 CreateListFromArrayLike ( obj [ , validElementTypes ] )
추상 연산 CreateListFromArrayLike. 인수 obj (ECMAScript 언어 값 ) 및 선택적 인수 validElementTypes ((any 또는 property-key )). 반환값: ECMAScript 언어 값 의 List 를 포함하는 정상 완료 또는 예외 완료. obj 의 인덱스 속성에서 요소를 가져오는 List 값을 생성하는 데 사용됩니다. validElementTypes 는 요소로 허용되는 값의 유형을 나타냅니다. 호출되면 다음 단계를 수행한다.
validElementTypes 가 제공되지 않았으면 validElementTypes 를 any 로 설정합니다.obj 가 Object가 아니면 TypeError 예외를 던집니다.length 를 ? LengthOfArrayLike (obj )로 둡니다.list 를 새로운 빈 List 로 둡니다.index 를 0으로 둡니다.index < length 인 동안 다음 단계를 반복합니다,indexName 을 ! ToString (𝔽 (index ))으로 둡니다.next 를 ? Get (obj , indexName )로 둡니다.validElementTypes 가 property-key 이고 next 가 속성 키가 아니면 TypeError 예외를 던집니다.next 를 list 에 추가합니다.index 를 index + 1로 설정합니다.list 를 반환합니다.
7.3.20 Invoke ( value , propertyKey [ , argList ] )
추상 연산 Invoke. 인수 value (ECMAScript 언어 값 ) 및 propertyKey (프로퍼티 키 ) 및 선택적 인수 argList (리스트 (요소: ECMAScript 언어 값 )). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 throw 완료 ). ECMAScript 언어 값 의 메서드 프로퍼티를 호출하는 데 사용됩니다. value 는 프로퍼티 조회 지점이면서 호출의 this 값이기도 합니다. argList 는 메서드에 전달되는 인수 값의 목록입니다. argList 가 존재하지 않으면 새로운 빈 List 를 값으로 사용합니다. 호출되면 다음 단계를 수행한다.
argList 가 존재하지 않으면, argList 를 새로운 빈 List 로 설정합니다.func 를 ? GetV (value , propertyKey )로 둡니다.? Call (func , value , argList )를 반환합니다.
7.3.21 OrdinaryHasInstance ( ctor , instance )
추상 연산 OrdinaryHasInstance. 인수 ctor (ECMAScript 언어 값 ) 및 instance (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). instance 가 ctor 가 제공하는 인스턴스 객체 상속 경로에서 상속하는지를 결정하는 기본 알고리즘을 구현합니다. 호출되면 다음 단계를 수행한다.
IsCallable (ctor )이 false 이면, false 를 반환합니다.ctor 에 [[BoundTargetFunction]] 내부 슬롯이 있으면, 다음을 수행합니다.boundCtor 를 ctor .[[BoundTargetFunction]] 으로 둡니다.? InstanceofOperator (instance , boundCtor )를 반환합니다. instance 가 Object가 아니면, false 를 반환합니다.proto 를 ? Get (ctor , "prototype" )로 둡니다.proto 가 Object가 아니면, TypeError 예외를 던집니다.다음을 반복합니다.instance 를 ? instance .[[GetPrototypeOf]] () 로 설정합니다.instance 가 null 이면, false 를 반환합니다.SameValue (proto , instance )가 true 이면, true 를 반환합니다.
7.3.22 SpeciesConstructor ( obj , defaultCtor )
추상 연산 SpeciesConstructor. 인수 obj (Object) 및 defaultCtor (생성자 ). 반환값: (정상 완료 (값: 생성자 ) 또는 throw 완료 ). obj 에서 파생되는 새로운 객체를 생성하는 데 사용해야 하는 생성자 를 가져오는 데 사용됩니다. defaultCtor 는 obj 에서 시작하여 생성자 %Symbol.species% 프로퍼티를 찾을 수 없는 경우 사용할 생성자 입니다. 호출되면 다음 단계를 수행한다.
ctor 를 ? Get (obj , "constructor" )로 둡니다.ctor 가 undefined 이면, defaultCtor 를 반환합니다.ctor 가 Object가 아니면, TypeError 예외를 던집니다.species 를 ? Get (ctor , %Symbol.species% )로 둡니다.species 가 undefined 또는 null 이면, defaultCtor 를 반환합니다.IsConstructor (species )가 true 이면, species 를 반환합니다.TypeError 예외를 던집니다.
7.3.23 EnumerableOwnProperties ( obj , kind )
추상 연산 EnumerableOwnProperties. 인수 obj (Object) 및 kind ((key , value 또는 key+value )). 반환값: (정상 완료 (값: 리스트 (요소: ECMAScript 언어 값 )) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
ownKeys 를 ? obj .[[OwnPropertyKeys]] () 로 둡니다.results 를 새로운 빈 List 로 둡니다.ownKeys 의 각 요소 key 에 대해 다음을 수행합니다.key 가 String이면, 다음을 수행합니다.propertyDesc 를 ? obj .[[GetOwnProperty]] (key ) 로 둡니다.propertyDesc 가 undefined 가 아니고 propertyDesc .[[Enumerable]] 이 true 이면, 다음을 수행합니다.kind 가 key 이면, 다음을 수행합니다.key 를 results 에 추가합니다.그렇지 않으면,value 를 ? Get (obj , key )로 둡니다.kind 가 value 이면, 다음을 수행합니다.value 를 results 에 추가합니다.그렇지 않으면,단언 : kind 는 key+value 입니다.entry 를 CreateArrayFromList (« key , value »)로 둡니다.entry 를 results 에 추가합니다. results 를 반환합니다.
7.3.24 GetFunctionRealm ( func )
추상 연산 GetFunctionRealm. 인수 func (함수 객체 ). 반환값: (정상 완료 (값: Realm 레코드 ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
func 에 [[Realm]] 내부 슬롯이 있으면, 다음을 수행합니다.func .[[Realm]] 을 반환합니다.func 가 바인딩된 함수 특수 객체 이면, 다음을 수행합니다.boundTargetFunc 를 func .[[BoundTargetFunction]] 으로 둡니다.? GetFunctionRealm (boundTargetFunc )을 반환합니다. func 가 Proxy 특수 객체 이면, 다음을 수행합니다.? ValidateNonRevokedProxy (func )를 수행합니다. proxyTarget 을 func .[[ProxyTarget]] 으로 둡니다.단언 : proxyTarget 은 함수 객체 입니다.? GetFunctionRealm (proxyTarget )을 반환합니다. 현재 Realm Record 를 반환합니다.
참고
4 단계에는 func 가 [[Realm]] 내부 슬롯을 갖지 않는 비표준 함수 특수 객체 인 경우에만 도달합니다.
7.3.25 CopyDataProperties ( target , source , excludedItems )
추상 연산 CopyDataProperties. 인수 target (Object), source (ECMAScript 언어 값 ) 및 excludedItems (리스트 (요소: 프로퍼티 키 )). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
source 가 undefined 또는 null 이면, unused 를 반환합니다.from 을 ! ToObject (source )로 둡니다.keys 를 ? from .[[OwnPropertyKeys]] () 로 둡니다.keys 의 각 요소 nextKey 에 대해 다음을 수행합니다.excluded 를 false 로 둡니다.excludedItems 의 각 요소 element 에 대해 다음을 수행합니다.SameValue (element , nextKey )가 true 이면, 다음을 수행합니다.excluded 를 true 로 설정합니다.excluded 가 false 이면, 다음을 수행합니다.propertyDesc 를 ? from .[[GetOwnProperty]] (nextKey ) 로 둡니다.propertyDesc 가 undefined 가 아니고 propertyDesc .[[Enumerable]] 이 true 이면, 다음을 수행합니다.propertyValue 를 ? Get (from , nextKey )로 둡니다.! CreateDataPropertyOrThrow (target , nextKey , propertyValue )를 수행합니다. unused 를 반환합니다.
참고
여기에 전달되는 대상은 항상 새로 생성된 객체이며, 오류가 던져진 경우 직접 접근할 수 없습니다.
7.3.26 PrivateElementFind ( obj , privateName )
추상 연산 PrivateElementFind. 인수 obj (Object) 및 privateName (비공개 이름 ). 반환값: (PrivateElement 또는 empty ). 호출되면 다음 단계를 수행한다.
obj .[[PrivateElements]] 에 entry .[[Key]] 가 privateName 인 PrivateElement entry 가 포함되어 있으면, 다음을 수행합니다.entry 를 반환합니다.empty 를 반환합니다.
7.3.27 PrivateFieldAdd ( obj , privateName , value )
추상 연산 PrivateFieldAdd. 인수 obj (Object), privateName (비공개 이름 ) 및 value (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
호스트 가 웹 브라우저이면, 다음을 수행합니다.? HostEnsureCanAddPrivateElement (obj )를 수행합니다. entry 를 PrivateElementFind (obj , privateName )로 둡니다.entry 가 empty 가 아니면, TypeError 예외를 던집니다.PrivateElement { [[Key]] : privateName , [[Kind]] : field , [[Value]] : value }를 obj .[[PrivateElements]] 에 추가합니다.unused 를 반환합니다.
7.3.28 PrivateMethodOrAccessorAdd ( obj , method )
추상 연산 PrivateMethodOrAccessorAdd. 인수 obj (Object) 및 method (PrivateElement ). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
단언 : method .[[Kind]] 는 method 또는 accessor 입니다.호스트 가 웹 브라우저이면, 다음을 수행합니다.? HostEnsureCanAddPrivateElement (obj )를 수행합니다. entry 를 PrivateElementFind (obj , method .[[Key]] )로 둡니다.entry 가 empty 가 아니면, TypeError 예외를 던집니다.method 를 obj .[[PrivateElements]] 에 추가합니다.unused 를 반환합니다.
참고
비공개 메서드와 접근자의 값은 인스턴스 간에 공유됩니다. 이 연산은 메서드 또는 접근자의 새 복사본을 생성하지 않습니다.
7.3.29 HostEnsureCanAddPrivateElement ( obj )
호스트 정의 추상 연산 HostEnsureCanAddPrivateElement. 인수 obj (Object). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 호스트 환경 이 특정 호스트 정의 특수 객체 에 비공개 요소를 추가하는 것을 방지할 수 있도록 합니다.
HostEnsureCanAddPrivateElement의 구현은 다음 요구 사항을 준수해야 합니다:
HostEnsureCanAddPrivateElement의 기본 구현은 NormalCompletion (unused )을 반환하는 것입니다.
이 추상 연산 은 웹 브라우저인 ECMAScript 호스트 에서만 호출됩니다.
7.3.30 PrivateGet ( obj , privateName )
추상 연산 PrivateGet. 인수 obj (Object) 및 privateName (비공개 이름 ). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
entry 를 PrivateElementFind (obj , privateName )로 둡니다.entry 가 empty 이면, TypeError 예외를 던집니다.entry .[[Kind]] 가 field 또는 method 이면, 다음을 수행합니다.entry .[[Value]] 를 반환합니다.단언 : entry .[[Kind]] 는 accessor 입니다.entry .[[Getter]] 가 undefined 이면, TypeError 예외를 던집니다.getter 를 entry .[[Getter]] 로 둡니다.? Call (getter , obj )를 반환합니다.
7.3.31 PrivateSet ( obj , privateName , value )
추상 연산 PrivateSet. 인수 obj (Object), privateName (비공개 이름 ) 및 value (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
entry 를 PrivateElementFind (obj , privateName )로 둡니다.entry 가 empty 이면, TypeError 예외를 던집니다.entry .[[Kind]] 가 method 이면, TypeError 예외를 던집니다.entry .[[Kind]] 가 field 이면, 다음을 수행합니다.entry .[[Value]] 를 value 로 설정합니다.그렇지 않으면,단언 : entry .[[Kind]] 는 accessor 입니다.entry .[[Setter]] 가 undefined 이면, TypeError 예외를 던집니다.setter 를 entry .[[Setter]] 로 둡니다.? Call (setter , obj , « value »)를 수행합니다. unused 를 반환합니다.
7.3.32 DefineField ( receiver , fieldRecord )
추상 연산 DefineField. 인수 receiver (Object) 및 fieldRecord (ClassFieldDefinition 레코드 ). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
fieldName 을 fieldRecord .[[Name]] 으로 둡니다.initializer 를 fieldRecord .[[Initializer]] 로 둡니다.initializer 가 empty 가 아니면, 다음을 수행합니다.initValue 를 ? Call (initializer , receiver )로 둡니다.그렇지 않으면,initValue 를 undefined 로 둡니다. fieldName 이 Private Name 이면, 다음을 수행합니다.? PrivateFieldAdd (receiver , fieldName , initValue )를 수행합니다. 그렇지 않으면,단언 : fieldName 은 프로퍼티 키 입니다.? CreateDataPropertyOrThrow (receiver , fieldName , initValue )를 수행합니다. unused 를 반환합니다.
7.3.33 InitializeInstanceElements ( obj , ctor )
추상 연산 InitializeInstanceElements. 인수 obj (Object) 및 ctor ((ECMAScript 함수 객체 또는 내장 함수 객체)). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
methods 를 ctor .[[PrivateMethods]] 로 둡니다.methods 의 각 PrivateElement method 에 대해 다음을 수행합니다.? PrivateMethodOrAccessorAdd (obj , method )를 수행합니다. fields 를 ctor .[[Fields]] 로 둡니다.fields 의 각 요소 fieldRecord 에 대해 다음을 수행합니다.? DefineField (obj , fieldRecord )를 수행합니다. unused 를 반환합니다.
7.3.34 AddValueToKeyedGroup ( groups , key , value )
추상 연산 AddValueToKeyedGroup. 인수 groups (리스트 (요소: 레코드 (필드: [[Key]] (ECMAScript 언어 값 ), [[Elements]] (리스트 (요소: ECMAScript 언어 값 ))))), key (ECMAScript 언어 값 ) 및 value (ECMAScript 언어 값 ). 반환값: unused . 호출되면 다음 단계를 수행한다.
groups 의 각 Record { [[Key]] , [[Elements]] } group 에 대해 다음을 수행합니다.SameValue (group .[[Key]] , key )가 true 이면, 다음을 수행합니다.단언 : groups 의 정확히 하나의 요소만 이 기준을 만족합니다.value 를 group .[[Elements]] 에 추가합니다.unused 를 반환합니다.group 을 Record { [[Key]] : key , [[Elements]] : « value » }로 둡니다.group 을 groups 에 추가합니다.unused 를 반환합니다.
7.3.35 GroupBy ( items , callback , keyCoercion )
추상 연산 GroupBy. 인수 items (ECMAScript 언어 값 ), callback (ECMAScript 언어 값 ) 및 keyCoercion ((property 또는 collection )). 반환값: (정상 완료 (값: 리스트 (요소: 레코드 (필드: [[Key]] (ECMAScript 언어 값 ), [[Elements]] (리스트 (요소: ECMAScript 언어 값 ))))) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
? RequireObjectCoercible (items )를 수행합니다. IsCallable (callback )이 false 이면, TypeError 예외를 던집니다.groups 를 새로운 빈 List 로 둡니다.iteratorRecord 를 ? GetIterator (items , sync )로 둡니다.k 를 0으로 둡니다.다음을 반복합니다.k ≥ 253 - 1이면, 다음을 수행합니다.error 를 ThrowCompletion (새로 생성된 TypeError 객체)으로 둡니다.? IteratorClose (iteratorRecord , error )를 반환합니다. next 를 ? IteratorStepValue (iteratorRecord )로 둡니다.next 가 done 이면, 다음을 수행합니다.groups 를 반환합니다.value 를 next 로 둡니다.key 를 Completion (Call (callback , undefined , « value , 𝔽 (k ) »))으로 둡니다.IfAbruptCloseIterator (key , iteratorRecord ).keyCoercion 이 property 이면, 다음을 수행합니다.key 를 Completion (ToPropertyKey (key ))으로 설정합니다.IfAbruptCloseIterator (key , iteratorRecord ).그렇지 않으면,단언 : keyCoercion 은 collection 입니다.key 를 CanonicalizeKeyedCollectionKey (key )로 설정합니다. AddValueToKeyedGroup (groups , key , value )를 수행합니다.k 를 k + 1로 설정합니다.
7.3.36 GetOptionsObject ( options )
추상 연산 GetOptionsObject. 인수 options (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: Object) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
options 가 undefined 이면, 다음을 수행합니다.OrdinaryObjectCreate (null )을 반환합니다.options 가 Object이면, 다음을 수행합니다.options 를 반환합니다.TypeError 예외를 던집니다.
7.3.37 SetterThatIgnoresPrototypeProperties ( thisValue , home , propertyKey , value )
추상 연산 SetterThatIgnoresPrototypeProperties. 인수 thisValue (ECMAScript 언어 값 ), home (Object), propertyKey (프로퍼티 키 ) 및 value (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
thisValue 가 Object가 아니면, 다음을 수행합니다.TypeError 예외를 던집니다.SameValue (thisValue , home )가 true 이면, 다음을 수행합니다.참고 : 여기에서 예외를 던지는 것은 엄격 모드 코드 에서 home 객체의 쓰기 불가능한 데이터 프로퍼티 에 할당하는 동작을 모방합니다.TypeError 예외를 던집니다.propertyDesc 를 ? thisValue .[[GetOwnProperty]] (propertyKey )로 둡니다.propertyDesc 가 undefined 이면, 다음을 수행합니다.? CreateDataPropertyOrThrow (thisValue , propertyKey , value )를 수행합니다. 그렇지 않으면,? Set (thisValue , propertyKey , value , true )를 수행합니다. unused 를 반환합니다.
7.4 Iterator 객체에 대한 연산
공통 반복 인터페이스(27.1 )를 참조하시기 바랍니다.
7.4.1 Iterator Record
Iterator Record 는 이터레이터 또는 비동기 이터레이터와 next 메서드를 함께 캡슐화하는 데 사용하는 Record 입니다.
Iterator Record에는 표 13 에 나열된 필드가 있습니다.
표 13: Iterator Record 필드
필드 이름
값
의미
[[Iterator]]
Object
이터레이터 인터페이스 또는 비동기 이터레이터 인터페이스를 준수하는 객체입니다.
[[NextMethod]]
ECMAScript 언어 값
[[Iterator]] 객체의 next 메서드입니다.
[[Done]]
Boolean
이터레이터가 완료되었거나 닫혔는지를 나타냅니다.
7.4.2 GetIteratorDirect ( obj )
추상 연산 GetIteratorDirect. 인수 obj (Object). 반환값: Iterator Record 를 포함하는 정상 완료 또는 throw 완료 . 호출되면 다음 단계를 수행한다.
nextMethod 를 ? Get (obj , "next" )로 둡니다.iteratorRecord 를 Iterator Record { [[Iterator]] : obj , [[NextMethod]] : nextMethod , [[Done]] : false }로 둡니다.iteratorRecord 를 반환합니다.
7.4.3 GetIteratorFromMethod ( obj , method )
추상 연산 GetIteratorFromMethod. 인수 obj (ECMAScript 언어 값 ) 및 method (함수 객체 ). 반환값: Iterator Record 를 포함하는 정상 완료 또는 throw 완료 . 호출되면 다음 단계를 수행한다.
iterator 를 ? Call (method , obj )로 둡니다.iterator 가 Object가 아니면, TypeError 예외를 던집니다.? GetIteratorDirect (iterator )를 반환합니다.
7.4.4 GetIterator ( obj , kind )
추상 연산 GetIterator. 인수 obj (ECMAScript 언어 값 ) 및 kind (sync 또는 async ). 반환값: Iterator Record 를 포함하는 정상 완료 또는 throw 완료 . 호출되면 다음 단계를 수행한다.
kind 가 async 이면, 다음을 수행합니다.method 를 ? GetMethod (obj , %Symbol.asyncIterator% )로 둡니다.method 가 undefined 이면, 다음을 수행합니다.syncMethod 를 ? GetMethod (obj , %Symbol.iterator% )로 둡니다.syncMethod 가 undefined 이면, TypeError 예외를 던집니다.syncIteratorRecord 를 ? GetIteratorFromMethod (obj , syncMethod )로 둡니다.CreateAsyncFromSyncIterator (syncIteratorRecord )를 반환합니다.그렇지 않으면,method 를 ? GetMethod (obj , %Symbol.iterator% )로 둡니다. method 가 undefined 이면, TypeError 예외를 던집니다.? GetIteratorFromMethod (obj , method )를 반환합니다.
7.4.5 GetIteratorFlattenable ( obj , primitiveHandling )
추상 연산 GetIteratorFlattenable. 인수 obj (ECMAScript 언어 값 ) 및 primitiveHandling (iterate-string-primitives 또는 reject-primitives ). 반환값: Iterator Record 를 포함하는 정상 완료 또는 throw 완료 . 호출되면 다음 단계를 수행한다.
obj 가 Object가 아니면, 다음을 수행합니다.primitiveHandling 이 reject-primitives 이면, TypeError 예외를 던집니다.단언 : primitiveHandling 은 iterate-string-primitives 입니다.obj 가 String이 아니면, TypeError 예외를 던집니다.method 를 ? GetMethod (obj , %Symbol.iterator% )로 둡니다.method 가 undefined 이면, 다음을 수행합니다.iterator 를 obj 로 둡니다.그렇지 않으면,iterator 를 ? Call (method , obj )로 둡니다. iterator 가 Object가 아니면, TypeError 예외를 던집니다.? GetIteratorDirect (iterator )를 반환합니다.
7.4.6 IteratorNext ( iteratorRecord [ , value ] )
추상 연산 IteratorNext. 인수 iteratorRecord (Iterator 레코드 ) 및 선택적 인수 value (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: Object) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
value 가 존재하지 않으면, 다음을 수행합니다.result 를 Completion (Call (iteratorRecord .[[NextMethod]] , iteratorRecord .[[Iterator]] ))으로 둡니다.그렇지 않으면,result 를 Completion (Call (iteratorRecord .[[NextMethod]] , iteratorRecord .[[Iterator]] , « value »))으로 둡니다. result 가 throw 완료 이면, 다음을 수행합니다.iteratorRecord .[[Done]] 을 true 로 설정합니다.? result 를 반환합니다. result 를 ! result 로 설정합니다.result 가 Object가 아니면, 다음을 수행합니다.iteratorRecord .[[Done]] 을 true 로 설정합니다.TypeError 예외를 던집니다.result 를 반환합니다.
7.4.7 IteratorComplete ( iteratorResult )
추상 연산 IteratorComplete. 인수 iteratorResult (Object). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
ToBoolean (? Get (iteratorResult , "done" ))을 반환합니다.
7.4.8 IteratorValue ( iteratorResult )
추상 연산 IteratorValue. 인수 iteratorResult (Object). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
? Get (iteratorResult , "value" )를 반환합니다.
7.4.9 IteratorStep ( iteratorRecord )
추상 연산 IteratorStep. 인수 iteratorRecord (Iterator 레코드 ). 반환값: (정상 완료 (값: (Object 또는 done )) 또는 throw 완료 ). iteratorRecord .[[NextMethod]] 을 호출하여 iteratorRecord .[[Iterator]] 에서 다음 값을 요청하고, 이터레이터가 끝에 도달했음을 나타내는 done 또는 다음 값이 있으면 IteratorResult 객체를 반환합니다. 호출되면 다음 단계를 수행한다.
result 를 ? IteratorNext (iteratorRecord )로 둡니다.done 을 Completion (IteratorComplete (result ))으로 둡니다.done 이 throw 완료 이면, 다음을 수행합니다.iteratorRecord .[[Done]] 을 true 로 설정합니다.? done 을 반환합니다. done 을 ! done 으로 설정합니다.done 이 true 이면, 다음을 수행합니다.iteratorRecord .[[Done]] 을 true 로 설정합니다.done 을 반환합니다.result 를 반환합니다.
7.4.10 IteratorStepValue ( iteratorRecord )
추상 연산 IteratorStepValue. 인수 iteratorRecord (Iterator 레코드 ). 반환값: (정상 완료 (값: (ECMAScript 언어 값 또는 done )) 또는 throw 완료 ). iteratorRecord .[[NextMethod]] 을 호출하여 iteratorRecord .[[Iterator]] 에서 다음 값을 요청하고, 이터레이터가 끝에 도달했음을 나타내는 done 또는 다음 값이 있으면 IteratorResult 객체의 값을 반환합니다. 호출되면 다음 단계를 수행한다.
result 를 ? IteratorStep (iteratorRecord )로 둡니다.result 가 done 이면, 다음을 수행합니다.done 을 반환합니다.value 를 Completion (IteratorValue (result ))으로 둡니다.value 가 throw 완료 이면, 다음을 수행합니다.iteratorRecord .[[Done]] 을 true 로 설정합니다.? value 를 반환합니다.
7.4.11 IteratorClose ( iteratorRecord , completion )
추상 연산 IteratorClose. 인수 iteratorRecord (Iterator 레코드 ) 및 completion (완료 레코드 ). 반환값: 완료 레코드 . 이터레이터가 완료 상태에 도달했을 때 일반적으로 수행하는 동작을 수행해야 함을 해당 이터레이터에 알리는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
단언 : iteratorRecord .[[Iterator]] 는 Object입니다.iterator 를 iteratorRecord .[[Iterator]] 로 둡니다.innerResult 를 Completion (GetMethod (iterator , "return" ))으로 둡니다.innerResult 가 정상 완료 이면, 다음을 수행합니다.return 을 innerResult .[[Value]] 로 둡니다.return 이 undefined 이면, ? completion 을 반환합니다.innerResult 를 Completion (Call (return , iterator ))으로 설정합니다.completion 이 throw 완료 이면, ? completion 을 반환합니다.innerResult 가 throw 완료 이면, ? innerResult 를 반환합니다.innerResult .[[Value]] 가 Object가 아니면, TypeError 예외를 던집니다.? completion 을 반환합니다.
7.4.12 IteratorCloseAll ( iterators , completion )
추상 연산 IteratorCloseAll. 인수 iterators (리스트 (요소: Iterator 레코드 )) 및 completion (완료 레코드 ). 반환값: 완료 레코드 . 호출되면 다음 단계를 수행한다.
iterators 의 각 요소 iterator 에 대해 List 역순으로 다음을 수행합니다.completion 을 Completion (IteratorClose (iterator , completion ))으로 설정합니다.? completion 을 반환합니다.
7.4.13 IfAbruptCloseIterator ( value , iteratorRecord )
IfAbruptCloseIterator는 Iterator Record 를 사용하는 알고리즘 단계 시퀀스의 축약 표현입니다. 다음 형식의 알고리즘 단계:
IfAbruptCloseIterator (value , iteratorRecord ).
는 다음과 같은 의미입니다:
단언 : value 는 Completion Record 입니다.value 가 비정상 완료 이면, ? IteratorClose (iteratorRecord , value )를 반환합니다.value 를 ! value 로 설정합니다.
7.4.14 IfAbruptCloseIterators ( value , iteratorRecords )
IfAbruptCloseIterators는 Iterator Record 의 목록을 사용하는 알고리즘 단계 시퀀스의 축약 표현입니다. 다음 형식의 알고리즘 단계:
IfAbruptCloseIterators (value , iteratorRecords ).
는 다음과 같은 의미입니다:
단언 : value 는 Completion Record 입니다.value 가 비정상 완료 이면, ? IteratorCloseAll (iteratorRecords , value )을 반환합니다.value 를 ! value 로 설정합니다.
7.4.15 AsyncIteratorClose ( iteratorRecord , completion )
추상 연산 AsyncIteratorClose. 인수 iteratorRecord (Iterator 레코드 ) 및 completion (완료 레코드 ). 반환값: 완료 레코드 . 비동기 이터레이터가 완료 상태에 도달했을 때 일반적으로 수행하는 동작을 수행해야 함을 해당 이터레이터에 알리는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
단언 : iteratorRecord .[[Iterator]] 는 Object입니다.iterator 를 iteratorRecord .[[Iterator]] 로 둡니다.innerResult 를 Completion (GetMethod (iterator , "return" ))으로 둡니다.innerResult 가 정상 완료 이면, 다음을 수행합니다.return 을 innerResult .[[Value]] 로 둡니다.return 이 undefined 이면, ? completion 을 반환합니다.innerResult 를 Completion (Call (return , iterator ))으로 설정합니다.innerResult 가 정상 완료 이면, innerResult 를 Completion (Await (innerResult .[[Value]] ))으로 설정합니다.completion 이 throw 완료 이면, ? completion 을 반환합니다.innerResult 가 throw 완료 이면, ? innerResult 를 반환합니다.innerResult .[[Value]] 가 Object가 아니면, TypeError 예외를 던집니다.? completion 을 반환합니다.
7.4.16 IfAbruptCloseAsyncIterator ( value , iteratorRecord )
IfAbruptCloseAsyncIterator는 Iterator Record 를 사용하는 알고리즘 단계 시퀀스의 축약 표현입니다. 다음 형식의 알고리즘 단계:
IfAbruptCloseAsyncIterator (value , iteratorRecord ).
는 다음과 같은 의미입니다:
단언 : value 는 Completion Record 입니다.value 가 비정상 완료 이면, ? AsyncIteratorClose (iteratorRecord , value )를 반환합니다.value 를 ! value 로 설정합니다.
7.4.17 CreateIteratorResultObject ( value , done )
추상 연산 CreateIteratorResultObject. 인수 value (ECMAScript 언어 값 ) 및 done (Boolean). 반환값: an Object that conforms to the IteratorResult interface. IteratorResult 인터페이스 를 준수하는 객체를 생성합니다. 호출되면 다음 단계를 수행한다.
obj 를 OrdinaryObjectCreate (%Object.prototype% )로 둡니다.! CreateDataPropertyOrThrow (obj , "value" , value )를 수행합니다. ! CreateDataPropertyOrThrow (obj , "done" , done )을 수행합니다. obj 를 반환합니다.
7.4.18 CreateListIteratorRecord ( list )
추상 연산 CreateListIteratorRecord. 인수 list (리스트 (요소: ECMAScript 언어 값 )). 반환값: Iterator 레코드 . [[NextMethod]] 가 list 의 연속된 요소를 반환하는 Iterator Record 를 생성합니다. 호출되면 다음 단계를 수행한다.
closure 를 매개변수가 없고 list 를 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:list 의 각 요소 value 에 대해 다음을 수행합니다.? GeneratorYield (CreateIteratorResultObject (value , false ))를 수행합니다. NormalCompletion (undefined )을 반환합니다.iterator 를 CreateIteratorFromClosure (closure , empty , %Iterator.prototype% )로 둡니다.Iterator Record { [[Iterator]] : iterator , [[NextMethod]] : %GeneratorPrototype.next%, [[Done]] : false }를 반환합니다.
참고
목록 이터레이터 객체에는 ECMAScript 코드에서 직접 접근할 수 없습니다.
7.4.19 IteratorToList ( iteratorRecord )
추상 연산 IteratorToList. 인수 iteratorRecord (Iterator 레코드 ). 반환값: (정상 완료 (값: 리스트 (요소: ECMAScript 언어 값 )) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
values 를 새로운 빈 List 로 둡니다.다음을 반복합니다.next 를 ? IteratorStepValue (iteratorRecord )로 둡니다.next 가 done 이면, 다음을 수행합니다.values 를 반환합니다.next 를 values 에 추가합니다.
7.5 폐기 가능한 객체에 대한 연산
공통 리소스 관리 인터페이스(27.2.1 )를 참조하시기 바랍니다.
7.5.1 DisposableResource Record
DisposableResource Record 는 폐기 가능한 객체와 해당 객체를 폐기하는 데 사용하는 메서드를 함께 캡슐화하는 Record 값입니다. DisposableResource Record는 CreateDisposableResource 추상 연산 에 의해 생성됩니다.
DisposableResource Record에는 표 14 에 나열된 필드가 있습니다:
표 14: DisposableResource Record 필드
필드 이름
값
의미
[[ResourceValue]]
Object 또는 undefined
폐기할 값입니다.
[[Kind]]
sync-dispose 또는 async-dispose
리소스가 using 선언 또는 DisposableStack 객체(sync-dispose )에 의해 추가되었는지, 아니면 await using 선언 또는 AsyncDisposableStack 객체(async-dispose )에 의해 추가되었는지를 나타냅니다.
[[DisposeMethod]]
함수 객체 또는 undefined
리소스를 폐기할 때 [[ResourceValue]] 를 this 값으로 하여 호출될 함수 객체 입니다.
7.5.2 AddDisposableResource ( disposableResourceStack , value , kind [ , method ] )
추상 연산 AddDisposableResource. 인수 disposableResourceStack (리스트 (요소: DisposableResource 레코드 )), value (ECMAScript 언어 값 ) 및 kind ((sync-dispose 또는 async-dispose )) 및 선택적 인수 method (함수 객체 ). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
method 가 존재하면, 다음을 수행합니다.단언 : value 는 undefined 입니다.resource 를 ? CreateDisposableResource (undefined , kind , method )로 둡니다.그렇지 않으면,value 가 null 또는 undefined 이고 kind 가 sync-dispose 이면, unused 를 반환합니다.참고 : value 가 null 또는 undefined 이고 kind 가 async-dispose 이면, 나중에 리소스를 폐기할 때에도 Await 를 수행하도록 보장하기 위해 해당 리소스가 평가되었음을 기록합니다.resource 를 ? CreateDisposableResource (value , kind )로 둡니다. resource 를 disposableResourceStack 에 추가합니다.unused 를 반환합니다.
7.5.3 CreateDisposableResource ( value , kind [ , method ] )
추상 연산 CreateDisposableResource. 인수 value (ECMAScript 언어 값 ) 및 kind ((sync-dispose 또는 async-dispose )) 및 선택적 인수 method (함수 객체 ). 반환값: (정상 완료 (값: DisposableResource 레코드 ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
method 가 존재하지 않으면, 다음을 수행합니다.value 가 null 또는 undefined 이면, 다음을 수행합니다.value 를 undefined 로 설정합니다.method 를 undefined 로 설정합니다.그렇지 않으면,method 를 ? GetDisposeMethod (value , kind )로 설정합니다.method 가 undefined 이면, TypeError 예외를 던집니다. DisposableResource Record { [[ResourceValue]] : value , [[Kind]] : kind , [[DisposeMethod]] : method }를 반환합니다.
7.5.4 GetDisposeMethod ( value , kind )
추상 연산 GetDisposeMethod. 인수 value (ECMAScript 언어 값 ) 및 kind ((sync-dispose 또는 async-dispose )). 반환값: (정상 완료 (값: (함수 객체 또는 undefined )) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
value 가 Object가 아니면, TypeError 예외를 던집니다.kind 가 sync-dispose 이면, ? GetMethod (value , %Symbol.dispose% )를 반환합니다.단언 : kind 는 async-dispose 입니다.asyncMethod 를 ? GetMethod (value , %Symbol.asyncDispose% )로 둡니다.asyncMethod 가 undefined 가 아니면, asyncMethod 를 반환합니다.syncMethod 를 ? GetMethod (value , %Symbol.dispose% )로 둡니다.syncMethod 가 undefined 이면, undefined 를 반환합니다.closure 를 매개변수가 없고 syncMethod 를 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:obj 를 this 값으로 둡니다.promiseCapability 를 ! NewPromiseCapability (%Promise% )로 둡니다.result 를 Completion (Call (syncMethod , obj ))으로 둡니다.IfAbruptRejectPromise (result , promiseCapability ).! Call (promiseCapability .[[Resolve]] , undefined , « undefined »)를 수행합니다. promiseCapability .[[Promise]] 를 반환합니다.참고 : 이 함수는 사용자 코드에서 관찰할 수 없습니다. 동기 %Symbol.dispose% 메서드가 반환한 Promise를 기다리지 않도록 하고, 동기 예외를 거부된 Promise로 변환하기 위해 사용됩니다.CreateBuiltinFunction (closure , 0, "" , « »)을 반환합니다.
7.5.5 DisposeResources ( disposableResourceStack , completion )
추상 연산 DisposeResources. 인수 disposableResourceStack (리스트 (요소: DisposableResource 레코드 )) 및 completion ((정상 완료 (값: (ECMAScript 언어 값 또는 empty )) 또는 중도 완료)). 반환값: (정상 완료 (값: (ECMAScript 언어 값 또는 empty )) 또는 중도 완료). 호출되면 다음 단계를 수행한다.
needsAwait 를 false 로 둡니다.hasAwaited 를 false 로 둡니다.outputCompletion 을 completion 으로 둡니다.disposableResourceStack 의 각 요소 resource 에 대해 List 역순으로 다음을 수행합니다.value 를 resource .[[ResourceValue]] 로 둡니다.kind 를 resource .[[Kind]] 로 둡니다.method 를 resource .[[DisposeMethod]] 로 둡니다.kind 가 sync-dispose 이고, needsAwait 가 true 이며, hasAwaited 가 false 이면, 다음을 수행합니다.! Await (undefined )를 수행합니다. needsAwait 를 false 로 설정합니다.method 가 undefined 가 아니면, 다음을 수행합니다.result 를 Completion (Call (method , value ))으로 둡니다.result 가 정상 완료 이고 kind 가 async-dispose 이면, 다음을 수행합니다.result 를 Completion (Await (result .[[Value]] ))으로 설정합니다.hasAwaited 를 true 로 설정합니다.result 가 throw 완료 이면, 다음을 수행합니다.outputCompletion 이 throw 완료 이면, 다음을 수행합니다.result 를 result .[[Value]] 로 설정합니다.suppressed 를 outputCompletion .[[Value]] 로 둡니다.error 를 새로 생성된 SuppressedError 객체로 둡니다.CreateNonEnumerableDataPropertyOrThrow (error , "error" , result )를 수행합니다.CreateNonEnumerableDataPropertyOrThrow (error , "suppressed" , suppressed )를 수행합니다.outputCompletion 을 ThrowCompletion (error )으로 설정합니다.그렇지 않으면,outputCompletion 을 result 로 설정합니다. 그렇지 않으면,단언 : kind 는 async-dispose 입니다.needsAwait 를 true 로 설정합니다.참고 : 이는 await using 선언의 초기화 값이 null 또는 undefined 였던 경우만 나타낼 수 있습니다. needsAwait 가 true 이고 hasAwaited 가 false 이면, 다음을 수행합니다.! Await (undefined )를 수행합니다. 참고 : 이 시점 이후 disposableResourceStack 은 다시 사용되지 않습니다. 구현체에서는 가비지 컬렉션 등의 방법으로 disposableResourceStack 의 내용을 버릴 수 있습니다.? outputCompletion 을 반환합니다.
8 구문 지향 연산
이 절에 정의된 것 외에도 특수한 구문 지향 연산 이 이 명세 전반에 걸쳐 정의되어 있습니다.
8.1 Runtime Semantics: Evaluation
구문 지향 연산 Evaluation. 인수 없음. 반환값: 완료 레코드 .
참고
이 연산의 정의는 이 명세의 “ECMAScript 언어” 절 전반에 분산되어 있습니다. 각 정의는 관련 생성 규칙을 정의하는 부분 다음에 나타납니다.
8.2 스코프 분석
8.2.1 Static Semantics: BoundNames
구문 지향 연산 BoundNames. 인수 없음. 반환값: 리스트 (요소: String).
참고
"*default*" 는 다른 이름이 없는 모듈의 기본 내보내기에 대한 합성 이름으로 이 명세에서 사용됩니다. 해당 이름으로 모듈의 [[Environment]] 에 항목이 생성되어 대응하는 값을 보유하며, 모듈에 대해 ResolveExport ( exportName [ , resolveSet ] ) 를 호출하여 "default" 라는 이름의 내보내기를 해석하면 [[BindingName]] 이 "*default*" 인 ResolvedBinding Record 가 반환되고, 이는 다시 모듈의 [[Environment]] 에서 위에서 언급한 값으로 해석됩니다. 이는 익명 기본 내보내기를 다른 내보내기와 동일하게 해석할 수 있도록 명세를 쉽게 작성하기 위한 것일 뿐입니다. 이 "*default*" String은 ECMAScript 코드나 모듈 연결 알고리즘에서 절대로 접근할 수 없습니다.
다음 생성 규칙별로 정의된다.
BindingIdentifier : Identifier
유일한 요소가 Identifier 의 StringValue 인 List 를 반환합니다.
BindingIdentifier : yield
« "yield" »를 반환합니다.
BindingIdentifier : await
« "await" »를 반환합니다.
LexicalDeclaration :
LetOrConst
BindingList
;
BindingList 의 BoundNames 를 반환합니다.
UsingDeclaration :
using
BindingList
;
AwaitUsingDeclaration :
CoverAwaitExpressionAndAwaitUsingDeclarationHead
BindingList
;
BindingList 의 BoundNames 를 반환합니다.
BindingList :
BindingList
,
LexicalBinding
names1 을 BindingList 의 BoundNames 로 둡니다.names2 를 LexicalBinding 의 BoundNames 로 둡니다.names1 과 names2 의 목록 연결 을 반환합니다.
LexicalBinding :
BindingIdentifier
Initializer opt
BindingIdentifier 의 BoundNames 를 반환합니다.
LexicalBinding :
BindingPattern
Initializer
BindingPattern 의 BoundNames 를 반환합니다.
VariableDeclarationList :
VariableDeclarationList
,
VariableDeclaration
names1 을 VariableDeclarationList 의 BoundNames 로 둡니다.names2 를 VariableDeclaration 의 BoundNames 로 둡니다.names1 과 names2 의 목록 연결 을 반환합니다.
VariableDeclaration :
BindingIdentifier
Initializer opt
BindingIdentifier 의 BoundNames 를 반환합니다.
VariableDeclaration :
BindingPattern
Initializer
BindingPattern 의 BoundNames 를 반환합니다.
ObjectBindingPattern :
{
}
새로운 빈 List 를 반환합니다.
ObjectBindingPattern :
{
BindingPropertyList
,
BindingRestProperty
}
names1 을 BindingPropertyList 의 BoundNames 로 둡니다.names2 를 BindingRestProperty 의 BoundNames 로 둡니다.names1 과 names2 의 목록 연결 을 반환합니다.
ArrayBindingPattern :
[
Elision opt
]
새로운 빈 List 를 반환합니다.
ArrayBindingPattern :
[
Elision opt
BindingRestElement
]
BindingRestElement 의 BoundNames 를 반환합니다.
ArrayBindingPattern :
[
BindingElementList
,
Elision opt
]
BindingElementList 의 BoundNames 를 반환합니다.
ArrayBindingPattern :
[
BindingElementList
,
Elision opt
BindingRestElement
]
names1 을 BindingElementList 의 BoundNames 로 둡니다.names2 를 BindingRestElement 의 BoundNames 로 둡니다.names1 과 names2 의 목록 연결 을 반환합니다.
BindingPropertyList :
BindingPropertyList
,
BindingProperty
names1 을 BindingPropertyList 의 BoundNames 로 둡니다.names2 를 BindingProperty 의 BoundNames 로 둡니다.names1 과 names2 의 목록 연결 을 반환합니다.
BindingElementList :
BindingElementList
,
BindingElisionElement
names1 을 BindingElementList 의 BoundNames 로 둡니다.names2 를 BindingElisionElement 의 BoundNames 로 둡니다.names1 과 names2 의 목록 연결 을 반환합니다.
BindingElisionElement :
Elision opt
BindingElement
BindingElement 의 BoundNames 를 반환합니다.
BindingProperty :
PropertyName
:
BindingElement
BindingElement 의 BoundNames 를 반환합니다.
SingleNameBinding :
BindingIdentifier
Initializer opt
BindingIdentifier 의 BoundNames 를 반환합니다.
BindingElement :
BindingPattern
Initializer opt
BindingPattern 의 BoundNames 를 반환합니다.
ForDeclaration :
LetOrConst
ForBinding
ForBinding 의 BoundNames 를 반환합니다.
FunctionDeclaration :
function
BindingIdentifier
(
FormalParameters
)
{
FunctionBody
}
BindingIdentifier 의 BoundNames 를 반환합니다.
FunctionDeclaration :
function
(
FormalParameters
)
{
FunctionBody
}
« "*default*" »를 반환합니다.
FormalParameters : [empty]
새로운 빈 List 를 반환합니다.
FormalParameters :
FormalParameterList
,
FunctionRestParameter
names1 을 FormalParameterList 의 BoundNames 로 둡니다.names2 를 FunctionRestParameter 의 BoundNames 로 둡니다.names1 과 names2 의 목록 연결 을 반환합니다.
FormalParameterList :
FormalParameterList
,
FormalParameter
names1 을 FormalParameterList 의 BoundNames 로 둡니다.names2 를 FormalParameter 의 BoundNames 로 둡니다.names1 과 names2 의 목록 연결 을 반환합니다.
ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList
formals 를 CoverParenthesizedExpressionAndArrowParameterList 가 포괄하는 ArrowFormalParameters 로 둡니다.formals 의 BoundNames 를 반환합니다.
GeneratorDeclaration :
function
*
BindingIdentifier
(
FormalParameters
)
{
GeneratorBody
}
BindingIdentifier 의 BoundNames 를 반환합니다.
GeneratorDeclaration :
function
*
(
FormalParameters
)
{
GeneratorBody
}
« "*default*" »를 반환합니다.
AsyncGeneratorDeclaration :
async
function
*
BindingIdentifier
(
FormalParameters
)
{
AsyncGeneratorBody
}
BindingIdentifier 의 BoundNames 를 반환합니다.
AsyncGeneratorDeclaration :
async
function
*
(
FormalParameters
)
{
AsyncGeneratorBody
}
« "*default*" »를 반환합니다.
ClassDeclaration :
class
BindingIdentifier
ClassTail
BindingIdentifier 의 BoundNames 를 반환합니다.
ClassDeclaration :
class
ClassTail
« "*default*" »를 반환합니다.
AsyncFunctionDeclaration :
async
function
BindingIdentifier
(
FormalParameters
)
{
AsyncFunctionBody
}
BindingIdentifier 의 BoundNames 를 반환합니다.
AsyncFunctionDeclaration :
async
function
(
FormalParameters
)
{
AsyncFunctionBody
}
« "*default*" »를 반환합니다.
CoverCallExpressionAndAsyncArrowHead :
MemberExpression
Arguments
head 를 CoverCallExpressionAndAsyncArrowHead 가 포괄하는 AsyncArrowHead 로 둡니다.head 의 BoundNames 를 반환합니다.
ImportDeclaration :
import
ImportClause
FromClause
WithClause opt
;
ImportClause 의 BoundNames 를 반환합니다.
ImportDeclaration :
import
ModuleSpecifier
WithClause opt
;
새로운 빈 List 를 반환합니다.
ImportClause :
ImportedDefaultBinding
,
NameSpaceImport
names1 을 ImportedDefaultBinding 의 BoundNames 로 둡니다.names2 를 NameSpaceImport 의 BoundNames 로 둡니다.names1 과 names2 의 목록 연결 을 반환합니다.
ImportClause :
ImportedDefaultBinding
,
NamedImports
names1 을 ImportedDefaultBinding 의 BoundNames 로 둡니다.names2 를 NamedImports 의 BoundNames 로 둡니다.names1 과 names2 의 목록 연결 을 반환합니다.
NamedImports :
{
}
새로운 빈 List 를 반환합니다.
ImportsList :
ImportsList
,
ImportSpecifier
names1 을 ImportsList 의 BoundNames 로 둡니다.names2 를 ImportSpecifier 의 BoundNames 로 둡니다.names1 과 names2 의 목록 연결 을 반환합니다.
ImportSpecifier :
ModuleExportName
as
ImportedBinding
ImportedBinding 의 BoundNames 를 반환합니다.
ExportDeclaration :
export
ExportFromClause
FromClause
WithClause opt
;
export
NamedExports
;
새로운 빈 List 를 반환합니다.
ExportDeclaration :
export
VariableStatement
VariableStatement 의 BoundNames 를 반환합니다.
ExportDeclaration :
export
Declaration
Declaration 의 BoundNames 를 반환합니다.
ExportDeclaration :
export
default
HoistableDeclaration
declNames 를 HoistableDeclaration 의 BoundNames 로 둡니다.declNames 에 "*default*" 요소가 포함되어 있지 않으면, "*default*" 를 declNames 에 추가합니다.declNames 를 반환합니다.
ExportDeclaration :
export
default
ClassDeclaration
declNames 를 ClassDeclaration 의 BoundNames 로 둡니다.declNames 에 "*default*" 요소가 포함되어 있지 않으면, "*default*" 를 declNames 에 추가합니다.declNames 를 반환합니다.
ExportDeclaration :
export
default
AssignmentExpression
;
« "*default*" »를 반환합니다.
8.2.2 Static Semantics: DeclarationPart
구문 지향 연산 DeclarationPart. 인수 없음. 반환값: 구문 분석 노드. 다음 생성 규칙별로 정의된다.
HoistableDeclaration : FunctionDeclaration
FunctionDeclaration 을 반환합니다.
HoistableDeclaration : GeneratorDeclaration
GeneratorDeclaration 을 반환합니다.
HoistableDeclaration : AsyncFunctionDeclaration
AsyncFunctionDeclaration 을 반환합니다.
HoistableDeclaration : AsyncGeneratorDeclaration
AsyncGeneratorDeclaration 을 반환합니다.
Declaration : ClassDeclaration
ClassDeclaration 을 반환합니다.
Declaration : LexicalDeclaration
LexicalDeclaration 을 반환합니다.
8.2.3 Static Semantics: IsConstantDeclaration
구문 지향 연산 IsConstantDeclaration. 인수 없음. 반환값: Boolean. 다음 생성 규칙별로 정의된다.
LexicalDeclaration :
LetOrConst
BindingList
;
LetOrConst 의 IsConstantDeclaration 을 반환합니다.
LetOrConst : let
false 를 반환합니다.
LetOrConst : const
true 를 반환합니다.
UsingDeclaration :
using
BindingList
;
AwaitUsingDeclaration :
CoverAwaitExpressionAndAwaitUsingDeclarationHead
BindingList
;
true 를 반환합니다.
FunctionDeclaration :
function
BindingIdentifier
(
FormalParameters
)
{
FunctionBody
}
function
(
FormalParameters
)
{
FunctionBody
}
GeneratorDeclaration :
function
*
BindingIdentifier
(
FormalParameters
)
{
GeneratorBody
}
function
*
(
FormalParameters
)
{
GeneratorBody
}
AsyncGeneratorDeclaration :
async
function
*
BindingIdentifier
(
FormalParameters
)
{
AsyncGeneratorBody
}
async
function
*
(
FormalParameters
)
{
AsyncGeneratorBody
}
AsyncFunctionDeclaration :
async
function
BindingIdentifier
(
FormalParameters
)
{
AsyncFunctionBody
}
async
function
(
FormalParameters
)
{
AsyncFunctionBody
}
false 를 반환합니다.
ClassDeclaration :
class
BindingIdentifier
ClassTail
class
ClassTail
false 를 반환합니다.
ExportDeclaration :
export
ExportFromClause
FromClause
;
export
NamedExports
;
export
default
AssignmentExpression
;
false 를 반환합니다.
참고
모듈의 기본 객체를 참조하는 데 사용하는 내부 바인딩 이름에 할당할 수 있는 구문이 없으므로 export default AssignmentExpression 을 상수 선언으로 취급할 필요는 없습니다.
8.2.4 Static Semantics: IsUsingDeclaration
구문 지향 연산 IsUsingDeclaration. 인수 없음. 반환값: Boolean. 다음 생성 규칙별로 정의된다.
LexicalDeclaration :
LetOrConst
BindingList
;
false 를 반환합니다.
UsingDeclaration :
using
BindingList
;
true 를 반환합니다.
AwaitUsingDeclaration :
CoverAwaitExpressionAndAwaitUsingDeclarationHead
BindingList
;
false 를 반환합니다.
ForDeclaration :
LetOrConst
ForBinding
false 를 반환합니다.
ForDeclaration :
using
ForBinding
true 를 반환합니다.
ForDeclaration :
await
using
ForBinding
false 를 반환합니다.
FunctionDeclaration :
function
BindingIdentifier
(
FormalParameters
)
{
FunctionBody
}
function
(
FormalParameters
)
{
FunctionBody
}
GeneratorDeclaration :
function
*
BindingIdentifier
(
FormalParameters
)
{
GeneratorBody
}
function
*
(
FormalParameters
)
{
GeneratorBody
}
AsyncGeneratorDeclaration :
async
function
*
BindingIdentifier
(
FormalParameters
)
{
AsyncGeneratorBody
}
async
function
*
(
FormalParameters
)
{
AsyncGeneratorBody
}
AsyncFunctionDeclaration :
async
function
BindingIdentifier
(
FormalParameters
)
{
AsyncFunctionBody
}
async
function
(
FormalParameters
)
{
AsyncFunctionBody
}
false 를 반환합니다.
ClassDeclaration :
class
BindingIdentifier
ClassTail
class
ClassTail
false 를 반환합니다.
8.2.5 Static Semantics: IsAwaitUsingDeclaration
구문 지향 연산 IsAwaitUsingDeclaration. 인수 없음. 반환값: Boolean. 다음 생성 규칙별로 정의된다.
LexicalDeclaration :
LetOrConst
BindingList
;
false 를 반환합니다.
UsingDeclaration :
using
BindingList
;
false 를 반환합니다.
AwaitUsingDeclaration :
CoverAwaitExpressionAndAwaitUsingDeclarationHead
BindingList
;
true 를 반환합니다.
ForDeclaration :
LetOrConst
ForBinding
false 를 반환합니다.
ForDeclaration :
using
ForBinding
false 를 반환합니다.
ForDeclaration :
await
using
ForBinding
true 를 반환합니다.
FunctionDeclaration :
function
BindingIdentifier
(
FormalParameters
)
{
FunctionBody
}
function
(
FormalParameters
)
{
FunctionBody
}
GeneratorDeclaration :
function
*
BindingIdentifier
(
FormalParameters
)
{
GeneratorBody
}
function
*
(
FormalParameters
)
{
GeneratorBody
}
AsyncGeneratorDeclaration :
async
function
*
BindingIdentifier
(
FormalParameters
)
{
AsyncGeneratorBody
}
async
function
*
(
FormalParameters
)
{
AsyncGeneratorBody
}
AsyncFunctionDeclaration :
async
function
BindingIdentifier
(
FormalParameters
)
{
AsyncFunctionBody
}
async
function
(
FormalParameters
)
{
AsyncFunctionBody
}
false 를 반환합니다.
ClassDeclaration :
class
BindingIdentifier
ClassTail
class
ClassTail
false 를 반환합니다.
8.2.6 Static Semantics: LexicallyDeclaredNames
구문 지향 연산 LexicallyDeclaredNames. 인수 없음. 반환값: 리스트 (요소: String). 다음 생성 규칙별로 정의된다.
Block :
{
}
새로운 빈 List 를 반환합니다.
StatementList :
StatementList
StatementListItem
names1 을 StatementList 의 LexicallyDeclaredNames 로 둡니다.names2 를 StatementListItem 의 LexicallyDeclaredNames 로 둡니다.names1 과 names2 의 목록 연결 을 반환합니다.
StatementListItem : Statement
Statement 가
Statement : LabelledStatement
이면, LabelledStatement 의 LexicallyDeclaredNames 를 반환합니다.새로운 빈 List 를 반환합니다.
StatementListItem : Declaration
Declaration 의 BoundNames 를 반환합니다.
CaseBlock :
{
}
새로운 빈 List 를 반환합니다.
CaseBlock :
{
CaseClauses opt
DefaultClause
CaseClauses opt
}
첫 번째 CaseClauses 가 존재하면, names1 을 첫 번째 CaseClauses 의 LexicallyDeclaredNames 로 둡니다. 그렇지 않으면 names1 을 새로운 빈 List 로 둡니다. names2 를 DefaultClause 의 LexicallyDeclaredNames 로 둡니다.두 번째 CaseClauses 가 존재하면, names3 을 두 번째 CaseClauses 의 LexicallyDeclaredNames 로 둡니다. 그렇지 않으면 names3 을 새로운 빈 List 로 둡니다. names1 , names2 및 names3 의 목록 연결 을 반환합니다.
CaseClauses :
CaseClauses
CaseClause
names1 을 CaseClauses 의 LexicallyDeclaredNames 로 둡니다.names2 를 CaseClause 의 LexicallyDeclaredNames 로 둡니다.names1 과 names2 의 목록 연결 을 반환합니다.
CaseClause :
case
Expression
:
StatementList opt
StatementList 가 존재하면, StatementList 의 LexicallyDeclaredNames 를 반환합니다.새로운 빈 List 를 반환합니다.
DefaultClause :
default
:
StatementList opt
StatementList 가 존재하면, StatementList 의 LexicallyDeclaredNames 를 반환합니다.새로운 빈 List 를 반환합니다.
LabelledStatement :
LabelIdentifier
:
LabelledItem
LabelledItem 의 LexicallyDeclaredNames 를 반환합니다.
LabelledItem : Statement
새로운 빈 List 를 반환합니다.
LabelledItem : FunctionDeclaration
FunctionDeclaration 의 BoundNames 를 반환합니다.
FunctionStatementList : [empty]
새로운 빈 List 를 반환합니다.
FunctionStatementList : StatementList
StatementList 의 TopLevelLexicallyDeclaredNames 를 반환합니다.
ClassStaticBlockStatementList : [empty]
새로운 빈 List 를 반환합니다.
ClassStaticBlockStatementList : StatementList
StatementList 의 TopLevelLexicallyDeclaredNames 를 반환합니다.
ConciseBody : ExpressionBody
새로운 빈 List 를 반환합니다.
AsyncConciseBody : ExpressionBody
새로운 빈 List 를 반환합니다.
Script : [empty]
새로운 빈 List 를 반환합니다.
ScriptBody : StatementList
StatementList 의 TopLevelLexicallyDeclaredNames 를 반환합니다.
참고 1
Script 의 최상위 수준에서 함수 선언은 렉시컬 선언이 아니라 var 선언처럼 취급됩니다.
참고 2
Module 의 LexicallyDeclaredNames에는 가져온 모든 바인딩의 이름이 포함됩니다.
ModuleItemList :
ModuleItemList
ModuleItem
names1 을 ModuleItemList 의 LexicallyDeclaredNames 로 둡니다.names2 를 ModuleItem 의 LexicallyDeclaredNames 로 둡니다.names1 과 names2 의 목록 연결 을 반환합니다.
ModuleItem : ImportDeclaration
ImportDeclaration 의 BoundNames 를 반환합니다.
ModuleItem : ExportDeclaration
ExportDeclaration 이 export VariableStatement 이면, 새로운 빈 List 를 반환합니다.ExportDeclaration 의 BoundNames 를 반환합니다.
ModuleItem : StatementListItem
StatementListItem 의 LexicallyDeclaredNames 를 반환합니다.
참고 3
Module 의 최상위 수준에서 함수 선언은 var 선언이 아니라 렉시컬 선언처럼 취급됩니다.
8.2.7 Static Semantics: LexicallyScopedDeclarations
구문 지향 연산 LexicallyScopedDeclarations. 인수 없음. 반환값: 리스트 (요소: 구문 분석 노드 ). 다음 생성 규칙별로 정의된다.
StatementList :
StatementList
StatementListItem
decls1 을 StatementList 의 LexicallyScopedDeclarations 로 둡니다.decls2 를 StatementListItem 의 LexicallyScopedDeclarations 로 둡니다.decls1 과 decls2 의 목록 연결 을 반환합니다.
StatementListItem : Statement
Statement 가
Statement : LabelledStatement
이면, LabelledStatement 의 LexicallyScopedDeclarations 를 반환합니다.새로운 빈 List 를 반환합니다.
StatementListItem : Declaration
유일한 요소가 Declaration 의 DeclarationPart 인 List 를 반환합니다.
CaseBlock :
{
}
새로운 빈 List 를 반환합니다.
CaseBlock :
{
CaseClauses opt
DefaultClause
CaseClauses opt
}
첫 번째 CaseClauses 가 존재하면, decls1 을 첫 번째 CaseClauses 의 LexicallyScopedDeclarations 로 둡니다. 그렇지 않으면 decls1 을 새로운 빈 List 로 둡니다. decls2 를 DefaultClause 의 LexicallyScopedDeclarations 로 둡니다.두 번째 CaseClauses 가 존재하면, decls3 을 두 번째 CaseClauses 의 LexicallyScopedDeclarations 로 둡니다. 그렇지 않으면 decls3 을 새로운 빈 List 로 둡니다. decls1 , decls2 및 decls3 의 목록 연결 을 반환합니다.
CaseClauses :
CaseClauses
CaseClause
decls1 을 CaseClauses 의 LexicallyScopedDeclarations 로 둡니다.decls2 를 CaseClause 의 LexicallyScopedDeclarations 로 둡니다.decls1 과 decls2 의 목록 연결 을 반환합니다.
CaseClause :
case
Expression
:
StatementList opt
StatementList 가 존재하면, StatementList 의 LexicallyScopedDeclarations 를 반환합니다.새로운 빈 List 를 반환합니다.
DefaultClause :
default
:
StatementList opt
StatementList 가 존재하면, StatementList 의 LexicallyScopedDeclarations 를 반환합니다.새로운 빈 List 를 반환합니다.
LabelledStatement :
LabelIdentifier
:
LabelledItem
LabelledItem 의 LexicallyScopedDeclarations 를 반환합니다.
LabelledItem : Statement
새로운 빈 List 를 반환합니다.
LabelledItem : FunctionDeclaration
« FunctionDeclaration »을 반환합니다.
FunctionStatementList : [empty]
새로운 빈 List 를 반환합니다.
FunctionStatementList : StatementList
StatementList 의 TopLevelLexicallyScopedDeclarations 를 반환합니다.
ClassStaticBlockStatementList : [empty]
새로운 빈 List 를 반환합니다.
ClassStaticBlockStatementList : StatementList
StatementList 의 TopLevelLexicallyScopedDeclarations 를 반환합니다.
ConciseBody : ExpressionBody
새로운 빈 List 를 반환합니다.
AsyncConciseBody : ExpressionBody
새로운 빈 List 를 반환합니다.
Script : [empty]
새로운 빈 List 를 반환합니다.
ScriptBody : StatementList
StatementList 의 TopLevelLexicallyScopedDeclarations 를 반환합니다.
Module : [empty]
새로운 빈 List 를 반환합니다.
ModuleItemList :
ModuleItemList
ModuleItem
decls1 을 ModuleItemList 의 LexicallyScopedDeclarations 로 둡니다.decls2 를 ModuleItem 의 LexicallyScopedDeclarations 로 둡니다.decls1 과 decls2 의 목록 연결 을 반환합니다.
ModuleItem : ImportDeclaration
새로운 빈 List 를 반환합니다.
ExportDeclaration :
export
ExportFromClause
FromClause
WithClause opt
;
export
NamedExports
;
export
VariableStatement
새로운 빈 List 를 반환합니다.
ExportDeclaration :
export
Declaration
유일한 요소가 Declaration 의 DeclarationPart 인 List 를 반환합니다.
ExportDeclaration :
export
default
HoistableDeclaration
유일한 요소가 HoistableDeclaration 의 DeclarationPart 인 List 를 반환합니다.
ExportDeclaration :
export
default
ClassDeclaration
유일한 요소가 ClassDeclaration 인 List 를 반환합니다.
ExportDeclaration :
export
default
AssignmentExpression
;
유일한 요소가 이 ExportDeclaration 인 List 를 반환합니다.
8.2.8 Static Semantics: VarDeclaredNames
구문 지향 연산 VarDeclaredNames. 인수 없음. 반환값: 리스트 (요소: String). 다음 생성 규칙별로 정의된다.
Statement :
EmptyStatement
ExpressionStatement
ContinueStatement
BreakStatement
ReturnStatement
ThrowStatement
DebuggerStatement
새로운 빈 List 를 반환합니다.
Block :
{
}
새로운 빈 List 를 반환합니다.
StatementList :
StatementList
StatementListItem
names1 을 StatementList 의 VarDeclaredNames 로 둡니다.names2 를 StatementListItem 의 VarDeclaredNames 로 둡니다.names1 과 names2 의 목록 연결 을 반환합니다.
StatementListItem : Declaration
새로운 빈 List 를 반환합니다.
VariableStatement :
var
VariableDeclarationList
;
VariableDeclarationList 의 BoundNames 를 반환합니다.
IfStatement :
if
(
Expression
)
Statement
else
Statement
names1 을 첫 번째 Statement 의 VarDeclaredNames 로 둡니다.names2 를 두 번째 Statement 의 VarDeclaredNames 로 둡니다.names1 과 names2 의 목록 연결 을 반환합니다.
IfStatement :
if
(
Expression
)
Statement
Statement 의 VarDeclaredNames 를 반환합니다.
DoWhileStatement :
do
Statement
while
(
Expression
)
;
Statement 의 VarDeclaredNames 를 반환합니다.
WhileStatement :
while
(
Expression
)
Statement
Statement 의 VarDeclaredNames 를 반환합니다.
ForStatement :
for
(
Expression opt
;
Expression opt
;
Expression opt
)
Statement
Statement 의 VarDeclaredNames 를 반환합니다.
ForStatement :
for
(
var
VariableDeclarationList
;
Expression opt
;
Expression opt
)
Statement
names1 을 VariableDeclarationList 의 BoundNames 로 둡니다.names2 를 Statement 의 VarDeclaredNames 로 둡니다.names1 과 names2 의 목록 연결 을 반환합니다.
ForStatement :
for
(
LexicalDeclaration
Expression opt
;
Expression opt
)
Statement
Statement 의 VarDeclaredNames 를 반환합니다.
ForInOfStatement :
for
(
LeftHandSideExpression
in
Expression
)
Statement
for
(
ForDeclaration
in
Expression
)
Statement
for
(
LeftHandSideExpression
of
AssignmentExpression
)
Statement
for
(
ForDeclaration
of
AssignmentExpression
)
Statement
for
await
(
LeftHandSideExpression
of
AssignmentExpression
)
Statement
for
await
(
ForDeclaration
of
AssignmentExpression
)
Statement
Statement 의 VarDeclaredNames 를 반환합니다.
ForInOfStatement :
for
(
var
ForBinding
in
Expression
)
Statement
for
(
var
ForBinding
of
AssignmentExpression
)
Statement
for
await
(
var
ForBinding
of
AssignmentExpression
)
Statement
names1 을 ForBinding 의 BoundNames 로 둡니다.names2 를 Statement 의 VarDeclaredNames 로 둡니다.names1 과 names2 의 목록 연결 을 반환합니다.
참고
이 절은 부속서 B.3.5 에 의해 확장됩니다.
WithStatement :
with
(
Expression
)
Statement
Statement 의 VarDeclaredNames 를 반환합니다.
SwitchStatement :
switch
(
Expression
)
CaseBlock
CaseBlock 의 VarDeclaredNames 를 반환합니다.
CaseBlock :
{
}
새로운 빈 List 를 반환합니다.
CaseBlock :
{
CaseClauses opt
DefaultClause
CaseClauses opt
}
첫 번째 CaseClauses 가 존재하면, names1 을 첫 번째 CaseClauses 의 VarDeclaredNames 로 둡니다. 그렇지 않으면 names1 을 새로운 빈 List 로 둡니다. names2 를 DefaultClause 의 VarDeclaredNames 로 둡니다.두 번째 CaseClauses 가 존재하면, names3 을 두 번째 CaseClauses 의 VarDeclaredNames 로 둡니다. 그렇지 않으면 names3 을 새로운 빈 List 로 둡니다. names1 , names2 및 names3 의 목록 연결 을 반환합니다.
CaseClauses :
CaseClauses
CaseClause
names1 을 CaseClauses 의 VarDeclaredNames 로 둡니다.names2 를 CaseClause 의 VarDeclaredNames 로 둡니다.names1 과 names2 의 목록 연결 을 반환합니다.
CaseClause :
case
Expression
:
StatementList opt
StatementList 가 존재하면, StatementList 의 VarDeclaredNames 를 반환합니다.새로운 빈 List 를 반환합니다.
DefaultClause :
default
:
StatementList opt
StatementList 가 존재하면, StatementList 의 VarDeclaredNames 를 반환합니다.새로운 빈 List 를 반환합니다.
LabelledStatement :
LabelIdentifier
:
LabelledItem
LabelledItem 의 VarDeclaredNames 를 반환합니다.
LabelledItem : FunctionDeclaration
새로운 빈 List 를 반환합니다.
TryStatement :
try
Block
Catch
names1 을 Block 의 VarDeclaredNames 로 둡니다.names2 를 Catch 의 VarDeclaredNames 로 둡니다.names1 과 names2 의 목록 연결 을 반환합니다.
TryStatement :
try
Block
Finally
names1 을 Block 의 VarDeclaredNames 로 둡니다.names2 를 Finally 의 VarDeclaredNames 로 둡니다.names1 과 names2 의 목록 연결 을 반환합니다.
TryStatement :
try
Block
Catch
Finally
names1 을 Block 의 VarDeclaredNames 로 둡니다.names2 를 Catch 의 VarDeclaredNames 로 둡니다.names3 을 Finally 의 VarDeclaredNames 로 둡니다.names1 , names2 및 names3 의 목록 연결 을 반환합니다.
Catch :
catch
(
CatchParameter
)
Block
Block 의 VarDeclaredNames 를 반환합니다.
FunctionStatementList : [empty]
새로운 빈 List 를 반환합니다.
FunctionStatementList : StatementList
StatementList 의 TopLevelVarDeclaredNames 를 반환합니다.
ClassStaticBlockStatementList : [empty]
새로운 빈 List 를 반환합니다.
ClassStaticBlockStatementList : StatementList
StatementList 의 TopLevelVarDeclaredNames 를 반환합니다.
ConciseBody : ExpressionBody
새로운 빈 List 를 반환합니다.
AsyncConciseBody : ExpressionBody
새로운 빈 List 를 반환합니다.
Script : [empty]
새로운 빈 List 를 반환합니다.
ScriptBody : StatementList
StatementList 의 TopLevelVarDeclaredNames 를 반환합니다.
ModuleItemList :
ModuleItemList
ModuleItem
names1 을 ModuleItemList 의 VarDeclaredNames 로 둡니다.names2 를 ModuleItem 의 VarDeclaredNames 로 둡니다.names1 과 names2 의 목록 연결 을 반환합니다.
ModuleItem : ImportDeclaration
새로운 빈 List 를 반환합니다.
ModuleItem : ExportDeclaration
ExportDeclaration 이 export VariableStatement 이면, ExportDeclaration 의 BoundNames 를 반환합니다.새로운 빈 List 를 반환합니다.
8.2.9 Static Semantics: VarScopedDeclarations
구문 지향 연산 VarScopedDeclarations. 인수 없음. 반환값: 리스트 (요소: 구문 분석 노드 ). 다음 생성 규칙별로 정의된다.
Statement :
EmptyStatement
ExpressionStatement
ContinueStatement
BreakStatement
ReturnStatement
ThrowStatement
DebuggerStatement
새로운 빈 List 를 반환합니다.
Block :
{
}
새로운 빈 List 를 반환합니다.
StatementList :
StatementList
StatementListItem
decls1 을 StatementList 의 VarScopedDeclarations 로 둡니다.decls2 를 StatementListItem 의 VarScopedDeclarations 로 둡니다.decls1 과 decls2 의 목록 연결 을 반환합니다.
StatementListItem : Declaration
새로운 빈 List 를 반환합니다.
VariableDeclarationList : VariableDeclaration
« VariableDeclaration »을 반환합니다.
VariableDeclarationList :
VariableDeclarationList
,
VariableDeclaration
decls1 을 VariableDeclarationList 의 VarScopedDeclarations 로 둡니다.decls1 과 « VariableDeclaration »의 목록 연결 을 반환합니다.
IfStatement :
if
(
Expression
)
Statement
else
Statement
decls1 을 첫 번째 Statement 의 VarScopedDeclarations 로 둡니다.decls2 를 두 번째 Statement 의 VarScopedDeclarations 로 둡니다.decls1 과 decls2 의 목록 연결 을 반환합니다.
IfStatement :
if
(
Expression
)
Statement
Statement 의 VarScopedDeclarations 를 반환합니다.
DoWhileStatement :
do
Statement
while
(
Expression
)
;
Statement 의 VarScopedDeclarations 를 반환합니다.
WhileStatement :
while
(
Expression
)
Statement
Statement 의 VarScopedDeclarations 를 반환합니다.
ForStatement :
for
(
Expression opt
;
Expression opt
;
Expression opt
)
Statement
Statement 의 VarScopedDeclarations 를 반환합니다.
ForStatement :
for
(
var
VariableDeclarationList
;
Expression opt
;
Expression opt
)
Statement
decls1 을 VariableDeclarationList 의 VarScopedDeclarations 로 둡니다.decls2 를 Statement 의 VarScopedDeclarations 로 둡니다.decls1 과 decls2 의 목록 연결 을 반환합니다.
ForStatement :
for
(
LexicalDeclaration
Expression opt
;
Expression opt
)
Statement
Statement 의 VarScopedDeclarations 를 반환합니다.
ForInOfStatement :
for
(
LeftHandSideExpression
in
Expression
)
Statement
for
(
ForDeclaration
in
Expression
)
Statement
for
(
LeftHandSideExpression
of
AssignmentExpression
)
Statement
for
(
ForDeclaration
of
AssignmentExpression
)
Statement
for
await
(
LeftHandSideExpression
of
AssignmentExpression
)
Statement
for
await
(
ForDeclaration
of
AssignmentExpression
)
Statement
Statement 의 VarScopedDeclarations 를 반환합니다.
ForInOfStatement :
for
(
var
ForBinding
in
Expression
)
Statement
for
(
var
ForBinding
of
AssignmentExpression
)
Statement
for
await
(
var
ForBinding
of
AssignmentExpression
)
Statement
decls1 을 « ForBinding »로 둡니다.decls2 를 Statement 의 VarScopedDeclarations 로 둡니다.decls1 과 decls2 의 목록 연결 을 반환합니다.
참고
이 절은 부속서 B.3.5 에 의해 확장됩니다.
WithStatement :
with
(
Expression
)
Statement
Statement 의 VarScopedDeclarations 를 반환합니다.
SwitchStatement :
switch
(
Expression
)
CaseBlock
CaseBlock 의 VarScopedDeclarations 를 반환합니다.
CaseBlock :
{
}
새로운 빈 List 를 반환합니다.
CaseBlock :
{
CaseClauses opt
DefaultClause
CaseClauses opt
}
첫 번째 CaseClauses 가 존재하면, decls1 을 첫 번째 CaseClauses 의 VarScopedDeclarations 로 둡니다. 그렇지 않으면 decls1 을 새로운 빈 List 로 둡니다. decls2 를 DefaultClause 의 VarScopedDeclarations 로 둡니다.두 번째 CaseClauses 가 존재하면, decls3 을 두 번째 CaseClauses 의 VarScopedDeclarations 로 둡니다. 그렇지 않으면 decls3 을 새로운 빈 List 로 둡니다. decls1 , decls2 및 decls3 의 목록 연결 을 반환합니다.
CaseClauses :
CaseClauses
CaseClause
decls1 을 CaseClauses 의 VarScopedDeclarations 로 둡니다.decls2 를 CaseClause 의 VarScopedDeclarations 로 둡니다.decls1 과 decls2 의 목록 연결 을 반환합니다.
CaseClause :
case
Expression
:
StatementList opt
StatementList 가 존재하면, StatementList 의 VarScopedDeclarations 를 반환합니다.새로운 빈 List 를 반환합니다.
DefaultClause :
default
:
StatementList opt
StatementList 가 존재하면, StatementList 의 VarScopedDeclarations 를 반환합니다.새로운 빈 List 를 반환합니다.
LabelledStatement :
LabelIdentifier
:
LabelledItem
LabelledItem 의 VarScopedDeclarations 를 반환합니다.
LabelledItem : FunctionDeclaration
새로운 빈 List 를 반환합니다.
TryStatement :
try
Block
Catch
decls1 을 Block 의 VarScopedDeclarations 로 둡니다.decls2 를 Catch 의 VarScopedDeclarations 로 둡니다.decls1 과 decls2 의 목록 연결 을 반환합니다.
TryStatement :
try
Block
Finally
decls1 을 Block 의 VarScopedDeclarations 로 둡니다.decls2 를 Finally 의 VarScopedDeclarations 로 둡니다.decls1 과 decls2 의 목록 연결 을 반환합니다.
TryStatement :
try
Block
Catch
Finally
decls1 을 Block 의 VarScopedDeclarations 로 둡니다.decls2 를 Catch 의 VarScopedDeclarations 로 둡니다.decls3 을 Finally 의 VarScopedDeclarations 로 둡니다.decls1 , decls2 및 decls3 의 목록 연결 을 반환합니다.
Catch :
catch
(
CatchParameter
)
Block
Block 의 VarScopedDeclarations 를 반환합니다.
FunctionStatementList : [empty]
새로운 빈 List 를 반환합니다.
FunctionStatementList : StatementList
StatementList 의 TopLevelVarScopedDeclarations 를 반환합니다.
ClassStaticBlockStatementList : [empty]
새로운 빈 List 를 반환합니다.
ClassStaticBlockStatementList : StatementList
StatementList 의 TopLevelVarScopedDeclarations 를 반환합니다.
ConciseBody : ExpressionBody
새로운 빈 List 를 반환합니다.
AsyncConciseBody : ExpressionBody
새로운 빈 List 를 반환합니다.
Script : [empty]
새로운 빈 List 를 반환합니다.
ScriptBody : StatementList
StatementList 의 TopLevelVarScopedDeclarations 를 반환합니다.
Module : [empty]
새로운 빈 List 를 반환합니다.
ModuleItemList :
ModuleItemList
ModuleItem
decls1 을 ModuleItemList 의 VarScopedDeclarations 로 둡니다.decls2 를 ModuleItem 의 VarScopedDeclarations 로 둡니다.decls1 과 decls2 의 목록 연결 을 반환합니다.
ModuleItem : ImportDeclaration
새로운 빈 List 를 반환합니다.
ModuleItem : ExportDeclaration
ExportDeclaration 이 export VariableStatement 이면, VariableStatement 의 VarScopedDeclarations 를 반환합니다.새로운 빈 List 를 반환합니다.
8.2.10 Static Semantics: TopLevelLexicallyDeclaredNames
구문 지향 연산 TopLevelLexicallyDeclaredNames. 인수 없음. 반환값: 리스트 (요소: String). 다음 생성 규칙별로 정의된다.
StatementList :
StatementList
StatementListItem
names1 을 StatementList 의 TopLevelLexicallyDeclaredNames 로 둡니다.names2 를 StatementListItem 의 TopLevelLexicallyDeclaredNames 로 둡니다.names1 과 names2 의 목록 연결 을 반환합니다.
StatementListItem : Statement
새로운 빈 List 를 반환합니다.
StatementListItem : Declaration
Declaration 이
Declaration : HoistableDeclaration
이면, 다음을 수행합니다.새로운 빈 List 를 반환합니다. Declaration 의 BoundNames 를 반환합니다.
참고
함수 또는 스크립트의 최상위 수준에서 함수 선언은 렉시컬 선언이 아니라 var 선언처럼 취급됩니다.
8.2.11 Static Semantics: TopLevelLexicallyScopedDeclarations
구문 지향 연산 TopLevelLexicallyScopedDeclarations. 인수 없음. 반환값: 리스트 (요소: 구문 분석 노드 ). 다음 생성 규칙별로 정의된다.
StatementList :
StatementList
StatementListItem
decls1 을 StatementList 의 TopLevelLexicallyScopedDeclarations 로 둡니다.decls2 를 StatementListItem 의 TopLevelLexicallyScopedDeclarations 로 둡니다.decls1 과 decls2 의 목록 연결 을 반환합니다.
StatementListItem : Statement
새로운 빈 List 를 반환합니다.
StatementListItem : Declaration
Declaration 이
Declaration : HoistableDeclaration
이면, 다음을 수행합니다.새로운 빈 List 를 반환합니다. « Declaration »을 반환합니다.
8.2.12 Static Semantics: TopLevelVarDeclaredNames
구문 지향 연산 TopLevelVarDeclaredNames. 인수 없음. 반환값: 리스트 (요소: String). 다음 생성 규칙별로 정의된다.
StatementList :
StatementList
StatementListItem
names1 을 StatementList 의 TopLevelVarDeclaredNames 로 둡니다.names2 를 StatementListItem 의 TopLevelVarDeclaredNames 로 둡니다.names1 과 names2 의 목록 연결 을 반환합니다.
StatementListItem : Declaration
Declaration 이
Declaration : HoistableDeclaration
이면, 다음을 수행합니다.HoistableDeclaration 의 BoundNames 를 반환합니다.새로운 빈 List 를 반환합니다.
StatementListItem : Statement
Statement 가
Statement : LabelledStatement
이면, Statement 의 TopLevelVarDeclaredNames 를 반환합니다.Statement 의 VarDeclaredNames 를 반환합니다.
참고
함수 또는 스크립트의 최상위 수준에서 내부 함수 선언은 var 선언처럼 취급됩니다.
LabelledStatement :
LabelIdentifier
:
LabelledItem
LabelledItem 의 TopLevelVarDeclaredNames 를 반환합니다.
LabelledItem : Statement
Statement 가
Statement : LabelledStatement
이면, Statement 의 TopLevelVarDeclaredNames 를 반환합니다.Statement 의 VarDeclaredNames 를 반환합니다.
LabelledItem : FunctionDeclaration
FunctionDeclaration 의 BoundNames 를 반환합니다.
8.2.13 Static Semantics: TopLevelVarScopedDeclarations
구문 지향 연산 TopLevelVarScopedDeclarations. 인수 없음. 반환값: 리스트 (요소: 구문 분석 노드 ). 다음 생성 규칙별로 정의된다.
StatementList :
StatementList
StatementListItem
decls1 을 StatementList 의 TopLevelVarScopedDeclarations 로 둡니다.decls2 를 StatementListItem 의 TopLevelVarScopedDeclarations 로 둡니다.decls1 과 decls2 의 목록 연결 을 반환합니다.
StatementListItem : Statement
Statement 가
Statement : LabelledStatement
이면, Statement 의 TopLevelVarScopedDeclarations 를 반환합니다.Statement 의 VarScopedDeclarations 를 반환합니다.
StatementListItem : Declaration
Declaration 이
Declaration : HoistableDeclaration
이면, 다음을 수행합니다.decl 을 HoistableDeclaration 의 DeclarationPart 로 둡니다.« decl »을 반환합니다. 새로운 빈 List 를 반환합니다.
LabelledStatement :
LabelIdentifier
:
LabelledItem
LabelledItem 의 TopLevelVarScopedDeclarations 를 반환합니다.
LabelledItem : Statement
Statement 가
Statement : LabelledStatement
이면, Statement 의 TopLevelVarScopedDeclarations 를 반환합니다.Statement 의 VarScopedDeclarations 를 반환합니다.
LabelledItem : FunctionDeclaration
« FunctionDeclaration »을 반환합니다.
8.3 레이블
8.3.1 Static Semantics: ContainsDuplicateLabels
구문 지향 연산 ContainsDuplicateLabels. 인수 labelSet (리스트 (요소: String)). 반환값: Boolean. 다음 생성 규칙별로 정의된다.
Statement :
VariableStatement
EmptyStatement
ExpressionStatement
ContinueStatement
BreakStatement
ReturnStatement
ThrowStatement
DebuggerStatement
Block :
{
}
StatementListItem :
Declaration
false 를 반환합니다.
StatementList :
StatementList
StatementListItem
hasDuplicates 를 인수 labelSet 을 사용한 StatementList 의 ContainsDuplicateLabels 로 둡니다.hasDuplicates 가 true 이면, true 를 반환합니다.인수 labelSet 을 사용한 StatementListItem 의 ContainsDuplicateLabels 를 반환합니다.
IfStatement :
if
(
Expression
)
Statement
else
Statement
hasDuplicate 를 인수 labelSet 을 사용한 첫 번째 Statement 의 ContainsDuplicateLabels 로 둡니다.hasDuplicate 가 true 이면, true 를 반환합니다.인수 labelSet 을 사용한 두 번째 Statement 의 ContainsDuplicateLabels 를 반환합니다.
IfStatement :
if
(
Expression
)
Statement
인수 labelSet 을 사용한 Statement 의 ContainsDuplicateLabels 를 반환합니다.
DoWhileStatement :
do
Statement
while
(
Expression
)
;
인수 labelSet 을 사용한 Statement 의 ContainsDuplicateLabels 를 반환합니다.
WhileStatement :
while
(
Expression
)
Statement
인수 labelSet 을 사용한 Statement 의 ContainsDuplicateLabels 를 반환합니다.
ForStatement :
for
(
Expression opt
;
Expression opt
;
Expression opt
)
Statement
for
(
var
VariableDeclarationList
;
Expression opt
;
Expression opt
)
Statement
for
(
LexicalDeclaration
Expression opt
;
Expression opt
)
Statement
인수 labelSet 을 사용한 Statement 의 ContainsDuplicateLabels 를 반환합니다.
ForInOfStatement :
for
(
LeftHandSideExpression
in
Expression
)
Statement
for
(
var
ForBinding
in
Expression
)
Statement
for
(
ForDeclaration
in
Expression
)
Statement
for
(
LeftHandSideExpression
of
AssignmentExpression
)
Statement
for
(
var
ForBinding
of
AssignmentExpression
)
Statement
for
(
ForDeclaration
of
AssignmentExpression
)
Statement
for
await
(
LeftHandSideExpression
of
AssignmentExpression
)
Statement
for
await
(
var
ForBinding
of
AssignmentExpression
)
Statement
for
await
(
ForDeclaration
of
AssignmentExpression
)
Statement
인수 labelSet 을 사용한 Statement 의 ContainsDuplicateLabels 를 반환합니다.
참고
이 절은 부속서 B.3.5 에 의해 확장됩니다.
WithStatement :
with
(
Expression
)
Statement
인수 labelSet 을 사용한 Statement 의 ContainsDuplicateLabels 를 반환합니다.
SwitchStatement :
switch
(
Expression
)
CaseBlock
인수 labelSet 을 사용한 CaseBlock 의 ContainsDuplicateLabels 를 반환합니다.
CaseBlock :
{
}
false 를 반환합니다.
CaseBlock :
{
CaseClauses opt
DefaultClause
CaseClauses opt
}
첫 번째 CaseClauses 가 존재하면, 다음을 수행합니다.인수 labelSet 을 사용한 첫 번째 CaseClauses 의 ContainsDuplicateLabels 가 true 이면, true 를 반환합니다. 인수 labelSet 을 사용한 DefaultClause 의 ContainsDuplicateLabels 가 true 이면, true 를 반환합니다. 두 번째 CaseClauses 가 존재하지 않으면, false 를 반환합니다. 인수 labelSet 을 사용한 두 번째 CaseClauses 의 ContainsDuplicateLabels 를 반환합니다.
CaseClauses :
CaseClauses
CaseClause
hasDuplicates 를 인수 labelSet 을 사용한 CaseClauses 의 ContainsDuplicateLabels 로 둡니다.hasDuplicates 가 true 이면, true 를 반환합니다.인수 labelSet 을 사용한 CaseClause 의 ContainsDuplicateLabels 를 반환합니다.
CaseClause :
case
Expression
:
StatementList opt
StatementList 가 존재하면, 인수 labelSet 을 사용한 StatementList 의 ContainsDuplicateLabels 를 반환합니다.false 를 반환합니다.
DefaultClause :
default
:
StatementList opt
StatementList 가 존재하면, 인수 labelSet 을 사용한 StatementList 의 ContainsDuplicateLabels 를 반환합니다.false 를 반환합니다.
LabelledStatement :
LabelIdentifier
:
LabelledItem
label 을 LabelIdentifier 의 StringValue 로 둡니다.labelSet 에 label 이 포함되어 있으면, true 를 반환합니다.newLabelSet 을 labelSet 과 « label »의 목록 연결 로 둡니다.인수 newLabelSet 을 사용한 LabelledItem 의 ContainsDuplicateLabels 를 반환합니다.
LabelledItem : FunctionDeclaration
false 를 반환합니다.
TryStatement :
try
Block
Catch
hasDuplicates 를 인수 labelSet 을 사용한 Block 의 ContainsDuplicateLabels 로 둡니다.hasDuplicates 가 true 이면, true 를 반환합니다.인수 labelSet 을 사용한 Catch 의 ContainsDuplicateLabels 를 반환합니다.
TryStatement :
try
Block
Finally
hasDuplicates 를 인수 labelSet 을 사용한 Block 의 ContainsDuplicateLabels 로 둡니다.hasDuplicates 가 true 이면, true 를 반환합니다.인수 labelSet 을 사용한 Finally 의 ContainsDuplicateLabels 를 반환합니다.
TryStatement :
try
Block
Catch
Finally
인수 labelSet 을 사용한 Block 의 ContainsDuplicateLabels 가 true 이면, true 를 반환합니다. 인수 labelSet 을 사용한 Catch 의 ContainsDuplicateLabels 가 true 이면, true 를 반환합니다. 인수 labelSet 을 사용한 Finally 의 ContainsDuplicateLabels 를 반환합니다.
Catch :
catch
(
CatchParameter
)
Block
인수 labelSet 을 사용한 Block 의 ContainsDuplicateLabels 를 반환합니다.
FunctionStatementList : [empty]
false 를 반환합니다.
ClassStaticBlockStatementList : [empty]
false 를 반환합니다.
ModuleItemList :
ModuleItemList
ModuleItem
hasDuplicates 를 인수 labelSet 을 사용한 ModuleItemList 의 ContainsDuplicateLabels 로 둡니다.hasDuplicates 가 true 이면, true 를 반환합니다.인수 labelSet 을 사용한 ModuleItem 의 ContainsDuplicateLabels 를 반환합니다.
ModuleItem :
ImportDeclaration
ExportDeclaration
false 를 반환합니다.
8.3.2 Static Semantics: ContainsUndefinedBreakTarget
구문 지향 연산 ContainsUndefinedBreakTarget. 인수 labelSet (리스트 (요소: String)). 반환값: Boolean. 다음 생성 규칙별로 정의된다.
Statement :
VariableStatement
EmptyStatement
ExpressionStatement
ContinueStatement
ReturnStatement
ThrowStatement
DebuggerStatement
Block :
{
}
StatementListItem :
Declaration
false 를 반환합니다.
StatementList :
StatementList
StatementListItem
hasUndefinedLabels 를 인수 labelSet 을 사용한 StatementList 의 ContainsUndefinedBreakTarget 으로 둡니다.hasUndefinedLabels 가 true 이면, true 를 반환합니다.인수 labelSet 을 사용한 StatementListItem 의 ContainsUndefinedBreakTarget 을 반환합니다.
IfStatement :
if
(
Expression
)
Statement
else
Statement
hasUndefinedLabels 를 인수 labelSet 을 사용한 첫 번째 Statement 의 ContainsUndefinedBreakTarget 으로 둡니다.hasUndefinedLabels 가 true 이면, true 를 반환합니다.인수 labelSet 을 사용한 두 번째 Statement 의 ContainsUndefinedBreakTarget 을 반환합니다.
IfStatement :
if
(
Expression
)
Statement
인수 labelSet 을 사용한 Statement 의 ContainsUndefinedBreakTarget 을 반환합니다.
DoWhileStatement :
do
Statement
while
(
Expression
)
;
인수 labelSet 을 사용한 Statement 의 ContainsUndefinedBreakTarget 을 반환합니다.
WhileStatement :
while
(
Expression
)
Statement
인수 labelSet 을 사용한 Statement 의 ContainsUndefinedBreakTarget 을 반환합니다.
ForStatement :
for
(
Expression opt
;
Expression opt
;
Expression opt
)
Statement
for
(
var
VariableDeclarationList
;
Expression opt
;
Expression opt
)
Statement
for
(
LexicalDeclaration
Expression opt
;
Expression opt
)
Statement
인수 labelSet 을 사용한 Statement 의 ContainsUndefinedBreakTarget 을 반환합니다.
ForInOfStatement :
for
(
LeftHandSideExpression
in
Expression
)
Statement
for
(
var
ForBinding
in
Expression
)
Statement
for
(
ForDeclaration
in
Expression
)
Statement
for
(
LeftHandSideExpression
of
AssignmentExpression
)
Statement
for
(
var
ForBinding
of
AssignmentExpression
)
Statement
for
(
ForDeclaration
of
AssignmentExpression
)
Statement
for
await
(
LeftHandSideExpression
of
AssignmentExpression
)
Statement
for
await
(
var
ForBinding
of
AssignmentExpression
)
Statement
for
await
(
ForDeclaration
of
AssignmentExpression
)
Statement
인수 labelSet 을 사용한 Statement 의 ContainsUndefinedBreakTarget 을 반환합니다.
참고
이 절은 부속서 B.3.5 에 의해 확장됩니다.
BreakStatement :
break
;
false 를 반환합니다.
BreakStatement :
break
LabelIdentifier
;
labelSet 에 LabelIdentifier 의 StringValue 가 포함되어 있으면, false 를 반환합니다.true 를 반환합니다.
WithStatement :
with
(
Expression
)
Statement
인수 labelSet 을 사용한 Statement 의 ContainsUndefinedBreakTarget 을 반환합니다.
SwitchStatement :
switch
(
Expression
)
CaseBlock
인수 labelSet 을 사용한 CaseBlock 의 ContainsUndefinedBreakTarget 을 반환합니다.
CaseBlock :
{
}
false 를 반환합니다.
CaseBlock :
{
CaseClauses opt
DefaultClause
CaseClauses opt
}
첫 번째 CaseClauses 가 존재하면, 다음을 수행합니다.인수 labelSet 을 사용한 첫 번째 CaseClauses 의 ContainsUndefinedBreakTarget 이 true 이면, true 를 반환합니다. 인수 labelSet 을 사용한 DefaultClause 의 ContainsUndefinedBreakTarget 이 true 이면, true 를 반환합니다. 두 번째 CaseClauses 가 존재하지 않으면, false 를 반환합니다. 인수 labelSet 을 사용한 두 번째 CaseClauses 의 ContainsUndefinedBreakTarget 을 반환합니다.
CaseClauses :
CaseClauses
CaseClause
hasUndefinedLabels 를 인수 labelSet 을 사용한 CaseClauses 의 ContainsUndefinedBreakTarget 으로 둡니다.hasUndefinedLabels 가 true 이면, true 를 반환합니다.인수 labelSet 을 사용한 CaseClause 의 ContainsUndefinedBreakTarget 을 반환합니다.
CaseClause :
case
Expression
:
StatementList opt
StatementList 가 존재하면, 인수 labelSet 을 사용한 StatementList 의 ContainsUndefinedBreakTarget 을 반환합니다.false 를 반환합니다.
DefaultClause :
default
:
StatementList opt
StatementList 가 존재하면, 인수 labelSet 을 사용한 StatementList 의 ContainsUndefinedBreakTarget 을 반환합니다.false 를 반환합니다.
LabelledStatement :
LabelIdentifier
:
LabelledItem
label 을 LabelIdentifier 의 StringValue 로 둡니다.newLabelSet 을 labelSet 과 « label »의 목록 연결 로 둡니다.인수 newLabelSet 을 사용한 LabelledItem 의 ContainsUndefinedBreakTarget 을 반환합니다.
LabelledItem : FunctionDeclaration
false 를 반환합니다.
TryStatement :
try
Block
Catch
hasUndefinedLabels 를 인수 labelSet 을 사용한 Block 의 ContainsUndefinedBreakTarget 으로 둡니다.hasUndefinedLabels 가 true 이면, true 를 반환합니다.인수 labelSet 을 사용한 Catch 의 ContainsUndefinedBreakTarget 을 반환합니다.
TryStatement :
try
Block
Finally
hasUndefinedLabels 를 인수 labelSet 을 사용한 Block 의 ContainsUndefinedBreakTarget 으로 둡니다.hasUndefinedLabels 가 true 이면, true 를 반환합니다.인수 labelSet 을 사용한 Finally 의 ContainsUndefinedBreakTarget 을 반환합니다.
TryStatement :
try
Block
Catch
Finally
인수 labelSet 을 사용한 Block 의 ContainsUndefinedBreakTarget 이 true 이면, true 를 반환합니다. 인수 labelSet 을 사용한 Catch 의 ContainsUndefinedBreakTarget 이 true 이면, true 를 반환합니다. 인수 labelSet 을 사용한 Finally 의 ContainsUndefinedBreakTarget 을 반환합니다.
Catch :
catch
(
CatchParameter
)
Block
인수 labelSet 을 사용한 Block 의 ContainsUndefinedBreakTarget 을 반환합니다.
FunctionStatementList : [empty]
false 를 반환합니다.
ClassStaticBlockStatementList : [empty]
false 를 반환합니다.
ModuleItemList :
ModuleItemList
ModuleItem
hasUndefinedLabels 를 인수 labelSet 을 사용한 ModuleItemList 의 ContainsUndefinedBreakTarget 으로 둡니다.hasUndefinedLabels 가 true 이면, true 를 반환합니다.인수 labelSet 을 사용한 ModuleItem 의 ContainsUndefinedBreakTarget 을 반환합니다.
ModuleItem :
ImportDeclaration
ExportDeclaration
false 를 반환합니다.
8.3.3 Static Semantics: ContainsUndefinedContinueTarget
구문 지향 연산 ContainsUndefinedContinueTarget. 인수 iterationSet (리스트 (요소: String)) 및 labelSet (리스트 (요소: String)). 반환값: Boolean. 다음 생성 규칙별로 정의된다.
Statement :
VariableStatement
EmptyStatement
ExpressionStatement
BreakStatement
ReturnStatement
ThrowStatement
DebuggerStatement
Block :
{
}
StatementListItem :
Declaration
false 를 반환합니다.
Statement : BlockStatement
인수 iterationSet 및 « »를 사용한 BlockStatement 의 ContainsUndefinedContinueTarget 을 반환합니다.
BreakableStatement : IterationStatement
newIterationSet 을 iterationSet 과 labelSet 의 목록 연결 로 둡니다.인수 newIterationSet 및 « »를 사용한 IterationStatement 의 ContainsUndefinedContinueTarget 을 반환합니다.
StatementList :
StatementList
StatementListItem
hasUndefinedLabels 를 인수 iterationSet 및 « »를 사용한 StatementList 의 ContainsUndefinedContinueTarget 으로 둡니다.hasUndefinedLabels 가 true 이면, true 를 반환합니다.인수 iterationSet 및 « »를 사용한 StatementListItem 의 ContainsUndefinedContinueTarget 을 반환합니다.
IfStatement :
if
(
Expression
)
Statement
else
Statement
hasUndefinedLabels 를 인수 iterationSet 및 « »를 사용한 첫 번째 Statement 의 ContainsUndefinedContinueTarget 으로 둡니다.hasUndefinedLabels 가 true 이면, true 를 반환합니다.인수 iterationSet 및 « »를 사용한 두 번째 Statement 의 ContainsUndefinedContinueTarget 을 반환합니다.
IfStatement :
if
(
Expression
)
Statement
인수 iterationSet 및 « »를 사용한 Statement 의 ContainsUndefinedContinueTarget 을 반환합니다.
DoWhileStatement :
do
Statement
while
(
Expression
)
;
인수 iterationSet 및 « »를 사용한 Statement 의 ContainsUndefinedContinueTarget 을 반환합니다.
WhileStatement :
while
(
Expression
)
Statement
인수 iterationSet 및 « »를 사용한 Statement 의 ContainsUndefinedContinueTarget 을 반환합니다.
ForStatement :
for
(
Expression opt
;
Expression opt
;
Expression opt
)
Statement
for
(
var
VariableDeclarationList
;
Expression opt
;
Expression opt
)
Statement
for
(
LexicalDeclaration
Expression opt
;
Expression opt
)
Statement
인수 iterationSet 및 « »를 사용한 Statement 의 ContainsUndefinedContinueTarget 을 반환합니다.
ForInOfStatement :
for
(
LeftHandSideExpression
in
Expression
)
Statement
for
(
var
ForBinding
in
Expression
)
Statement
for
(
ForDeclaration
in
Expression
)
Statement
for
(
LeftHandSideExpression
of
AssignmentExpression
)
Statement
for
(
var
ForBinding
of
AssignmentExpression
)
Statement
for
(
ForDeclaration
of
AssignmentExpression
)
Statement
for
await
(
LeftHandSideExpression
of
AssignmentExpression
)
Statement
for
await
(
var
ForBinding
of
AssignmentExpression
)
Statement
for
await
(
ForDeclaration
of
AssignmentExpression
)
Statement
인수 iterationSet 및 « »를 사용한 Statement 의 ContainsUndefinedContinueTarget 을 반환합니다.
참고
이 절은 부속서 B.3.5 에 의해 확장됩니다.
ContinueStatement :
continue
;
false 를 반환합니다.
ContinueStatement :
continue
LabelIdentifier
;
iterationSet 에 LabelIdentifier 의 StringValue 가 포함되어 있으면, false 를 반환합니다.true 를 반환합니다.
WithStatement :
with
(
Expression
)
Statement
인수 iterationSet 및 « »를 사용한 Statement 의 ContainsUndefinedContinueTarget 을 반환합니다.
SwitchStatement :
switch
(
Expression
)
CaseBlock
인수 iterationSet 및 « »를 사용한 CaseBlock 의 ContainsUndefinedContinueTarget 을 반환합니다.
CaseBlock :
{
}
false 를 반환합니다.
CaseBlock :
{
CaseClauses opt
DefaultClause
CaseClauses opt
}
첫 번째 CaseClauses 가 존재하면, 다음을 수행합니다.인수 iterationSet 및 « »를 사용한 첫 번째 CaseClauses 의 ContainsUndefinedContinueTarget 이 true 이면, true 를 반환합니다. 인수 iterationSet 및 « »를 사용한 DefaultClause 의 ContainsUndefinedContinueTarget 이 true 이면, true 를 반환합니다. 두 번째 CaseClauses 가 존재하지 않으면, false 를 반환합니다. 인수 iterationSet 및 « »를 사용한 두 번째 CaseClauses 의 ContainsUndefinedContinueTarget 을 반환합니다.
CaseClauses :
CaseClauses
CaseClause
hasUndefinedLabels 를 인수 iterationSet 및 « »를 사용한 CaseClauses 의 ContainsUndefinedContinueTarget 으로 둡니다.hasUndefinedLabels 가 true 이면, true 를 반환합니다.인수 iterationSet 및 « »를 사용한 CaseClause 의 ContainsUndefinedContinueTarget 을 반환합니다.
CaseClause :
case
Expression
:
StatementList opt
StatementList 가 존재하면, 인수 iterationSet 및 « »를 사용한 StatementList 의 ContainsUndefinedContinueTarget 을 반환합니다.false 를 반환합니다.
DefaultClause :
default
:
StatementList opt
StatementList 가 존재하면, 인수 iterationSet 및 « »를 사용한 StatementList 의 ContainsUndefinedContinueTarget 을 반환합니다.false 를 반환합니다.
LabelledStatement :
LabelIdentifier
:
LabelledItem
label 을 LabelIdentifier 의 StringValue 로 둡니다.newLabelSet 을 labelSet 과 « label »의 목록 연결 로 둡니다.인수 iterationSet 및 newLabelSet 을 사용한 LabelledItem 의 ContainsUndefinedContinueTarget 을 반환합니다.
LabelledItem : FunctionDeclaration
false 를 반환합니다.
TryStatement :
try
Block
Catch
hasUndefinedLabels 를 인수 iterationSet 및 « »를 사용한 Block 의 ContainsUndefinedContinueTarget 으로 둡니다.hasUndefinedLabels 가 true 이면, true 를 반환합니다.인수 iterationSet 및 « »를 사용한 Catch 의 ContainsUndefinedContinueTarget 을 반환합니다.
TryStatement :
try
Block
Finally
hasUndefinedLabels 를 인수 iterationSet 및 « »를 사용한 Block 의 ContainsUndefinedContinueTarget 으로 둡니다.hasUndefinedLabels 가 true 이면, true 를 반환합니다.인수 iterationSet 및 « »를 사용한 Finally 의 ContainsUndefinedContinueTarget 을 반환합니다.
TryStatement :
try
Block
Catch
Finally
인수 iterationSet 및 « »를 사용한 Block 의 ContainsUndefinedContinueTarget 이 true 이면, true 를 반환합니다. 인수 iterationSet 및 « »를 사용한 Catch 의 ContainsUndefinedContinueTarget 이 true 이면, true 를 반환합니다. 인수 iterationSet 및 « »를 사용한 Finally 의 ContainsUndefinedContinueTarget 을 반환합니다.
Catch :
catch
(
CatchParameter
)
Block
인수 iterationSet 및 « »를 사용한 Block 의 ContainsUndefinedContinueTarget 을 반환합니다.
FunctionStatementList : [empty]
false 를 반환합니다.
ClassStaticBlockStatementList : [empty]
false 를 반환합니다.
ModuleItemList :
ModuleItemList
ModuleItem
hasUndefinedLabels 를 인수 iterationSet 및 « »를 사용한 ModuleItemList 의 ContainsUndefinedContinueTarget 으로 둡니다.hasUndefinedLabels 가 true 이면, true 를 반환합니다.인수 iterationSet 및 « »를 사용한 ModuleItem 의 ContainsUndefinedContinueTarget 을 반환합니다.
ModuleItem :
ImportDeclaration
ExportDeclaration
false 를 반환합니다.
8.4 함수 이름 추론
8.4.1 Static Semantics: HasName
구문 지향 연산 HasName. 인수 없음. 반환값: Boolean. 다음 생성 규칙별로 정의된다.
PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList
expr 을 CoverParenthesizedExpressionAndArrowParameterList 가 포괄하는 ParenthesizedExpression 로 둡니다.expr 의 IsFunctionDefinition 이 false 이면, false 를 반환합니다.expr 의 HasName 을 반환합니다.
FunctionExpression :
function
(
FormalParameters
)
{
FunctionBody
}
GeneratorExpression :
function
*
(
FormalParameters
)
{
GeneratorBody
}
AsyncGeneratorExpression :
async
function
*
(
FormalParameters
)
{
AsyncGeneratorBody
}
AsyncFunctionExpression :
async
function
(
FormalParameters
)
{
AsyncFunctionBody
}
ArrowFunction :
ArrowParameters
=>
ConciseBody
AsyncArrowFunction :
async
AsyncArrowBindingIdentifier
=>
AsyncConciseBody
CoverCallExpressionAndAsyncArrowHead
=>
AsyncConciseBody
ClassExpression :
class
ClassTail
false 를 반환합니다.
FunctionExpression :
function
BindingIdentifier
(
FormalParameters
)
{
FunctionBody
}
GeneratorExpression :
function
*
BindingIdentifier
(
FormalParameters
)
{
GeneratorBody
}
AsyncGeneratorExpression :
async
function
*
BindingIdentifier
(
FormalParameters
)
{
AsyncGeneratorBody
}
AsyncFunctionExpression :
async
function
BindingIdentifier
(
FormalParameters
)
{
AsyncFunctionBody
}
ClassExpression :
class
BindingIdentifier
ClassTail
true 를 반환합니다.
8.4.2 Static Semantics: IsFunctionDefinition
구문 지향 연산 IsFunctionDefinition. 인수 없음. 반환값: Boolean. 다음 생성 규칙별로 정의된다.
PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList
expr 을 CoverParenthesizedExpressionAndArrowParameterList 가 포괄하는 ParenthesizedExpression 로 둡니다.expr 의 IsFunctionDefinition 을 반환합니다.
PrimaryExpression :
this
IdentifierReference
Literal
ArrayLiteral
ObjectLiteral
RegularExpressionLiteral
TemplateLiteral
MemberExpression :
MemberExpression
[
Expression
]
MemberExpression
.
IdentifierName
MemberExpression
TemplateLiteral
SuperProperty
MetaProperty
new
MemberExpression
Arguments
MemberExpression
.
PrivateIdentifier
NewExpression :
new
NewExpression
LeftHandSideExpression :
CallExpression
OptionalExpression
UpdateExpression :
LeftHandSideExpression
++
LeftHandSideExpression
--
++
UnaryExpression
--
UnaryExpression
UnaryExpression :
delete
UnaryExpression
void
UnaryExpression
typeof
UnaryExpression
+
UnaryExpression
-
UnaryExpression
~
UnaryExpression
!
UnaryExpression
CoverAwaitExpressionAndAwaitUsingDeclarationHead
ExponentiationExpression :
UpdateExpression
**
ExponentiationExpression
MultiplicativeExpression :
MultiplicativeExpression
MultiplicativeOperator
ExponentiationExpression
AdditiveExpression :
AdditiveExpression
+
MultiplicativeExpression
AdditiveExpression
-
MultiplicativeExpression
ShiftExpression :
ShiftExpression
<<
AdditiveExpression
ShiftExpression
>>
AdditiveExpression
ShiftExpression
>>>
AdditiveExpression
RelationalExpression :
RelationalExpression
<
ShiftExpression
RelationalExpression
>
ShiftExpression
RelationalExpression
<=
ShiftExpression
RelationalExpression
>=
ShiftExpression
RelationalExpression
instanceof
ShiftExpression
RelationalExpression
in
ShiftExpression
PrivateIdentifier
in
ShiftExpression
EqualityExpression :
EqualityExpression
==
RelationalExpression
EqualityExpression
!=
RelationalExpression
EqualityExpression
===
RelationalExpression
EqualityExpression
!==
RelationalExpression
BitwiseANDExpression :
BitwiseANDExpression
&
EqualityExpression
BitwiseXORExpression :
BitwiseXORExpression
^
BitwiseANDExpression
BitwiseORExpression :
BitwiseORExpression
|
BitwiseXORExpression
LogicalANDExpression :
LogicalANDExpression
&&
BitwiseORExpression
LogicalORExpression :
LogicalORExpression
||
LogicalANDExpression
CoalesceExpression :
CoalesceExpressionHead
??
BitwiseORExpression
ConditionalExpression :
ShortCircuitExpression
?
AssignmentExpression
:
AssignmentExpression
AssignmentExpression :
YieldExpression
LeftHandSideExpression
=
AssignmentExpression
LeftHandSideExpression
AssignmentOperator
AssignmentExpression
LeftHandSideExpression
&&=
AssignmentExpression
LeftHandSideExpression
||=
AssignmentExpression
LeftHandSideExpression
??=
AssignmentExpression
Expression :
Expression
,
AssignmentExpression
false 를 반환합니다.
AssignmentExpression :
ArrowFunction
AsyncArrowFunction
FunctionExpression :
function
BindingIdentifier opt
(
FormalParameters
)
{
FunctionBody
}
GeneratorExpression :
function
*
BindingIdentifier opt
(
FormalParameters
)
{
GeneratorBody
}
AsyncGeneratorExpression :
async
function
*
BindingIdentifier opt
(
FormalParameters
)
{
AsyncGeneratorBody
}
AsyncFunctionExpression :
async
function
BindingIdentifier opt
(
FormalParameters
)
{
AsyncFunctionBody
}
ClassExpression :
class
BindingIdentifier opt
ClassTail
true 를 반환합니다.
8.4.3 Static Semantics: IsAnonymousFunctionDefinition ( expr )
추상 연산 IsAnonymousFunctionDefinition. 인수 expr ((an AssignmentExpression Parse Node, an Initializer Parse Node 또는 an Expression Parse Node)). 반환값: Boolean. 인수가 이름을 바인딩하지 않는 함수 정의인지 결정합니다. 호출되면 다음 단계를 수행한다.
expr 의 IsFunctionDefinition 이 false 이면, false 를 반환합니다.hasName 을 expr 의 HasName 으로 둡니다.hasName 이 true 이면, false 를 반환합니다.true 를 반환합니다.
8.4.4 Static Semantics: IsIdentifierRef
구문 지향 연산 IsIdentifierRef. 인수 없음. 반환값: Boolean. 다음 생성 규칙별로 정의된다.
PrimaryExpression : IdentifierReference
true 를 반환합니다.
PrimaryExpression :
this
Literal
ArrayLiteral
ObjectLiteral
FunctionExpression
ClassExpression
GeneratorExpression
AsyncFunctionExpression
AsyncGeneratorExpression
RegularExpressionLiteral
TemplateLiteral
CoverParenthesizedExpressionAndArrowParameterList
MemberExpression :
MemberExpression
[
Expression
]
MemberExpression
.
IdentifierName
MemberExpression
TemplateLiteral
SuperProperty
MetaProperty
new
MemberExpression
Arguments
MemberExpression
.
PrivateIdentifier
NewExpression :
new
NewExpression
LeftHandSideExpression :
CallExpression
OptionalExpression
false 를 반환합니다.
8.4.5 Runtime Semantics: NamedEvaluation
구문 지향 연산 NamedEvaluation. 인수 name ((프로퍼티 키 또는 비공개 이름 )). 반환값: (정상 완료 (값: 함수 객체 ) 또는 중도 완료). 다음 생성 규칙별로 정의된다.
PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList
expr 을 CoverParenthesizedExpressionAndArrowParameterList 가 포괄하는 ParenthesizedExpression 로 둡니다.인수 name 을 사용한 expr 의 ? NamedEvaluation 을 반환합니다.
ParenthesizedExpression :
(
Expression
)
단언 : IsAnonymousFunctionDefinition (Expression )은 true 입니다.인수 name 을 사용한 Expression 의 ? NamedEvaluation 을 반환합니다.
FunctionExpression :
function
(
FormalParameters
)
{
FunctionBody
}
인수 name 을 사용한 FunctionExpression 의 InstantiateOrdinaryFunctionExpression 을 반환합니다.
GeneratorExpression :
function
*
(
FormalParameters
)
{
GeneratorBody
}
인수 name 을 사용한 GeneratorExpression 의 InstantiateGeneratorFunctionExpression 을 반환합니다.
AsyncGeneratorExpression :
async
function
*
(
FormalParameters
)
{
AsyncGeneratorBody
}
인수 name 을 사용한 AsyncGeneratorExpression 의 InstantiateAsyncGeneratorFunctionExpression 을 반환합니다.
AsyncFunctionExpression :
async
function
(
FormalParameters
)
{
AsyncFunctionBody
}
인수 name 을 사용한 AsyncFunctionExpression 의 InstantiateAsyncFunctionExpression 을 반환합니다.
ArrowFunction :
ArrowParameters
=>
ConciseBody
인수 name 을 사용한 ArrowFunction 의 InstantiateArrowFunctionExpression 을 반환합니다.
AsyncArrowFunction :
async
AsyncArrowBindingIdentifier
=>
AsyncConciseBody
CoverCallExpressionAndAsyncArrowHead
=>
AsyncConciseBody
인수 name 을 사용한 AsyncArrowFunction 의 InstantiateAsyncArrowFunctionExpression 을 반환합니다.
ClassExpression :
class
ClassTail
sourceText 를 ClassExpression 에 일치하는 소스 텍스트 로 둡니다.인수 undefined , name 및 sourceText 를 사용한 ClassTail 의 ? ClassDefinitionEvaluation 을 반환합니다.
8.5 포함 여부
8.5.1 Static Semantics: Contains
구문 지향 연산 Contains. 인수 symbol (문법 기호). 반환값: Boolean.
아래에 나열되지 않은 이 명세의 모든 문법 생성 규칙 대안에는 암묵적으로 다음과 같은 Contains의 기본 정의가 있습니다:
이 Parse Node의 각 자식 노드 child 에 대해 다음을 수행합니다.child 가 symbol 의 인스턴스이면, true 를 반환합니다.child 가 비단말 기호의 인스턴스이면, 다음을 수행합니다.contained 를 child Contains symbol 의 결과로 둡니다.contained 가 true 이면, true 를 반환합니다. false 를 반환합니다.
FunctionDeclaration :
function
BindingIdentifier
(
FormalParameters
)
{
FunctionBody
}
function
(
FormalParameters
)
{
FunctionBody
}
FunctionExpression :
function
BindingIdentifier opt
(
FormalParameters
)
{
FunctionBody
}
GeneratorDeclaration :
function
*
BindingIdentifier
(
FormalParameters
)
{
GeneratorBody
}
function
*
(
FormalParameters
)
{
GeneratorBody
}
GeneratorExpression :
function
*
BindingIdentifier opt
(
FormalParameters
)
{
GeneratorBody
}
AsyncGeneratorDeclaration :
async
function
*
BindingIdentifier
(
FormalParameters
)
{
AsyncGeneratorBody
}
async
function
*
(
FormalParameters
)
{
AsyncGeneratorBody
}
AsyncGeneratorExpression :
async
function
*
BindingIdentifier opt
(
FormalParameters
)
{
AsyncGeneratorBody
}
AsyncFunctionDeclaration :
async
function
BindingIdentifier
(
FormalParameters
)
{
AsyncFunctionBody
}
async
function
(
FormalParameters
)
{
AsyncFunctionBody
}
AsyncFunctionExpression :
async
function
BindingIdentifier opt
(
FormalParameters
)
{
AsyncFunctionBody
}
false 를 반환합니다.
참고 1
하위 구조에 의존하는 정적 의미 규칙은 일반적으로 함수 정의 내부를 살펴보지 않습니다.
ClassTail :
ClassHeritage opt
{
ClassBody
}
symbol 이 ClassBody 이면, true 를 반환합니다.symbol 이 ClassHeritage 이면, 다음을 수행합니다.ClassHeritage 가 존재하면, true 를 반환합니다.false 를 반환합니다.ClassHeritage 가 존재하면, 다음을 수행합니다.ClassHeritage Contains symbol 이 true 이면, true 를 반환합니다.인수 symbol 을 사용한 ClassBody 의 ComputedPropertyContains 결과를 반환합니다.
참고 2
하위 구조에 의존하는 정적 의미 규칙은 일반적으로 PropertyName 을 제외하고 클래스 본문 내부를 살펴보지 않습니다.
ClassStaticBlock :
static
{
ClassStaticBlockBody
}
false 를 반환합니다.
참고 3
하위 구조에 의존하는 정적 의미 규칙은 일반적으로 static 초기화 블록 내부를 살펴보지 않습니다.
ArrowFunction :
ArrowParameters
=>
ConciseBody
symbol 이 NewTarget , SuperProperty , SuperCall , super 또는 this 중 하나가 아니면, false 를 반환합니다.ArrowParameters Contains symbol 이 true 이면, true 를 반환합니다.ConciseBody Contains symbol 을 반환합니다.
ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList
formals 를 CoverParenthesizedExpressionAndArrowParameterList 가 포괄하는 ArrowFormalParameters 로 둡니다.formals Contains symbol 을 반환합니다.
AsyncArrowFunction :
async
AsyncArrowBindingIdentifier
=>
AsyncConciseBody
symbol 이 NewTarget , SuperProperty , SuperCall , super 또는 this 중 하나가 아니면, false 를 반환합니다.AsyncConciseBody Contains symbol 을 반환합니다.
AsyncArrowFunction :
CoverCallExpressionAndAsyncArrowHead
=>
AsyncConciseBody
symbol 이 NewTarget , SuperProperty , SuperCall , super 또는 this 중 하나가 아니면, false 를 반환합니다.head 를 CoverCallExpressionAndAsyncArrowHead 가 포괄하는 AsyncArrowHead 로 둡니다.head Contains symbol 이 true 이면, true 를 반환합니다.AsyncConciseBody Contains symbol 을 반환합니다.
참고 4
Contains는 ArrowFunction 또는 AsyncArrowFunction 내에서 new.target, this 및 super 사용을 감지하는 데 사용됩니다.
PropertyDefinition : MethodDefinition
symbol 이 MethodDefinition 이면, true 를 반환합니다.인수 symbol 을 사용한 MethodDefinition 의 ComputedPropertyContains 결과를 반환합니다.
LiteralPropertyName : IdentifierName
false 를 반환합니다.
MemberExpression :
MemberExpression
.
IdentifierName
MemberExpression Contains symbol 이 true 이면, true 를 반환합니다.false 를 반환합니다.
SuperProperty :
super
.
IdentifierName
symbol 이 ReservedWord super이면, true 를 반환합니다.false 를 반환합니다.
CallExpression :
CallExpression
.
IdentifierName
CallExpression Contains symbol 이 true 이면, true 를 반환합니다.false 를 반환합니다.
OptionalChain :
?.
IdentifierName
false 를 반환합니다.
OptionalChain :
OptionalChain
.
IdentifierName
OptionalChain Contains symbol 이 true 이면, true 를 반환합니다.false 를 반환합니다.
8.5.2 Static Semantics: ComputedPropertyContains
구문 지향 연산 ComputedPropertyContains. 인수 symbol (문법 기호). 반환값: Boolean. 다음 생성 규칙별로 정의된다.
ClassElementName : PrivateIdentifier
PropertyName : LiteralPropertyName
false 를 반환합니다.
PropertyName : ComputedPropertyName
ComputedPropertyName Contains symbol 의 결과를 반환합니다.
MethodDefinition :
ClassElementName
(
UniqueFormalParameters
)
{
FunctionBody
}
get
ClassElementName
(
)
{
FunctionBody
}
set
ClassElementName
(
PropertySetParameterList
)
{
FunctionBody
}
인수 symbol 을 사용한 ClassElementName 의 ComputedPropertyContains 결과를 반환합니다.
GeneratorMethod :
*
ClassElementName
(
UniqueFormalParameters
)
{
GeneratorBody
}
인수 symbol 을 사용한 ClassElementName 의 ComputedPropertyContains 결과를 반환합니다.
AsyncGeneratorMethod :
async
*
ClassElementName
(
UniqueFormalParameters
)
{
AsyncGeneratorBody
}
인수 symbol 을 사용한 ClassElementName 의 ComputedPropertyContains 결과를 반환합니다.
ClassElementList :
ClassElementList
ClassElement
inList 를 인수 symbol 을 사용한 ClassElementList 의 ComputedPropertyContains 로 둡니다.inList 가 true 이면, true 를 반환합니다.인수 symbol 을 사용한 ClassElement 의 ComputedPropertyContains 결과를 반환합니다.
ClassElement : ClassStaticBlock
false 를 반환합니다.
ClassElement : ;
false 를 반환합니다.
AsyncMethod :
async
ClassElementName
(
UniqueFormalParameters
)
{
AsyncFunctionBody
}
인수 symbol 을 사용한 ClassElementName 의 ComputedPropertyContains 결과를 반환합니다.
FieldDefinition :
ClassElementName
Initializer opt
인수 symbol 을 사용한 ClassElementName 의 ComputedPropertyContains 결과를 반환합니다.
8.6 기타
이러한 연산은 명세 전반의 여러 위치에서 사용됩니다.
8.6.1 Runtime Semantics: InstantiateFunctionObject
구문 지향 연산 InstantiateFunctionObject. 인수 envRecord (Environment 레코드 ) 및 privateEnv ((PrivateEnvironment 레코드 또는 null )). 반환값: ECMAScript 함수 객체. 다음 생성 규칙별로 정의된다.
FunctionDeclaration :
function
BindingIdentifier
(
FormalParameters
)
{
FunctionBody
}
function
(
FormalParameters
)
{
FunctionBody
}
인수 envRecord 및 privateEnv 를 사용한 FunctionDeclaration 의 InstantiateOrdinaryFunctionObject 를 반환합니다.
GeneratorDeclaration :
function
*
BindingIdentifier
(
FormalParameters
)
{
GeneratorBody
}
function
*
(
FormalParameters
)
{
GeneratorBody
}
인수 envRecord 및 privateEnv 를 사용한 GeneratorDeclaration 의 InstantiateGeneratorFunctionObject 를 반환합니다.
AsyncGeneratorDeclaration :
async
function
*
BindingIdentifier
(
FormalParameters
)
{
AsyncGeneratorBody
}
async
function
*
(
FormalParameters
)
{
AsyncGeneratorBody
}
인수 envRecord 및 privateEnv 를 사용한 AsyncGeneratorDeclaration 의 InstantiateAsyncGeneratorFunctionObject 를 반환합니다.
AsyncFunctionDeclaration :
async
function
BindingIdentifier
(
FormalParameters
)
{
AsyncFunctionBody
}
async
function
(
FormalParameters
)
{
AsyncFunctionBody
}
인수 envRecord 및 privateEnv 를 사용한 AsyncFunctionDeclaration 의 InstantiateAsyncFunctionObject 를 반환합니다.
8.6.2 Runtime Semantics: BindingInitialization
구문 지향 연산 BindingInitialization. 인수 value (ECMAScript 언어 값 ) 및 envRecord ((Environment 레코드 또는 undefined )). 반환값: (정상 완료 (값: unused ) 또는 중도 완료).
참고
envRecord 에 undefined 를 전달하면 초기화 값을 할당하는 데 PutValue 연산을 사용해야 함을 나타냅니다. 이는 var 문과 일부 비엄격 함수 의 형식 매개변수 목록에서 발생합니다(10.2.11 참조). 이러한 경우 렉시컬 바인딩은 이니셜라이저를 평가하기 전에 끌어올려지고 미리 초기화됩니다.
다음 생성 규칙별로 정의된다.
BindingIdentifier : Identifier
name 을 Identifier 의 StringValue 로 둡니다.? InitializeBoundName (name , value , envRecord )을 반환합니다.
BindingIdentifier : yield
? InitializeBoundName ("yield" , value , envRecord )을 반환합니다.
BindingIdentifier : await
? InitializeBoundName ("await" , value , envRecord )을 반환합니다.
BindingPattern : ObjectBindingPattern
? RequireObjectCoercible (value )를 수행합니다. 인수 value 및 envRecord 를 사용한 ObjectBindingPattern 의 ? BindingInitialization 을 반환합니다.
BindingPattern : ArrayBindingPattern
iteratorRecord 를 ? GetIterator (value , sync )로 둡니다.result 를 인수 iteratorRecord 및 envRecord 를 사용한 ArrayBindingPattern 의 IteratorBindingInitialization 의 Completion 으로 둡니다.iteratorRecord .[[Done]] 이 false 이면, ? IteratorClose (iteratorRecord , result )를 반환합니다.? result 를 반환합니다.
ObjectBindingPattern :
{
}
unused 를 반환합니다.
ObjectBindingPattern :
{
BindingPropertyList
,opt
}
인수 value 및 envRecord 를 사용한 BindingPropertyList 의 ? PropertyBindingInitialization 을 수행합니다. unused 를 반환합니다.
ObjectBindingPattern :
{
BindingRestProperty
}
excludedNames 를 새로운 빈 List 로 둡니다.인수 value , envRecord 및 excludedNames 를 사용한 BindingRestProperty 의 ? RestBindingInitialization 을 반환합니다.
ObjectBindingPattern :
{
BindingPropertyList
,
BindingRestProperty
}
excludedNames 를 인수 value 및 envRecord 를 사용한 BindingPropertyList 의 ? PropertyBindingInitialization 으로 둡니다.인수 value , envRecord 및 excludedNames 를 사용한 BindingRestProperty 의 ? RestBindingInitialization 을 반환합니다.
8.6.2.1 InitializeBoundName ( name , value , envRecord )
추상 연산 InitializeBoundName. 인수 name (String), value (ECMAScript 언어 값 ) 및 envRecord ((Environment 레코드 또는 undefined )). 반환값: (정상 완료 (값: unused ) 또는 중도 완료). 호출되면 다음 단계를 수행한다.
envRecord 가 undefined 가 아니면, 다음을 수행합니다.! envRecord .InitializeBinding (name , value )을 수행합니다. unused 를 반환합니다.lhs 를 ? ResolveBinding (name )으로 둡니다.? PutValue (lhs , value )를 반환합니다.
8.6.3 Runtime Semantics: IteratorBindingInitialization
구문 지향 연산 IteratorBindingInitialization. 인수 iteratorRecord (Iterator 레코드 ) 및 envRecord ((Environment 레코드 또는 undefined )). 반환값: (정상 완료 (값: unused ) 또는 중도 완료).
참고
envRecord 에 undefined 가 전달되면 초기화 값을 할당하는 데 PutValue 연산을 사용해야 함을 나타냅니다. 이는 비엄격 함수 의 형식 매개변수 목록에서 발생합니다. 이 경우 동일한 이름을 갖는 여러 매개변수가 존재할 가능성을 처리하기 위해 형식 매개변수 바인딩을 미리 초기화합니다.
다음 생성 규칙별로 정의된다.
ArrayBindingPattern :
[
]
unused 를 반환합니다.
ArrayBindingPattern :
[
Elision
]
인수 iteratorRecord 를 사용한 Elision 의 ? IteratorDestructuringAssignmentEvaluation 을 반환합니다.
ArrayBindingPattern :
[
Elision opt
BindingRestElement
]
Elision 이 존재하면, 다음을 수행합니다.인수 iteratorRecord 를 사용한 Elision 의 ? IteratorDestructuringAssignmentEvaluation 을 수행합니다. 인수 iteratorRecord 및 envRecord 를 사용한 BindingRestElement 의 ? IteratorBindingInitialization 을 반환합니다.
ArrayBindingPattern :
[
BindingElementList
,
Elision
]
인수 iteratorRecord 및 envRecord 를 사용한 BindingElementList 의 ? IteratorBindingInitialization 을 수행합니다. 인수 iteratorRecord 를 사용한 Elision 의 ? IteratorDestructuringAssignmentEvaluation 을 반환합니다.
ArrayBindingPattern :
[
BindingElementList
,
Elision opt
BindingRestElement
]
인수 iteratorRecord 및 envRecord 를 사용한 BindingElementList 의 ? IteratorBindingInitialization 을 수행합니다. Elision 이 존재하면, 다음을 수행합니다.인수 iteratorRecord 를 사용한 Elision 의 ? IteratorDestructuringAssignmentEvaluation 을 수행합니다. 인수 iteratorRecord 및 envRecord 를 사용한 BindingRestElement 의 ? IteratorBindingInitialization 을 반환합니다.
BindingElementList :
BindingElementList
,
BindingElisionElement
인수 iteratorRecord 및 envRecord 를 사용한 BindingElementList 의 ? IteratorBindingInitialization 을 수행합니다. 인수 iteratorRecord 및 envRecord 를 사용한 BindingElisionElement 의 ? IteratorBindingInitialization 을 반환합니다.
BindingElisionElement :
Elision
BindingElement
인수 iteratorRecord 를 사용한 Elision 의 ? IteratorDestructuringAssignmentEvaluation 을 수행합니다. 인수 iteratorRecord 및 envRecord 를 사용한 BindingElement 의 ? IteratorBindingInitialization 을 반환합니다.
SingleNameBinding :
BindingIdentifier
Initializer opt
name 을 BindingIdentifier 의 StringValue 로 둡니다.lhs 를 ? ResolveBinding (name , envRecord )로 둡니다.value 를 undefined 로 둡니다.iteratorRecord .[[Done]] 이 false 이면, 다음을 수행합니다.next 를 ? IteratorStepValue (iteratorRecord )로 둡니다.next 가 done 이 아니면, 다음을 수행합니다.value 를 next 로 설정합니다.Initializer 가 존재하고 value 가 undefined 이면, 다음을 수행합니다.IsAnonymousFunctionDefinition (Initializer )이 true 이면, 다음을 수행합니다.value 를 인수 name 을 사용한 Initializer 의 ? NamedEvaluation 으로 설정합니다.그렇지 않으면,defaultValue 를 Initializer 의 ? Evaluation 으로 둡니다.value 를 ? GetValue (defaultValue )로 설정합니다. envRecord 가 undefined 이면, ? PutValue (lhs , value )를 반환합니다.? InitializeReferencedBinding (lhs , value )을 반환합니다.
BindingElement :
BindingPattern
Initializer opt
value 를 undefined 로 둡니다.iteratorRecord .[[Done]] 이 false 이면, 다음을 수행합니다.next 를 ? IteratorStepValue (iteratorRecord )로 둡니다.next 가 done 이 아니면, 다음을 수행합니다.value 를 next 로 설정합니다.Initializer 가 존재하고 value 가 undefined 이면, 다음을 수행합니다.defaultValue 를 Initializer 의 ? Evaluation 으로 둡니다.value 를 ? GetValue (defaultValue )로 설정합니다.인수 value 및 envRecord 를 사용한 BindingPattern 의 ? BindingInitialization 을 반환합니다.
BindingRestElement :
...
BindingIdentifier
lhs 를 ? ResolveBinding (BindingIdentifier 의 StringValue , envRecord )로 둡니다.array 를 ! ArrayCreate (0)으로 둡니다.n 을 0으로 둡니다.다음을 반복합니다.next 를 done 으로 둡니다.iteratorRecord .[[Done]] 이 false 이면, 다음을 수행합니다.next 를 ? IteratorStepValue (iteratorRecord )로 설정합니다.next 가 done 이면, 다음을 수행합니다.envRecord 가 undefined 이면, ? PutValue (lhs , array )를 반환합니다.? InitializeReferencedBinding (lhs , array )을 반환합니다. ! CreateDataPropertyOrThrow (array , ! ToString (𝔽 (n )), next )를 수행합니다. n 을 n + 1로 설정합니다.
BindingRestElement :
...
BindingPattern
array 를 ! ArrayCreate (0)으로 둡니다.n 을 0으로 둡니다.다음을 반복합니다.next 를 done 으로 둡니다.iteratorRecord .[[Done]] 이 false 이면, 다음을 수행합니다.next 를 ? IteratorStepValue (iteratorRecord )로 설정합니다.next 가 done 이면, 다음을 수행합니다.인수 array 및 envRecord 를 사용한 BindingPattern 의 ? BindingInitialization 을 반환합니다. ! CreateDataPropertyOrThrow (array , ! ToString (𝔽 (n )), next )를 수행합니다. n 을 n + 1로 설정합니다.
FormalParameters : [empty]
unused 를 반환합니다.
FormalParameters :
FormalParameterList
,
FunctionRestParameter
인수 iteratorRecord 및 envRecord 를 사용한 FormalParameterList 의 ? IteratorBindingInitialization 을 수행합니다. 인수 iteratorRecord 및 envRecord 를 사용한 FunctionRestParameter 의 ? IteratorBindingInitialization 을 반환합니다.
FormalParameterList :
FormalParameterList
,
FormalParameter
인수 iteratorRecord 및 envRecord 를 사용한 FormalParameterList 의 ? IteratorBindingInitialization 을 수행합니다. 인수 iteratorRecord 및 envRecord 를 사용한 FormalParameter 의 ? IteratorBindingInitialization 을 반환합니다.
ArrowParameters : BindingIdentifier
value 를 undefined 로 둡니다.단언 : iteratorRecord .[[Done]] 은 false 입니다.next 를 ? IteratorStepValue (iteratorRecord )로 둡니다.next 가 done 이 아니면, 다음을 수행합니다.value 를 next 로 설정합니다.인수 value 및 envRecord 를 사용한 BindingIdentifier 의 ? BindingInitialization 을 반환합니다.
ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList
formals 를 CoverParenthesizedExpressionAndArrowParameterList 가 포괄하는 ArrowFormalParameters 로 둡니다.인수 iteratorRecord 및 envRecord 를 사용한 formals 의 ? IteratorBindingInitialization 을 반환합니다.
AsyncArrowBindingIdentifier : BindingIdentifier
value 를 undefined 로 둡니다.단언 : iteratorRecord .[[Done]] 은 false 입니다.next 를 ? IteratorStepValue (iteratorRecord )로 둡니다.next 가 done 이 아니면, 다음을 수행합니다.value 를 next 로 설정합니다.인수 value 및 envRecord 를 사용한 BindingIdentifier 의 ? BindingInitialization 을 반환합니다.
8.6.4 Static Semantics: AssignmentTargetType
구문 지향 연산 AssignmentTargetType. 인수 없음. 반환값: (simple , web-compat 또는 invalid ). 다음 생성 규칙별로 정의된다.
IdentifierReference : Identifier
IsStrict (this IdentifierReference )가 true 이고 Identifier 의 StringValue 가 "eval" 또는 "arguments" 이면, invalid 를 반환합니다.simple 을 반환합니다.
IdentifierReference :
yield
await
CallExpression :
CallExpression
[
Expression
]
CallExpression
.
IdentifierName
CallExpression
.
PrivateIdentifier
MemberExpression :
MemberExpression
[
Expression
]
MemberExpression
.
IdentifierName
SuperProperty
MemberExpression
.
PrivateIdentifier
simple 을 반환합니다.
PrimaryExpression :
CoverParenthesizedExpressionAndArrowParameterList
expr 을 CoverParenthesizedExpressionAndArrowParameterList 가 포괄하는 ParenthesizedExpression 로 둡니다.expr 의 AssignmentTargetType 을 반환합니다.
CallExpression :
CoverCallExpressionAndAsyncArrowHead
CallExpression
Arguments
Normative Optional
호스트 가 웹 브라우저이거나 그 밖의 방식으로 함수 호출 할당 대상의 런타임 오류 을 지원하고 IsStrict (this CallExpression )가 false 이면, 다음을 수행합니다.web-compat 을 반환합니다.invalid 를 반환합니다.
PrimaryExpression :
this
Literal
ArrayLiteral
ObjectLiteral
FunctionExpression
ClassExpression
GeneratorExpression
AsyncFunctionExpression
AsyncGeneratorExpression
RegularExpressionLiteral
TemplateLiteral
CallExpression :
SuperCall
ImportCall
CallExpression
TemplateLiteral
NewExpression :
new
NewExpression
MemberExpression :
MemberExpression
TemplateLiteral
new
MemberExpression
Arguments
NewTarget :
new
.
target
ImportMeta :
import
.
meta
LeftHandSideExpression :
OptionalExpression
UpdateExpression :
LeftHandSideExpression
++
LeftHandSideExpression
--
++
UnaryExpression
--
UnaryExpression
UnaryExpression :
delete
UnaryExpression
void
UnaryExpression
typeof
UnaryExpression
+
UnaryExpression
-
UnaryExpression
~
UnaryExpression
!
UnaryExpression
CoverAwaitExpressionAndAwaitUsingDeclarationHead
ExponentiationExpression :
UpdateExpression
**
ExponentiationExpression
MultiplicativeExpression :
MultiplicativeExpression
MultiplicativeOperator
ExponentiationExpression
AdditiveExpression :
AdditiveExpression
+
MultiplicativeExpression
AdditiveExpression
-
MultiplicativeExpression
ShiftExpression :
ShiftExpression
<<
AdditiveExpression
ShiftExpression
>>
AdditiveExpression
ShiftExpression
>>>
AdditiveExpression
RelationalExpression :
RelationalExpression
<
ShiftExpression
RelationalExpression
>
ShiftExpression
RelationalExpression
<=
ShiftExpression
RelationalExpression
>=
ShiftExpression
RelationalExpression
instanceof
ShiftExpression
RelationalExpression
in
ShiftExpression
PrivateIdentifier
in
ShiftExpression
EqualityExpression :
EqualityExpression
==
RelationalExpression
EqualityExpression
!=
RelationalExpression
EqualityExpression
===
RelationalExpression
EqualityExpression
!==
RelationalExpression
BitwiseANDExpression :
BitwiseANDExpression
&
EqualityExpression
BitwiseXORExpression :
BitwiseXORExpression
^
BitwiseANDExpression
BitwiseORExpression :
BitwiseORExpression
|
BitwiseXORExpression
LogicalANDExpression :
LogicalANDExpression
&&
BitwiseORExpression
LogicalORExpression :
LogicalORExpression
||
LogicalANDExpression
CoalesceExpression :
CoalesceExpressionHead
??
BitwiseORExpression
ConditionalExpression :
ShortCircuitExpression
?
AssignmentExpression
:
AssignmentExpression
AssignmentExpression :
YieldExpression
ArrowFunction
AsyncArrowFunction
LeftHandSideExpression
=
AssignmentExpression
LeftHandSideExpression
AssignmentOperator
AssignmentExpression
LeftHandSideExpression
&&=
AssignmentExpression
LeftHandSideExpression
||=
AssignmentExpression
LeftHandSideExpression
??=
AssignmentExpression
Expression :
Expression
,
AssignmentExpression
invalid 를 반환합니다.
8.6.5 Static Semantics: PropName
구문 지향 연산 PropName. 인수 없음. 반환값: (String 또는 empty ). 다음 생성 규칙별로 정의된다.
PropertyDefinition : IdentifierReference
IdentifierReference 의 StringValue 를 반환합니다.
PropertyDefinition :
...
AssignmentExpression
empty 를 반환합니다.
PropertyDefinition :
PropertyName
:
AssignmentExpression
PropertyName 의 PropName 을 반환합니다.
LiteralPropertyName : IdentifierName
AttributeKey : IdentifierName
IdentifierName 의 StringValue 를 반환합니다.
LiteralPropertyName : StringLiteral
AttributeKey : StringLiteral
StringLiteral 의 SV 를 반환합니다.
LiteralPropertyName : NumericLiteral
number 를 NumericLiteral 의 NumericValue 로 둡니다.! ToString (number )을 반환합니다.
ComputedPropertyName :
[
AssignmentExpression
]
empty 를 반환합니다.
MethodDefinition :
ClassElementName
(
UniqueFormalParameters
)
{
FunctionBody
}
get
ClassElementName
(
)
{
FunctionBody
}
set
ClassElementName
(
PropertySetParameterList
)
{
FunctionBody
}
ClassElementName 의 PropName 을 반환합니다.
GeneratorMethod :
*
ClassElementName
(
UniqueFormalParameters
)
{
GeneratorBody
}
ClassElementName 의 PropName 을 반환합니다.
AsyncGeneratorMethod :
async
*
ClassElementName
(
UniqueFormalParameters
)
{
AsyncGeneratorBody
}
ClassElementName 의 PropName 을 반환합니다.
ClassElement : ClassStaticBlock
empty 를 반환합니다.
ClassElement : ;
empty 를 반환합니다.
AsyncMethod :
async
ClassElementName
(
UniqueFormalParameters
)
{
AsyncFunctionBody
}
ClassElementName 의 PropName 을 반환합니다.
FieldDefinition :
ClassElementName
Initializer opt
ClassElementName 의 PropName 을 반환합니다.
ClassElementName : PrivateIdentifier
empty 를 반환합니다.
8.6.6 Static Semantics: ContainsUsing
구문 지향 연산 ContainsUsing. 인수 없음. 반환값: Boolean. 다음 생성 규칙별로 정의된다.
StatementList :
StatementList
StatementListItem
파생된 StatementList 의 ContainsUsing 이 true 이면, true 를 반환합니다. StatementListItem 의 ContainsUsing 이 true 이면, true 를 반환합니다.false 를 반환합니다.
StatementListItem : Statement
false 를 반환합니다.
StatementListItem : Declaration
Declaration 의 IsUsingDeclaration 이 true 이면, true 를 반환합니다.Declaration 의 IsAwaitUsingDeclaration 이 true 이면, true 를 반환합니다.false 를 반환합니다.
9 실행 가능 코드와 실행 컨텍스트
9.1 Environment Record
Environment Record 는 ECMAScript 코드의 렉시컬 중첩 구조를 기반으로 Identifier 를 특정 변수 및 함수와 연결하는 관계를 정의하는 데 사용하는 명세 타입입니다. 일반적으로 Environment Record는 FunctionDeclaration , BlockStatement 또는 TryStatement 의 Catch 절과 같은 ECMAScript 코드의 특정 구문 구조와 연결됩니다. 이러한 코드가 평가될 때마다 해당 코드가 생성하는 식별자 바인딩을 기록하기 위해 새로운 Environment Record가 생성됩니다.
모든 Environment Record에는 [[OuterEnv]] 필드가 있으며, 이 필드는 null 이거나 바깥쪽 Environment Record에 대한 참조입니다. 이는 Environment Record의 논리적 중첩을 모델링하는 데 사용됩니다. (안쪽) Environment Record의 바깥쪽 참조는 해당 안쪽 Environment Record를 논리적으로 둘러싸는 Environment Record에 대한 참조입니다. 물론 바깥쪽 Environment Record 자체도 자신의 바깥쪽 Environment Record를 가질 수 있습니다. 하나의 Environment Record는 여러 안쪽 Environment Record의 바깥쪽 환경으로 사용될 수 있습니다. 예를 들어 FunctionDeclaration 에 두 개의 중첩된 FunctionDeclaration 이 포함되어 있으면, 각 중첩 함수의 Environment Record는 둘러싸는 함수의 현재 평가에 대한 Environment Record를 바깥쪽 Environment Record로 갖습니다.
Environment Record는 순수하게 명세상의 메커니즘이며 ECMAScript 구현체의 특정 산출물과 대응할 필요는 없습니다. ECMAScript 프로그램에서 이러한 값에 직접 접근하거나 조작하는 것은 불가능합니다.
9.1.1 Environment Record 타입 계층
Environment Record 는 단순한 객체 지향 계층 구조에 존재한다고 생각할 수 있습니다. 여기에서 Environment Record 는 세 개의 구체적인 하위 클래스인 Declarative Environment Record , Object Environment Record 및 Global Environment Record 를 갖는 추상 클래스입니다. Function Environment Record 와 Module Environment Record 는 Declarative Environment Record 의 하위 클래스입니다.
Environment Record 추상 클래스에는 표 15 에 정의된 추상 명세 메서드가 포함됩니다. 이러한 추상 메서드는 각 구체적인 하위 클래스마다 서로 다른 구체적 알고리즘을 갖습니다.
표 15: Environment Records 의 추상 메서드
메서드
목적
정의
HasBinding ( name )
추상 메서드 HasBinding. 인수 name (String). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ).
Environment Record 에 name 에 대한 바인딩이 있는지 결정합니다.
다음 타입에 구체적인 정의가 있습니다:
CreateMutableBinding ( name , deletable )
추상 메서드 CreateMutableBinding. 인수 name (String) 및 deletable (Boolean). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ).
Environment Record 에 새롭지만 초기화되지 않은 변경 가능한 바인딩을 생성합니다. name 은 바인딩된 이름의 텍스트입니다. deletable 이 true 이면 나중에 해당 바인딩을 삭제할 수 있습니다.
다음 타입에 구체적인 정의가 있습니다:
CreateImmutableBinding ( name , strict )
추상 메서드 CreateImmutableBinding. 인수 name (String) 및 strict (Boolean). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ).
Environment Record 에 새롭지만 초기화되지 않은 변경 불가능한 바인딩을 생성합니다. name 은 바인딩된 이름의 텍스트입니다. strict 가 true 이면 해당 바인딩이 초기화된 후 이를 설정하려는 시도는 해당 바인딩을 참조하는 연산의 엄격 모드 설정과 관계없이 항상 예외를 던집니다.
다음 타입에 구체적인 정의가 있습니다:
InitializeBinding ( name , value )
추상 메서드 InitializeBinding. 인수 name (String) 및 value (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ).
Environment Record 에 이미 존재하지만 초기화되지 않은 바인딩의 값을 설정합니다. name 은 바인딩된 이름의 텍스트입니다. value 는 바인딩에 사용할 값입니다.
다음 타입에 구체적인 정의가 있습니다:
SetMutableBinding ( name , value , strict )
추상 메서드 SetMutableBinding. 인수 name (String), value (ECMAScript 언어 값 ) 및 strict (Boolean). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ).
Environment Record 에 이미 존재하는 변경 가능한 바인딩의 값을 설정합니다. name 은 바인딩된 이름의 텍스트입니다. value 는 바인딩의 값입니다. strict 가 true 이고 바인딩을 설정할 수 없으면 TypeError 예외를 던집니다.
다음 타입에 구체적인 정의가 있습니다:
GetBindingValue ( name , strict )
추상 메서드 GetBindingValue. 인수 name (String) 및 strict (Boolean). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 throw 완료 ).
Environment Record 에 이미 존재하는 바인딩의 값을 반환합니다. name 은 바인딩된 이름의 텍스트입니다. strict 는 엄격 모드 코드 에서 시작된 참조 또는 그 밖에 엄격 모드 참조 의미론이 필요한 참조를 식별하는 데 사용됩니다. strict 가 true 이고 바인딩이 존재하지 않으면 ReferenceError 예외를 던집니다. 바인딩은 존재하지만 초기화되지 않았으면 strict 값과 관계없이 ReferenceError 를 던집니다.
다음 타입에 구체적인 정의가 있습니다:
DeleteBinding ( name )
추상 메서드 DeleteBinding. 인수 name (String). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ).
Environment Record 에서 바인딩을 삭제합니다. name 은 바인딩된 이름의 텍스트입니다. name 에 대한 바인딩이 존재하면 해당 바인딩을 제거하고 true 를 반환합니다. 바인딩이 존재하지만 제거할 수 없으면 false 를 반환합니다. 바인딩이 존재하지 않으면 true 를 반환합니다.
다음 타입에 구체적인 정의가 있습니다:
HasThisBinding ( )
추상 메서드 HasThisBinding. 인수 없음. 반환값: Boolean.
Environment Record 가 this 바인딩을 설정하는지 결정합니다. 설정하면 true 를 반환하고 그렇지 않으면 false 를 반환합니다.
다음 타입에 구체적인 정의가 있습니다:
GetThisBinding ( )
추상 메서드 GetThisBinding. 인수 없음. 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 throw 완료 ).
이 Environment Record 의 this 바인딩 값을 반환합니다. this 바인딩이 초기화되지 않았으면 ReferenceError 를 던집니다.
다음 타입에 구체적인 정의가 있습니다:
HasSuperBinding ( )
추상 메서드 HasSuperBinding. 인수 없음. 반환값: Boolean.
Environment Record 가 super 메서드 바인딩을 설정하는지 결정합니다. 설정하면 true 를 반환하고 그렇지 않으면 false 를 반환합니다. true 를 반환하면 해당 Environment Record 가 Function Environment Record 임을 의미하지만, 그 역은 성립하지 않습니다.
다음 타입에 구체적인 정의가 있습니다:
WithBaseObject ( )
추상 메서드 WithBaseObject. 인수 없음. 반환값: (Object 또는 undefined ).
이 Environment Record 가 with 문과 연결되어 있으면 with 객체를 반환합니다. 그렇지 않으면 undefined 를 반환합니다.
다음 타입에 구체적인 정의가 있습니다:
9.1.1.1 Declarative Environment Record
각 Declarative Environment Record 는 변수, 상수, let, 클래스, 모듈, import 및/또는 함수 선언을 포함하는 ECMAScript 프로그램 스코프와 연결됩니다. Declarative Environment Record는 해당 스코프 안의 선언에서 정의한 식별자 집합을 바인딩합니다.
모든 Declarative Environment Record에는 DisposableResource Record 의 List 를 포함하는 [[DisposableResourceStack]] 필드도 있습니다. 이 목록의 요소는 Environment Record 를 생성한 Evaluation 단계가 완료될 때 폐기해야 하는 using 선언 및 await using 선언에 의해 추적됩니다.
9.1.1.1.1 HasBinding ( name )
a Declarative Environment Record envRecord 의 구체 메서드 HasBinding . 인수 name (String). 반환값: 정상 완료 (값: Boolean). 인수 식별자가 해당 Record 에 의해 바인딩된 식별자 중 하나인지 결정합니다. 호출되면 다음 단계를 수행한다.
envRecord 에 name 에 대한 바인딩이 있으면, true 를 반환합니다.false 를 반환합니다.
9.1.1.1.2 CreateMutableBinding ( name , deletable )
a Declarative Environment Record envRecord 의 구체 메서드 CreateMutableBinding . 인수 name (String) 및 deletable (Boolean). 반환값: 정상 완료 (값: unused ). 초기화되지 않은 이름 name 에 대한 새로운 변경 가능한 바인딩을 생성합니다. 이 Environment Record 에는 name 에 대한 바인딩이 이미 존재해서는 안 됩니다. deletable 이 true 이면 새 바인딩을 삭제할 수 있는 것으로 표시합니다. 호출되면 다음 단계를 수행한다.
단언 : envRecord 에는 name 에 대한 바인딩이 이미 존재하지 않습니다.envRecord 에 name 에 대한 변경 가능한 바인딩을 생성하고 초기화되지 않았음을 기록합니다. deletable 이 true 이면 새로 생성한 바인딩을 이후의 DeleteBinding 호출로 삭제할 수 있음을 기록합니다.unused 를 반환합니다.
9.1.1.1.3 CreateImmutableBinding ( name , strict )
a Declarative Environment Record envRecord 의 구체 메서드 CreateImmutableBinding . 인수 name (String) 및 strict (Boolean). 반환값: 정상 완료 (값: unused ). 초기화되지 않은 이름 name 에 대한 새로운 변경 불가능한 바인딩을 생성합니다. 이 Environment Record 에는 name 에 대한 바인딩이 이미 존재해서는 안 됩니다. strict 가 true 이면 새 바인딩을 엄격 바인딩으로 표시합니다. 호출되면 다음 단계를 수행한다.
단언 : envRecord 에는 name 에 대한 바인딩이 이미 존재하지 않습니다.envRecord 에 name 에 대한 변경 불가능한 바인딩을 생성하고 초기화되지 않았음을 기록합니다. strict 가 true 이면 새로 생성한 바인딩을 엄격 바인딩으로 기록합니다.unused 를 반환합니다.
9.1.1.1.4 InitializeBinding ( name , value )
a Declarative Environment Record envRecord 의 구체 메서드 InitializeBinding . 인수 name (String) 및 value (ECMAScript 언어 값 ). 반환값: 정상 완료 (값: unused ). 이 메서드는 이름이 name 인 식별자의 현재 바인딩 값을 value 값으로 설정하는 데 사용됩니다. name 에 대한 초기화되지 않은 바인딩이 이미 존재해야 합니다. 호출되면 다음 단계를 수행한다.
단언 : envRecord 에는 name 에 대한 초기화되지 않은 바인딩이 있어야 합니다.envRecord 에서 name 의 바인딩된 값을 value 로 설정합니다.envRecord 에서 name 에 대한 바인딩이 초기화되었음을 기록 합니다.unused 를 반환합니다.
9.1.1.1.5 SetMutableBinding ( name , value , strict )
a Declarative Environment Record envRecord 의 구체 메서드 SetMutableBinding . 인수 name (String), value (ECMAScript 언어 값 ) 및 strict (Boolean). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 이름이 name 인 식별자의 현재 바인딩 값을 value 값으로 변경하려고 시도합니다. 일반적으로 name 에 대한 바인딩이 이미 존재하지만 드문 경우에는 존재하지 않을 수 있습니다. 바인딩이 변경 불가능한 바인딩이고 strict 가 true 이면 TypeError 를 던집니다. 호출되면 다음 단계를 수행한다.
envRecord 에 name 에 대한 바인딩이 없으면, 다음을 수행합니다.strict 가 true 이면, ReferenceError 예외를 던집니다.! envRecord .CreateMutableBinding (name , true )를 수행합니다. ! envRecord .InitializeBinding (name , value )을 수행합니다. unused 를 반환합니다.envRecord 에서 name 에 대한 바인딩이 엄격 바인딩이면 strict 를 true 로 설정합니다.envRecord 에서 name 에 대한 바인딩이 아직 초기화되지 않았으면, 다음을 수행합니다.ReferenceError 예외를 던집니다.그렇지 않고 envRecord 에서 name 에 대한 바인딩이 변경 가능한 바인딩이면, 다음을 수행합니다.해당 바인딩 값을 value 로 변경합 니다. 그렇지 않으면,단언 : 이는 변경 불가능한 바인딩의 값을 변경하려는 시도입니다.strict 가 true 이면, TypeError 예외를 던집니다. unused 를 반환합니다.
참고
1 단계에서 누락된 바인딩이 발생하는 ECMAScript 코드의 예는 다음과 같습니다:
function f ( ) { eval ("var x; x = (delete x, 0);" ); }
9.1.1.1.6 GetBindingValue ( name , strict )
a Declarative Environment Record envRecord 의 구체 메서드 GetBindingValue . 인수 name (String) 및 strict (Boolean). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 throw 완료 ). 이름이 name 인 바인딩된 식별자의 값을 반환합니다. 바인딩은 존재하지만 초기화되지 않았으면 strict 값과 관계없이 ReferenceError 를 던집니다. 호출되면 다음 단계를 수행한다.
단언 : envRecord 에는 name 에 대한 바인딩이 있습니다.envRecord 에서 name 에 대한 바인딩이 초기화되지 않은 바인딩이면, ReferenceError 예외를 던집니다.현재 envRecord 에서 name 에 바인딩된 값을 반환합니다.
9.1.1.1.7 DeleteBinding ( name )
a Declarative Environment Record envRecord 의 구체 메서드 DeleteBinding . 인수 name (String). 반환값: 정상 완료 (값: Boolean). 명시적으로 삭제 가능 대상으로 지정된 바인딩만 삭제할 수 있습니다. 호출되면 다음 단계를 수행한다.
단언 : envRecord 에는 name 에 대한 바인딩이 있습니다.name 에 대한 바인딩을 삭제할 수 없으면, false 를 반환합니다.envRecord 에서 name 에 대한 바인딩을 제거합니다.true 를 반환합니다.
9.1.1.1.8 HasThisBinding ( )
a Declarative Environment Record envRecord 의 구체 메서드 HasThisBinding . 인수 없음. 반환값: false . 호출되면 다음 단계를 수행한다.
false 를 반환합니다.
참고
9.1.1.1.9 GetThisBinding ( )
Declarative Environment Record 의 GetThisBinding 구체 메서드는 이 명세에서 절대로 사용되지 않습니다.
9.1.1.1.10 HasSuperBinding ( )
a Declarative Environment Record envRecord 의 구체 메서드 HasSuperBinding . 인수 없음. 반환값: false . 호출되면 다음 단계를 수행한다.
false 를 반환합니다.
참고
9.1.1.1.11 WithBaseObject ( )
a Declarative Environment Record envRecord 의 구체 메서드 WithBaseObject . 인수 없음. 반환값: undefined . 호출되면 다음 단계를 수행한다.
undefined 를 반환합니다.
9.1.1.2 Object Environment Record
각 Object Environment Record 는 바인딩 객체 라고 하는 객체와 연결됩니다. Object Environment Record는 자신의 바인딩 객체의 프로퍼티 이름 과 직접 대응하는 문자열 식별자 이름 집합을 바인딩합니다. IdentifierName 형태의 String이 아닌 프로퍼티 키 는 바인딩된 식별자 집합에 포함되지 않습니다. [[Enumerable]] 속성의 설정과 관계없이 자체 프로퍼티와 상속된 프로퍼티를 모두 집합에 포함합니다. 객체에 프로퍼티를 동적으로 추가하거나 삭제할 수 있으므로 Object Environment Record가 바인딩하는 식별자 집합은 프로퍼티를 추가하거나 삭제하는 모든 연산의 부작용으로 변경될 수 있습니다. 이러한 부작용의 결과로 생성되는 모든 바인딩은 대응하는 프로퍼티의 Writable 속성이 false 이더라도 변경 가능한 바인딩으로 간주합니다. Object Environment Record에는 변경 불가능한 바인딩이 존재하지 않습니다.
with 문(14.11 )을 위해 생성된 Object Environment Record는 함수 호출에 사용할 암묵적인 this 값으로 자신의 바인딩 객체를 제공할 수 있습니다. 이 기능은 Boolean [[IsWithEnvironment]] 필드로 제어됩니다.
Object Environment Record에는 표 16 에 나열된 추가 상태 필드가 있습니다.
표 16: Object Environment Record 의 추가 필드
9.1.1.2.1 HasBinding ( name )
an Object Environment Record envRecord 의 구체 메서드 HasBinding . 인수 name (String). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 연결된 바인딩 객체에 이름이 name 인 프로퍼티가 있는지 결정합니다. 호출되면 다음 단계를 수행한다.
bindingObj 를 envRecord .[[BindingObject]] 로 둡니다.foundBinding 을 ? HasProperty (bindingObj , name )으로 둡니다.foundBinding 이 false 이면, false 를 반환합니다.envRecord .[[IsWithEnvironment]] 가 false 이면, true 를 반환합니다.unscopables 를 ? Get (bindingObj , %Symbol.unscopables% )로 둡니다.unscopables 가 Object이면, 다음을 수행합니다.blocked 를 ToBoolean (? Get (unscopables , name ))로 둡니다.blocked 가 true 이면, false 를 반환합니다.true 를 반환합니다.
9.1.1.2.2 CreateMutableBinding ( name , deletable )
an Object Environment Record envRecord 의 구체 메서드 CreateMutableBinding . 인수 name (String) 및 deletable (Boolean). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). Environment Record 와 연결된 바인딩 객체에 이름이 name 인 프로퍼티를 생성하고 undefined 값으로 초기화합니다. deletable 이 true 이면 새 프로퍼티의 [[Configurable]] 속성을 true 로 설정하고, 그렇지 않으면 false 로 설정합니다. 호출되면 다음 단계를 수행한다.
bindingObj 를 envRecord .[[BindingObject]] 로 둡니다.? DefinePropertyOrThrow (bindingObj , name , PropertyDescriptor { [[Value]] : undefined , [[Writable]] : true , [[Enumerable]] : true , [[Configurable]] : deletable })를 수행합니다. unused 를 반환합니다.
참고
일반적으로 envRecord 에는 name 에 대한 바인딩이 없지만, 바인딩이 있는 경우 DefinePropertyOrThrow 의 의미론에 따라 기존 바인딩이 교체되거나 가려지거나 비정상 완료 가 반환될 수 있습니다.
9.1.1.2.3 CreateImmutableBinding ( name , strict )
Object Environment Record 의 CreateImmutableBinding 구체 메서드는 이 명세에서 절대로 사용되지 않습니다.
9.1.1.2.4 InitializeBinding ( name , value )
an Object Environment Record envRecord 의 구체 메서드 InitializeBinding . 인수 name (String) 및 value (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 이름이 name 인 식별자의 현재 바인딩 값을 value 값으로 설정하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
? envRecord .SetMutableBinding (name , value , false ) 를 수행합니다. unused 를 반환합니다.
참고
이 명세에서 Object Environment Record 에 대한 CreateMutableBinding 의 모든 사용은 같은 이름에 대한 InitializeBinding 호출이 바로 뒤따릅니다. 따라서 이 명세에서는 Object Environment Record 의 바인딩 초기화 상태를 명시적으로 추적하지 않습니다.
9.1.1.2.5 SetMutableBinding ( name , value , strict )
an Object Environment Record envRecord 의 구체 메서드 SetMutableBinding . 인수 name (String), value (ECMAScript 언어 값 ) 및 strict (Boolean). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). Environment Record 와 연결된 바인딩 객체에서 이름이 name 인 프로퍼티 값을 value 값으로 설정하려고 시도합니다. 일반적으로 name 이라는 프로퍼티가 이미 존재하지만, 존재하지 않거나 현재 쓰기 가능하지 않은 경우 오류 처리는 strict 에 따라 결정됩니다. 호출되면 다음 단계를 수행한다.
bindingObj 를 envRecord .[[BindingObject]] 로 둡니다.stillExists 를 ? HasProperty (bindingObj , name )으로 둡니다.stillExists 가 false 이고 strict 가 true 이면, ReferenceError 예외를 던집니다.? Set (bindingObj , name , value , strict )를 수행합니다. unused 를 반환합니다.
9.1.1.2.6 GetBindingValue ( name , strict )
an Object Environment Record envRecord 의 구체 메서드 GetBindingValue . 인수 name (String) 및 strict (Boolean). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 throw 완료 ). 연결된 바인딩 객체에서 이름이 name 인 프로퍼티의 값을 반환합니다. 해당 프로퍼티는 이미 존재해야 하지만 존재하지 않는 경우 결과는 strict 에 따라 달라집니다. 호출되면 다음 단계를 수행한다.
bindingObj 를 envRecord .[[BindingObject]] 로 둡니다.value 를 ? HasProperty (bindingObj , name )으로 둡니다.value 가 false 이면, 다음을 수행합니다.strict 가 false 이면, undefined 를 반환합니다.ReferenceError 예외를 던집니다.? Get (bindingObj , name )을 반환합니다.
9.1.1.2.7 DeleteBinding ( name )
an Object Environment Record envRecord 의 구체 메서드 DeleteBinding . 인수 name (String). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 환경 객체의 [[Configurable]] 속성 값이 true 인 프로퍼티에 대응하는 바인딩만 삭제할 수 있습니다. 호출되면 다음 단계를 수행한다.
bindingObj 를 envRecord .[[BindingObject]] 로 둡니다.? bindingObj .[[Delete]] (name ) 을 반환합니다.
9.1.1.2.8 HasThisBinding ( )
an Object Environment Record envRecord 의 구체 메서드 HasThisBinding . 인수 없음. 반환값: false . 호출되면 다음 단계를 수행한다.
false 를 반환합니다.
참고
9.1.1.2.9 GetThisBinding ( )
Object Environment Record 의 GetThisBinding 구체 메서드는 이 명세에서 절대로 사용되지 않습니다.
9.1.1.2.10 HasSuperBinding ( )
an Object Environment Record envRecord 의 구체 메서드 HasSuperBinding . 인수 없음. 반환값: false . 호출되면 다음 단계를 수행한다.
false 를 반환합니다.
참고
9.1.1.2.11 WithBaseObject ( )
an Object Environment Record envRecord 의 구체 메서드 WithBaseObject . 인수 없음. 반환값: (Object 또는 undefined ). 호출되면 다음 단계를 수행한다.
envRecord .[[IsWithEnvironment]] 가 true 이면, envRecord .[[BindingObject]] 를 반환합니다.undefined 를 반환합니다.
9.1.1.3 Function Environment Record
Function Environment Record 는 함수의 최상위 스코프를 나타내는 데 사용하는 Declarative Environment Record 이며, 함수가 ArrowFunction 함수 또는 AsyncArrowFunction 함수가 아니면 this 바인딩을 제공합니다. 함수가 ArrowFunction 함수 또는 AsyncArrowFunction 함수가 아니고 super를 참조하면, 해당 Function Environment Record에는 함수 내부에서 super 메서드 호출을 수행하는 데 사용하는 상태도 포함됩니다.
Function Environment Record에는 표 17 에 나열된 추가 상태 필드가 있습니다.
표 17: Function Environment Record 의 추가 필드
Function Environment Record는 표 15 에 나열된 모든 Declarative Environment Record 메서드를 지원하며, HasThisBinding , GetThisBinding 및 HasSuperBinding 을 제외한 모든 메서드에 대해 동일한 명세를 공유합니다.
9.1.1.3.1 BindThisValue ( envRecord , value )
추상 연산 BindThisValue. 인수 envRecord (Function Environment 레코드 ) 및 value (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). envRecord .[[ThisValue]] 를 설정하고 초기화되었음을 기록합니다. 호출되면 다음 단계를 수행한다.
단언 : envRecord .[[ThisBindingStatus]] 는 lexical 이 아닙니다.envRecord .[[ThisBindingStatus]] 가 initialized 이면, ReferenceError 예외를 던집니다.envRecord .[[ThisValue]] 를 value 로 설정합니다.envRecord .[[ThisBindingStatus]] 를 initialized 로 설정합니다.unused 를 반환합니다.
9.1.1.3.2 HasThisBinding ( )
a Function Environment Record envRecord 의 구체 메서드 HasThisBinding . 인수 없음. 반환값: Boolean. 호출되면 다음 단계를 수행한다.
envRecord .[[ThisBindingStatus]] 가 lexical 이면, false 를 반환합니다.true 를 반환합니다.
9.1.1.3.3 GetThisBinding ( )
a Function Environment Record envRecord 의 구체 메서드 GetThisBinding . 인수 없음. 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
단언 : envRecord .[[ThisBindingStatus]] 는 lexical 이 아닙니다.envRecord .[[ThisBindingStatus]] 가 uninitialized 이면, ReferenceError 예외를 던집니다.envRecord .[[ThisValue]] 를 반환합니다.
9.1.1.3.4 HasSuperBinding ( )
a Function Environment Record envRecord 의 구체 메서드 HasSuperBinding . 인수 없음. 반환값: Boolean. 호출되면 다음 단계를 수행한다.
envRecord .[[ThisBindingStatus]] 가 lexical 이면, false 를 반환합니다.envRecord .[[FunctionObject]] .[[HomeObject]] 가 undefined 이면, false 를 반환합니다.true 를 반환합니다.
9.1.1.3.5 GetSuperBase ( envRecord )
추상 연산 GetSuperBase. 인수 envRecord (Function Environment 레코드 ). 반환값: (Object, null 또는 undefined ). envRecord 에 바인딩된 super 프로퍼티 접근의 기반이 되는 객체를 반환합니다. undefined 값은 이러한 접근이 런타임 오류를 생성함을 나타냅니다. 호출되면 다음 단계를 수행한다.
home 을 envRecord .[[FunctionObject]] .[[HomeObject]] 로 둡니다.home 이 undefined 이면, undefined 를 반환합니다.단언 : home 은 일반 객체 입니다.! home .[[GetPrototypeOf]] ()를 반환합니다.
9.1.1.4 Global Environment Record
Global Environment Record 는 공통 realm 에서 처리되는 모든 ECMAScript Script 요소가 공유하는 가장 바깥쪽 스코프를 나타내는 데 사용됩니다. Global Environment Record는 내장 전역(절 19 ), 전역 객체 의 프로퍼티 및 Script 내에서 발생하는 모든 최상위 선언(8.2.11 , 8.2.13 )에 대한 바인딩을 제공합니다.
Global Environment Record는 논리적으로 하나의 Record 이지만, Object Environment Record 와 Declarative Environment Record 를 캡슐화한 복합체로 명시됩니다. Object Environment Record 는 연결된 Realm Record 의 전역 객체 를 기반 객체로 갖습니다. 이 전역 객체 는 Global Environment Record의 GetThisBinding 구체 메서드가 반환하는 값입니다. Global Environment Record의 Object Environment Record 구성 요소에는 모든 내장 전역(절 19 )에 대한 바인딩과 전역 코드 에 포함된 FunctionDeclaration , GeneratorDeclaration , AsyncFunctionDeclaration , AsyncGeneratorDeclaration 또는 VariableStatement 가 도입한 모든 바인딩이 포함됩니다. 전역 코드 에 있는 그 밖의 모든 ECMAScript 선언에 대한 바인딩은 Global Environment Record의 Declarative Environment Record 구성 요소에 포함됩니다.
프로퍼티는 전역 객체 에 직접 생성될 수 있습니다. 따라서 Global Environment Record의 Object Environment Record 구성 요소에는 FunctionDeclaration , GeneratorDeclaration , AsyncFunctionDeclaration , AsyncGeneratorDeclaration 또는 VariableDeclaration 선언에 의해 명시적으로 생성된 바인딩과 전역 객체 의 프로퍼티로서 암묵적으로 생성된 바인딩이 모두 포함될 수 있습니다.
Global Environment Record에는 표 18 에 나열된 추가 필드가 있습니다.
표 18: Global Environment Record 의 추가 필드
9.1.1.4.1 HasBinding ( name )
a Global Environment Record envRecord 의 구체 메서드 HasBinding . 인수 name (String). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 인수 식별자가 해당 Record 에 의해 바인딩된 식별자 중 하나인지 결정합니다. 호출되면 다음 단계를 수행한다.
declRecord 를 envRecord .[[DeclarativeRecord]] 로 둡니다.! declRecord .HasBinding (name )이 true 이면, true 를 반환합니다. objRecord 를 envRecord .[[ObjectRecord]] 로 둡니다.? objRecord .HasBinding (name ) 을 반환합니다.
9.1.1.4.2 CreateMutableBinding ( name , deletable )
a Global Environment Record envRecord 의 구체 메서드 CreateMutableBinding . 인수 name (String) 및 deletable (Boolean). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 초기화되지 않은 이름 name 에 대한 새로운 변경 가능한 바인딩을 생성합니다. 바인딩은 연결된 DeclarativeRecord에 생성됩니다. DeclarativeRecord에는 name 에 대한 바인딩이 이미 존재해서는 안 됩니다. deletable 이 true 이면 새 바인딩을 삭제 가능 대상으로 표시합니다. 호출되면 다음 단계를 수행한다.
declRecord 를 envRecord .[[DeclarativeRecord]] 로 둡니다.! declRecord .HasBinding (name )이 true 이면, TypeError 예외를 던집니다. ! declRecord .CreateMutableBinding (name , deletable )을 반환합니다.
9.1.1.4.3 CreateImmutableBinding ( name , strict )
a Global Environment Record envRecord 의 구체 메서드 CreateImmutableBinding . 인수 name (String) 및 strict (Boolean). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 초기화되지 않은 이름 name 에 대한 새로운 변경 불가능한 바인딩을 생성합니다. 이 Environment Record 에는 name 에 대한 바인딩이 이미 존재해서는 안 됩니다. strict 가 true 이면 새 바인딩을 엄격 바인딩으로 표시합니다. 호출되면 다음 단계를 수행한다.
declRecord 를 envRecord .[[DeclarativeRecord]] 로 둡니다.! declRecord .HasBinding (name )이 true 이면, TypeError 예외를 던집니다. ! declRecord .CreateImmutableBinding (name , strict )을 반환합니다.
9.1.1.4.4 InitializeBinding ( name , value )
a Global Environment Record envRecord 의 구체 메서드 InitializeBinding . 인수 name (String) 및 value (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 이름이 name 인 식별자의 현재 바인딩 값을 value 값으로 설정하는 데 사용됩니다. name 에 대한 초기화되지 않은 바인딩이 이미 존재해야 합니다. 호출되면 다음 단계를 수행한다.
declRecord 를 envRecord .[[DeclarativeRecord]] 로 둡니다.! declRecord .HasBinding (name )이 true 이면, 다음을 수행합니다.! declRecord .InitializeBinding (name , value )을 반환합니다. 단언 : 바인딩이 존재하면 Object Environment Record 에 있어야 합니다.objRecord 를 envRecord .[[ObjectRecord]] 로 둡니다.? objRecord .InitializeBinding (name , value ) 을 반환합니다.
9.1.1.4.5 SetMutableBinding ( name , value , strict )
a Global Environment Record envRecord 의 구체 메서드 SetMutableBinding . 인수 name (String), value (ECMAScript 언어 값 ) 및 strict (Boolean). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 이름이 name 인 식별자의 현재 바인딩 값을 value 값으로 변경하려고 시도합니다. 바인딩이 변경 불가능한 바인딩이고 strict 가 true 이면 TypeError 를 던집니다. 일반적으로 name 이라는 바인딩이 이미 존재하지만, 존재하지 않거나 현재 쓰기 가능하지 않은 경우 오류 처리는 strict 에 따라 결정됩니다. 호출되면 다음 단계를 수행한다.
declRecord 를 envRecord .[[DeclarativeRecord]] 로 둡니다.! declRecord .HasBinding (name )이 true 이면, 다음을 수행합니다.? declRecord .SetMutableBinding (name , value , strict )을 반환합니다. objRecord 를 envRecord .[[ObjectRecord]] 로 둡니다.? objRecord .SetMutableBinding (name , value , strict ) 을 반환합니다.
9.1.1.4.6 GetBindingValue ( name , strict )
a Global Environment Record envRecord 의 구체 메서드 GetBindingValue . 인수 name (String) 및 strict (Boolean). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 throw 완료 ). 이름이 name 인 바인딩된 식별자의 값을 반환합니다. 바인딩이 초기화되지 않은 바인딩이면 ReferenceError 예외를 던집니다. 일반적으로 name 이라는 바인딩이 이미 존재하지만, 존재하지 않거나 현재 쓰기 가능하지 않은 경우 오류 처리는 strict 에 따라 결정됩니다. 호출되면 다음 단계를 수행한다.
declRecord 를 envRecord .[[DeclarativeRecord]] 로 둡니다.! declRecord .HasBinding (name )이 true 이면, 다음을 수행합니다.? declRecord .GetBindingValue (name , strict )을 반환합니다. objRecord 를 envRecord .[[ObjectRecord]] 로 둡니다.? objRecord .GetBindingValue (name , strict ) 을 반환합니다.
9.1.1.4.7 DeleteBinding ( name )
a Global Environment Record envRecord 의 구체 메서드 DeleteBinding . 인수 name (String). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 명시적으로 삭제 가능 대상으로 지정된 바인딩만 삭제할 수 있습니다. 호출되면 다음 단계를 수행한다.
declRecord 를 envRecord .[[DeclarativeRecord]] 로 둡니다.! declRecord .HasBinding (name )이 true 이면, 다음을 수행합니다.! declRecord .DeleteBinding (name )을 반환합니다. objRecord 를 envRecord .[[ObjectRecord]] 로 둡니다.globalObj 를 objRecord .[[BindingObject]] 로 둡니다.existingProperty 를 ? HasOwnProperty (globalObj , name )으로 둡니다.existingProperty 가 true 이면, 다음을 수행합니다.? objRecord .DeleteBinding (name ) 을 반환합니다. true 를 반환합니다.
9.1.1.4.8 HasThisBinding ( )
a Global Environment Record envRecord 의 구체 메서드 HasThisBinding . 인수 없음. 반환값: true . 호출되면 다음 단계를 수행한다.
true 를 반환합니다.
참고
9.1.1.4.9 GetThisBinding ( )
a Global Environment Record envRecord 의 구체 메서드 GetThisBinding . 인수 없음. 반환값: 정상 완료 (값: Object). 호출되면 다음 단계를 수행한다.
envRecord .[[GlobalThisValue]] 를 반환합니다.
9.1.1.4.10 HasSuperBinding ( )
a Global Environment Record envRecord 의 구체 메서드 HasSuperBinding . 인수 없음. 반환값: false . 호출되면 다음 단계를 수행한다.
false 를 반환합니다.
참고
9.1.1.4.11 WithBaseObject ( )
a Global Environment Record envRecord 의 구체 메서드 WithBaseObject . 인수 없음. 반환값: undefined . 호출되면 다음 단계를 수행한다.
undefined 를 반환합니다.
9.1.1.4.12 HasLexicalDeclaration ( envRecord , name )
추상 연산 HasLexicalDeclaration. 인수 envRecord (Global Environment 레코드 ) 및 name (String). 반환값: Boolean. 인수 식별자에 LexicalDeclaration 또는 ClassDeclaration 과 같은 렉시컬 선언을 사용하여 생성된 envRecord 내 바인딩이 있는지 결정합니다. 호출되면 다음 단계를 수행한다.
declRecord 를 envRecord .[[DeclarativeRecord]] 로 둡니다.! declRecord .HasBinding (name )을 반환합니다.
9.1.1.4.13 HasRestrictedGlobalProperty ( envRecord , name )
추상 연산 HasRestrictedGlobalProperty. 인수 envRecord (Global Environment 레코드 ) 및 name (String). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 인수 식별자가 전역 렉시컬 바인딩으로 가려져서는 안 되는 전역 객체 프로퍼티의 이름인지 결정합니다. 호출되면 다음 단계를 수행한다.
objRecord 를 envRecord .[[ObjectRecord]] 로 둡니다.globalObj 를 objRecord .[[BindingObject]] 로 둡니다.existingProperty 를 ? globalObj .[[GetOwnProperty]] (name ) 으로 둡니다.existingProperty 가 undefined 이면, false 를 반환합니다.existingProperty .[[Configurable]] 이 true 이면, false 를 반환합니다.true 를 반환합니다.
참고
전역 객체 에는 var 또는 함수 선언을 사용해 선언하지 않고 직접 생성된 프로퍼티가 존재할 수 있습니다. 전역 객체 의 구성 불가능한 프로퍼티와 같은 이름을 갖는 전역 렉시컬 바인딩은 생성할 수 없습니다. 전역 프로퍼티 "undefined" 는 이러한 프로퍼티의 예입니다.
9.1.1.4.14 CanDeclareGlobalVar ( envRecord , name )
추상 연산 CanDeclareGlobalVar. 인수 envRecord (Global Environment 레코드 ) 및 name (String). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 동일한 인수 name 으로 대응하는 CreateGlobalVarBinding 호출을 수행했을 때 성공할지를 결정합니다. 중복 var 선언과 기존 전역 객체 프로퍼티에 대한 var 선언은 허용됩니다. 호출되면 다음 단계를 수행한다.
objRecord 를 envRecord .[[ObjectRecord]] 로 둡니다.globalObj 를 objRecord .[[BindingObject]] 로 둡니다.hasProperty 를 ? HasOwnProperty (globalObj , name )으로 둡니다.hasProperty 가 true 이면, true 를 반환합니다.? IsExtensible (globalObj )을 반환합니다.
9.1.1.4.15 CanDeclareGlobalFunction ( envRecord , name )
추상 연산 CanDeclareGlobalFunction. 인수 envRecord (Global Environment 레코드 ) 및 name (String). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 동일한 인수 name 으로 대응하는 CreateGlobalFunctionBinding 호출을 수행했을 때 성공할지를 결정합니다. 호출되면 다음 단계를 수행한다.
objRecord 를 envRecord .[[ObjectRecord]] 로 둡니다.globalObj 를 objRecord .[[BindingObject]] 로 둡니다.existingProperty 를 ? globalObj .[[GetOwnProperty]] (name ) 으로 둡니다.existingProperty 가 undefined 이면, ? IsExtensible (globalObj )을 반환합니다.existingProperty .[[Configurable]] 이 true 이면, true 를 반환합니다.IsDataDescriptor (existingProperty )가 true 이고 existingProperty 가 속성 값 { [[Writable]] : true , [[Enumerable]] : true }를 가지면, true 를 반환합니다.false 를 반환합니다.
9.1.1.4.16 CreateGlobalVarBinding ( envRecord , name , deletable )
추상 연산 CreateGlobalVarBinding. 인수 envRecord (Global Environment 레코드 ), name (String) 및 deletable (Boolean). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 연결된 Object Environment Record 에 변경 가능한 바인딩을 생성하고 초기화합니다. 바인딩이 이미 존재하면 이를 재사용하며 초기화된 것으로 간주합니다. 호출되면 다음 단계를 수행한다.
objRecord 를 envRecord .[[ObjectRecord]] 로 둡니다.globalObj 를 objRecord .[[BindingObject]] 로 둡니다.hasProperty 를 ? HasOwnProperty (globalObj , name )으로 둡니다.extensible 을 ? IsExtensible (globalObj )로 둡니다.hasProperty 가 false 이고 extensible 이 true 이면, 다음을 수행합니다.? objRecord .CreateMutableBinding (name , deletable ) 를 수행합니다. ? objRecord .InitializeBinding (name , undefined ) 를 수행합니다. unused 를 반환합니다.
9.1.1.4.17 CreateGlobalFunctionBinding ( envRecord , name , value , deletable )
추상 연산 CreateGlobalFunctionBinding. 인수 envRecord (Global Environment 레코드 ), name (String), value (ECMAScript 함수 객체) 및 deletable (Boolean). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 연결된 Object Environment Record 에 변경 가능한 바인딩을 생성하고 초기화합니다. 바인딩이 이미 존재하면 이를 교체합니다. 호출되면 다음 단계를 수행한다.
objRecord 를 envRecord .[[ObjectRecord]] 로 둡니다.globalObj 를 objRecord .[[BindingObject]] 로 둡니다.existingProperty 를 ? globalObj .[[GetOwnProperty]] (name ) 으로 둡니다.existingProperty 가 undefined 이거나 existingProperty .[[Configurable]] 이 true 이면, 다음을 수행합니다.propertyDesc 를 PropertyDescriptor { [[Value]] : value , [[Writable]] : true , [[Enumerable]] : true , [[Configurable]] : deletable }로 둡니다.그렇지 않으면,propertyDesc 를 PropertyDescriptor { [[Value]] : value }로 둡니다. ? DefinePropertyOrThrow (globalObj , name , propertyDesc )를 수행합니다. ? Set (globalObj , name , value , false )를 수행합니다. unused 를 반환합니다.
참고
전역 함수 선언은 항상 전역 객체 의 자체 프로퍼티로 나타납니다. 가능한 경우 기존 자체 프로퍼티를 표준 속성 값 집합을 갖도록 재구성합니다. 7 단계는 InitializeBinding 구체 메서드를 호출하는 것과 동등하며, globalObj 가 Proxy이면 동일한 Proxy 트랩 호출 시퀀스를 생성합니다.
9.1.1.5 Module Environment Record
Module Environment Record 는 ECMAScript Module 의 바깥쪽 스코프를 나타내는 데 사용하는 Declarative Environment Record 입니다. 일반적인 변경 가능한 바인딩과 변경 불가능한 바인딩 외에도 Module Environment Record는 다른 Environment Record 에 존재하는 대상 바인딩에 대한 간접 접근을 제공하는 변경 불가능한 import 바인딩도 제공합니다.
Module Environment Record는 표 15 에 나열된 모든 Declarative Environment Record 메서드를 지원하며, GetBindingValue , DeleteBinding , HasThisBinding 및 GetThisBinding 을 제외한 모든 메서드에 대해 동일한 명세를 공유합니다.
9.1.1.5.1 GetBindingValue ( name , strict )
a Module Environment Record envRecord 의 구체 메서드 GetBindingValue . 인수 name (String) 및 strict (Boolean). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 throw 완료 ). 이름이 name 인 바인딩된 식별자의 값을 반환합니다. 그러나 바인딩이 간접 바인딩이면 대상 바인딩의 값을 반환합니다. 바인딩은 존재하지만 초기화되지 않았으면 ReferenceError 를 던집니다. 호출되면 다음 단계를 수행한다.
단언 : strict 는 true 입니다.단언 : envRecord 에는 name 에 대한 바인딩이 있습니다.name 에 대한 바인딩이 간접 바인딩이면, 다음을 수행합니다.module 과 targetName 을 이 name 에 대한 바인딩이 생성될 때 제공된 간접 참조 값으로 둡니다.targetEnv 를 module .[[Environment]] 로 둡니다.targetEnv 가 empty 이면, ReferenceError 예외를 던집니다.? targetEnv .GetBindingValue (targetName , true )를 반환합니다. envRecord 에서 name 에 대한 바인딩이 초기화되지 않은 바인딩이면, ReferenceError 예외를 던집니다.현재 envRecord 에서 name 에 바인딩된 값을 반환합니다.
참고
Module 은 항상 엄격 모드 코드 이므로 strict 는 항상 true 입니다.
9.1.1.5.2 DeleteBinding ( name )
Module Environment Record 의 DeleteBinding 구체 메서드는 이 명세에서 절대로 사용되지 않습니다.
참고
9.1.1.5.3 HasThisBinding ( )
a Module Environment Record envRecord 의 구체 메서드 HasThisBinding . 인수 없음. 반환값: true . 호출되면 다음 단계를 수행한다.
true 를 반환합니다.
참고
9.1.1.5.4 GetThisBinding ( )
a Module Environment Record envRecord 의 구체 메서드 GetThisBinding . 인수 없음. 반환값: 정상 완료 (값: undefined ). 호출되면 다음 단계를 수행한다.
undefined 를 반환합니다.
9.1.1.5.5 CreateImportBinding ( envRecord , name , targetModule , targetName )
추상 연산 CreateImportBinding. 인수 envRecord (Module Environment 레코드 ), name (String), targetModule (Module 레코드 ) 및 targetName (String). 반환값: unused . 이름 name 에 대해 초기화된 새로운 변경 불가능한 간접 바인딩을 생성합니다. envRecord 에는 name 에 대한 바인딩이 이미 존재해서는 안 됩니다. targetName 은 targetModule 의 Module Environment Record 에 존재하는 바인딩의 이름입니다. 새 바인딩의 값에 접근하면 대상 바인딩의 바인딩된 값에 간접적으로 접근합니다. 호출되면 다음 단계를 수행한다.
단언 : envRecord 에는 name 에 대한 바인딩이 이미 존재하지 않습니다.단언 : targetModule .[[Environment]] 가 인스턴스화되면 targetName 에 대한 직접 바인딩을 갖습니다.envRecord 에 name 에 대한 변경 불가능한 간접 바인딩을 생성하여 targetModule 및 targetName 을 대상 바인딩으로 참조하게 하고, 바인딩이 초기화되었음을 기록합니다.unused 를 반환합니다.
9.1.2 Environment Record 연산
다음 추상 연산 은 이 명세에서 Environment Record 에 대해 연산하는 데 사용됩니다:
9.1.2.1 GetIdentifierReference ( envRecord , name , strict )
추상 연산 GetIdentifierReference. 인수 envRecord ((Environment 레코드 또는 null )), name (String) 및 strict (Boolean). 반환값: (정상 완료 (값: Reference 레코드 ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
envRecord 가 null 이면, 다음을 수행합니다.Reference Record { [[Base]] : unresolvable , [[ReferencedName]] : name , [[Strict]] : strict , [[ThisValue]] : empty }를 반환합니다.exists 를 ? envRecord .HasBinding (name ) 으로 둡니다.exists 가 true 이면, 다음을 수행합니다.Reference Record { [[Base]] : envRecord , [[ReferencedName]] : name , [[Strict]] : strict , [[ThisValue]] : empty }를 반환합니다.outer 를 envRecord .[[OuterEnv]] 로 둡니다.? GetIdentifierReference (outer , name , strict )를 반환합니다.
9.1.2.2 NewDeclarativeEnvironment ( outerEnv )
추상 연산 NewDeclarativeEnvironment. 인수 outerEnv ((Environment 레코드 또는 null )). 반환값: Declarative Environment 레코드 . 호출되면 다음 단계를 수행한다.
envRecord 를 바인딩을 포함하지 않는 새로운 Declarative Environment Record 로 둡니다.envRecord .[[OuterEnv]] 를 outerEnv 로 설정합니다.envRecord .[[DisposableResourceStack]] 을 새로운 빈 List 로 설정합니다.envRecord 를 반환합니다.
9.1.2.3 NewObjectEnvironment ( obj , isWithEnv , outerEnv )
추상 연산 NewObjectEnvironment. 인수 obj (Object), isWithEnv (Boolean) 및 outerEnv ((Environment 레코드 또는 null )). 반환값: Object Environment 레코드 . 호출되면 다음 단계를 수행한다.
envRecord 를 새로운 Object Environment Record 로 둡니다.envRecord .[[BindingObject]] 를 obj 로 설정합니다.envRecord .[[IsWithEnvironment]] 을 isWithEnv 로 설정합니다.envRecord .[[OuterEnv]] 를 outerEnv 로 설정합니다.envRecord 를 반환합니다.
9.1.2.4 NewFunctionEnvironment ( func , newTarget )
추상 연산 NewFunctionEnvironment. 인수 func (ECMAScript 함수 객체) 및 newTarget ((Object 또는 undefined )). 반환값: Function Environment 레코드 . 호출되면 다음 단계를 수행한다.
envRecord 를 바인딩을 포함하지 않는 새로운 Function Environment Record 로 둡니다.envRecord .[[FunctionObject]] 를 func 로 설정합니다.func .[[ThisMode]] 가 lexical 이면, envRecord .[[ThisBindingStatus]] 를 lexical 로 설정합니다.그렇지 않으면 envRecord .[[ThisBindingStatus]] 를 uninitialized 로 설정합니다. envRecord .[[NewTarget]] 을 newTarget 으로 설정합니다.envRecord .[[OuterEnv]] 를 func .[[Environment]] 로 설정합니다.envRecord .[[DisposableResourceStack]] 을 새로운 빈 List 로 설정합니다.envRecord 를 반환합니다.
9.1.2.5 NewGlobalEnvironment ( obj , thisValue )
추상 연산 NewGlobalEnvironment. 인수 obj (Object) 및 thisValue (Object). 반환값: Global Environment 레코드 . 호출되면 다음 단계를 수행한다.
objRecord 를 NewObjectEnvironment (obj , false , null )로 둡니다.declRecord 를 NewDeclarativeEnvironment (null )로 둡니다.envRecord 를 새로운 Global Environment Record 로 둡니다.envRecord .[[ObjectRecord]] 를 objRecord 로 설정합니다.envRecord .[[GlobalThisValue]] 를 thisValue 로 설정합니다.envRecord .[[DeclarativeRecord]] 를 declRecord 로 설정합니다.envRecord .[[OuterEnv]] 를 null 로 설정합니다.envRecord 를 반환합니다.
9.1.2.6 NewModuleEnvironment ( outerEnv )
추상 연산 NewModuleEnvironment. 인수 outerEnv (Global Environment 레코드 ). 반환값: Module Environment 레코드 . 호출되면 다음 단계를 수행한다.
envRecord 를 바인딩을 포함하지 않는 새로운 Module Environment Record 로 둡니다.envRecord .[[OuterEnv]] 를 outerEnv 로 설정합니다.envRecord .[[DisposableResourceStack]] 을 새로운 빈 List 로 설정합니다.envRecord 를 반환합니다.
9.2 PrivateEnvironment Record
PrivateEnvironment Record 는 ECMAScript 코드에서 ClassDeclaration 및 ClassExpression 의 렉시컬 중첩 구조를 기반으로 Private Name 을 추적하는 데 사용하는 명세 메커니즘입니다. 이는 Environment Record 와 유사하지만 서로 구별됩니다. 각 PrivateEnvironment Record 는 ClassDeclaration 또는 ClassExpression 과 연결됩니다. 이러한 클래스가 평가될 때마다 해당 클래스에서 선언한 Private Name 을 기록하기 위해 새로운 PrivateEnvironment Record 가 생성됩니다.
각 PrivateEnvironment Record 에는 표 19 에 정의된 필드가 있습니다.
표 19: PrivateEnvironment Record 필드
9.2.1 PrivateEnvironment Record 연산
다음 추상 연산 은 이 명세에서 PrivateEnvironment Record 에 대해 연산하는 데 사용됩니다:
9.2.1.1 NewPrivateEnvironment ( outerPrivateEnv )
추상 연산 NewPrivateEnvironment. 인수 outerPrivateEnv ((PrivateEnvironment 레코드 또는 null )). 반환값: PrivateEnvironment 레코드 . 호출되면 다음 단계를 수행한다.
names 를 새로운 빈 List 로 둡니다.PrivateEnvironment Record { [[OuterPrivateEnvironment]] : outerPrivateEnv , [[Names]] : names }를 반환합니다.
9.2.1.2 ResolvePrivateIdentifier ( privateEnv , identifier )
추상 연산 ResolvePrivateIdentifier. 인수 privateEnv (PrivateEnvironment 레코드 ) 및 identifier (String). 반환값: 비공개 이름 . 호출되면 다음 단계를 수행한다.
names 를 privateEnv .[[Names]] 로 둡니다.names 의 각 Private Name privateName 에 대해 다음을 수행합니다.privateName .[[Description]] 이 identifier 이면, 다음을 수행합니다.privateName 을 반환합니다.outerPrivateEnv 를 privateEnv .[[OuterPrivateEnvironment]] 로 둡니다.단언 : outerPrivateEnv 는 null 이 아닙니다.ResolvePrivateIdentifier (outerPrivateEnv , identifier )를 반환합니다.
9.3 Realm
모든 ECMAScript 코드는 평가되기 전에 realm 과 연결되어야 합니다. 개념적으로 realm 은 내재 객체 집합, ECMAScript 전역 환경, 해당 전역 환경의 스코프 내에서 로드된 모든 ECMAScript 코드 및 기타 연결된 상태와 리소스로 구성됩니다.
realm 은 이 명세에서 표 20 에 명시된 필드를 갖는 Realm Record 로 나타냅니다:
표 20: Realm Record 필드
9.3.1 InitializeHostDefinedRealm ( )
추상 연산 InitializeHostDefinedRealm. 인수 없음. 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
realm 을 새로운 Realm Record 로 둡니다.CreateIntrinsics (realm )를 수행합니다.realm .[[AgentSignifier]] 을 AgentSignifier ()로 설정합니다.realm .[[TemplateMap]] 을 새로운 빈 List 로 설정합니다.newContext 를 새로운 실행 컨텍스트 로 둡니다.newContext 의 Function을 null 로 설정합니다.newContext 의 Realm 을 realm 으로 설정합니다.newContext 의 ScriptOrModule을 null 로 설정합니다.newContext 를 실행 컨텍스트 스택 에 푸시합니다. 이제 newContext 가 실행 중인 실행 컨텍스트 입니다.호스트 가 realm 의 전역 객체 로 사용할 특정 객체를 요구하면, 다음을 수행합니다.global 을 호스트 정의 방식으로 생성한 해당 객체로 둡니다.그렇지 않으면,global 을 OrdinaryObjectCreate (realm .[[Intrinsics]] .[[%Object.prototype% ]])로 둡니다. 호스트 가 realm 의 전역 스코프에서 this 바인딩이 전역 객체 가 아닌 객체를 반환하도록 요구하면, 다음을 수행합니다.thisValue 를 호스트 정의 방식으로 생성한 해당 객체로 둡니다.그렇지 않으면,thisValue 를 global 로 둡니다. realm .[[GlobalObject]] 를 global 로 설정합니다.realm .[[GlobalEnv]] 를 NewGlobalEnvironment (global , thisValue )로 설정합니다.? SetDefaultGlobalBindings (realm )를 수행합니다. global 에 호스트 정의 전역 객체 프로퍼티를 생성합니다.unused 를 반환합니다.
9.3.2 CreateIntrinsics ( realmRecord )
추상 연산 CreateIntrinsics. 인수 realmRecord (Realm 레코드 ). 반환값: unused . 호출되면 다음 단계를 수행한다.
realmRecord .[[Intrinsics]] 를 새로운 Record 로 설정합니다.realmRecord .[[Intrinsics]] 의 필드를 표 6 에 나열된 값으로 설정합니다. 필드 이름은 표의 “Intrinsic Name” 열에 나열된 이름입니다. 각 필드의 값은 절 19 부터 28 까지 각 객체의 명세에 정의된 프로퍼티 값으로 완전히 재귀적으로 채워진 새로운 객체 값입니다. 모든 객체 프로퍼티 값은 새로 생성된 객체 값입니다. 내장 함수 객체 인 모든 값은 CreateBuiltinFunction (steps , length , name , slots , realmRecord , proto , async )을 수행하여 생성합니다. 여기에서 steps 는 이 명세가 제공하는 해당 함수의 정의이고, name 은 함수의 "name" 프로퍼티 초기값이며, length 는 함수의 "length" 프로퍼티 초기값이고, slots 는 지정된 함수 내부 슬롯 이름의 목록이며(있는 경우), proto 는 함수의 [[Prototype]] 내부 슬롯에 지정된 값이고, async 는 함수가 “async”로 설명되면 true , 그렇지 않으면 false 입니다. 내재 객체와 그 프로퍼티의 생성은 아직 생성되지 않은 객체에 대한 의존성이 발생하지 않도록 순서를 정해야 합니다.AddRestrictedFunctionProperties (realmRecord .[[Intrinsics]] .[[%Function.prototype% ]], realmRecord )를 수행합니다.unused 를 반환합니다.
9.3.3 SetDefaultGlobalBindings ( realmRecord )
추상 연산 SetDefaultGlobalBindings. 인수 realmRecord (Realm 레코드 ). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
global 을 realmRecord .[[GlobalObject]] 로 둡니다.절 19 에 명시된 전역 객체 의 각 프로퍼티에 대해 다음을 수행합니다.name 을 프로퍼티 이름 의 String 값으로 둡니다.propertyDesc 를 해당 프로퍼티에 지정된 속성을 포함하는, 프로퍼티에 대해 모든 필드가 채워진 데이터 Property Descriptor 로 둡니다. 19.2 , 19.3 또는 19.4 에 나열된 프로퍼티의 경우 [[Value]] 속성의 값은 realmRecord 의 대응하는 내재 객체입니다.? DefinePropertyOrThrow (global , name , propertyDesc )를 수행합니다. unused 를 반환합니다.
9.4 실행 컨텍스트
실행 컨텍스트 는 ECMAScript 구현체가 코드의 런타임 평가를 추적하는 데 사용하는 명세 장치입니다. 어느 시점이든 실제로 코드를 실행 중인 실행 컨텍스트 는 에이전트 당 최대 하나입니다. 이를 에이전트 의 실행 중인 실행 컨텍스트 라고 합니다. 이 명세에서 실행 중인 실행 컨텍스트 에 대한 모든 참조는 주변 에이전트 의 실행 중인 실행 컨텍스트 를 나타냅니다.
실행 컨텍스트 스택 은 실행 컨텍스트를 추적하는 데 사용됩니다. 실행 중인 실행 컨텍스트 는 항상 이 스택의 최상위 요소입니다. 현재 실행 중인 실행 컨텍스트 와 연결된 실행 가능 코드에서 해당 실행 컨텍스트와 연결되지 않은 실행 가능 코드로 제어가 이전될 때마다 새로운 실행 컨텍스트가 생성됩니다. 새로 생성된 실행 컨텍스트는 스택에 푸시되어 실행 중인 실행 컨텍스트 가 됩니다.
실행 컨텍스트에는 연결된 코드의 실행 진행 상황을 추적하는 데 필요한 구현체별 상태가 포함됩니다. 각 실행 컨텍스트에는 최소한 표 21 에 나열된 상태 구성 요소가 있습니다.
표 21: 모든 실행 컨텍스트 의 상태 구성 요소
실행 중인 실행 컨텍스트 에 의한 코드 평가는 이 명세에 정의된 여러 지점에서 일시 중단될 수 있습니다. 실행 중인 실행 컨텍스트 가 일시 중단되면 다른 실행 컨텍스트가 실행 중인 실행 컨텍스트 가 되어 자신의 코드를 평가하기 시작할 수 있습니다. 이후 어느 시점에 일시 중단된 실행 컨텍스트가 다시 실행 중인 실행 컨텍스트 가 되어 이전에 일시 중단된 지점부터 코드 평가를 계속할 수 있습니다. 실행 중인 실행 컨텍스트 상태의 실행 컨텍스트 간 전환은 일반적으로 스택과 같은 후입선출 방식으로 이루어집니다. 그러나 일부 ECMAScript 기능에는 비LIFO 방식의 실행 컨텍스트 전환이 필요합니다.
실행 중인 실행 컨텍스트 의 Realm 구성 요소 값은 현재 Realm Record 라고도 합니다. 실행 중인 실행 컨텍스트 의 Function 구성 요소 값은 활성 함수 객체 라고도 합니다.
ECMAScript 코드 실행 컨텍스트 에는 표 22 에 나열된 추가 상태 구성 요소가 있습니다.
표 22: ECMAScript 코드 실행 컨텍스트 의 추가 상태 구성 요소
실행 컨텍스트의 LexicalEnvironment와 VariableEnvironment 구성 요소는 항상 Environment Record 입니다.
Generator의 평가를 나타내는 실행 컨텍스트에는 표 23 에 나열된 추가 상태 구성 요소가 있습니다.
표 23: Generator 실행 컨텍스트 의 추가 상태 구성 요소
구성 요소
목적
Generator
이 실행 컨텍스트 가 평가 중인 Generator입니다.
대부분의 상황에서 이 명세의 알고리즘은 실행 중인 실행 컨텍스트 (실행 컨텍스트 스택 의 최상위)만 직접 조작합니다. 따라서 “LexicalEnvironment” 및 “VariableEnvironment”라는 용어를 별도의 한정 없이 사용하면 실행 중인 실행 컨텍스트 의 해당 구성 요소를 가리킵니다.
실행 컨텍스트는 순수하게 명세상의 메커니즘이며 ECMAScript 구현체의 특정 산출물과 대응할 필요는 없습니다. ECMAScript 코드가 실행 컨텍스트에 직접 접근하거나 이를 관찰하는 것은 불가능합니다.
9.4.1 GetActiveScriptOrModule ( )
추상 연산 GetActiveScriptOrModule. 인수 없음. 반환값: (Script 레코드 , Module 레코드 또는 null ). 실행 중인 실행 컨텍스트 를 기반으로 실행 중인 스크립트 또는 모듈을 결정하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
실행 컨텍스트 스택 이 비어 있으면, null 을 반환합니다.executionContext 를 실행 컨텍스트 스택 에서 ScriptOrModule 구성 요소가 null 이 아닌 가장 위쪽의 실행 컨텍스트 로 둡니다.그러한 실행 컨텍스트 가 존재하지 않으면, null 을 반환합니다. executionContext 의 ScriptOrModule을 반환합니다.
9.4.2 ResolveBinding ( name [ , envRecord ] )
추상 연산 ResolveBinding. 인수 name (String) 및 선택적 인수 envRecord ((Environment 레코드 또는 undefined )). 반환값: (정상 완료 (값: Reference 레코드 ) 또는 throw 완료 ). name 의 바인딩을 결정하는 데 사용됩니다. envRecord 를 사용하여 바인딩을 검색할 Environment Record 를 명시적으로 제공할 수 있습니다. 호출되면 다음 단계를 수행한다.
envRecord 가 존재하지 않거나 envRecord 가 undefined 이면, 다음을 수행합니다.envRecord 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 설정합니다.단언 : envRecord 는 Environment Record 입니다.strict 를 IsStrict (평가 중인 구문 생성 규칙)으로 둡니다.? GetIdentifierReference (envRecord , name , strict )를 반환합니다.
참고
ResolveBinding의 결과는 항상 [[ReferencedName]] 필드가 name 인 Reference Record 입니다.
9.4.3 GetThisEnvironment ( )
추상 연산 GetThisEnvironment. 인수 없음. 반환값: Environment 레코드 . 현재 키워드 this의 바인딩을 제공하는 Environment Record 를 찾습니다. 호출되면 다음 단계를 수행한다.
envRecord 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.다음을 반복합니다.exists 를 envRecord .HasThisBinding ()으로 둡니다.exists 가 true 이면, envRecord 를 반환합니다.outer 를 envRecord .[[OuterEnv]] 로 둡니다.단언 : outer 는 null 이 아닙니다.envRecord 를 outer 로 설정합니다.
참고
환경 목록은 항상 this 바인딩을 갖는 전역 환경으로 끝나므로 2 단계의 반복은 항상 종료됩니다.
9.4.4 ResolveThisBinding ( )
추상 연산 ResolveThisBinding. 인수 없음. 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 throw 완료 ). 실행 중인 실행 컨텍스트 의 LexicalEnvironment를 사용하여 키워드 this의 바인딩을 결정합니다. 호출되면 다음 단계를 수행한다.
envRecord 를 GetThisEnvironment ()로 둡니다.? envRecord .GetThisBinding ()을 반환합니다.
9.4.5 GetNewTarget ( )
추상 연산 GetNewTarget. 인수 없음. 반환값: (Object 또는 undefined ). 실행 중인 실행 컨텍스트 의 LexicalEnvironment를 사용하여 NewTarget 값을 결정합니다. 호출되면 다음 단계를 수행한다.
envRecord 를 GetThisEnvironment ()로 둡니다.단언 : envRecord 에는 [[NewTarget]] 필드가 있습니다.envRecord .[[NewTarget]] 을 반환합니다.
9.4.6 GetGlobalObject ( )
추상 연산 GetGlobalObject. 인수 없음. 반환값: Object. 현재 실행 중인 실행 컨텍스트 가 사용하는 전역 객체 를 반환합니다. 호출되면 다음 단계를 수행한다.
currentRealm 을 현재 Realm Record 로 둡니다.currentRealm .[[GlobalObject]] 를 반환합니다.
9.4.7 RunSuspendedContext ( context , completionRecord )
추상 연산 RunSuspendedContext. 인수 context (실행 컨텍스트 ) 및 completionRecord (완료 레코드 ). 반환값: (정상 완료 (값: (ECMAScript 언어 값 또는 unused )) 또는 중도 완료). context 를 재개하고(completionRecord 를 재개 값으로 전달합니다) 결과를 기다립니다. 호출되면 다음 단계를 수행한다.
callerContext 를 실행 중인 실행 컨텍스트 로 둡니다.callerContext 를 일시 중단합니다.context 를 실행 컨텍스트 스택 에 푸시합니다. 이제 context 가 실행 중인 실행 컨텍스트 입니다.context 의 일시 중단된 평가를 재개합니다 . 이때 completionRecord 를 해당 컨텍스트를 일시 중단시킨 연산의 결과로 전달합니다. result 를 재개된 계산이 전달한 Completion Record 로 둡니다.단언 : 이 단계에 도달했을 때 context 는 이미 실행 컨텍스트 스택 에서 제거되었고 callerContext 가 다시 실행 중인 실행 컨텍스트 입니다.Completion (result )를 반환합니다.
9.4.8 RunCallerContext ( value )
추상 연산 RunCallerContext. 인수 value ((ECMAScript 언어 값 또는 empty )). 반환값: 완료 레코드 . 호출자 컨텍스트를 재개하고(value 를 재개 값으로 전달합니다), 결과가 있으면 이를 기다립니다. 호출되면 다음 단계를 수행한다.
genContext 를 실행 중인 실행 컨텍스트 로 둡니다.genContext 를 실행 컨텍스트 스택 에서 제거하고 실행 컨텍스트 스택 최상위에 있는 실행 컨텍스트 를 실행 중인 실행 컨텍스트 로 복원합니다.callerContext 를 실행 중인 실행 컨텍스트 로 둡니다.NormalCompletion (value )을 전달하여 callerContext 를 재개합니다.참고 : 위 단계는 제어를 callerContext 로 이전하고 일시 중단합니다. 이 알고리즘의 이후 단계로 제어가 진행될 수 있는 유일한 방법은 genContext 가 다시 재개되는 것이며, 이는 영원히 발생하지 않을 수도 있습니다.단언 : genContext 가 실행 중인 실행 컨텍스트 입니다.result 를 방금 genContext 가 재개될 때 사용된 Completion Record 로 둡니다.Completion (result )를 반환합니다.
9.5 Job과 Job을 큐에 넣는 호스트 연산
Job 은 매개변수가 없고 다른 ECMAScript 계산이 현재 진행 중이지 않을 때 ECMAScript 계산을 시작하는 Abstract Closure 입니다.
Job 은 특정 에이전트 에서 ECMAScript 호스트 환경 에 의해 실행되도록 예약됩니다. 이 명세에서는 Job 을 예약하기 위한 호스트 훅 HostEnqueueGenericJob , HostEnqueueFinalizationRegistryCleanupJob , HostEnqueuePromiseJob 및 HostEnqueueTimeoutJob 을 설명합니다. 이 명세의 호스트 훅 은 Job 예약에 부과되는 추가 제약 조건에 따라 구성됩니다. 호스트 는 Job 을 예약하는 추가 추상 연산 을 정의할 수 있습니다. 이러한 연산은 Job Abstract Closure 와 realm (Realm Record 또는 null )을 매개변수로 받습니다. Realm Record 가 제공되면 해당 연산은 제공된 realm 을 소유하는 에이전트 에서 미래의 어느 시점에 Job 을 수행하도록 예약합니다. realm 대신 null 이 제공되면 해당 Job 은 ECMAScript 코드를 평가하지 않습니다. 구현은 다음 요구 사항을 준수해야 합니다:
참고 1
호스트 환경 은 예약과 관련하여 모든
Job 을 동일하게 취급할 필요가 없습니다. 예를 들어 웹 브라우저와 Node.js는 Promise 처리
Job 을 다른 작업보다 더 높은 우선순위로 취급합니다. 향후 기능에서는 이처럼 높은 우선순위로 처리되지 않는
Job 이 추가될 수 있습니다.
특정 시점에 scriptOrModule (Script Record , Module Record 또는 null )은 다음 조건이 모두 참인 경우 활성 스크립트 또는 모듈 입니다:
특정 시점에 실행은 다음 조건이 모두 참이면 ECMAScript 코드를 평가할 준비가 된 상태입니다:
참고 2
호스트 환경 은 실행 컨텍스트 를 실행 컨텍스트 스택 에 푸시하여 코드 평가를 위한 실행을 준비할 수 있습니다. 구체적인 단계는 구현체 정의 입니다.
구체적으로 어떤 Realm 을 선택할지는 호스트 환경 이 결정합니다. 이 최초 실행 컨텍스트 와 Realm 은 콜백 함수가 호출되기 전까지만 사용됩니다. Promise 핸들러와 같이 Job 과 관련된 콜백 함수가 호출되면 해당 호출은 자신의 실행 컨텍스트 와 Realm 을 푸시합니다.
특정 종류의 Job 에는 추가 적합성 요구 사항이 있습니다.
9.5.1 JobCallback Record
JobCallback Record 는 함수 객체 와 호스트 정의 값을 저장하는 데 사용하는 Record 입니다. 호스트 가 큐에 넣은 Job 을 통해 호출되는 함수 객체 는 추가적인 호스트 정의 문맥을 가질 수 있습니다. 이 상태를 전파하기 위해 Job Abstract Closure 는 함수 객체 를 직접 캡처하여 호출하지 않아야 합니다. 대신 HostMakeJobCallback 과 HostCallJobCallback 을 사용합니다.
참고
예를 들어 WHATWG HTML 명세(https://html.spec.whatwg.org/ )는 호스트 정의 값을 사용하여 Promise 콜백에 대한 incumbent settings object를 전파합니다.
JobCallback Record에는 표 24 에 나열된 필드가 있습니다.
표 24: JobCallback Record 필드
필드 이름
값
의미
[[Callback]]
함수 객체
Job 이 호출될 때 호출할 함수입니다.
[[HostDefined]]
임의의 값(기본값은 empty )
호스트 가 사용하도록 예약된 필드입니다.
9.5.2 HostMakeJobCallback ( callback )
호스트 정의 추상 연산 HostMakeJobCallback. 인수 callback (함수 객체 ). 반환값: JobCallback 레코드 .
HostMakeJobCallback의 구현은 다음 요구 사항을 준수해야 합니다:
HostMakeJobCallback의 기본 구현은 호출될 때 다음 단계를 수행합니다:
JobCallback Record { [[Callback]] : callback , [[HostDefined]] : empty }를 반환합니다.
웹 브라우저가 아닌 ECMAScript 호스트 는 HostMakeJobCallback의 기본 구현을 사용해야 합니다.
참고
이는 콜백이 나중에 예약되어 실행되도록 하는 함수에 전달되는 시점에 호출됩니다. 예를 들어 promise.then(thenAction)은 반응 Job 을 예약하는 시점이 아니라 Promise.prototype.then을 호출하는 시점에 thenAction에 대해 MakeJobCallback을 호출합니다.
9.5.3 HostCallJobCallback ( jobCallback , thisValue , argList )
호스트 정의 추상 연산 HostCallJobCallback. 인수 jobCallback (JobCallback 레코드 ), thisValue (ECMAScript 언어 값 ) 및 argList (리스트 (요소: ECMAScript 언어 값 )). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 throw 완료 ).
HostCallJobCallback의 구현은 다음 요구 사항을 준수해야 합니다:
Call (jobCallback .[[Callback]] , thisValue , argList )을 수행하고 그 결과를 반환해야 합니다.
참고
이 요구 사항은 호스트 가 이 명세에 정의된 함수 객체 의 [[Call]] 동작을 변경할 수 없음을 의미합니다.
HostCallJobCallback의 기본 구현은 호출될 때 다음 단계를 수행합니다:
단언 : IsCallable (jobCallback .[[Callback]] )은 true 입니다.? Call (jobCallback .[[Callback]] , thisValue , argList )을 반환합니다.
웹 브라우저가 아닌 ECMAScript 호스트 는 HostCallJobCallback의 기본 구현을 사용해야 합니다.
9.5.4 HostEnqueueGenericJob ( job , realm )
호스트 정의 추상 연산 HostEnqueueGenericJob. 인수 job (a Job Abstract Closure ) 및 realm (Realm 레코드 ). 반환값: unused . realm .[[AgentSignifier]] 로 나타내는 에이전트 에서 미래의 어느 시점에 수행되도록 realm realm 에 job 을 예약합니다. 이 알고리즘과 함께 사용하는 Abstract Closure 는 우선순위나 순서와 같은 추가 제약 조건 없이 예약되도록 의도되었습니다.
HostEnqueueGenericJob의 구현은 9.5 의 요구 사항을 준수해야 합니다.
9.5.5 HostEnqueuePromiseJob ( job , realm )
호스트 정의 추상 연산 HostEnqueuePromiseJob. 인수 job (a Job Abstract Closure ) 및 realm ((Realm 레코드 또는 null )). 반환값: unused . 미래의 어느 시점에 수행되도록 job 을 예약합니다. 이 알고리즘과 함께 사용하는 Abstract Closure 는 Promise 처리와 관련되거나 그 밖에 Promise 처리 연산과 같은 우선순위로 예약되도록 의도되었습니다.
HostEnqueuePromiseJob의 구현은 9.5 의 요구 사항뿐만 아니라 다음 사항도 준수해야 합니다:
realm 이 null 이 아니면 job 이 호출될 때마다 구현체는 job 호출 시점에 실행이 ECMAScript 코드를 평가할 준비가 되도록 구현체 정의 단계를 수행해야 합니다.
HostEnqueuePromiseJob이 호출되는 시점의 GetActiveScriptOrModule ()을 scriptOrModule 로 둡니다. realm 이 null 이 아니면 job 이 호출될 때마다 구현체는 job 호출 시점에 scriptOrModule 이 활성 스크립트 또는 모듈 이 되도록 구현체 정의 단계를 수행해야 합니다.
Job 은 이를 예약한 HostEnqueuePromiseJob 호출과 동일한 순서로 실행되어야 합니다.
참고
NewPromiseResolveThenableJob 이 반환한 Job 의 realm 은 일반적으로 then 함수 객체 에 대해 GetFunctionRealm 을 호출한 결과입니다. NewPromiseReactionJob 이 반환한 Job 의 realm 은 핸들러가 undefined 가 아니면 일반적으로 핸들러에 대해 GetFunctionRealm 을 호출한 결과입니다. 핸들러가 undefined 이면 realm 은 null 입니다. 두 종류의 Job 모두 GetFunctionRealm 이 비정상적으로 완료되면(즉, 해제된 Proxy에서 호출된 경우) realm 은 GetFunctionRealm 호출 시점의 현재 Realm Record 입니다. realm 이 null 이면 사용자 ECMAScript 코드는 평가되지 않고 새로운 ECMAScript 객체(예: Error 객체)도 생성되지 않습니다. 예를 들어 WHATWG HTML 명세(https://html.spec.whatwg.org/ )는 realm 을 사용하여 스크립트를 실행할 수 있는지와 entry 개념을 검사합니다.
9.5.6 HostEnqueueTimeoutJob ( timeoutJob , realm , milliseconds )
호스트 정의 추상 연산 HostEnqueueTimeoutJob. 인수 timeoutJob (a Job Abstract Closure ), realm (Realm 레코드 ) 및 milliseconds (음이 아닌 유한한 Number). 반환값: unused . realm .[[AgentSignifier]] 로 나타내는 에이전트 에서 최소 milliseconds 밀리초 후에 수행되도록 realm realm 에 timeoutJob 을 예약합니다.
HostEnqueueTimeoutJob의 구현은 9.5 의 요구 사항을 준수해야 합니다.
9.6 에이전트
에이전트 는 ECMAScript 실행 컨텍스트 의 집합, 실행 컨텍스트 스택 , 실행 중인 실행 컨텍스트 , Agent Record 및 실행 스레드 로 구성됩니다. 실행 스레드 를 제외한 에이전트 의 구성 요소는 해당 에이전트 에만 속합니다.
에이전트 의 실행 스레드 는 다른 에이전트 와 독립적으로 해당 에이전트 의 실행 컨텍스트 에서 알고리즘 단계를 실행합니다. 단, 스레드를 공유하는 에이전트 중 [[CanBlock]] 필드가 true 인 Agent Record 를 갖는 에이전트 가 없다면 하나의 실행 스레드 를 여러 에이전트 의 실행 스레드 로 사용할 수 있습니다.
참고 1
예를 들어 일부 웹 브라우저는 브라우저 창의 관련 없는 여러 탭 사이에서 하나의 실행 스레드 를 공유합니다.
에이전트 의 실행 스레드 가 알고리즘 단계를 실행하는 동안 해당 에이전트 는 그 단계의 주변 에이전트 입니다. 단계는 주변 에이전트 를 사용하여 에이전트 가 보유하는 명세 수준 실행 객체, 즉 실행 중인 실행 컨텍스트 , 실행 컨텍스트 스택 및 Agent Record 의 필드에 접근합니다.
에이전트 식별자 는 Agent를 식별하는 데 사용하는 전역적으로 고유한 불투명 값입니다.
표 25: Agent Record 필드
필드 이름
값
의미
[[LittleEndian]]
Boolean
GetValueFromBuffer 및 SetValueInBuffer 알고리즘에서 isLittleEndian 매개변수가 필요할 때 계산되는 기본값입니다. 선택은 구현체 정의 이며 구현체에 가장 효율적인 대안을 사용해야 합니다.
[[CanBlock]]
Boolean
에이전트 가 블로킹될 수 있는지를 결정합니다.
[[Signifier]]
에이전트 식별자
에이전트 클러스터 내에서 에이전트 를 고유하게 식별합니다.
[[IsLockFree1]]
Boolean
1바이트 값 에 대한 원자적 연산이 lock-free이면 true , 그렇지 않으면 false 입니다.
[[IsLockFree2]]
Boolean
2바이트 값 에 대한 원자적 연산이 lock-free이면 true , 그렇지 않으면 false 입니다.
[[IsLockFree8]]
Boolean
8바이트 값 에 대한 원자적 연산이 lock-free이면 true , 그렇지 않으면 false 입니다.
[[CandidateExecution]]
후보 실행 Record
메모리 모델 을 참조하시기 바랍니다.
[[KeptAlive]]
Object 또는 Symbol의 List
처음에는 새로운 빈 List 이며, 현재 Job 이 끝날 때까지 생존 상태 로 유지할 객체 및/또는 Symbol의 목록을 나타냅니다.
[[ModuleAsyncEvaluationCount]]
정수
처음에는 0이며, 비동기이거나 비동기 의존성을 갖는 모듈의 [[AsyncEvaluationOrder]] 필드에 증가하는 고유 값을 할당하는 데 사용됩니다.
[[GlobalSymbolRegistry]]
GlobalSymbolRegistry Record 의 List
처음에는 새로운 빈 List 이며, Symbol.for 가 생성한 Symbol 값의 목록을 나타냅니다.
[[LittleEndian]] , [[Signifier]] , [[IsLockFree1]] , [[IsLockFree2]] 및 [[IsLockFree8]] 의 값은 변경될 수 없습니다.
[[GlobalSymbolRegistry]] List 는 추가만 가능하며 다시 할당되지 않습니다.
참고 2
[[IsLockFree1]] , [[IsLockFree2]] 및 [[IsLockFree8]] 의 값은 반드시 하드웨어에 의해 결정되는 것은 아니며, 시간에 따라 또는 ECMAScript 구현체마다 달라질 수 있는 구현 선택을 반영할 수도 있습니다.
[[IsLockFree4]] 필드는 없습니다. 4바이트 원자적 연산은 항상 lock-free입니다.
실제로 어떤 형태의 락을 사용하여 원자적 연산을 구현하면 해당 연산은 lock-free가 아닙니다. lock-free가 wait-free를 의미하지는 않습니다. lock-free 원자적 연산을 완료하는 데 필요한 머신 단계 수에는 상한이 없습니다.
크기가 n 인 원자적 접근이 lock-free라는 사실은 크기가 n 인 비원자적 접근의 (인지되는) 원자성에 대해 아무것도 의미하지 않습니다. 특히 비원자적 접근은 여전히 여러 개의 별도 메모리 접근 시퀀스로 수행될 수 있습니다. 자세한 내용은 ReadSharedMemory 및 WriteSharedMemory 를 참조하시기 바랍니다.
참고 3
에이전트 는 명세상의 메커니즘이며 ECMAScript 구현체의 특정 산출물과 대응할 필요는 없습니다.
9.6.1 AgentSignifier ( )
추상 연산 AgentSignifier. 인수 없음. 반환값: an agent signifier. 호출되면 다음 단계를 수행한다.
agentRecord 를 주변 에이전트 의 Agent Record 로 둡니다.agentRecord .[[Signifier]] 을 반환합니다.
9.6.2 AgentCanSuspend ( )
추상 연산 AgentCanSuspend. 인수 없음. 반환값: Boolean. 호출되면 다음 단계를 수행한다.
agentRecord 를 주변 에이전트 의 Agent Record 로 둡니다.agentRecord .[[CanBlock]] 을 반환합니다.
참고
일부 환경에서는 특정 에이전트 가 일시 중단되는 것이 합리적이지 않을 수 있습니다. 예를 들어 웹 브라우저 환경에서는 문서의 주 이벤트 처리 스레드가 일시 중단되는 것은 허용하지 않으면서 worker의 이벤트 처리 스레드는 일시 중단할 수 있도록 하는 것이 합리적일 수 있습니다.
9.6.3 IncrementModuleAsyncEvaluationCount ( )
추상 연산 IncrementModuleAsyncEvaluationCount. 인수 없음. 반환값: 음이 아닌 정수. 호출되면 다음 단계를 수행한다.
agentRecord 를 주변 에이전트 의 Agent Record 로 둡니다.count 를 agentRecord .[[ModuleAsyncEvaluationCount]] 로 둡니다.agentRecord .[[ModuleAsyncEvaluationCount]] 를 count + 1로 설정합니다.count 를 반환합니다.
참고
이 값은 보류 중인 모듈 사이의 상대적인 평가 순서를 추적하는 데만 사용됩니다. 보류 중인 모듈이 없을 때 구현체는 관찰할 수 없는 방식으로 [[ModuleAsyncEvaluationCount]] 를 0으로 재설정할 수 있습니다.
9.7 에이전트 클러스터
에이전트 클러스터 는 공유 메모리에서 연산하여 서로 통신할 수 있는 에이전트 의 극대 집합입니다.
참고 1
서로 다른 에이전트 의 프로그램은 명시되지 않은 수단으로 메모리를 공유할 수 있습니다. 최소한 SharedArrayBuffer의 기반 메모리는 클러스터의 에이전트 사이에서 공유할 수 있습니다.
메시지 전달을 통해 통신할 수 있지만 메모리를 공유할 수 없는 에이전트 가 있을 수 있으며, 이러한 에이전트 는 절대로 같은 에이전트 클러스터에 있지 않습니다.
모든 에이전트 는 정확히 하나의 에이전트 클러스터에 속합니다.
참고 2
클러스터의 모든 에이전트 가 특정 시점에 동시에 생존해 있을 필요는 없습니다. 에이전트 A 가 다른 에이전트 B 를 생성한 뒤 A 가 종료되고, B 가 에이전트 C 를 생성하는 경우, A 가 B 와 일부 메모리를 공유할 수 있고 B 가 C 와 일부 메모리를 공유할 수 있었다면 세 에이전트 는 같은 클러스터에 있습니다.
클러스터 내의 모든 에이전트 는 각자의 Agent Record 에 있는 [[LittleEndian]] 필드에 대해 동일한 값을 가져야 합니다.
참고 3
에이전트 클러스터 내의 서로 다른 에이전트 가 서로 다른 [[LittleEndian]] 값을 가지면 다중 바이트 데이터에 공유 메모리를 사용하기 어려워집니다.
클러스터 내의 모든 에이전트 는 각자의 Agent Record 에 있는 [[IsLockFree1]] 필드에 대해 동일한 값을 가져야 하며, [[IsLockFree2]] 및 [[IsLockFree8]] 필드도 마찬가지입니다.
클러스터 내의 모든 에이전트 는 각자의 Agent Record 에 있는 [[Signifier]] 필드에 서로 다른 값을 가져야 합니다.
임베딩은 에이전트 의 인지나 협조 없이 에이전트 를 비활성화(전진 진행 중지)하거나 활성화(전진 진행 재개)할 수 있습니다. 임베딩이 이를 수행하는 경우 클러스터 내 일부 에이전트 는 활성 상태로 둔 채 다른 에이전트 를 무기한 비활성화 상태로 두어서는 안 됩니다.
참고 4
앞의 제한은 다른 에이전트 가 비활성화되었기 때문에 어떤 에이전트 가 교착되거나 기아 상태에 빠지는 상황을 방지하기 위한 것입니다. 예를 들어 어떤 창의 문서와 독립적인 수명을 갖는 HTML shared worker가 그러한 독립 문서의 dedicated worker와 메모리를 공유할 수 있고, dedicated worker가 락을 보유한 상태에서 문서와 해당 dedicated worker가 비활성화된 후(예: 문서가 창의 방문 기록에 들어간 경우) shared worker가 해당 락을 획득하려고 시도한다면, shared worker는 dedicated worker가 다시 활성화될 때까지, 어쩌면 영원히, 블로킹됩니다. 그동안 다른 창에서 shared worker에 접근하려는 다른 worker는 기아 상태에 빠집니다.
이 제한의 결과로 임베딩 내부에서 동일한 suspend/wake 집합에 속하지 않는 에이전트 사이에서는 메모리를 공유할 수 없습니다.
임베딩은 에이전트 클러스터의 다른 에이전트 가 사전에 알거나 협조하지 않아도 에이전트 를 종료할 수 있습니다. 에이전트 가 자신 또는 클러스터 내 다른 에이전트 의 프로그램적 동작이 아니라 클러스터 외부의 요인으로 종료되면, 임베딩은 두 전략 중 하나를 선택해야 합니다. 클러스터의 모든 에이전트 를 종료하거나, 클러스터의 에이전트 가 협력하여 최소 하나의 남은 구성원이 종료를 감지할 수 있도록 신뢰할 수 있는 API를 제공해야 하며, 종료 데이터에는 종료된 에이전트 를 식별하기에 충분한 정보가 포함되어야 합니다.
참고 5
이러한 종료의 예로는 운영 체제나 사용자가 별도 프로세스에서 실행 중인 에이전트 를 종료하는 경우, 또는 에이전트 별 리소스 계측 결과 해당 에이전트 가 폭주 중임을 나타내어 임베딩 자체가 다른 에이전트 와 같은 프로세스에서 실행 중인 에이전트 를 종료하는 경우가 있습니다.
다음의 각 명세 값과 그 값에서 전이적으로 도달 가능한 값은 정확히 하나의 에이전트 클러스터에 속합니다.
클러스터의 임의의 에이전트 가 ECMAScript 코드를 평가하기 전에, 클러스터 내 모든 에이전트 의 Agent Record 에 있는 [[CandidateExecution]] 필드는 초기 후보 실행 으로 설정됩니다. 초기 후보 실행 은 [[EventsRecords]] 필드가 각 에이전트 마다 하나씩 Agent Events Record 를 포함하는 List 인 빈 후보 실행 입니다. 각 Agent Events Record 의 [[AgentSignifier]] 필드는 해당 에이전트 의 에이전트 식별자 이며, [[EventList]] 와 [[AgentSynchronizesWith]] 필드는 빈 List 입니다.
참고 6
에이전트 클러스터의 모든 에이전트 는 Agent Record 의 [[CandidateExecution]] 필드에서 동일한 후보 실행 을 공유합니다. 후보 실행 은 메모리 모델 에서 사용하는 명세 메커니즘입니다.
참고 7
에이전트 클러스터는 명세상의 메커니즘이며 ECMAScript 구현체의 특정 산출물과 대응할 필요는 없습니다.
9.8 전진 진행
에이전트 가 전진 진행을 한다 는 것은 이 명세에 따라 평가 단계를 수행하는 것을 의미합니다.
에이전트 의 실행 중인 실행 컨텍스트 가 외부 이벤트를 동기적으로 무기한 기다리게 되면 에이전트 는 블로킹 상태가 됩니다. Agent Record 의 [[CanBlock]] 필드가 true 인 에이전트 만 이러한 의미에서 블로킹될 수 있습니다. 블로킹되지 않은 에이전트 는 블로킹 상태가 아닌 에이전트 입니다.
구현체는 다음을 보장해야 합니다:
전용 실행 스레드 를 갖는 모든 블로킹되지 않은 에이전트 는 결국 전진 진행을 합니다.
하나의 실행 스레드 를 공유하는 에이전트 집합에서는 하나의 에이전트 가 결국 전진 진행을 합니다.
에이전트 는 명시적으로 블로킹을 제공하는 API를 통하는 경우를 제외하고 다른 에이전트 가 블로킹되도록 해서는 안 됩니다.
참고
이 요구 사항은 메모리 모델 의 생존성 보장과 함께 모든 seq-cst 쓰기가 결국 모든 에이전트 에서 관찰 가능해짐을 보장합니다.
9.9 WeakRef 및 FinalizationRegistry 대상의 처리 모델
9.9.1 목표
이 명세는 어떤 객체나 Symbol이 가비지 컬렉션될 것이라는 보장도 하지 않습니다. 생존하지 않는 객체나 Symbol도 오랜 시간이 지난 후 해제될 수도 있고, 전혀 해제되지 않을 수도 있습니다. 이러한 이유로 이 명세에서는 가비지 컬렉션에 의해 발생하는 동작을 설명할 때 “할 수 있습니다”라는 표현을 사용합니다.
WeakRef 및 FinalizationRegistry 의 의미론은 특정 시점에 발생하는 두 연산을 기반으로 합니다:
이 두 동작(ClearKeptObjects 또는 CleanupFinalizationRegistry )은 모두 동기 ECMAScript 실행을 중단시켜서는 안 됩니다. 호스트 가 더 긴 동기 ECMAScript 실행 구간 을 구성할 수 있으므로 이 명세에서는 ClearKeptObjects 및 CleanupFinalizationRegistry 의 예약을 호스트 환경 에 위임합니다.
일부 ECMAScript 구현체에는 ECMAScript가 유휴 상태일 때를 포함하여 백그라운드에서 실행되는 가비지 컬렉터 구현이 있습니다. 호스트 환경 이 CleanupFinalizationRegistry 를 예약할 수 있게 하면 finalizer 작업을 실행하기 위해 ECMAScript 실행을 재개하고, 보유 중인 값을 해제하여 전체 메모리 사용량을 줄일 수 있습니다.
9.9.2 생존성
객체 및/또는 Symbol의 어떤 집합 objSet 에 대해 objSet 에 대한 가상의 WeakRef 비인식 실행은, 참조 대상이 objSet 의 요소인 WeakRef 에 대해 추상 연산 WeakRefDeref 가 항상 undefined 를 반환하는 실행입니다.
참고 1
WeakRef 비인식성과 생존성은 함께 두 가지 개념을 포착합니다. 첫째,
WeakRef 자체는 참조 대상을 생존 상태로 유지하지 않습니다. 둘째, 생존성의 순환이 값이 생존 상태임을 의미하지는 않습니다. 구체적으로
v 의 생존성 결정이
WeakRef 참조 대상
r 의 생존성 결정에 의존하는 경우,
r 의 생존성은
v 의 생존성을 가정할 수 없습니다. 그렇게 하면 순환 추론이 됩니다.
참고 2
WeakRef 비인식성은 순환을 고려하기 위해 개별 값이 아니라 객체 또는 Symbol의 집합에 대해 정의됩니다. 개별 값에 대해 정의하면 순환 안의
WeakRef 참조 대상은 그 동일성이 순환 내 다른
WeakRef 참조 대상을 통해서만 관찰되더라도 생존 상태로 간주됩니다.
참고 3
비공식적으로 개별 객체 또는 Symbol을 포함하는 모든 집합이 생존 상태이면 해당 객체 또는 Symbol도 생존 상태라고 합니다.
평가 중 어느 시점이든 객체 및/또는 Symbol의 집합 objSet 은 다음 조건 중 하나라도 충족하면 생존 상태 로 간주합니다:
objSet 의 어떤 요소가 임의의 에이전트 의 [[KeptAlive]] List 에 포함되어 있습니다.
objSet 에 대해, objSet 의 값 중 하나의 동일성을 관찰하는 유효한 미래의 가상 WeakRef 비인식 실행이 존재합니다.
참고 4
위의 두 번째 조건은 값의 동일성을
WeakRef 가 아닌 수단으로 관찰할 수 있으면 해당 값이 생존 상태라는 직관을 포착하려는 것입니다. 값의 동일성은 엄격 동등성 비교 결과를 관찰하거나 해당 값이 Map의 키로 사용되는 것을 관찰하여 확인할 수 있습니다.
참고 5
객체 또는 Symbol이 필드, 내부 슬롯 또는 프로퍼티에 존재한다고 해서 해당 값이 생존 상태임을 의미하지는 않습니다. 예를 들어 문제의 값이 프로그램에 다시 전달되지 않는다면 관찰할 수 없습니다.
이는 WeakMap의 키, WeakSet의 구성원, 그리고 FinalizationRegistry Cell Record 의 [[WeakRefTarget]] 및 [[UnregisterToken]] 필드에 해당합니다.
위 정의에 따르면 WeakMap의 키가 생존 상태가 아니라면 이에 대응하는 값도 반드시 생존 상태라고 할 수는 없습니다.
참고 6
생존성은 엔진이 어떤
WeakRef 를 비워서는 안 되는지를 보장하기 위한 하한입니다. 여기에서 정의한 생존성은 결정 불가능합니다. 실제로 엔진은 도달 가능성과 같은 보수적인 근사를 사용합니다. 구현에는 상당한 재량이 있을 것으로 예상됩니다.
9.9.3 실행
어느 시점이든 객체 및/또는 Symbol의 집합 objSet 이 생존 상태 가 아니면 ECMAScript 구현체는 다음 단계를 원자적으로 수행할 수 있습니다:
objSet 의 각 요소 value 에 대해 다음을 수행합니다.ref .[[WeakRefTarget]] 이 value 인 각 WeakRef ref 에 대해 다음을 수행합니다.ref .[[WeakRefTarget]] 을 empty 로 설정합니다.finalizationRegistry .[[Cells]] 가 cell .[[WeakRefTarget]] 이 value 인 Record cell 을 포함하는 각 FinalizationRegistry finalizationRegistry 에 대해 다음을 수행합니다.cell .[[WeakRefTarget]] 을 empty 로 설정합니다.enqueueCleanup 을 true 또는 false 중 하나를 선택하는 구현체 정의 선택으로 둡니다.enqueueCleanup 이 true 이면, HostEnqueueFinalizationRegistryCleanupJob (finalizationRegistry )을 수행합니다.map .[[WeakMapData]] 가 entry .[[Key]] 가 value 인 Record entry 를 포함하는 각 WeakMap map 에 대해 다음을 수행합니다.entry .[[Key]] 를 empty 로 설정합니다.entry .[[Value]] 를 empty 로 설정합니다.set .[[WeakSetData]] 가 value 를 포함하는 각 WeakSet set 에 대해 다음을 수행합니다.set .[[WeakSetData]] 에서 값이 value 인 요소를 값이 empty 인 요소로 교체합니다.
참고 1
생존성의 정의와 함께 이 절은 구현체가 WeakRef 에 적용할 수 있는 최적화를 규정합니다.
객체의 동일성을 관찰하지 않고도 객체에 접근할 수 있습니다. 동일성이 관찰되지 않는 탈출하지 않는 객체의 프로퍼티에 대해 죽은 변수 제거 및 스칼라 대체와 같은 최적화가 허용됩니다. 따라서 이러한 최적화로 해당 객체를 가리키는 WeakRef 가 관찰 가능하게 비워지는 것도 허용됩니다.
반면 객체의 동일성을 관찰할 수 있고 해당 객체가 WeakRef 의 [[WeakRefTarget]] 내부 슬롯에 있으면, WeakRef 를 관찰 가능하게 비우는 재구체화와 같은 최적화는 금지됩니다.
HostEnqueueFinalizationRegistryCleanupJob 호출은 선택 사항이므로 FinalizationRegistry 에 등록된 객체가 반드시 해당 FinalizationRegistry 를 생존 상태 로 유지하는 것은 아닙니다. 구현체는 어떤 이유로든 FinalizationRegistry 콜백을 생략할 수 있습니다. 예를 들어 FinalizationRegistry 자체가 생존 상태 가 아니게 되거나 애플리케이션이 종료 중인 경우가 있습니다.
참고 2
구현체는 생존 상태 가 아닌 객체 또는 Symbol의 최대 집합에 대해 WeakRef 를 비울 의무가 없습니다.
구현체가 WeakRef 를 비울 생존하지 않는 집합 objSet 을 선택하면, 이 정의에 따라 objSet 의 모든 값에 대한 WeakRef 를 동시에 비워야 합니다. 다시 말해, 구현체가 값 v 를 가리키는 WeakRef 를 비우면서, 비우지 않을 경우 v 의 값을 관찰하는 실행이 가능해지는 다른 WeakRef 를 비우지 않는 것은 적합하지 않습니다.
9.9.4 호스트 훅
9.9.4.1 HostEnqueueFinalizationRegistryCleanupJob ( finalizationRegistry )
호스트 정의 추상 연산 HostEnqueueFinalizationRegistryCleanupJob. 인수 finalizationRegistry (FinalizationRegistry ). 반환값: unused .
cleanupJob 을 매개변수가 없고 finalizationRegistry 를 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Job Abstract Closure 로 둡니다:
cleanupResult 를 Completion (CleanupFinalizationRegistry (finalizationRegistry ))으로 둡니다.cleanupResult 가 비정상 완료 이면 오류 보고를 위한 호스트 정의 단계를 수행합니다.unused 를 반환합니다.
HostEnqueueFinalizationRegistryCleanupJob의 구현은 가능하면 미래의 어느 시점에 수행되도록 cleanupJob 을 예약합니다. 또한 9.5 의 요구 사항도 준수해야 합니다.
9.10 ClearKeptObjects ( )
추상 연산 ClearKeptObjects. 인수 없음. 반환값: unused . ECMAScript 구현체는 동기 ECMAScript 실행 시퀀스가 완료될 때 ClearKeptObjects를 호출하는 것이 기대됩니다. 호출되면 다음 단계를 수행한다.
agentRecord 를 주변 에이전트 의 Agent Record 로 둡니다.agentRecord .[[KeptAlive]] 를 새로운 빈 List 로 설정합니다.unused 를 반환합니다.
9.11 AddToKeptObjects ( value )
추상 연산 AddToKeptObjects. 인수 value ((Object 또는 Symbol)). 반환값: unused . 호출되면 다음 단계를 수행한다.
agentRecord 를 주변 에이전트 의 Agent Record 로 둡니다.value 를 agentRecord .[[KeptAlive]] 에 추가합니다.unused 를 반환합니다.
참고
추상 연산 AddToKeptObjects가 대상 객체 또는 Symbol을 인수로 호출되면
ClearKeptObjects 가 호출될 때까지 대상을 강하게 참조하는 목록에 해당 대상을 추가합니다.
9.12 CleanupFinalizationRegistry ( finalizationRegistry )
추상 연산 CleanupFinalizationRegistry. 인수 finalizationRegistry (FinalizationRegistry ). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
단언 : finalizationRegistry 에는 [[Cells]] 및 [[CleanupCallback]] 내부 슬롯이 있습니다.callback 을 finalizationRegistry .[[CleanupCallback]] 으로 둡니다.finalizationRegistry .[[Cells]] 가 cell .[[WeakRefTarget]] 이 empty 인 Record cell 을 포함하는 동안, 구현체는 다음 단계를 수행할 수 있습니다:그러한 cell 중 하나를 선택합니다. finalizationRegistry .[[Cells]] 에서 cell 을 제거합니다.? HostCallJobCallback (callback , undefined , « cell .[[HeldValue]] »)을 수행합니다. unused 를 반환합니다.
9.13 CanBeHeldWeakly ( arg )
추상 연산 CanBeHeldWeakly. 인수 arg (ECMAScript 언어 값 ). 반환값: Boolean. arg 가 약한 참조로 사용하기에 적합한 경우에만 true 를 반환합니다. 약한 참조로 사용하기에 적합한 값만 WeakMap의 키, WeakSet의 요소, WeakRef 의 대상 또는 FinalizationRegistry 의 대상 중 하나가 될 수 있습니다. 호출되면 다음 단계를 수행한다.
arg 가 Object이면, true 를 반환합니다.arg 가 Symbol이고 KeyForSymbol (arg )이 undefined 이면, true 를 반환합니다.false 를 반환합니다.
참고
언어 동일성 이 없는 언어 값은 사전 참조 없이 만들어질 수 있으므로 약한 참조로 사용하기에 적합하지 않습니다. Symbol.for 가 생성한 Symbol 값은 다른 Symbol 값과 달리 언어 동일성이 없으므로 약한 참조로 사용하기에 적합하지 않습니다. 잘 알려진 Symbol 은 가비지 컬렉션되지 않을 가능성이 높지만, 수가 제한되어 있어 다양한 구현 방식으로 관리할 수 있으므로 약한 참조로 사용하기에 적합한 것으로 취급됩니다. 그러나 생존 상태 인 WeakMap에서 잘 알려진 Symbol에 연결된 모든 값은 가비지 컬렉션되지 않을 가능성이 높아 구현체에서 메모리 리소스를 “누수”할 수 있습니다.
10 일반 객체와 특수 객체의 동작
10.1 일반 객체 내부 메서드와 내부 슬롯
모든 일반 객체 에는 [[Prototype]] 이라는 내부 슬롯이 있습니다. 이 내부 슬롯의 값은 null 또는 객체이며 상속을 구현하는 데 사용됩니다. propertyKey 라는 이름의 프로퍼티가 일반 객체 obj 에는 없지만 해당 [[Prototype]] 객체에는 존재한다고 가정합니다. propertyKey 가 [[Prototype]] 객체의 데이터 프로퍼티 를 참조하면 obj 는 get 접근을 위해 이를 상속하며, propertyKey 가 obj 의 프로퍼티인 것처럼 동작합니다. propertyKey 가 [[Prototype]] 객체의 쓰기 가능한 데이터 프로퍼티 를 참조하면 obj 에서 propertyKey 에 대한 set 접근은 obj 에 propertyKey 라는 이름의 새로운 데이터 프로퍼티 를 생성합니다. propertyKey 가 [[Prototype]] 객체의 쓰기 불가능한 데이터 프로퍼티 를 참조하면 obj 에서 propertyKey 에 대한 set 접근은 실패합니다. propertyKey 가 [[Prototype]] 객체의 접근자 프로퍼티 를 참조하면 해당 접근자는 get 접근과 set 접근 모두에 대해 obj 에 상속됩니다.
모든 일반 객체 에는 Boolean 값을 갖는 [[Extensible]] 내부 슬롯이 있으며, 이는 6.1.7.3 에 명시된 확장 가능성과 관련된 내부 메서드 불변 조건을 충족하는 데 사용됩니다. 즉, 객체의 [[Extensible]] 내부 슬롯 값이 false 로 설정되고 나면 더 이상 객체에 프로퍼티를 추가하거나, 객체의 [[Prototype]] 내부 슬롯 값을 수정하거나, 이후 [[Extensible]] 값을 true 로 변경할 수 없습니다.
다음 알고리즘 설명에서는 obj 가 일반 객체 이고, propertyKey 가 프로퍼티 키 값이며, value 가 임의의 ECMAScript 언어 값 이고, propertyDesc 가 Property Descriptor Record 라고 가정합니다.
각 일반 객체 내부 메서드는 이름이 유사한 추상 연산 에 위임합니다. 그러한 추상 연산 이 다른 내부 메서드에 의존하면 이름이 유사한 추상 연산 을 직접 호출하는 대신 obj 에서 내부 메서드를 호출합니다. 이러한 의미론은 일반 객체 내부 메서드가 특수 객체 에 적용될 때 해당 특수 객체 에서 재정의된 내부 메서드가 호출되도록 보장합니다.
10.1.1 [[GetPrototypeOf]] ( )
an ordinary object obj 의 내부 메서드 [[GetPrototypeOf]] . 인수 없음. 반환값: 정상 완료 (값: (Object 또는 null )). 호출되면 다음 단계를 수행한다.
OrdinaryGetPrototypeOf (obj )를 반환합니다.
10.1.1.1 OrdinaryGetPrototypeOf ( obj )
추상 연산 OrdinaryGetPrototypeOf. 인수 obj (Object). 반환값: (Object 또는 null ). 호출되면 다음 단계를 수행한다.
obj .[[Prototype]] 을 반환합니다.
10.1.2 [[SetPrototypeOf]] ( proto )
an ordinary object obj 의 내부 메서드 [[SetPrototypeOf]] . 인수 proto ((Object 또는 null )). 반환값: 정상 완료 (값: Boolean). 호출되면 다음 단계를 수행한다.
OrdinarySetPrototypeOf (obj , proto )를 반환합니다.
10.1.2.1 OrdinarySetPrototypeOf ( obj , proto )
추상 연산 OrdinarySetPrototypeOf. 인수 obj (Object) 및 proto ((Object 또는 null )). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
current 를 obj .[[Prototype]] 으로 둡니다.SameValue (proto , current )가 true 이면, true 를 반환합니다.extensible 을 obj .[[Extensible]] 로 둡니다.extensible 이 false 이면, false 를 반환합니다.cursor 를 proto 로 둡니다.done 을 false 로 둡니다.done 이 false 인 동안 다음을 반복합니다.cursor 가 null 이면, 다음을 수행합니다.done 을 true 로 설정합니다.그렇지 않고 SameValue (cursor , obj )가 true 이면, 다음을 수행합니다.false 를 반환합니다. 그렇지 않으면,cursor .[[GetPrototypeOf]] 가 10.1.1 에 정의된 일반 객체 내부 메서드가 아니면 done 을 true 로 설정합니다.그렇지 않으면 cursor 를 cursor .[[Prototype]] 으로 설정합니다. obj .[[Prototype]] 을 proto 로 설정합니다.true 를 반환합니다.
참고
7 단계의 반복은 [[GetPrototypeOf]] 및 [[SetPrototypeOf]] 에 일반 객체 정의만 사용하는 객체로 이루어진 모든 프로토타입 체인에 순환이 생기지 않도록 보장합니다.
10.1.3 [[IsExtensible]] ( )
an ordinary object obj 의 내부 메서드 [[IsExtensible]] . 인수 없음. 반환값: 정상 완료 (값: Boolean). 호출되면 다음 단계를 수행한다.
OrdinaryIsExtensible (obj )를 반환합니다.
10.1.3.1 OrdinaryIsExtensible ( obj )
추상 연산 OrdinaryIsExtensible. 인수 obj (Object). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
obj .[[Extensible]] 을 반환합니다.
10.1.4 [[PreventExtensions]] ( )
an ordinary object obj 의 내부 메서드 [[PreventExtensions]] . 인수 없음. 반환값: 정상 완료 (값: true ). 호출되면 다음 단계를 수행한다.
OrdinaryPreventExtensions (obj )를 반환합니다.
10.1.4.1 OrdinaryPreventExtensions ( obj )
추상 연산 OrdinaryPreventExtensions. 인수 obj (Object). 반환값: true . 호출되면 다음 단계를 수행한다.
obj .[[Extensible]] 을 false 로 설정합니다.true 를 반환합니다.
10.1.5 [[GetOwnProperty]] ( propertyKey )
an ordinary object obj 의 내부 메서드 [[GetOwnProperty]] . 인수 propertyKey (프로퍼티 키 ). 반환값: 정상 완료 (값: (프로퍼티 서술자 또는 undefined )). 호출되면 다음 단계를 수행한다.
OrdinaryGetOwnProperty (obj , propertyKey )를 반환합니다.
10.1.5.1 OrdinaryGetOwnProperty ( obj , propertyKey )
추상 연산 OrdinaryGetOwnProperty. 인수 obj (Object) 및 propertyKey (프로퍼티 키 ). 반환값: (프로퍼티 서술자 또는 undefined ). 호출되면 다음 단계를 수행한다.
obj 에 키가 propertyKey 인 자체 프로퍼티가 없으면, undefined 를 반환합니다.propertyDesc 를 필드가 없는 새로 생성된 Property Descriptor 로 둡니다.ownProperty 를 키가 propertyKey 인 obj 의 자체 프로퍼티로 둡니다.ownProperty 가 데이터 프로퍼티 이면, 다음을 수행합니다.propertyDesc .[[Value]] 를 ownProperty 의 [[Value]] 속성 값으로 설정합니다.propertyDesc .[[Writable]] 을 ownProperty 의 [[Writable]] 속성 값으로 설정합니다.그렇지 않으면,단언 : ownProperty 는 접근자 프로퍼티 입니다.propertyDesc .[[Getter]] 를 ownProperty 의 [[Getter]] 속성 값으로 설정합니다.propertyDesc .[[Setter]] 를 ownProperty 의 [[Setter]] 속성 값으로 설정합니다. propertyDesc .[[Enumerable]] 을 ownProperty 의 [[Enumerable]] 속성 값으로 설정합니다.propertyDesc .[[Configurable]] 을 ownProperty 의 [[Configurable]] 속성 값으로 설정합니다.propertyDesc 를 반환합니다.
10.1.6 [[DefineOwnProperty]] ( propertyKey , propertyDesc )
an ordinary object obj 의 내부 메서드 [[DefineOwnProperty]] . 인수 propertyKey (프로퍼티 키 ) 및 propertyDesc (프로퍼티 서술자 ). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
? OrdinaryDefineOwnProperty (obj , propertyKey , propertyDesc )를 반환합니다.
10.1.6.1 OrdinaryDefineOwnProperty ( obj , propertyKey , propertyDesc )
추상 연산 OrdinaryDefineOwnProperty. 인수 obj (Object), propertyKey (프로퍼티 키 ) 및 propertyDesc (프로퍼티 서술자 ). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
current 를 ? obj .[[GetOwnProperty]] (propertyKey ) 로 둡니다.extensible 을 ? IsExtensible (obj )로 둡니다.ValidateAndApplyPropertyDescriptor (obj , propertyKey , extensible , propertyDesc , current )를 반환합니다.
10.1.6.2 IsCompatiblePropertyDescriptor ( extensible , propertyDesc , current )
추상 연산 IsCompatiblePropertyDescriptor. 인수 extensible (Boolean), propertyDesc (프로퍼티 서술자 ) 및 current ((프로퍼티 서술자 또는 undefined )). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
ValidateAndApplyPropertyDescriptor (undefined , "" , extensible , propertyDesc , current )를 반환합니다.
10.1.6.3 ValidateAndApplyPropertyDescriptor ( obj , propertyKey , extensible , propertyDesc , current )
추상 연산 ValidateAndApplyPropertyDescriptor. 인수 obj ((Object 또는 undefined )), propertyKey (프로퍼티 키 ), extensible (Boolean), propertyDesc (프로퍼티 서술자 ) 및 current ((프로퍼티 서술자 또는 undefined )). 반환값: Boolean. 지정된 extensibility 와 현재 프로퍼티 current 를 갖는 객체의 프로퍼티로 propertyDesc 를 적용하면서 불변 조건 을 유지할 수 있는 경우에만 true 를 반환합니다. 이러한 적용이 가능하고 obj 가 undefined 가 아니면 propertyKey 라는 이름의 프로퍼티에 적용하며, 필요한 경우 해당 프로퍼티를 생성합니다. 호출되면 다음 단계를 수행한다.
단언 : propertyKey 는 프로퍼티 키 입니다.current 가 undefined 이면, 다음을 수행합니다.extensible 이 false 이면, false 를 반환합니다.obj 가 undefined 이면, true 를 반환합니다.IsAccessorDescriptor (propertyDesc )가 true 이면, 다음을 수행합니다.객체 obj 에 propertyKey 라는 이름의 자체 접근자 프로퍼티 를 생성합니다. 해당 프로퍼티의 [[Getter]] , [[Setter]] , [[Enumerable]] 및 [[Configurable]] 속성은 propertyDesc 에 대응하는 필드가 있으면 해당 필드 값으로 설정하고, 그렇지 않으면 해당 속성의 기본값 으로 설정합니다. 그렇지 않으면,객체 obj 에 propertyKey 라는 이름의 자체 데이터 프로퍼티 를 생성합니다. 해당 프로퍼티의 [[Value]] , [[Writable]] , [[Enumerable]] 및 [[Configurable]] 속성은 propertyDesc 에 대응하는 필드가 있으면 해당 필드 값으로 설정하고, 그렇지 않으면 해당 속성의 기본값 으로 설정합니다. true 를 반환합니다.단언 : current 는 모든 필드가 채워진 Property Descriptor 입니다.propertyDesc 에 필드가 하나도 없으면, true 를 반환합니다.current .[[Configurable]] 이 false 이면, 다음을 수행합니다.propertyDesc 에 [[Configurable]] 필드가 있고 propertyDesc .[[Configurable]] 이 true 이면, false 를 반환합니다.propertyDesc 에 [[Enumerable]] 필드가 있고 propertyDesc .[[Enumerable]] 이 current .[[Enumerable]] 과 다르면, false 를 반환합니다.IsGenericDescriptor (propertyDesc )가 false 이고 IsAccessorDescriptor (propertyDesc )가 IsAccessorDescriptor (current )와 다르면, false 를 반환합니다.IsAccessorDescriptor (current )가 true 이면, 다음을 수행합니다.propertyDesc 에 [[Getter]] 필드가 있고 SameValue (propertyDesc .[[Getter]] , current .[[Getter]] )가 false 이면, false 를 반환합니다.propertyDesc 에 [[Setter]] 필드가 있고 SameValue (propertyDesc .[[Setter]] , current .[[Setter]] )가 false 이면, false 를 반환합니다.그렇지 않고 current .[[Writable]] 이 false 이면, 다음을 수행합니다.propertyDesc 에 [[Writable]] 필드가 있고 propertyDesc .[[Writable]] 이 true 이면, false 를 반환합니다.참고 : SameValue 는 다른 방법으로 구별될 수 있는 NaN 값에 대해 true 를 반환합니다. 여기에서 반환하면 obj 의 기존 프로퍼티가 수정되지 않도록 보장합니다.propertyDesc 에 [[Value]] 필드가 있으면, SameValue (propertyDesc .[[Value]] , current .[[Value]] )를 반환합니다. obj 가 undefined 가 아니면, 다음을 수행합니다.IsDataDescriptor (current )가 true 이고 IsAccessorDescriptor (propertyDesc )가 true 이면, 다음을 수행합니다.propertyDesc 에 [[Configurable]] 필드가 있으면 configurable 을 propertyDesc .[[Configurable]] 로 둡니다. 그렇지 않으면 configurable 을 current .[[Configurable]] 로 둡니다.propertyDesc 에 [[Enumerable]] 필드가 있으면 enumerable 을 propertyDesc .[[Enumerable]] 로 둡니다. 그렇지 않으면 enumerable 을 current .[[Enumerable]] 로 둡니다.객체 obj 에서 propertyKey 라는 이름의 프로퍼티를 접근자 프로퍼티 로 교체합니다. 해당 프로퍼티의 [[Configurable]] 및 [[Enumerable]] 속성은 각각 configurable 및 enumerable 로 설정하고, [[Getter]] 및 [[Setter]] 속성은 propertyDesc 에 대응하는 필드가 있으면 해당 필드 값으로 설정하며, 그렇지 않으면 해당 속성의 기본값 으로 설정합니다. 그렇지 않고 IsAccessorDescriptor (current )가 true 이고 IsDataDescriptor (propertyDesc )가 true 이면, 다음을 수행합니다.propertyDesc 에 [[Configurable]] 필드가 있으면 configurable 을 propertyDesc .[[Configurable]] 로 둡니다. 그렇지 않으면 configurable 을 current .[[Configurable]] 로 둡니다.propertyDesc 에 [[Enumerable]] 필드가 있으면 enumerable 을 propertyDesc .[[Enumerable]] 로 둡니다. 그렇지 않으면 enumerable 을 current .[[Enumerable]] 로 둡니다.객체 obj 에서 propertyKey 라는 이름의 프로퍼티를 데이터 프로퍼티 로 교체합니다. 해당 프로퍼티의 [[Configurable]] 및 [[Enumerable]] 속성은 각각 configurable 및 enumerable 로 설정하고, [[Value]] 및 [[Writable]] 속성은 propertyDesc 에 대응하는 필드가 있으면 해당 필드 값으로 설정하며, 그렇지 않으면 해당 속성의 기본값 으로 설정합니다. 그렇지 않으면,propertyDesc 의 각 필드 이름 fieldName 에 대해 객체 obj 에서 propertyKey 라는 이름의 프로퍼티에 있는 fieldName 이라는 이름의 속성을 propertyDesc 의 fieldName 필드 값으로 설정합니다. true 를 반환합니다.
10.1.7 [[HasProperty]] ( propertyKey )
an ordinary object obj 의 내부 메서드 [[HasProperty]] . 인수 propertyKey (프로퍼티 키 ). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
? OrdinaryHasProperty (obj , propertyKey )를 반환합니다.
10.1.7.1 OrdinaryHasProperty ( obj , propertyKey )
추상 연산 OrdinaryHasProperty. 인수 obj (Object) 및 propertyKey (프로퍼티 키 ). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
hasOwn 을 ? obj .[[GetOwnProperty]] (propertyKey ) 로 둡니다.hasOwn 이 undefined 가 아니면, true 를 반환합니다.parent 를 ? obj .[[GetPrototypeOf]] () 로 둡니다.parent 가 null 이 아니면, 다음을 수행합니다.? parent .[[HasProperty]] (propertyKey ) 를 반환합니다. false 를 반환합니다.
10.1.8 [[Get]] ( propertyKey , receiver )
an ordinary object obj 의 내부 메서드 [[Get]] . 인수 propertyKey (프로퍼티 키 ) 및 receiver (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
? OrdinaryGet (obj , propertyKey , receiver )를 반환합니다.
10.1.8.1 OrdinaryGet ( obj , propertyKey , receiver )
추상 연산 OrdinaryGet. 인수 obj (Object), propertyKey (프로퍼티 키 ) 및 receiver (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
propertyDesc 를 ? obj .[[GetOwnProperty]] (propertyKey ) 로 둡니다.propertyDesc 가 undefined 이면, 다음을 수행합니다.parent 를 ? obj .[[GetPrototypeOf]] () 로 둡니다.parent 가 null 이면, undefined 를 반환합니다.? parent .[[Get]] (propertyKey , receiver ) 를 반환합니다. IsDataDescriptor (propertyDesc )가 true 이면, propertyDesc .[[Value]] 를 반환합니다.단언 : IsAccessorDescriptor (propertyDesc )는 true 입니다.getter 를 propertyDesc .[[Getter]] 로 둡니다.getter 가 undefined 이면, undefined 를 반환합니다.? Call (getter , receiver )를 반환합니다.
10.1.9 [[Set]] ( propertyKey , value , receiver )
an ordinary object obj 의 내부 메서드 [[Set]] . 인수 propertyKey (프로퍼티 키 ), value (ECMAScript 언어 값 ) 및 receiver (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
? OrdinarySet (obj , propertyKey , value , receiver )를 반환합니다.
10.1.9.1 OrdinarySet ( obj , propertyKey , value , receiver )
추상 연산 OrdinarySet. 인수 obj (Object), propertyKey (프로퍼티 키 ), value (ECMAScript 언어 값 ) 및 receiver (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
ownDesc 를 ? obj .[[GetOwnProperty]] (propertyKey ) 로 둡니다.? OrdinarySetWithOwnDescriptor (obj , propertyKey , value , receiver , ownDesc )를 반환합니다.
10.1.9.2 OrdinarySetWithOwnDescriptor ( obj , propertyKey , value , receiver , ownDesc )
추상 연산 OrdinarySetWithOwnDescriptor. 인수 obj (Object), propertyKey (프로퍼티 키 ), value (ECMAScript 언어 값 ), receiver (ECMAScript 언어 값 ) 및 ownDesc ((프로퍼티 서술자 또는 undefined )). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
ownDesc 가 undefined 이면, 다음을 수행합니다.parent 를 ? obj .[[GetPrototypeOf]] () 로 둡니다.parent 가 null 이 아니면, ? parent .[[Set]] (propertyKey , value , receiver ) 를 반환합니다.ownDesc 를 PropertyDescriptor { [[Value]] : undefined , [[Writable]] : true , [[Enumerable]] : true , [[Configurable]] : true }로 설정합니다.IsDataDescriptor (ownDesc )가 true 이면, 다음을 수행합니다.ownDesc .[[Writable]] 이 false 이면, false 를 반환합니다.receiver 가 Object가 아니면, false 를 반환합니다.existingDesc 를 ? receiver .[[GetOwnProperty]] (propertyKey ) 로 둡니다.existingDesc 가 undefined 이면, 다음을 수행합니다.단언 : receiver 에는 현재 프로퍼티 propertyKey 가 없습니다.? CreateDataProperty (receiver , propertyKey , value )를 반환합니다. IsAccessorDescriptor (existingDesc )가 true 이면, false 를 반환합니다.existingDesc .[[Writable]] 이 false 이면, false 를 반환합니다.valueDesc 를 PropertyDescriptor { [[Value]] : value }로 둡니다.? receiver .[[DefineOwnProperty]] (propertyKey , valueDesc ) 를 반환합니다. 단언 : IsAccessorDescriptor (ownDesc )는 true 입니다.setter 를 ownDesc .[[Setter]] 로 둡니다.setter 가 undefined 이면, false 를 반환합니다.? Call (setter , receiver , « value »)를 수행합니다. true 를 반환합니다.
10.1.10 [[Delete]] ( propertyKey )
an ordinary object obj 의 내부 메서드 [[Delete]] . 인수 propertyKey (프로퍼티 키 ). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
? OrdinaryDelete (obj , propertyKey )를 반환합니다.
10.1.10.1 OrdinaryDelete ( obj , propertyKey )
추상 연산 OrdinaryDelete. 인수 obj (Object) 및 propertyKey (프로퍼티 키 ). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
propertyDesc 를 ? obj .[[GetOwnProperty]] (propertyKey ) 로 둡니다.propertyDesc 가 undefined 이면, true 를 반환합니다.propertyDesc .[[Configurable]] 이 true 이면, 다음을 수행합니다.obj 에서 이름이 propertyKey 인 자체 프로퍼티를 제거합니다.true 를 반환합니다.false 를 반환합니다.
10.1.11 [[OwnPropertyKeys]] ( )
an ordinary object obj 의 내부 메서드 [[OwnPropertyKeys]] . 인수 없음. 반환값: 정상 완료 (값: 리스트 (요소: 프로퍼티 키 )). 호출되면 다음 단계를 수행한다.
OrdinaryOwnPropertyKeys (obj )를 반환합니다.
10.1.11.1 OrdinaryOwnPropertyKeys ( obj )
추상 연산 OrdinaryOwnPropertyKeys. 인수 obj (Object). 반환값: 리스트 (요소: 프로퍼티 키 ). 호출되면 다음 단계를 수행한다.
keys 를 새로운 빈 List 로 둡니다.배열 인덱스 인 obj 의 각 자체 프로퍼티 키 propertyKey 에 대해 숫자 인덱스 오름차순으로 다음을 수행합니다.propertyKey 를 keys 에 추가합니다.String이고 배열 인덱스 가 아닌 obj 의 각 자체 프로퍼티 키 propertyKey 에 대해 프로퍼티 생성 시간 오름차순으로 다음을 수행합니다.propertyKey 를 keys 에 추가합니다. Symbol인 obj 의 각 자체 프로퍼티 키 propertyKey 에 대해 프로퍼티 생성 시간 오름차순으로 다음을 수행합니다.propertyKey 를 keys 에 추가합니다. keys 를 반환합니다.
10.1.12 OrdinaryObjectCreate ( proto [ , additionalInternalSlotsList ] )
추상 연산 OrdinaryObjectCreate. 인수 proto ((Object 또는 null )) 및 선택적 인수 additionalInternalSlotsList (리스트 (요소: 내부 슬롯 이름)). 반환값: Object. 새로운 일반 객체 의 런타임 생성을 명시하는 데 사용됩니다. additionalInternalSlotsList 에는 [[Prototype]] 및 [[Extensible]] 외에 객체의 일부로 정의해야 하는 추가 내부 슬롯의 이름이 포함됩니다. additionalInternalSlotsList 가 제공되지 않으면 새로운 빈 List 를 사용합니다. 호출되면 다음 단계를 수행한다.
internalSlotsList 를 « [[Prototype]] , [[Extensible]] »로 둡니다.additionalInternalSlotsList 가 존재하면 internalSlotsList 를 internalSlotsList 와 additionalInternalSlotsList 의 목록 연결 로 설정합니다.obj 를 MakeBasicObject (internalSlotsList )로 둡니다.obj .[[Prototype]] 을 proto 로 설정합니다.obj 를 반환합니다.
참고
OrdinaryObjectCreate는 MakeBasicObject 를 호출하는 것 이상을 거의 수행하지 않지만, 이를 사용하면 특수 객체 가 아니라 일반 객체 를 생성하려는 의도가 전달됩니다. 따라서 이 명세에서는 이후 객체의 내부 메서드를 결과가 일반 객체 가 아니게 되는 방식으로 수정하는 알고리즘에서 이를 호출하지 않습니다. 특수 객체 를 생성하는 연산은 MakeBasicObject 를 직접 호출합니다.
10.1.13 OrdinaryCreateFromConstructor ( ctor , intrinsicDefaultProto [ , internalSlotsList ] )
추상 연산 OrdinaryCreateFromConstructor. 인수 ctor (함수 객체 ) 및 intrinsicDefaultProto (String) 및 선택적 인수 internalSlotsList (리스트 (요소: 내부 슬롯 이름)). 반환값: (정상 완료 (값: Object) 또는 throw 완료 ). 생성자 의 "prototype" 속성이 존재하면 해당 속성에서 [[Prototype]] 값을 가져오고, 그렇지 않으면 생성자 의 영역에서 intrinsicDefaultProto 로 지정된 내장 객체를 [[Prototype]] 값으로 사용하는 일반 객체 를 생성합니다. internalSlotsList 에는 해당 객체의 일부로 정의해야 하는 추가 내부 슬롯의 이름이 포함됩니다. 호출되면 다음 단계를 수행한다.
단언 : intrinsicDefaultProto 는 이 명세에서 내재 객체에 사용하는 이름입니다. 대응하는 객체는 객체의 [[Prototype]] 값으로 사용하도록 의도된 내재 객체여야 합니다.proto 를 ? GetPrototypeFromConstructor (ctor , intrinsicDefaultProto )로 둡니다.internalSlotsList 가 존재하면 slots 를 internalSlotsList 로 둡니다.그렇지 않으면 slots 를 새로운 빈 List 로 둡니다. OrdinaryObjectCreate (proto , slots )를 반환합니다.
10.1.14 GetPrototypeFromConstructor ( ctor , intrinsicDefaultProto )
추상 연산 GetPrototypeFromConstructor. 인수 ctor (함수 객체 ) 및 intrinsicDefaultProto (String). 반환값: (정상 완료 (값: Object) 또는 throw 완료 ). 특정 생성자 를 사용하여 생성된 객체에 사용해야 하는 [[Prototype]] 값을 결정합니다. 생성자 의 "prototype" 속성이 존재하면 해당 속성에서 값을 가져옵니다. 그렇지 않으면 생성자 의 영역에서 intrinsicDefaultProto 로 지정된 내장 객체를 사용합니다. 호출되면 다음 단계를 수행한다.
단언 : intrinsicDefaultProto 는 이 명세에서 정의한 내장 객체의 이름입니다. 해당 객체는 객체의 [[Prototype]] 값으로 사용하도록 의도된 내장 객체여야 합니다.proto 를 ? Get (ctor , "prototype" )으로 설정합니다.proto 가 Object이면 proto 를 반환합니다.참고 : ctor 의 영역에서 가져온 대체 값은 현재 실행 중인 실행 컨텍스트 와 무관합니다.realm 을 ? GetFunctionRealm (ctor )으로 설정합니다.realm .[[Intrinsics]] 에서 intrinsicDefaultProto 로 식별되는 필드의 값을 반환합니다.
10.1.15 RequireInternalSlot ( obj , internalSlot )
추상 연산 RequireInternalSlot. 인수 obj (ECMAScript 언어 값 ) 및 internalSlot (내부 슬롯 이름). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). obj 가 Object이고 주어진 내부 슬롯을 갖는 경우가 아니면 예외를 던집니다. 호출되면 다음 단계를 수행한다.
obj 가 Object가 아니면, TypeError 예외를 던집니다.obj 에 internalSlot 내부 슬롯이 없으면, TypeError 예외를 던집니다.unused 를 반환합니다.
10.2 ECMAScript 함수 객체
ECMAScript 함수 객체 는 렉시컬 환경을 클로저로 캡처한 매개변수화된 ECMAScript 코드를 캡슐화하고 해당 코드의 동적 평가를 지원합니다. ECMAScript 함수 객체 는 일반 객체 이며 다른 일반 객체 와 동일한 내부 슬롯과 내부 메서드를 갖습니다. ECMAScript 함수 객체 의 코드는 엄격 모드 코드 (11.2.2 )이거나 비엄격 코드 일 수 있습니다. 코드가 엄격 모드 코드 인 ECMAScript 함수 객체 를 엄격 함수 라고 합니다. 코드가 엄격 모드 코드 가 아닌 함수 객체 를 비엄격 함수 라고 합니다.
[[Extensible]] 및 [[Prototype]] 외에도 ECMAScript 함수 객체 에는 표 26 에 나열된 내부 슬롯이 있습니다.
표 26: ECMAScript 함수 객체 의 내부 슬롯
내부 슬롯
타입
설명
[[Environment]]
Environment Record
함수가 클로저로 캡처한 Environment Record 입니다. 함수 코드 를 평가할 때 바깥쪽 환경으로 사용됩니다.
[[PrivateEnvironment]]
PrivateEnvironment Record 또는 null
함수가 클로저로 캡처한 Private Name 에 대한 PrivateEnvironment Record 입니다. 이 함수가 구문상 클래스 내부에 포함되지 않으면 null 입니다. 함수 코드 를 평가할 때 내부 클래스의 바깥쪽 PrivateEnvironment로 사용됩니다.
[[FormalParameters]]
Parse Node
함수의 형식 매개변수 목록을 정의하는 소스 텍스트의 루트 Parse Node입니다.
[[ECMAScriptCode]]
Parse Node
함수 본문을 정의하는 소스 텍스트의 루트 Parse Node입니다.
[[ConstructorKind]]
base 또는 derived
함수가 파생 클래스 생성자 인지를 나타냅니다.
[[Realm]]
Realm Record
함수가 생성된 realm 이며 함수 평가 중 접근하는 모든 내재 객체를 제공합니다.
[[ScriptOrModule]]
Script Record 또는 Module Record
함수가 생성된 스크립트 또는 모듈입니다.
[[ThisMode]]
lexical , strict 또는 global
함수의 형식 매개변수와 코드 본문 내에서 this 참조를 해석하는 방법을 정의합니다. lexical 은 this가 렉시컬하게 둘러싸는 함수의 this 값을 참조함을 의미합니다. strict 는 함수 호출에서 제공된 this 값을 정확히 그대로 사용함을 의미합니다. global 은 undefined 또는 null 인 this 값을 전역 객체 에 대한 참조로 해석하고, 그 밖의 모든 this 값은 먼저 ToObject 에 전달함을 의미합니다.
[[Strict]]
Boolean
엄격 함수 이면 true , 비엄격 함수 이면 false 입니다.
[[HomeObject]]
Object 또는 undefined
함수가 super를 사용하면 이는 [[GetPrototypeOf]] 가 super 프로퍼티 조회를 시작할 객체를 제공하는 객체입니다.
[[SourceText]]
유니코드 코드 포인트 시퀀스
함수를 정의하는 소스 텍스트 입니다.
[[Fields]]
ClassFieldDefinition Record 의 List
함수가 클래스이면 클래스의 비정적 필드와 대응하는 이니셜라이저를 나타내는 Record 의 목록입니다.
[[PrivateMethods]]
PrivateElement 의 List
함수가 클래스이면 클래스의 비정적 비공개 메서드와 접근자를 나타내는 목록입니다.
[[ClassFieldInitializerName]]
String, Symbol, Private Name 또는 empty
함수가 클래스 필드의 이니셜라이저로 생성되었으면 해당 필드의 NamedEvaluation 에 사용할 이름이고, 그렇지 않으면 empty 입니다.
[[IsClassConstructor]]
Boolean
함수가 클래스 생성자 인지를 나타냅니다. (true 이면 함수의 [[Call]] 을 호출하면 즉시 TypeError 예외를 던집니다.)
모든 ECMAScript 함수 객체 에는 여기에 정의된 [[Call]] 내부 메서드가 있습니다. 생성자 이기도 한 ECMAScript 함수에는 추가로 [[Construct]] 내부 메서드가 있습니다.
10.2.1 [[Call]] ( thisArg , argList )
an ECMAScript function object func 의 내부 메서드 [[Call]] . 인수 thisArg (ECMAScript 언어 값 ) 및 argList (리스트 (요소: ECMAScript 언어 값 )). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
callerContext 를 실행 중인 실행 컨텍스트 로 둡니다.calleeContext 를 PrepareForOrdinaryCall (func , undefined )로 둡니다.단언 : 이제 calleeContext 가 실행 중인 실행 컨텍스트 입니다.func .[[IsClassConstructor]] 가 true 이면, 다음을 수행합니다.error 를 새로 생성된 TypeError 객체로 둡니다.참고 : error 는 func 와 연결된 Realm Record 를 사용하여 calleeContext 에서 생성됩니다.실행 컨텍스트 스택 에서 calleeContext 를 제거하고 callerContext 를 실행 중인 실행 컨텍스트 로 복원합니다.error 를 던집니다.OrdinaryCallBindThis (func , calleeContext , thisArg )를 수행합니다.result 를 Completion (OrdinaryCallEvaluateBody (func , argList ))로 둡니다.실행 컨텍스트 스택 에서 calleeContext 를 제거하고 callerContext 를 실행 중인 실행 컨텍스트 로 복원합니다.result 가 throw 완료 이면, ? result 를 반환합니다.단언 : result 는 return 완료 입니다.result .[[Value]] 를 반환합니다.
참고
7 단계에서 calleeContext 가 실행 컨텍스트 스택 에서 제거될 때, 접근 가능한 Generator에 의해 일시 중단되고 이후 재개를 위해 유지되고 있다면 파기해서는 안 됩니다.
10.2.1.1 PrepareForOrdinaryCall ( func , newTarget )
추상 연산 PrepareForOrdinaryCall. 인수 func (ECMAScript 함수 객체) 및 newTarget ((Object 또는 undefined )). 반환값: 실행 컨텍스트 . 호출되면 다음 단계를 수행한다.
callerContext 를 실행 중인 실행 컨텍스트 로 둡니다.calleeContext 를 새로운 ECMAScript 코드 실행 컨텍스트 로 둡니다.calleeContext 의 Function을 func 로 설정합니다.calleeRealm 을 func .[[Realm]] 로 둡니다.calleeContext 의 Realm 을 calleeRealm 로 설정합니다.calleeContext 의 ScriptOrModule을 func .[[ScriptOrModule]] 로 설정합니다.localEnv 를 NewFunctionEnvironment (func , newTarget )으로 둡니다.calleeContext 의 LexicalEnvironment를 localEnv 로 설정합니다.calleeContext 의 VariableEnvironment를 localEnv 로 설정합니다.calleeContext 의 PrivateEnvironment를 func .[[PrivateEnvironment]] 로 설정합니다.callerContext 가 아직 일시 중단되지 않았으면 callerContext 를 일시 중단합니다.calleeContext 를 실행 컨텍스트 스택 에 푸시합니다. 이제 calleeContext 가 실행 중인 실행 컨텍스트 입니다.참고 : 이 시점 이후 생성되는 모든 예외 객체는 calleeRealm 과 연결됩니다.calleeContext 를 반환합니다.
10.2.1.2 OrdinaryCallBindThis ( func , calleeContext , thisArg )
추상 연산 OrdinaryCallBindThis. 인수 func (ECMAScript 함수 객체), calleeContext (실행 컨텍스트 ) 및 thisArg (ECMAScript 언어 값 ). 반환값: unused . 호출되면 다음 단계를 수행한다.
thisMode 를 func .[[ThisMode]] 로 둡니다.thisMode 가 lexical 이면, unused 를 반환합니다.calleeRealm 을 func .[[Realm]] 로 둡니다.localEnv 를 calleeContext 의 LexicalEnvironment로 둡니다.thisMode 가 strict 이면, 다음을 수행합니다.thisValue 를 thisArg 로 둡니다.그렇지 않으면,thisArg 가 undefined 또는 null 이면, 다음을 수행합니다.globalEnv 를 calleeRealm .[[GlobalEnv]] 로 둡니다.단언 : globalEnv 는 Global Environment Record 입니다.thisValue 를 globalEnv .[[GlobalThisValue]] 로 둡니다.그렇지 않으면,thisValue 를 ! ToObject (thisArg )로 둡니다.참고 : ToObject 는 calleeRealm 을 사용하여 래퍼 객체를 생성합니다. 단언 : localEnv 는 Function Environment Record 입니다.단언 : localEnv .[[ThisBindingStatus]] 가 initialized 가 아니므로 다음 단계는 절대로 비정상 완료 를 반환하지 않습니다.! BindThisValue (localEnv , thisValue )를 수행합니다. unused 를 반환합니다.
10.2.1.3 Runtime Semantics: EvaluateBody
구문 지향 연산 EvaluateBody. 인수 func (ECMAScript 함수 객체) 및 argList (리스트 (요소: ECMAScript 언어 값 )). 반환값: (return 완료 또는 throw 완료 ). 다음 생성 규칙별로 정의된다.
FunctionBody : FunctionStatementList
인수 func 및 argList 를 사용한 FunctionBody 의 ? EvaluateFunctionBody 를 반환합니다.
ConciseBody : ExpressionBody
인수 func 및 argList 를 사용한 ConciseBody 의 ? EvaluateConciseBody 를 반환합니다.
GeneratorBody : FunctionBody
인수 func 및 argList 를 사용한 GeneratorBody 의 ? EvaluateGeneratorBody 를 반환합니다.
AsyncGeneratorBody : FunctionBody
인수 func 및 argList 를 사용한 AsyncGeneratorBody 의 ? EvaluateAsyncGeneratorBody 를 반환합니다.
AsyncFunctionBody : FunctionBody
인수 func 및 argList 를 사용한 AsyncFunctionBody 의 ? EvaluateAsyncFunctionBody 를 반환합니다.
AsyncConciseBody : ExpressionBody
인수 func 및 argList 를 사용한 AsyncConciseBody 의 ? EvaluateAsyncConciseBody 를 반환합니다.
Initializer :
=
AssignmentExpression
단언 : argList 는 비어 있습니다.단언 : func .[[ClassFieldInitializerName]] 은 empty 가 아닙니다.IsAnonymousFunctionDefinition (AssignmentExpression )이 true 이면, 다음을 수행합니다.value 를 인수 func .[[ClassFieldInitializerName]] 을 사용한 Initializer 의 ? NamedEvaluation 으로 둡니다.그렇지 않으면,rhs 를 AssignmentExpression 의 ? Evaluation 으로 둡니다.value 를 ? GetValue (rhs )로 둡니다. ReturnCompletion (value )을 반환합니다.
참고
필드 이니셜라이저가 함수 경계를 구성하더라도 FunctionDeclarationInstantiation 을 호출하는 것은 관찰 가능한 효과가 없으므로 생략합니다.
ClassStaticBlockBody : ClassStaticBlockStatementList
단언 : argList 는 비어 있습니다.인수 func 를 사용한 ClassStaticBlockBody 의 ? EvaluateClassStaticBlockBody 를 반환합니다.
10.2.1.4 OrdinaryCallEvaluateBody ( func , argList )
추상 연산 OrdinaryCallEvaluateBody. 인수 func (ECMAScript 함수 객체) 및 argList (리스트 (요소: ECMAScript 언어 값 )). 반환값: (return 완료 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
인수 func 및 argList 를 사용한 func .[[ECMAScriptCode]] 의 ? EvaluateBody 를 반환합니다.
10.2.2 [[Construct]] ( argList , newTarget )
an ECMAScript function object func 의 내부 메서드 [[Construct]] . 인수 argList (리스트 (요소: ECMAScript 언어 값 )) 및 newTarget (생성자 ). 반환값: (정상 완료 (값: Object) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
callerContext 를 실행 중인 실행 컨텍스트 로 둡니다.kind 를 func .[[ConstructorKind]] 로 둡니다.kind 가 base 이면, 다음을 수행합니다.thisArg 를 ? OrdinaryCreateFromConstructor (newTarget , "%Object.prototype%" )로 둡니다.calleeContext 를 PrepareForOrdinaryCall (func , newTarget )로 둡니다.단언 : 이제 calleeContext 가 실행 중인 실행 컨텍스트 입니다.kind 가 base 이면, 다음을 수행합니다.OrdinaryCallBindThis (func , calleeContext , thisArg )를 수행합니다.initializeResult 를 Completion (InitializeInstanceElements (thisArg , func ))로 둡니다.initializeResult 가 비정상 완료 이면, 다음을 수행합니다.실행 컨텍스트 스택 에서 calleeContext 를 제거하고 callerContext 를 실행 중인 실행 컨텍스트 로 복원합니다.? initializeResult 를 반환합니다. ctorEnv 를 calleeContext 의 LexicalEnvironment로 둡니다.result 를 Completion (OrdinaryCallEvaluateBody (func , argList ))로 둡니다.실행 컨텍스트 스택 에서 calleeContext 를 제거하고 callerContext 를 실행 중인 실행 컨텍스트 로 복원합니다.result 가 throw 완료 이면, ? result 를 반환합니다.단언 : result 는 return 완료 입니다.result .[[Value]] 가 Object이면, result .[[Value]] 를 반환합니다.kind 가 base 이면, thisArg 를 반환합니다.result .[[Value]] 가 undefined 가 아니면, TypeError 예외를 던집니다.thisBinding 을 ? ctorEnv .GetThisBinding ()으로 둡니다.단언 : thisBinding 은 Object입니다.thisBinding 을 반환합니다.
10.2.3 OrdinaryFunctionCreate ( proto , sourceText , paramList , body , thisMode , envRecord , privateEnv )
추상 연산 OrdinaryFunctionCreate. 인수 proto (Object), sourceText (a sequence of Unicode code points), paramList (구문 분석 노드), body (구문 분석 노드), thisMode ((lexical-this 또는 non-lexical-this )), envRecord (Environment 레코드 ) 및 privateEnv ((PrivateEnvironment 레코드 또는 null )). 반환값: ECMAScript 함수 객체. 기본 [[Call]] 내부 메서드를 갖고 [[Construct]] 내부 메서드는 없는 새로운 함수의 런타임 생성을 명시하는 데 사용됩니다(다만 MakeConstructor 와 같은 연산에 의해 이후 [[Construct]] 가 추가될 수 있습니다). sourceText 는 생성할 함수의 구문 정의에 해당하는 소스 텍스트입니다. 호출되면 다음 단계를 수행한다.
internalSlotsList 를 표 26 에 나열된 내부 슬롯으로 둡니다.func 를 OrdinaryObjectCreate (proto , internalSlotsList )로 둡니다.func .[[Call]] 을 10.2.1 에 명시된 정의로 설정합니다.func .[[SourceText]] 를 sourceText 로 설정합니다.func .[[FormalParameters]] 를 paramList 로 설정합니다.func .[[ECMAScriptCode]] 를 body 로 설정합니다.strict 를 IsStrict (body )로 둡니다.func .[[Strict]] 을 strict 로 설정합니다.thisMode 가 lexical-this 이면 func .[[ThisMode]] 를 lexical 로 설정합니다.그렇지 않고 strict 가 true 이면 func .[[ThisMode]] 를 strict 로 설정합니다. 그렇지 않으면 func .[[ThisMode]] 를 global 로 설정합니다. func .[[IsClassConstructor]] 를 false 로 설정합니다.func .[[Environment]] 을 envRecord 로 설정합니다.func .[[PrivateEnvironment]] 을 privateEnv 로 설정합니다.func .[[ScriptOrModule]] 을 GetActiveScriptOrModule ()로 설정합니다.func .[[Realm]] 을 현재 Realm Record 로 설정합니다.func .[[HomeObject]] 을 undefined 로 설정합니다.func .[[Fields]] 를 새로운 빈 List 로 설정합니다.func .[[PrivateMethods]] 를 새로운 빈 List 로 설정합니다.func .[[ClassFieldInitializerName]] 을 empty 로 설정합니다.length 를 paramList 의 ExpectedArgumentCount 로 둡니다.SetFunctionLength (func , length )를 수행합니다.func 를 반환합니다.
10.2.4 AddRestrictedFunctionProperties ( func , realm )
추상 연산 AddRestrictedFunctionProperties. 인수 func (함수 객체 ) 및 realm (Realm 레코드 ). 반환값: unused . 호출되면 다음 단계를 수행한다.
단언 : realm .[[Intrinsics]] .[[%ThrowTypeError% ]]가 존재하며 초기화되어 있습니다.thrower 를 realm .[[Intrinsics]] .[[%ThrowTypeError% ]]로 둡니다.! DefinePropertyOrThrow (func , "caller" , PropertyDescriptor { [[Getter]] : thrower , [[Setter]] : thrower , [[Enumerable]] : false , [[Configurable]] : true })를 수행합니다. ! DefinePropertyOrThrow (func , "arguments" , PropertyDescriptor { [[Getter]] : thrower , [[Setter]] : thrower , [[Enumerable]] : false , [[Configurable]] : true })를 수행합니다. unused 를 반환합니다.
10.2.4.1 %ThrowTypeError% ( )
이 함수는 %ThrowTypeError% 내재 객체입니다.
각 realm 마다 한 번 정의되는 익명 내장 함수 객체 입니다.
호출되면 다음 단계를 수행합니다:
TypeError 예외를 던집니다.
이 함수의 [[Extensible]] 내부 슬롯 값은 false 입니다.
이 함수의 "length" 프로퍼티는 속성 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false }를 갖습니다.
이 함수의 "name" 프로퍼티는 속성 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false }를 갖습니다.
10.2.5 MakeConstructor ( func [ , writableProto [ , proto ] ] )
추상 연산 MakeConstructor. 인수 func ((ECMAScript 함수 객체 또는 내장 함수 객체)) 및 선택적 인수 writableProto (Boolean) 및 proto (Object). 반환값: unused . func 를 생성자 로 변환합니다. 호출되면 다음 단계를 수행한다.
func 가 ECMAScript 함수 객체 이면, 다음을 수행합니다.단언 : IsConstructor (func )는 false 입니다.단언 : func 는 "prototype" 자체 프로퍼티를 갖지 않는 확장 가능한 객체입니다.func .[[Construct]] 를 10.2.2 에 명시된 정의로 설정합니다.그렇지 않으면,func .[[Construct]] 를 10.3.2 에 명시된 정의로 설정합니다. func .[[ConstructorKind]] 를 base 로 설정합니다.writableProto 가 존재하지 않으면 writableProto 를 true 로 설정합니다.proto 가 존재하지 않으면, 다음을 수행합니다.proto 를 OrdinaryObjectCreate (%Object.prototype% )로 설정합니다.! DefinePropertyOrThrow (proto , "constructor" , PropertyDescriptor { [[Value]] : func , [[Writable]] : writableProto , [[Enumerable]] : false , [[Configurable]] : true })를 수행합니다. ! DefinePropertyOrThrow (func , "prototype" , PropertyDescriptor { [[Value]] : proto , [[Writable]] : writableProto , [[Enumerable]] : false , [[Configurable]] : false })를 수행합니다. unused 를 반환합니다.
10.2.6 MakeClassConstructor ( func )
추상 연산 MakeClassConstructor. 인수 func (ECMAScript 함수 객체). 반환값: unused . 호출되면 다음 단계를 수행한다.
단언 : func .[[IsClassConstructor]] 는 false 입니다.func .[[IsClassConstructor]] 를 true 로 설정합니다.unused 를 반환합니다.
10.2.7 MakeMethod ( func , homeObj )
추상 연산 MakeMethod. 인수 func (ECMAScript 함수 객체) 및 homeObj (Object). 반환값: unused . func 를 메서드로 구성합니다. 호출되면 다음 단계를 수행한다.
단언 : homeObj 는 일반 객체 입니다.func .[[HomeObject]] 을 homeObj 로 설정합니다.unused 를 반환합니다.
10.2.8 DefineMethodProperty ( homeObj , name , closure , enumerable )
추상 연산 DefineMethodProperty. 인수 homeObj (Object), name ((프로퍼티 키 또는 비공개 이름 )), closure (함수 객체 ) 및 enumerable (Boolean). 반환값: (정상 완료 (값: (PrivateElement 또는 empty )) 또는 중도 완료). 호출되면 다음 단계를 수행한다.
단언 : homeObj 는 일반 확장 가능 객체입니다.name 이 Private Name 이면, PrivateElement { [[Key]] : name , [[Kind]] : method , [[Value]] : closure }를 반환합니다.propertyDesc 를 PropertyDescriptor { [[Value]] : closure , [[Writable]] : true , [[Enumerable]] : enumerable , [[Configurable]] : true }로 둡니다.? DefinePropertyOrThrow (homeObj , name , propertyDesc )를 수행합니다. 참고 : DefinePropertyOrThrow 는 name 이 "prototype" 인 클래스 정적 메서드를 정의하려고 할 때만 비정상 완료 를 반환합니다.empty 를 반환합니다.
10.2.9 SetFunctionName ( func , name [ , prefix ] )
추상 연산 SetFunctionName. 인수 func (함수 객체 ) 및 name ((프로퍼티 키 또는 비공개 이름 )) 및 선택적 인수 prefix (String). 반환값: unused . func 에 "name" 프로퍼티를 추가합니다. 호출되면 다음 단계를 수행한다.
단언 : func 는 "name" 자체 프로퍼티를 갖지 않는 확장 가능한 객체입니다.name 이 Symbol이면, 다음을 수행합니다.description 을 name .[[Description]] 으로 둡니다.description 이 undefined 이면 name 을 빈 String으로 설정합니다.그렇지 않으면 name 을 "[" , description 및 "]" 의 문자열 연결 로 설정합니다. 그렇지 않고 name 이 Private Name 이면, 다음을 수행합니다.name 을 name .[[Description]] 으로 설정합니다. initialName 을 name 으로 둡니다.prefix 가 존재하면, 다음을 수행합니다.prefixedName 을 prefix , 코드 단위 0x0020 (SPACE) 및 name 의 문자열 연결 로 둡니다.initialName 을 prefixedName 으로 설정합니다.Normative Optional, Legacy
initialName 을 name 또는 prefixedName 중 구현체 정의 방식으로 선택한 값으로 설정합니다.name 을 prefixedName 으로 설정합니다.func 에 [[InitialName]] 내부 슬롯이 있으면 func .[[InitialName]] 을 initialName 으로 설정합니다.! DefinePropertyOrThrow (func , "name" , PropertyDescriptor { [[Value]] : name , [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true })를 수행합니다. unused 를 반환합니다.
참고
func .[[InitialName]] 에 prefixedName 을 사용할지 여부에 대한 선택은 Function.prototype.toString ( ) 의 출력에 영향을 줍니다. 5.c 단계에서 서로 다른 내장 함수에 대해 서로 다른 선택을 하는 것은 권장되지 않는 레거시 동작입니다.
10.2.10 SetFunctionLength ( func , length )
추상 연산 SetFunctionLength. 인수 func (함수 객체 ) 및 length ((음이 아닌 정수 또는 +∞)). 반환값: unused . func 에 "length" 프로퍼티를 추가합니다. 호출되면 다음 단계를 수행한다.
단언 : func 는 "length" 자체 프로퍼티를 갖지 않는 확장 가능한 객체입니다.! DefinePropertyOrThrow (func , "length" , PropertyDescriptor { [[Value]] : 𝔽 (length ), [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true })를 수행합니다. unused 를 반환합니다.
10.2.11 FunctionDeclarationInstantiation ( func , argList )
추상 연산 FunctionDeclarationInstantiation. 인수 func (ECMAScript 함수 객체) 및 argList (리스트 (요소: ECMAScript 언어 값 )). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). func 는 실행 컨텍스트 를 설정하는 대상 함수 객체 입니다.
참고
ECMAScript 함수를 평가하기 위한 실행 컨텍스트 를 설정하면 새로운 Function Environment Record 가 생성되고 각 형식 매개변수에 대한 바인딩이 해당 Environment Record 에서 인스턴스화됩니다. 함수 본문의 각 선언도 인스턴스화됩니다. 함수의 형식 매개변수에 기본값 이니셜라이저가 포함되지 않으면 본문 선언은 매개변수와 동일한 Environment Record 에서 인스턴스화됩니다. 기본값 매개변수 이니셜라이저가 존재하면 본문 선언을 위해 두 번째 Environment Record 가 생성됩니다. 형식 매개변수와 함수는 FunctionDeclarationInstantiation의 일부로 초기화됩니다. 그 밖의 모든 바인딩은 함수 본문 평가 중에 초기화됩니다.
호출되면 다음 단계를 수행합니다:
calleeContext 를 실행 중인 실행 컨텍스트 로 둡니다.code 를 func .[[ECMAScriptCode]] 로 둡니다.strict 를 func .[[Strict]] 로 둡니다.formals 를 func .[[FormalParameters]] 로 둡니다.paramNames 를 formals 의 BoundNames 로 둡니다.paramNames 에 중복 항목이 있으면 hasDuplicates 를 true 로 둡니다. 그렇지 않으면 hasDuplicates 를 false 로 둡니다.simpleParamList 를 formals 의 IsSimpleParameterList 로 둡니다.hasParamExprs 를 formals 의 ContainsExpression 으로 둡니다.variableNames 를 code 의 VarDeclaredNames 로 둡니다.variableDecls 를 code 의 VarScopedDeclarations 로 둡니다.lexicalNames 를 code 의 LexicallyDeclaredNames 로 둡니다.funcNames 를 새로운 빈 List 로 둡니다.funcsToInitialize 를 새로운 빈 List 로 둡니다.variableDecls 의 각 요소 variableDecl 에 대해 List 역순으로 다음을 수행합니다.variableDecl 이 VariableDeclaration 도 ForBinding 도 BindingIdentifier 도 아니면, 다음을 수행합니다.단언 : variableDecl 은 FunctionDeclaration , GeneratorDeclaration , AsyncFunctionDeclaration 또는 AsyncGeneratorDeclaration 중 하나입니다.funcName 을 variableDecl 의 BoundNames 의 유일한 요소로 둡니다.funcNames 에 funcName 이 포함되어 있지 않으면, 다음을 수행합니다.funcName 을 funcNames 의 첫 번째 요소로 삽입합니다.참고 : 동일한 이름의 함수 선언이 여러 개 있으면 마지막 선언을 사용합니다.variableDecl 을 funcsToInitialize 의 첫 번째 요소로 삽입합니다.argumentsObjNeeded 를 true 로 둡니다.func .[[ThisMode]] 가 lexical 이면, 다음을 수행합니다.참고 : 화살표 함수에는 arguments 객체가 없습니다.argumentsObjNeeded 를 false 로 설정합니다.그렇지 않고 paramNames 에 "arguments" 가 포함되어 있으면, 다음을 수행합니다.argumentsObjNeeded 를 false 로 설정합니다. 그렇지 않고 hasParamExprs 가 false 이면, 다음을 수행합니다.funcNames 에 "arguments" 가 포함되어 있거나 lexicalNames 에 "arguments" 가 포함되어 있으면, 다음을 수행합니다.argumentsObjNeeded 를 false 로 설정합니다. strict 가 true 이거나 hasParamExprs 가 false 이면, 다음을 수행합니다.참고 : 엄격 모드 코드 의 eval 호출은 eval 외부에서 볼 수 있는 새로운 바인딩을 생성할 수 없으므로 매개변수에는 하나의 Environment Record 만 필요합니다.envRecord 를 calleeContext 의 LexicalEnvironment로 둡니다.그렇지 않으면,참고 : 형식 매개변수 목록에서 직접 eval 호출로 생성된 바인딩이 매개변수가 선언되는 환경 바깥에 있도록 보장하기 위해 별도의 Environment Record 가 필요합니다.calleeEnv 를 calleeContext 의 LexicalEnvironment로 둡니다.envRecord 를 NewDeclarativeEnvironment (calleeEnv )로 둡니다.단언 : calleeContext 의 VariableEnvironment와 calleeEnv 는 같은 Environment Record 입니다.calleeContext 의 LexicalEnvironment를 envRecord 로 설정합니다. paramNames 의 각 String paramName 에 대해 다음을 수행합니다.alreadyDeclared 를 ! envRecord .HasBinding (paramName )으로 둡니다.참고 : 조기 오류 는 중복 매개변수 이름이 매개변수 기본값이나 나머지 매개변수를 갖지 않는 비엄격 함수 에서만 나타날 수 있도록 보장합니다.alreadyDeclared 가 false 이면, 다음을 수행합니다.! envRecord .CreateMutableBinding (paramName , false )를 수행합니다. hasDuplicates 가 true 이면, 다음을 수행합니다.! envRecord .InitializeBinding (paramName , undefined )를 수행합니다. argumentsObjNeeded 가 true 이면, 다음을 수행합니다.strict 가 true 이거나 simpleParamList 가 false 이면, 다음을 수행합니다.argumentsObj 를 CreateUnmappedArgumentsObject (argList )로 둡니다.그렇지 않으면,참고 : 매핑된 arguments 객체는 나머지 매개변수, 매개변수 기본값 이니셜라이저 또는 구조 분해 매개변수가 없는 비엄격 함수 에만 제공됩니다.argumentsObj 를 CreateMappedArgumentsObject (func , formals , argList , envRecord )로 둡니다. strict 가 true 이면, 다음을 수행합니다.! envRecord .CreateImmutableBinding ("arguments" , false )를 수행합니다. 참고 : 엄격 모드 코드 에서는 조기 오류 가 이 바인딩에 할당하려는 시도를 방지하므로 변경 가능 여부를 관찰할 수 없습니다.그렇지 않으면,! envRecord .CreateMutableBinding ("arguments" , false )를 수행합니다. ! envRecord .InitializeBinding ("arguments" , argumentsObj )를 수행합니다. paramBindings 를 paramNames 와 « "arguments" »의 목록 연결 로 둡니다.그렇지 않으면,paramBindings 를 paramNames 로 둡니다. iteratorRecord 를 CreateListIteratorRecord (argList )로 둡니다.hasDuplicates 가 true 이면, 다음을 수행합니다.usedEnv 를 undefined 로 둡니다.그렇지 않으면,usedEnv 를 envRecord 로 둡니다. 참고 : 다음 단계는 ReturnCompletion 을 반환할 수 없습니다. 표현식 위치에서 그러한 완료가 발생할 수 있는 유일한 방법은 YieldExpression 을 사용하는 것이지만, 이는 15.5.1 및 15.6.1 의 조기 오류 규칙 에 의해 매개변수 목록에서 금지됩니다.인수 iteratorRecord 및 usedEnv 를 사용한 formals 의 ? IteratorBindingInitialization 을 수행합니다. hasParamExprs 가 false 이면, 다음을 수행합니다.참고 : 매개변수와 최상위 var에는 하나의 Environment Record 만 필요합니다.instantiatedVariableNames 를 List paramBindings 의 복사본으로 둡니다.variableNames 의 각 요소 name 에 대해 다음을 수행합니다.instantiatedVariableNames 에 name 이 포함되어 있지 않으면, 다음을 수행합니다.name 을 instantiatedVariableNames 에 추가합니다.! envRecord .CreateMutableBinding (name , false )를 수행합니다. ! envRecord .InitializeBinding (name , undefined )를 수행합니다. variableEnv 를 envRecord 로 둡니다.그렇지 않으면,참고 : 형식 매개변수 목록의 표현식에서 생성된 클로저가 함수 본문의 선언을 볼 수 없도록 별도의 Environment Record 가 필요합니다.variableEnv 를 NewDeclarativeEnvironment (envRecord )로 둡니다.calleeContext 의 VariableEnvironment를 variableEnv 로 설정합니다.instantiatedVariableNames 를 새로운 빈 List 로 둡니다.variableNames 의 각 요소 name 에 대해 다음을 수행합니다.instantiatedVariableNames 에 name 이 포함되어 있지 않으면, 다음을 수행합니다.name 을 instantiatedVariableNames 에 추가합니다.! variableEnv .CreateMutableBinding (name , false )를 수행합니다. paramBindings 에 name 이 포함되어 있지 않거나 funcNames 에 name 이 포함되어 있으면, 다음을 수행합니다.initialValue 를 undefined 로 둡니다.그렇지 않으면,initialValue 를 ! envRecord .GetBindingValue (name , false )로 둡니다. ! variableEnv .InitializeBinding (name , initialValue )을 수행합니다. 참고 : 형식 매개변수와 같은 이름의 var는 처음에는 대응하는 초기화된 매개변수와 같은 값을 갖습니다. strict 가 true 이면, 다음을 수행합니다.lexicalEnv 를 variableEnv 로 둡니다.그렇지 않으면,Normative Optional
호스트 가 웹 브라우저이거나 그 밖의 방식으로 블록 수준 함수 선언의 웹 레거시 호환성 의미론 을 지원하면, 다음을 수행합니다.code Contains x 가 true 인 Block , CaseClause 또는 DefaultClause x 의 StatementList 에 직접 포함된 각 FunctionDeclaration funcDecl 에 대해 다음을 수행합니다.funcName 을 funcDecl 의 BindingIdentifier 의 StringValue 로 둡니다.FunctionDeclaration funcDecl 을 funcName 을 BindingIdentifier 로 갖는 VariableStatement 로 교체해도 func 에 대한 조기 오류 가 발생하지 않고 paramNames 에 funcName 이 포함되어 있지 않으면, 다음을 수행합니다.참고 : funcName 에 대한 var 바인딩은 여기에서 funcName 이 VarDeclaredName도, 형식 매개변수 이름도, 다른 FunctionDeclaration 도 아닌 경우에만 인스턴스화됩니다.instantiatedVariableNames 에 funcName 이 포함되어 있지 않고 funcName 이 "arguments" 가 아니면, 다음을 수행합니다.! variableEnv .CreateMutableBinding (funcName , false )를 수행합니다. ! variableEnv .InitializeBinding (funcName , undefined )를 수행합니다. funcName 을 instantiatedVariableNames 에 추가합니다.FunctionDeclaration funcDecl 이 평가될 때 15.2.6 에 제공된 FunctionDeclaration Evaluation 알고리즘 대신 다음 단계를 수행합니다.funcEnv 를 실행 중인 실행 컨텍스트 의 VariableEnvironment로 둡니다.blockEnv 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.funcObj 를 ! blockEnv .GetBindingValue (funcName , false )로 둡니다.! funcEnv .SetMutableBinding (funcName , funcObj , false )를 수행합니다. unused 를 반환합니다.lexicalEnv 를 NewDeclarativeEnvironment (variableEnv )로 둡니다.참고 : 비엄격 함수 는 최상위 렉시컬 선언에 별도의 Environment Record 를 사용하여 직접 eval 이 eval 코드에서 도입한 var 스코프 선언과 기존 최상위 렉시컬 스코프 선언 사이의 충돌 여부를 결정할 수 있도록 합니다. 엄격 직접 eval 은 항상 모든 선언을 새로운 Environment Record 에 배치하므로 엄격 함수 에는 이것이 필요하지 않습니다. calleeContext 의 LexicalEnvironment를 lexicalEnv 로 설정합니다.lexicalDecls 를 code 의 LexicallyScopedDeclarations 로 둡니다.lexicalDecls 의 각 요소 lexicalDecl 에 대해 다음을 수행합니다.참고 : 렉시컬하게 선언된 이름은 함수/제너레이터 선언, 형식 매개변수 또는 var 이름과 같을 수 없습니다. 렉시컬하게 선언된 이름은 여기에서 인스턴스화만 되고 초기화되지는 않습니다.lexicalDecl 의 BoundNames 의 각 요소 name 에 대해 다음을 수행합니다.lexicalDecl 의 IsConstantDeclaration 이 true 이면, 다음을 수행합니다.! lexicalEnv .CreateImmutableBinding (name , true )를 수행합니다. 그렇지 않으면,! lexicalEnv .CreateMutableBinding (name , false )를 수행합니다. privateEnv 를 calleeContext 의 PrivateEnvironment로 둡니다.funcsToInitialize 의 각 Parse Node funcDecl 에 대해 다음을 수행합니다.funcName 을 funcDecl 의 BoundNames 의 유일한 요소로 둡니다.funcObj 를 인수 lexicalEnv 및 privateEnv 를 사용한 funcDecl 의 InstantiateFunctionObject 로 둡니다.! variableEnv .SetMutableBinding (funcName , funcObj , false )를 수행합니다. unused 를 반환합니다.
10.3 내장 함수 객체
내장 함수 객체 는 일반 객체 이며 10.1 에 명시된 일반 객체 에 대한 요구 사항을 충족해야 합니다.
모든 일반 객체 에 필요한 내부 슬롯(10.1 참조) 외에도 내장 함수 객체 에는 다음 내부 슬롯이 있어야 합니다:
달리 명시되지 않는 한 내장 함수 객체 의 [[Prototype]] 내부 슬롯 초기값은 %Function.prototype% 입니다.
내장 함수 객체 에는 10.3.1 의 정의를 따르는 [[Call]] 내부 메서드가 있어야 합니다.
내장 함수 객체 가 “constructor”로 설명되어 있거나 이 명세의 어떤 알고리즘이 해당 [[Construct]] 내부 메서드를 명시적으로 설정하는 경우에만 [[Construct]] 내부 메서드를 갖습니다. 이러한 [[Construct]] 내부 메서드는 10.3.2 의 정의를 따라야 합니다.
구현체는 이 명세에 정의되지 않은 추가 내장 함수 객체 를 제공할 수 있습니다.
10.3.1 [[Call]] ( thisArg , argList )
a built-in function object func 의 내부 메서드 [[Call]] . 인수 thisArg (ECMAScript 언어 값 ) 및 argList (리스트 (요소: ECMAScript 언어 값 )). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
? BuiltinCallOrConstruct (func , thisArg , argList , undefined )를 반환합니다.
10.3.2 [[Construct]] ( argList , newTarget )
a built-in function object func (when the method is present)의 내부 메서드 [[Construct]] . 인수 argList (리스트 (요소: ECMAScript 언어 값 )) 및 newTarget (생성자 ). 반환값: (정상 완료 (값: Object) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
result 를 ? BuiltinCallOrConstruct (func , uninitialized , argList , newTarget )로 둡니다.단언 : result 는 Object입니다.result 를 반환합니다.
10.3.3 BuiltinCallOrConstruct ( func , thisArg , argList , newTarget )
추상 연산 BuiltinCallOrConstruct. 인수 func (내장 함수 객체), thisArg ((ECMAScript 언어 값 또는 uninitialized )), argList (리스트 (요소: ECMAScript 언어 값 )) 및 newTarget ((생성자 또는 undefined )). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
callerContext 를 실행 중인 실행 컨텍스트 로 둡니다.callerContext 가 아직 일시 중단되지 않았으면 callerContext 를 일시 중단합니다.calleeContext 를 새로운 실행 컨텍스트 로 둡니다.calleeContext 의 Function을 func 로 설정합니다.calleeRealm 을 func .[[Realm]] 로 둡니다.calleeContext 의 Realm 을 calleeRealm 으로 설정합니다.calleeContext 의 ScriptOrModule을 null 로 설정합니다.calleeContext 에 필요한 구현체 정의 초기화를 수행합니다.calleeContext 를 실행 컨텍스트 스택 에 푸시합니다. 이제 calleeContext 가 실행 중인 실행 컨텍스트 입니다.func .[[Async]] 가 true 이면, 다음을 수행합니다.promiseCapability 를 ! NewPromiseCapability (%Promise% )로 둡니다.resultsClosure 를 매개변수가 없고 func , thisArg , argList 및 newTarget 을 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:result 를 func 의 명세에 부합하는 방식으로 func 를 평가한 결과 인 Completion Record 로 둡니다. thisArg 가 uninitialized 이면 this 값은 초기화되지 않습니다. 그렇지 않으면 thisArg 가 this 값을 제공합니다. argList 는 이름 있는 매개변수를 제공합니다. newTarget 은 NewTarget 값을 제공합니다.참고 : func 가 이 문서에 정의되어 있으면 “func 의 명세”는 알고리즘 단계 또는 다른 수단으로 해당 함수에 대해 명시된 동작입니다.Completion (result )를 반환합니다.AsyncFunctionStart (promiseCapability , resultsClosure )를 수행합니다.실행 컨텍스트 스택 에서 calleeContext 를 제거하고 callerContext 를 실행 중인 실행 컨텍스트 로 복원합니다.promiseCapability .[[Promise]] 를 반환합니다.result 를 func 의 명세에 부합하는 방식으로 func 를 평가한 결과 인 Completion Record 로 둡니다. thisArg 가 uninitialized 이면 this 값은 초기화되지 않습니다. 그렇지 않으면 thisArg 가 this 값을 제공합니다. argList 는 이름 있는 매개변수를 제공합니다. newTarget 은 NewTarget 값을 제공합니다.참고 : func 가 이 문서에 정의되어 있으면 “func 의 명세”는 알고리즘 단계 또는 다른 수단으로 해당 함수에 대해 명시된 동작입니다.실행 컨텍스트 스택 에서 calleeContext 를 제거하고 callerContext 를 실행 중인 실행 컨텍스트 로 복원합니다.? result 를 반환합니다.
참고
calleeContext 가 일시 중단되어 접근 가능한 Generator에 의해 이후 재개를 위해 유지되고 있다면 실행 컨텍스트 스택 에서 제거될 때 파기해서는 안 됩니다.
10.3.4 CreateBuiltinFunction ( behaviour , length , name , additionalInternalSlotsList [ , realm [ , proto [ , prefix [ , async ] ] ] ] )
추상 연산 CreateBuiltinFunction. 인수 behaviour ((추상 클로저 , a set of algorithm steps 또는 some other definition of a function's behaviour provided in this specification)), length ((음이 아닌 정수 또는 +∞)), name ((프로퍼티 키 또는 비공개 이름 )) 및 additionalInternalSlotsList (리스트 (요소: 내부 슬롯 이름)) 및 선택적 인수 realm (Realm 레코드 ), proto ((Object 또는 null )), prefix (String) 및 async (Boolean). 반환값: 내장 함수 객체. additionalInternalSlotsList 에는 객체의 일부로 정의해야 하는 추가 내부 슬롯의 이름이 포함됩니다. 이 연산은 내장 함수 객체 를 생성합니다. 호출되면 다음 단계를 수행한다.
realm 이 존재하지 않으면 realm 을 현재 Realm Record 로 설정합니다.proto 가 존재하지 않으면 proto 를 realm .[[Intrinsics]] .[[%Function.prototype% ]]로 설정합니다.async 가 존재하지 않으면 async 를 false 로 설정합니다.internalSlotsList 를 10.3 가 생성하려는 내장 함수 객체 에 요구하는 모든 내부 슬롯의 이름을 포함하는 List 로 둡니다.additionalInternalSlotsList 의 요소를 internalSlotsList 에 추가합니다.func 를 호출될 때 behaviour 가 지정한 대응 매개변수의 값으로 제공된 인수를 사용하여 behaviour 가 설명하는 동작을 수행하는 새로운 내장 함수 객체 로 둡니다. 새로운 함수 객체 에는 이름이 internalSlotsList 의 요소인 내부 슬롯과 [[InitialName]] 내부 슬롯이 있습니다.func .[[Async]] 를 async 로 설정합니다.func .[[Prototype]] 을 proto 로 설정합니다.func .[[Extensible]] 을 true 로 설정합니다.func .[[Realm]] 을 realm 으로 설정합니다.func .[[InitialName]] 을 null 로 설정합니다.SetFunctionLength (func , length )를 수행합니다.prefix 가 존재하지 않으면, 다음을 수행합니다.SetFunctionName (func , name )을 수행합니다.그렇지 않으면,SetFunctionName (func , name , prefix )을 수행합니다. func 를 반환합니다.
이 명세에 정의된 각 내장 함수는 CreateBuiltinFunction 추상 연산 을 호출하여 생성됩니다.
10.4 내장 특수 객체의 내부 메서드와 슬롯
이 명세에서는 여러 종류의 내장 특수 객체 를 정의합니다. 이러한 객체는 일반적으로 몇몇 특정 상황을 제외하면 일반 객체 와 유사하게 동작합니다. 다음 특수 객체 는 아래에서 명시적으로 달리 지정한 경우를 제외하고 일반 객체 내부 메서드를 사용합니다:
10.4.1 바인딩된 함수 특수 객체
바인딩된 함수 특수 객체 는 다른 함수 객체 를 래핑하는 특수 객체 입니다. 바인딩된 함수 특수 객체 는 호출 가능합니다([[Call]] 내부 메서드를 가지며 [[Construct]] 내부 메서드를 가질 수도 있습니다). 바인딩된 함수 특수 객체 를 호출하면 일반적으로 래핑된 함수가 호출됩니다.
객체의 [[Call]] 및 (해당하는 경우) [[Construct]] 내부 메서드가 다음 구현을 사용하고, 그 밖의 필수 내부 메서드가 10.1 에 있는 정의를 사용하면 해당 객체는 바인딩된 함수 특수 객체 입니다. 이러한 메서드는 BoundFunctionCreate 에서 설치됩니다.
바인딩된 함수 특수 객체 에는 표 26 에 나열된 ECMAScript 함수 객체 의 내부 슬롯이 없습니다. 대신 [[Prototype]] 및 [[Extensible]] 외에도 표 27 에 나열된 내부 슬롯이 있습니다.
표 27: 바인딩된 함수 특수 객체 의 내부 슬롯
내부 슬롯
타입
설명
[[BoundTargetFunction]]
호출 가능한 Object
래핑된 함수 객체 입니다.
[[BoundThis]]
ECMAScript 언어 값
래핑된 함수를 호출할 때 항상 this 값으로 전달되는 값입니다.
[[BoundArguments]]
ECMAScript 언어 값 의 List
래핑된 함수를 호출할 때마다 첫 번째 인수로 사용되는 요소를 갖는 값의 목록입니다.
10.4.1.1 [[Call]] ( thisArg , argList )
a bound function exotic object func 의 내부 메서드 [[Call]] . 인수 thisArg (ECMAScript 언어 값 ) 및 argList (리스트 (요소: ECMAScript 언어 값 )). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
target 을 func .[[BoundTargetFunction]] 으로 둡니다.boundThis 를 func .[[BoundThis]] 로 둡니다.boundArgs 를 func .[[BoundArguments]] 로 둡니다.args 를 boundArgs 와 argList 의 목록 연결 로 둡니다.? Call (target , boundThis , args )를 반환합니다.
10.4.1.2 [[Construct]] ( argList , newTarget )
a bound function exotic object func 의 내부 메서드 [[Construct]] . 인수 argList (리스트 (요소: ECMAScript 언어 값 )) 및 newTarget (생성자 ). 반환값: (정상 완료 (값: Object) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
target 을 func .[[BoundTargetFunction]] 으로 둡니다.단언 : IsConstructor (target )은 true 입니다.boundArgs 를 func .[[BoundArguments]] 로 둡니다.args 를 boundArgs 와 argList 의 목록 연결 로 둡니다.SameValue (func , newTarget )가 true 이면 newTarget 을 target 으로 설정합니다.? Construct (target , args , newTarget )를 반환합니다.
10.4.1.3 BoundFunctionCreate ( targetFunc , boundThis , boundArgs )
추상 연산 BoundFunctionCreate. 인수 targetFunc (함수 객체 ), boundThis (ECMAScript 언어 값 ) 및 boundArgs (리스트 (요소: ECMAScript 언어 값 )). 반환값: (정상 완료 (값: 함수 객체 ) 또는 throw 완료 ). 새로운 바인딩된 함수 특수 객체 의 생성을 명시하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
proto 를 ? targetFunc .[[GetPrototypeOf]] () 로 둡니다.internalSlotsList 를 « [[Prototype]] , [[Extensible]] »과 표 27 에 나열된 내부 슬롯의 목록 연결 로 둡니다.obj 를 MakeBasicObject (internalSlotsList )로 둡니다.obj .[[Prototype]] 을 proto 로 설정합니다.obj .[[Call]] 을 10.4.1.1 에 명시된 대로 설정합니다.IsConstructor (targetFunc )가 true 이면, 다음을 수행합니다.obj .[[Construct]] 를 10.4.1.2 에 명시된 대로 설정합니다.obj .[[BoundTargetFunction]] 을 targetFunc 로 설정합니다.obj .[[BoundThis]] 를 boundThis 로 설정합니다.obj .[[BoundArguments]] 를 boundArgs 로 설정합니다.obj 를 반환합니다.
10.4.2 Array 특수 객체
Array는 배열 인덱스 프로퍼티 키 를 특별하게 처리하는 특수 객체 입니다(6.1.7 참조). 프로퍼티 이름 이 배열 인덱스 인 프로퍼티를 요소 라고도 합니다. 모든 Array에는 구성 불가능한 "length" 프로퍼티가 있으며, 그 값은 수학적 값 이 232 보다 엄격히 작은 음이 아닌 정수 Number입니다. "length" 프로퍼티의 값은 이름이 배열 인덱스 인 모든 자체 프로퍼티 이름 의 숫자 값보다 큽니다. Array의 자체 프로퍼티가 생성되거나 변경될 때마다 이 불변 조건을 유지하기 위해 필요에 따라 다른 프로퍼티를 조정합니다. 구체적으로 이름이 배열 인덱스 인 자체 프로퍼티가 추가될 때마다 필요한 경우 "length" 프로퍼티 값을 해당 배열 인덱스 의 숫자 값보다 1 큰 값으로 변경합 니다. 또한 "length" 프로퍼티 값이 변경될 때마다 배열 인덱스 이름의 값이 새로운 길이보다 작지 않은 모든 자체 프로퍼티를 삭제합니다. 이 제약 조건은 Array의 자체 프로퍼티에만 적용되며 프로토타입에서 상속될 수 있는 "length" 또는 배열 인덱스 프로퍼티의 영향을 받지 않습니다.
객체의 [[DefineOwnProperty]] 내부 메서드가 다음 구현을 사용하고 그 밖의 필수 내부 메서드가 10.1 에 있는 정의를 사용하면 해당 객체는 Array 특수 객체 (또는 간단히 Array)입니다. 이러한 메서드는 ArrayCreate 에서 설치됩니다.
10.4.2.1 [[DefineOwnProperty]] ( propertyKey , propertyDesc )
an Array exotic object array 의 내부 메서드 [[DefineOwnProperty]] . 인수 propertyKey (프로퍼티 키 ) 및 propertyDesc (프로퍼티 서술자 ). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
propertyKey 가 "length" 이면, ? ArraySetLength (array , propertyDesc )를 반환합니다.propertyKey 가 배열 인덱스 이면, 다음을 수행합니다.lengthDesc 를 OrdinaryGetOwnProperty (array , "length" )로 둡니다.단언 : lengthDesc 는 undefined 가 아닙니다.단언 : IsDataDescriptor (lengthDesc )는 true 입니다.단언 : lengthDesc .[[Configurable]] 은 false 입니다.length 를 lengthDesc .[[Value]] 로 둡니다.단언 : length 는 음이 아닌 정수 Number입니다.index 를 ! ToUint32 (propertyKey )로 둡니다.index ≥ length 이고 lengthDesc .[[Writable]] 이 false 이면, false 를 반환합니다.succeeded 를 ! OrdinaryDefineOwnProperty (array , propertyKey , propertyDesc )로 둡니다.succeeded 가 false 이면, false 를 반환합니다.index ≥ length 이면, 다음을 수행합니다.lengthDesc .[[Value]] 를 index + 1 𝔽 로 설정합니다.succeeded 를 ! OrdinaryDefineOwnProperty (array , "length" , lengthDesc )로 설정합니다.단언 : succeeded 는 true 입니다.true 를 반환합니다.? OrdinaryDefineOwnProperty (array , propertyKey , propertyDesc )를 반환합니다.
10.4.2.2 ArrayCreate ( length [ , proto ] )
추상 연산 ArrayCreate. 인수 length (음이 아닌 정수) 및 선택적 인수 proto (Object). 반환값: (정상 완료 (값: Array 특수 객체 ) 또는 throw 완료 ). 새로운 Array의 생성을 명시하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
length > 232 - 1이면, RangeError 예외를 던집니다.proto 가 존재하지 않으면 proto 를 %Array.prototype% 로 설정합니다.array 를 MakeBasicObject (« [[Prototype]] , [[Extensible]] »)로 둡니다.array .[[Prototype]] 을 proto 로 설정합니다.array .[[DefineOwnProperty]] 를 10.4.2.1 에 명시된 대로 설정합니다.! OrdinaryDefineOwnProperty (array , "length" , PropertyDescriptor { [[Value]] : 𝔽 (length ), [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : false })를 수행합니다. array 를 반환합니다.
10.4.2.3 ArraySpeciesCreate ( originalArray , length )
추상 연산 ArraySpeciesCreate. 인수 originalArray (Object) 및 length (음이 아닌 정수). 반환값: (정상 완료 (값: Object) 또는 throw 완료 ). originalArray 에서 파생된 생성자 함수를 사용하여 새로운 Array 또는 유사한 객체의 생성을 명시하는 데 사용됩니다. 생성자 함수가 반드시 Array를 반환하도록 강제하지는 않습니다. 호출되면 다음 단계를 수행한다.
isArray 를 ? IsArray (originalArray )로 둡니다.isArray 가 false 이면, ? ArrayCreate (length )를 반환합니다.ctor 를 ? Get (originalArray , "constructor" )로 둡니다.IsConstructor (ctor )가 true 이면, 다음을 수행합니다.thisRealm 을 현재 Realm Record 로 둡니다.ctorRealm 을 ? GetFunctionRealm (ctor )로 둡니다.thisRealm 과 ctorRealm 이 같은 Realm Record 가 아니면, 다음을 수행합니다.SameValue (ctor , ctorRealm .[[Intrinsics]] .[[%Array% ]])가 true 이면 ctor 를 undefined 로 설정합니다.ctor 가 Object이면, 다음을 수행합니다.ctor 를 ? Get (ctor , %Symbol.species% )로 설정합니다.ctor 가 null 이면 ctor 를 undefined 로 설정합니다.ctor 가 undefined 이면, ? ArrayCreate (length )를 반환합니다.IsConstructor (ctor )가 false 이면, TypeError 예외를 던집니다.? Construct (ctor , « 𝔽 (length ) »)를 반환합니다.
참고
originalArray 가 실행 중인 실행 컨텍스트 의 realm 이 아닌 realm 의 표준 내장 Array 생성자 를 사용하여 생성되었다면, 실행 중인 실행 컨텍스트 의 realm 을 사용하여 새로운 Array를 생성합니다. 이는 현재 ArraySpeciesCreate를 사용하여 정의된 Array.prototype 메서드에 대해 역사적으로 이러한 동작을 해 온 웹 브라우저와의 호환성을 유지합니다.
10.4.2.4 ArraySetLength ( array , propertyDesc )
추상 연산 ArraySetLength. 인수 array (Array) 및 propertyDesc (프로퍼티 서술자 ). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
propertyDesc 에 [[Value]] 필드가 없으면, 다음을 수행합니다.! OrdinaryDefineOwnProperty (array , "length" , propertyDesc )를 반환합니다. newLengthDesc 를 propertyDesc 의 복사본으로 둡니다.newLength 를 ? ToUint32 (propertyDesc .[[Value]] )로 둡니다.numberLength 를 ? ToNumber (propertyDesc .[[Value]] )로 둡니다.SameValueZero (newLength , numberLength )가 false 이면, RangeError 예외를 던집니다.newLengthDesc .[[Value]] 를 newLength 로 설정합니다.oldLengthDesc 를 OrdinaryGetOwnProperty (array , "length" )로 둡니다.단언 : oldLengthDesc 는 undefined 가 아닙니다.단언 : IsDataDescriptor (oldLengthDesc )는 true 입니다.단언 : oldLengthDesc .[[Configurable]] 은 false 입니다.oldLength 를 oldLengthDesc .[[Value]] 로 둡니다.newLength ≥ oldLength 이면, 다음을 수행합니다.! OrdinaryDefineOwnProperty (array , "length" , newLengthDesc )를 반환합니다. oldLengthDesc .[[Writable]] 이 false 이면, false 를 반환합니다.newLengthDesc 에 [[Writable]] 필드가 없거나 newLengthDesc .[[Writable]] 이 true 이면, 다음을 수행합니다.newWritable 을 true 로 둡니다.그렇지 않으면,참고 : 일부 요소를 삭제할 수 없는 경우를 대비하여 [[Writable]] 속성을 false 로 설정하는 작업을 연기합니다.newWritable 을 false 로 둡니다.newLengthDesc .[[Writable]] 을 true 로 설정합니다. succeeded 를 ! OrdinaryDefineOwnProperty (array , "length" , newLengthDesc )로 둡니다.succeeded 가 false 이면, false 를 반환합니다.배열 인덱스 이고 ! ToUint32 (propertyKey ) ≥ newLength 인 array 의 각 자체 프로퍼티 키 propertyKey 에 대해 숫자 인덱스 내림차순으로 다음을 수행합니다.deleteSucceeded 를 ! array .[[Delete]] (propertyKey )로 둡니다.deleteSucceeded 가 false 이면, 다음을 수행합니다.newLengthDesc .[[Value]] 를 ! ToUint32 (propertyKey ) + 1 𝔽 로 설정합니다.newWritable 이 false 이면 newLengthDesc .[[Writable]] 을 false 로 설정합니다.! OrdinaryDefineOwnProperty (array , "length" , newLengthDesc )를 수행합니다. false 를 반환합니다.newWritable 이 false 이면, 다음을 수행합니다.succeeded 를 ! OrdinaryDefineOwnProperty (array , "length" , PropertyDescriptor { [[Writable]] : false })로 설정합니다.단언 : succeeded 는 true 입니다.true 를 반환합니다.
참고
3 및 4 단계에서 propertyDesc .[[Value]] 가 객체이면 해당 valueOf 메서드를 두 번 호출합니다. 이는 이 명세 제2판부터 이러한 효과로 명시된 레거시 동작입니다.
10.4.3 String 특수 객체
String 객체는 String 값을 캡슐화하고 해당 String 값의 개별 코드 단위 요소에 대응하는 가상 정수 인덱스 데이터 프로퍼티 를 노출하는 특수 객체 입니다. String 특수 객체 에는 항상 "length" 라는 데이터 프로퍼티 가 있으며, 그 값은 캡슐화된 String 값의 길이입니다. 코드 단위 데이터 프로퍼티 와 "length" 프로퍼티는 모두 쓰기 불가능하고 구성 불가능합니다.
객체의 [[GetOwnProperty]] , [[DefineOwnProperty]] 및 [[OwnPropertyKeys]] 내부 메서드가 다음 구현을 사용하고, 그 밖의 필수 내부 메서드가 10.1 에 있는 정의를 사용하면 해당 객체는 String 특수 객체 (또는 간단히 String 객체)입니다. 이러한 메서드는 StringCreate 에서 설치됩니다.
String 특수 객체 에는 일반 객체 와 동일한 내부 슬롯이 있습니다. 또한 [[StringData]] 내부 슬롯도 있습니다.
10.4.3.1 [[GetOwnProperty]] ( propertyKey )
a String exotic object string 의 내부 메서드 [[GetOwnProperty]] . 인수 propertyKey (프로퍼티 키 ). 반환값: 정상 완료 (값: (프로퍼티 서술자 또는 undefined )). 호출되면 다음 단계를 수행한다.
propertyDesc 를 OrdinaryGetOwnProperty (string , propertyKey )로 둡니다.propertyDesc 가 undefined 가 아니면, propertyDesc 를 반환합니다.StringGetOwnProperty (string , propertyKey )를 반환합니다.
10.4.3.2 [[DefineOwnProperty]] ( propertyKey , propertyDesc )
a String exotic object string 의 내부 메서드 [[DefineOwnProperty]] . 인수 propertyKey (프로퍼티 키 ) 및 propertyDesc (프로퍼티 서술자 ). 반환값: 정상 완료 (값: Boolean). 호출되면 다음 단계를 수행한다.
stringDesc 를 StringGetOwnProperty (string , propertyKey )로 둡니다.stringDesc 가 undefined 가 아니면, 다음을 수행합니다.extensible 을 string .[[Extensible]] 로 둡니다.IsCompatiblePropertyDescriptor (extensible , propertyDesc , stringDesc )를 반환합니다.! OrdinaryDefineOwnProperty (string , propertyKey , propertyDesc )를 반환합니다.
10.4.3.3 [[OwnPropertyKeys]] ( )
a String exotic object obj 의 내부 메서드 [[OwnPropertyKeys]] . 인수 없음. 반환값: 정상 완료 (값: 리스트 (요소: 프로퍼티 키 )). 호출되면 다음 단계를 수행한다.
keys 를 새로운 빈 List 로 둡니다.string 을 obj .[[StringData]] 로 둡니다.단언 : string 은 String입니다.length 를 string 의 길이로 둡니다.0 ≤ i < length 를 만족하는 각 정수 i 에 대해 오름차순으로 다음을 수행합니다.! ToString (𝔽 (i ))을 keys 에 추가합니다. 배열 인덱스 이고 ! ToIntegerOrInfinity (propertyKey ) ≥ length 인 obj 의 각 자체 프로퍼티 키 propertyKey 에 대해 숫자 인덱스 오름차순으로 다음을 수행합니다.propertyKey 를 keys 에 추가합니다.String이고 배열 인덱스 가 아닌 obj 의 각 자체 프로퍼티 키 propertyKey 에 대해 프로퍼티 생성 시간 오름차순으로 다음을 수행합니다.propertyKey 를 keys 에 추가합니다. Symbol인 obj 의 각 자체 프로퍼티 키 propertyKey 에 대해 프로퍼티 생성 시간 오름차순으로 다음을 수행합니다.propertyKey 를 keys 에 추가합니다. keys 를 반환합니다.
10.4.3.4 StringCreate ( value , proto )
추상 연산 StringCreate. 인수 value (String) 및 proto (Object). 반환값: String 특수 객체 . 새로운 String 특수 객체 의 생성을 명시하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
string 을 MakeBasicObject (« [[Prototype]] , [[Extensible]] , [[StringData]] »)로 둡니다.string .[[Prototype]] 을 proto 로 설정합니다.string .[[StringData]] 를 value 로 설정합니다.string .[[GetOwnProperty]] 을 10.4.3.1 에 명시된 대로 설정합니다.string .[[DefineOwnProperty]] 을 10.4.3.2 에 명시된 대로 설정합니다.string .[[OwnPropertyKeys]] 를 10.4.3.3 에 명시된 대로 설정합니다.length 를 value 의 길이로 둡니다.! DefinePropertyOrThrow (string , "length" , PropertyDescriptor { [[Value]] : 𝔽 (length ), [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false })를 수행합니다. string 을 반환합니다.
10.4.3.5 StringGetOwnProperty ( string , propertyKey )
추상 연산 StringGetOwnProperty. 인수 string (String 특수 객체 ) 및 propertyKey (프로퍼티 키 ). 반환값: (프로퍼티 서술자 또는 undefined ). 호출되면 다음 단계를 수행한다.
propertyKey 가 String이 아니면, undefined 를 반환합니다.numericIndex 를 CanonicalNumericIndexString (propertyKey )으로 둡니다.numericIndex 가 정수 Number가 아니면, undefined 를 반환합니다.numericIndex 가 -0 𝔽 이거나 numericIndex < -0 𝔽 이면, undefined 를 반환합니다.stringData 를 string .[[StringData]] 로 둡니다.단언 : stringData 는 String입니다.length 를 stringData 의 길이로 둡니다.ℝ (numericIndex ) ≥ length 이면, undefined 를 반환합니다.resultString 을 stringData 의 ℝ (numericIndex )부터 ℝ (numericIndex ) + 1까지의 부분 문자열 로 둡니다.PropertyDescriptor { [[Value]] : resultString , [[Writable]] : false , [[Enumerable]] : true , [[Configurable]] : false }를 반환합니다.
10.4.4 arguments 특수 객체
대부분의 ECMAScript 함수는 자신의 코드에서 arguments 객체를 사용할 수 있도록 합니다. 함수 정의의 특성에 따라 해당 arguments 객체는 일반 객체 또는 arguments 특수 객체 입니다. arguments 특수 객체 는 배열 인덱스 프로퍼티가 연결된 ECMAScript 함수 호출의 형식 매개변수 바인딩에 매핑되는 특수 객체 입니다.
객체의 내부 메서드가 다음 구현을 사용하고 여기에서 명시되지 않은 메서드는 10.1 에 있는 정의를 사용하면 해당 객체는 arguments 특수 객체 입니다. 이러한 메서드는 CreateMappedArgumentsObject 에서 설치됩니다.
참고 1
arguments 특수 객체 에는 일반 객체 와 동일한 내부 슬롯이 있습니다. 또한 [[ParameterMap]] 내부 슬롯도 있습니다. 일반 arguments 객체에도 [[ParameterMap]] 내부 슬롯이 있으며 그 값은 항상 undefined 입니다. 일반 arguments 객체에서 [[ParameterMap]] 내부 슬롯은 Object.prototype.toString(20.1.3.6 )이 이를 arguments 객체로 식별하기 위해서만 사용합니다.
참고 2
arguments 특수 객체 에서 숫자 이름 값이 대응하는 함수 객체 의 형식 매개변수 수보다 작은 정수 인덱스 데이터 프로퍼티 는 처음에는 함수 실행 컨텍스트 의 대응하는 인수 바인딩과 값을 공유합니다. 이는 프로퍼티를 변경하면 대응하는 인수 바인딩의 값도 변경되고 그 반대도 성립함을 의미합니다. 이러한 프로퍼티를 삭제한 다음 다시 정의하거나 프로퍼티를 접근자 프로퍼티 로 변경하면 이 대응 관계가 끊어집니다. arguments 객체가 일반 객체 이면 해당 프로퍼티 값은 단순히 함수에 전달된 인수의 복사본이며 프로퍼티 값과 형식 매개변수 값 사이에 동적인 연결이 없습니다.
참고 3
ParameterMap 객체와 그 프로퍼티 값은 arguments 객체와 인수 바인딩 사이의 대응 관계를 명시하기 위한 장치로 사용됩니다. ParameterMap 객체와 그 프로퍼티 값인 객체는 ECMAScript 코드에서 직접 관찰할 수 없습니다. ECMAScript 구현체는 명시된 의미론을 구현하기 위해 이러한 객체를 실제로 생성하거나 사용할 필요가 없습니다.
참고 4
일반 arguments 객체는 접근 시 TypeError 예외를 던지는 "callee" 라는 이름의 구성 불가능한 접근자 프로퍼티 를 정의합니다. "callee" 프로퍼티는 일부 종류의 비엄격 함수 에 대해서만 생성되는 arguments 특수 객체 에서는 더 구체적인 의미를 갖습니다. 일반 변형에서 이 프로퍼티를 정의하는 이유는 적합한 ECMAScript 구현체가 다른 방식으로 이를 정의하지 않도록 보장하기 위해서입니다.
참고 5
arguments 특수 객체 의 ECMAScript 구현체에는 역사적으로 "caller" 라는 이름의 접근자 프로퍼티 가 포함되어 있었습니다. ECMAScript 2017 이전에는 이 명세가 일반 arguments 객체에서 예외를 던지는 "caller" 프로퍼티의 정의를 포함했습니다. 구현체가 더 이상 이 확장을 포함하지 않으므로 ECMAScript 2017에서는 예외를 던지는 "caller" 접근자에 대한 요구 사항을 삭제했습니다.
10.4.4.1 [[GetOwnProperty]] ( propertyKey )
an arguments exotic object args 의 내부 메서드 [[GetOwnProperty]] . 인수 propertyKey (프로퍼티 키 ). 반환값: 정상 완료 (값: (프로퍼티 서술자 또는 undefined )). 호출되면 다음 단계를 수행한다.
propertyDesc 를 OrdinaryGetOwnProperty (args , propertyKey )로 둡니다.propertyDesc 가 undefined 이면, undefined 를 반환합니다.map 을 args .[[ParameterMap]] 으로 둡니다.isMapped 를 ! HasOwnProperty (map , propertyKey )로 둡니다.isMapped 가 true 이면, 다음을 수행합니다.propertyDesc .[[Value]] 를 ! Get (map , propertyKey )으로 설정합니다.propertyDesc 를 반환합니다.
10.4.4.2 [[DefineOwnProperty]] ( propertyKey , propertyDesc )
an arguments exotic object args 의 내부 메서드 [[DefineOwnProperty]] . 인수 propertyKey (프로퍼티 키 ) 및 propertyDesc (프로퍼티 서술자 ). 반환값: 정상 완료 (값: Boolean). 호출되면 다음 단계를 수행한다.
map 을 args .[[ParameterMap]] 으로 둡니다.isMapped 를 ! HasOwnProperty (map , propertyKey )로 둡니다.newArgDesc 를 propertyDesc 로 둡니다.isMapped 가 true 이고 IsDataDescriptor (propertyDesc )가 true 이면, 다음을 수행합니다.propertyDesc 에 [[Value]] 필드가 없고, propertyDesc 에 [[Writable]] 필드가 있으며, propertyDesc .[[Writable]] 이 false 이면, 다음을 수행합니다.newArgDesc 를 propertyDesc 의 복사본으로 설정합니다.newArgDesc .[[Value]] 를 ! Get (map , propertyKey )으로 설정합니다.allowed 를 ! OrdinaryDefineOwnProperty (args , propertyKey , newArgDesc )로 둡니다.allowed 가 false 이면, false 를 반환합니다.isMapped 가 true 이면, 다음을 수행합니다.IsAccessorDescriptor (propertyDesc )가 true 이면, 다음을 수행합니다.! map .[[Delete]] (propertyKey )를 수행합니다. 그렇지 않으면,propertyDesc 에 [[Value]] 필드가 있으면, 다음을 수행합니다.단언 : arguments 객체가 매핑하는 형식 매개변수는 항상 쓰기 가능하므로 다음 Set은 성공합니다.! Set (map , propertyKey , propertyDesc .[[Value]] , false )를 수행합니다. propertyDesc 에 [[Writable]] 필드가 있고 propertyDesc .[[Writable]] 이 false 이면, 다음을 수행합니다.! map .[[Delete]] (propertyKey )를 수행합니다. true 를 반환합니다.
10.4.4.3 [[Get]] ( propertyKey , receiver )
an arguments exotic object args 의 내부 메서드 [[Get]] . 인수 propertyKey (프로퍼티 키 ) 및 receiver (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
map 을 args .[[ParameterMap]] 으로 둡니다.isMapped 를 ! HasOwnProperty (map , propertyKey )로 둡니다.isMapped 가 false 이면, ? OrdinaryGet (args , propertyKey , receiver )를 반환합니다.단언 : map 에는 propertyKey 에 대한 형식 매개변수 매핑이 포함되어 있습니다.! Get (map , propertyKey )을 반환합니다.
10.4.4.4 [[Set]] ( propertyKey , value , receiver )
an arguments exotic object args 의 내부 메서드 [[Set]] . 인수 propertyKey (프로퍼티 키 ), value (ECMAScript 언어 값 ) 및 receiver (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
SameValue (args , receiver )가 false 이면, 다음을 수행합니다.isMapped 를 false 로 둡니다.그렇지 않으면,map 을 args .[[ParameterMap]] 으로 둡니다.isMapped 를 ! HasOwnProperty (map , propertyKey )로 둡니다. isMapped 가 true 이면, 다음을 수행합니다.단언 : arguments 객체가 매핑하는 형식 매개변수는 항상 쓰기 가능하므로 다음 Set은 성공합니다.! Set (map , propertyKey , value , false )를 수행합니다. ? OrdinarySet (args , propertyKey , value , receiver )를 반환합니다.
10.4.4.5 [[Delete]] ( propertyKey )
an arguments exotic object args 의 내부 메서드 [[Delete]] . 인수 propertyKey (프로퍼티 키 ). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
map 을 args .[[ParameterMap]] 으로 둡니다.isMapped 를 ! HasOwnProperty (map , propertyKey )로 둡니다.result 를 ? OrdinaryDelete (args , propertyKey )로 둡니다.result 가 true 이고 isMapped 가 true 이면, 다음을 수행합니다.! map .[[Delete]] (propertyKey )를 수행합니다. result 를 반환합니다.
10.4.4.6 CreateUnmappedArgumentsObject ( argList )
추상 연산 CreateUnmappedArgumentsObject. 인수 argList (리스트 (요소: ECMAScript 언어 값 )). 반환값: 일반 객체 . 호출되면 다음 단계를 수행한다.
length 를 argList 의 요소 수로 둡니다.obj 를 OrdinaryObjectCreate (%Object.prototype% , « [[ParameterMap]] »)로 둡니다.obj .[[ParameterMap]] 을 undefined 로 설정합니다.! DefinePropertyOrThrow (obj , "length" , PropertyDescriptor { [[Value]] : 𝔽 (length ), [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : true })를 수행합니다. index 를 0으로 둡니다.index < length 인 동안 다음을 반복합니다.value 를 argList [index ]로 둡니다.! CreateDataPropertyOrThrow (obj , ! ToString (𝔽 (index )), value )를 수행합니다. index 를 index + 1로 설정합니다.! DefinePropertyOrThrow (obj , %Symbol.iterator% , PropertyDescriptor { [[Value]] : %Array.prototype.values%, [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : true })를 수행합니다. ! DefinePropertyOrThrow (obj , "callee" , PropertyDescriptor { [[Getter]] : %ThrowTypeError% , [[Setter]] : %ThrowTypeError% , [[Enumerable]] : false , [[Configurable]] : false })를 수행합니다. obj 를 반환합니다.
10.4.4.7 CreateMappedArgumentsObject ( func , formals , argList , envRecord )
추상 연산 CreateMappedArgumentsObject. 인수 func (ECMAScript 함수 객체), formals (구문 분석 노드), argList (리스트 (요소: ECMAScript 언어 값 )) 및 envRecord (Environment 레코드 ). 반환값: arguments 특수 객체 . 호출되면 다음 단계를 수행한다.
단언 : formals 에는 나머지 매개변수, 바인딩 패턴 또는 이니셜라이저가 포함되어 있지 않습니다. 중복 식별자는 포함할 수 있습니다.length 를 argList 의 요소 수로 둡니다.obj 를 MakeBasicObject (« [[Prototype]] , [[Extensible]] , [[ParameterMap]] »)로 둡니다.obj .[[GetOwnProperty]] 을 10.4.4.1 에 명시된 대로 설정합니다.obj .[[DefineOwnProperty]] 을 10.4.4.2 에 명시된 대로 설정합니다.obj .[[Get]] 을 10.4.4.3 에 명시된 대로 설정합니다.obj .[[Set]] 을 10.4.4.4 에 명시된 대로 설정합니다.obj .[[Delete]] 를 10.4.4.5 에 명시된 대로 설정합니다.obj .[[Prototype]] 을 %Object.prototype% 로 설정합니다.map 을 OrdinaryObjectCreate (null )로 둡니다.obj .[[ParameterMap]] 을 map 으로 설정합니다.paramNames 를 formals 의 BoundNames 로 둡니다.paramCount 를 paramNames 의 요소 수로 둡니다.index 를 0으로 둡니다.index < length 인 동안 다음을 반복합니다.value 를 argList [index ]로 둡니다.! CreateDataPropertyOrThrow (obj , ! ToString (𝔽 (index )), value )를 수행합니다. index 를 index + 1로 설정합니다.! DefinePropertyOrThrow (obj , "length" , PropertyDescriptor { [[Value]] : 𝔽 (length ), [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : true })를 수행합니다. mappedNames 를 새로운 빈 List 로 둡니다.index 를 paramCount - 1로 설정합니다.index ≥ 0인 동안 다음을 반복합니다.name 을 paramNames [index ]로 둡니다.mappedNames 에 name 이 포함되어 있지 않으면, 다음을 수행합니다.name 을 mappedNames 에 추가합니다.index < length 이면, 다음을 수행합니다.getter 를 MakeArgGetter (name , envRecord )로 둡니다.setter 를 MakeArgSetter (name , envRecord )로 둡니다.! map .[[DefineOwnProperty]] (! ToString (𝔽 (index )), PropertyDescriptor { [[Setter]] : setter , [[Getter]] : getter , [[Enumerable]] : false , [[Configurable]] : true })를 수행합니다. index 를 index - 1로 설정합니다.! DefinePropertyOrThrow (obj , %Symbol.iterator% , PropertyDescriptor { [[Value]] : %Array.prototype.values%, [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : true })를 수행합니다. ! DefinePropertyOrThrow (obj , "callee" , PropertyDescriptor { [[Value]] : func , [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : true })를 수행합니다. obj 를 반환합니다.
10.4.4.7.1 MakeArgGetter ( name , envRecord )
추상 연산 MakeArgGetter. 인수 name (String) 및 envRecord (Environment 레코드 ). 반환값: 함수 객체 . 실행될 때 envRecord 에서 name 에 바인딩된 값을 반환하는 내장 함수 객체 를 생성합니다. 호출되면 다음 단계를 수행한다.
getterClosure 를 매개변수가 없고 name 및 envRecord 를 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:NormalCompletion (! envRecord .GetBindingValue (name , false ))을 반환합니다.getter 를 CreateBuiltinFunction (getterClosure , 0, "" , « »)로 둡니다.참고 : ECMAScript 코드에서 getter 에 직접 접근할 수는 없습니다.getter 를 반환합니다.
10.4.4.7.2 MakeArgSetter ( name , envRecord )
추상 연산 MakeArgSetter. 인수 name (String) 및 envRecord (Environment 레코드 ). 반환값: 함수 객체 . 실행될 때 envRecord 에서 name 에 바인딩된 값을 설정하는 내장 함수 객체 를 생성합니다. 호출되면 다음 단계를 수행한다.
setterClosure 를 매개변수 (value )를 갖고 name 및 envRecord 를 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:NormalCompletion (! envRecord .SetMutableBinding (name , value , false ))을 반환합니다.setter 를 CreateBuiltinFunction (setterClosure , 1, "" , « »)로 둡니다.참고 : ECMAScript 코드에서 setter 에 직접 접근할 수는 없습니다.setter 를 반환합니다.
10.4.5 TypedArray 특수 객체
TypedArray 는 정규 숫자 문자열 인 프로퍼티 키 를 특별하게 처리하는 특수 객체 입니다. 범위 내의 정수 인덱스 인 부분집합을 사용하여 균일한 타입의 요소를 인덱싱하고, 나머지는 프로토타입 체인을 순회하지 않고 존재하지 않도록 하는 불변 조건을 강제합니다.
참고
임의의 Number n 에 대한 ToString (n )이 정규 숫자 문자열 이므로 구현체는 실제로 문자열 변환을 수행하지 않고 Number를 TypedArray 의 프로퍼티 키 로 취급할 수 있습니다.
TypedArray 에는 일반 객체 와 동일한 내부 슬롯이 있으며 추가로 [[ViewedArrayBuffer]] , [[TypedArrayName]] , [[ContentType]] , [[ByteLength]] , [[ByteOffset]] 및 [[ArrayLength]] 내부 슬롯이 있습니다.
객체의 [[PreventExtensions]] , [[GetOwnProperty]] , [[HasProperty]] , [[DefineOwnProperty]] , [[Get]] , [[Set]] , [[Delete]] 및 [[OwnPropertyKeys]] 내부 메서드가 이 절의 정의를 사용하고, 그 밖의 필수 내부 메서드가 10.1 에 있는 정의를 사용하면 해당 객체는 TypedArray 입니다. 이러한 메서드는 TypedArrayCreate 에서 설치됩니다.
10.4.5.1 [[PreventExtensions]] ( )
a TypedArray obj 의 내부 메서드 [[PreventExtensions]] . 인수 없음. 반환값: 정상 완료 (값: Boolean). 호출되면 다음 단계를 수행한다.
참고 : 6.1.7.3 에 명시된 확장 가능성과 관련된 불변 조건은 obj 가 프로퍼티를 얻을 수 있거나(또는 잃었다가 다시 얻을 수 있으면) 이 메서드가 true 를 반환하는 것을 허용하지 않습니다. 이러한 상황은 기반 버퍼의 크기가 조정될 때 정수 인덱스 이름의 프로퍼티에서 발생할 수 있습니다.IsTypedArrayFixedLength (obj )가 false 이면, false 를 반환합니다.OrdinaryPreventExtensions (obj )를 반환합니다.
10.4.5.2 [[GetOwnProperty]] ( propertyKey )
a TypedArray obj 의 내부 메서드 [[GetOwnProperty]] . 인수 propertyKey (프로퍼티 키 ). 반환값: 정상 완료 (값: (프로퍼티 서술자 또는 undefined )). 호출되면 다음 단계를 수행한다.
propertyKey 가 String이면, 다음을 수행합니다.numericIndex 를 CanonicalNumericIndexString (propertyKey )으로 둡니다.numericIndex 가 undefined 가 아니면, 다음을 수행합니다.value 를 TypedArrayGetElement (obj , numericIndex )로 둡니다.value 가 undefined 이면, undefined 를 반환합니다.PropertyDescriptor { [[Value]] : value , [[Writable]] : true , [[Enumerable]] : true , [[Configurable]] : true }를 반환합니다. OrdinaryGetOwnProperty (obj , propertyKey )를 반환합니다.
10.4.5.3 [[HasProperty]] ( propertyKey )
a TypedArray obj 의 내부 메서드 [[HasProperty]] . 인수 propertyKey (프로퍼티 키 ). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
propertyKey 가 String이면, 다음을 수행합니다.numericIndex 를 CanonicalNumericIndexString (propertyKey )으로 둡니다.numericIndex 가 undefined 가 아니면, IsValidIntegerIndex (obj , numericIndex )를 반환합니다.? OrdinaryHasProperty (obj , propertyKey )를 반환합니다.
10.4.5.4 [[DefineOwnProperty]] ( propertyKey , propertyDesc )
a TypedArray obj 의 내부 메서드 [[DefineOwnProperty]] . 인수 propertyKey (프로퍼티 키 ) 및 propertyDesc (프로퍼티 서술자 ). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
propertyKey 가 String이면, 다음을 수행합니다.numericIndex 를 CanonicalNumericIndexString (propertyKey )으로 둡니다.numericIndex 가 undefined 가 아니면, 다음을 수행합니다.IsValidIntegerIndex (obj , numericIndex )가 false 이면, false 를 반환합니다.propertyDesc 에 [[Configurable]] 필드가 있고 propertyDesc .[[Configurable]] 이 false 이면, false 를 반환합니다.propertyDesc 에 [[Enumerable]] 필드가 있고 propertyDesc .[[Enumerable]] 이 false 이면, false 를 반환합니다.IsAccessorDescriptor (propertyDesc )가 true 이면, false 를 반환합니다.propertyDesc 에 [[Writable]] 필드가 있고 propertyDesc .[[Writable]] 이 false 이면, false 를 반환합니다.propertyDesc 에 [[Value]] 필드가 있으면 ? TypedArraySetElement (obj , numericIndex , propertyDesc .[[Value]] )를 수행합니다.true 를 반환합니다.! OrdinaryDefineOwnProperty (obj , propertyKey , propertyDesc )를 반환합니다.
10.4.5.5 [[Get]] ( propertyKey , receiver )
a TypedArray obj 의 내부 메서드 [[Get]] . 인수 propertyKey (프로퍼티 키 ) 및 receiver (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
propertyKey 가 String이면, 다음을 수행합니다.numericIndex 를 CanonicalNumericIndexString (propertyKey )으로 둡니다.numericIndex 가 undefined 가 아니면, 다음을 수행합니다.TypedArrayGetElement (obj , numericIndex )를 반환합니다.? OrdinaryGet (obj , propertyKey , receiver )를 반환합니다.
10.4.5.6 [[Set]] ( propertyKey , value , receiver )
a TypedArray obj 의 내부 메서드 [[Set]] . 인수 propertyKey (프로퍼티 키 ), value (ECMAScript 언어 값 ) 및 receiver (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
propertyKey 가 String이면, 다음을 수행합니다.numericIndex 를 CanonicalNumericIndexString (propertyKey )으로 둡니다.numericIndex 가 undefined 가 아니면, 다음을 수행합니다.SameValue (obj , receiver )가 true 이면, 다음을 수행합니다.? TypedArraySetElement (obj , numericIndex , value )를 수행합니다. true 를 반환합니다.IsValidIntegerIndex (obj , numericIndex )가 false 이면, true 를 반환합니다.? OrdinarySet (obj , propertyKey , value , receiver )를 반환합니다.
10.4.5.7 [[Delete]] ( propertyKey )
a TypedArray obj 의 내부 메서드 [[Delete]] . 인수 propertyKey (프로퍼티 키 ). 반환값: 정상 완료 (값: Boolean). 호출되면 다음 단계를 수행한다.
propertyKey 가 String이면, 다음을 수행합니다.numericIndex 를 CanonicalNumericIndexString (propertyKey )으로 둡니다.numericIndex 가 undefined 가 아니면, 다음을 수행합니다.IsValidIntegerIndex (obj , numericIndex )가 false 이면, true 를 반환합니다.false 를 반환합니다.! OrdinaryDelete (obj , propertyKey )를 반환합니다.
10.4.5.8 [[OwnPropertyKeys]] ( )
a TypedArray obj 의 내부 메서드 [[OwnPropertyKeys]] . 인수 없음. 반환값: 정상 완료 (값: 리스트 (요소: 프로퍼티 키 )). 호출되면 다음 단계를 수행한다.
taRecord 를 MakeTypedArrayWithBufferWitnessRecord (obj , seq-cst )로 둡니다.keys 를 새로운 빈 List 로 둡니다.IsTypedArrayOutOfBounds (taRecord )가 false 이면, 다음을 수행합니다.length 를 TypedArrayLength (taRecord )로 둡니다.0 ≤ i < length 를 만족하는 각 정수 i 에 대해 오름차순으로 다음을 수행합니다.! ToString (𝔽 (i ))을 keys 에 추가합니다. String이고 정수 인덱스 가 아닌 obj 의 각 자체 프로퍼티 키 propertyKey 에 대해 프로퍼티 생성 시간 오름차순으로 다음을 수행합니다.propertyKey 를 keys 에 추가합니다. Symbol인 obj 의 각 자체 프로퍼티 키 propertyKey 에 대해 프로퍼티 생성 시간 오름차순으로 다음을 수행합니다.propertyKey 를 keys 에 추가합니다. keys 를 반환합니다.
10.4.5.9 버퍼 감시 Record가 있는 TypedArray
TypedArray With Buffer Witness Record 는 TypedArray 와 조회하는 버퍼의 캐시된 바이트 길이를 함께 캡슐화하는 데 사용하는 Record 입니다. 조회하는 버퍼가 확장 가능한 SharedArrayBuffer 인 경우 바이트 길이 데이터 블록에 대해 하나의 ReadSharedMemory 이벤트만 발생하도록 보장하는 데 사용됩니다.
TypedArray With Buffer Witness Record에는 표 28 에 나열된 필드가 있습니다.
표 28: TypedArray With Buffer Witness Record 필드
필드 이름
값
의미
[[Object]]
TypedArray
버퍼의 바이트 길이가 로드되는 TypedArray 입니다.
[[CachedBufferByteLength]]
음이 아닌 정수 또는 detached
Record 가 생성될 당시 객체의 [[ViewedArrayBuffer]] 바이트 길이입니다.
10.4.5.10 MakeTypedArrayWithBufferWitnessRecord ( obj , order )
추상 연산 MakeTypedArrayWithBufferWitnessRecord. 인수 obj (TypedArray ) 및 order ((seq-cst 또는 unordered )). 반환값: TypedArray With Buffer Witness 레코드 . 호출되면 다음 단계를 수행한다.
buffer 를 obj .[[ViewedArrayBuffer]] 로 둡니다.IsDetachedBuffer (buffer )가 true 이면, 다음을 수행합니다.byteLength 를 detached 로 둡니다.그렇지 않으면,byteLength 를 ArrayBufferByteLength (buffer , order )로 둡니다. TypedArray With Buffer Witness Record { [[Object]] : obj , [[CachedBufferByteLength]] : byteLength }를 반환합니다.
10.4.5.11 TypedArrayCreate ( proto )
추상 연산 TypedArrayCreate. 인수 proto (Object). 반환값: TypedArray . 새로운 TypedArray 의 생성을 명시하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
internalSlotsList 를 « [[Prototype]] , [[Extensible]] , [[ViewedArrayBuffer]] , [[TypedArrayName]] , [[ContentType]] , [[ByteLength]] , [[ByteOffset]] , [[ArrayLength]] »로 둡니다.ta 를 MakeBasicObject (internalSlotsList )로 둡니다.ta .[[PreventExtensions]] 를 10.4.5.1 에 명시된 대로 설정합니다.ta .[[GetOwnProperty]] 을 10.4.5.2 에 명시된 대로 설정합니다.ta .[[HasProperty]] 를 10.4.5.3 에 명시된 대로 설정합니다.ta .[[DefineOwnProperty]] 을 10.4.5.4 에 명시된 대로 설정합니다.ta .[[Get]] 을 10.4.5.5 에 명시된 대로 설정합니다.ta .[[Set]] 을 10.4.5.6 에 명시된 대로 설정합니다.ta .[[Delete]] 를 10.4.5.7 에 명시된 대로 설정합니다.ta .[[OwnPropertyKeys]] 를 10.4.5.8 에 명시된 대로 설정합니다.ta .[[Prototype]] 을 proto 로 설정합니다.ta 를 반환합니다.
10.4.5.12 TypedArrayByteLength ( taRecord )
추상 연산 TypedArrayByteLength. 인수 taRecord (TypedArray With Buffer Witness 레코드 ). 반환값: 음이 아닌 정수. 호출되면 다음 단계를 수행한다.
단언 : IsTypedArrayOutOfBounds (taRecord )는 false 입니다.obj 를 taRecord .[[Object]] 로 둡니다.obj .[[ByteLength]] 가 auto 가 아니면, obj .[[ByteLength]] 를 반환합니다.length 를 TypedArrayLength (taRecord )로 둡니다.elementSize 를 TypedArrayElementSize (obj )로 둡니다.참고 : 기반 버퍼가 정수 배수가 아닌 크기로 조정된 경우에도 반환되는 바이트 길이는 항상 elementSize 의 정수 배수입니다.length × elementSize 를 반환합니다.
10.4.5.13 TypedArrayLength ( taRecord )
추상 연산 TypedArrayLength. 인수 taRecord (TypedArray With Buffer Witness 레코드 ). 반환값: 음이 아닌 정수. 호출되면 다음 단계를 수행한다.
단언 : IsTypedArrayOutOfBounds (taRecord )는 false 입니다.obj 를 taRecord .[[Object]] 로 둡니다.obj .[[ArrayLength]] 가 auto 가 아니면, obj .[[ArrayLength]] 를 반환합니다.단언 : IsFixedLengthArrayBuffer (obj .[[ViewedArrayBuffer]] )는 false 입니다.byteOffset 을 obj .[[ByteOffset]] 으로 둡니다.elementSize 를 TypedArrayElementSize (obj )로 둡니다.byteLength 를 taRecord .[[CachedBufferByteLength]] 로 둡니다.단언 : byteLength 는 detached 가 아닙니다.floor ((byteLength - byteOffset ) / elementSize )를 반환합니다.
10.4.5.14 IsTypedArrayOutOfBounds ( taRecord )
추상 연산 IsTypedArrayOutOfBounds. 인수 taRecord (TypedArray With Buffer Witness 레코드 ). 반환값: Boolean. 객체의 숫자 프로퍼티 중 하나라도 기반 버퍼의 범위에 포함되지 않는 인덱스의 값을 참조하는지 검사합니다. 호출되면 다음 단계를 수행한다.
obj 를 taRecord .[[Object]] 로 둡니다.bufferByteLength 를 taRecord .[[CachedBufferByteLength]] 로 둡니다.IsDetachedBuffer (obj .[[ViewedArrayBuffer]] )가 true 이면, 다음을 수행합니다.단언 : bufferByteLength 는 detached 입니다.true 를 반환합니다.단언 : bufferByteLength 는 음이 아닌 정수 입니다.byteOffsetStart 를 obj .[[ByteOffset]] 으로 둡니다.obj .[[ArrayLength]] 가 auto 이면, 다음을 수행합니다.byteOffsetEnd 를 bufferByteLength 로 둡니다.그렇지 않으면,elementSize 를 TypedArrayElementSize (obj )로 둡니다.arrayByteLength 를 obj .[[ArrayLength]] × elementSize 로 둡니다.byteOffsetEnd 를 byteOffsetStart + arrayByteLength 로 둡니다. 참고 : [[ByteOffset]] 이 bufferByteLength 인 길이 0의 TypedArray 는 범위를 벗어난 것으로 간주하지 않습니다.byteOffsetStart > bufferByteLength 이거나 byteOffsetEnd > bufferByteLength 이면, true 를 반환합니다.false 를 반환합니다.
10.4.5.15 IsTypedArrayFixedLength ( obj )
추상 연산 IsTypedArrayFixedLength. 인수 obj (TypedArray ). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
obj .[[ArrayLength]] 가 auto 이면, false 를 반환합니다.buffer 를 obj .[[ViewedArrayBuffer]] 로 둡니다.IsFixedLengthArrayBuffer (buffer )가 false 이고 IsSharedArrayBuffer (buffer )가 false 이면, false 를 반환합니다.true 를 반환합니다.
10.4.5.16 IsValidIntegerIndex ( obj , index )
추상 연산 IsValidIntegerIndex. 인수 obj (TypedArray ) 및 index (Number). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
IsDetachedBuffer (obj .[[ViewedArrayBuffer]] )가 true 이면, false 를 반환합니다.index 가 정수 Number가 아니면, false 를 반환합니다.index 가 -0 𝔽 이거나 index < -0 𝔽 이면, false 를 반환합니다.taRecord 를 MakeTypedArrayWithBufferWitnessRecord (obj , unordered )로 둡니다.참고 : obj 의 기반 버퍼가 확장 가능한 SharedArrayBuffer 인 경우 범위 검사는 동기화 연산이 아닙니다.IsTypedArrayOutOfBounds (taRecord )가 true 이면, false 를 반환합니다.length 를 TypedArrayLength (taRecord )로 둡니다.ℝ (index ) ≥ length 이면, false 를 반환합니다.true 를 반환합니다.
10.4.5.17 TypedArrayGetElement ( obj , index )
추상 연산 TypedArrayGetElement. 인수 obj (TypedArray ) 및 index (Number). 반환값: (Number, BigInt 또는 undefined ). 호출되면 다음 단계를 수행한다.
IsValidIntegerIndex (obj , index )가 false 이면, undefined 를 반환합니다.offset 을 obj .[[ByteOffset]] 으로 둡니다.elementSize 를 TypedArrayElementSize (obj )로 둡니다.byteIndexInBuffer 를 (ℝ (index ) × elementSize ) + offset 으로 둡니다.elementType 을 TypedArrayElementType (obj )으로 둡니다.GetValueFromBuffer (obj .[[ViewedArrayBuffer]] , byteIndexInBuffer , elementType , true , unordered )를 반환합니다.
10.4.5.18 TypedArraySetElement ( obj , index , value )
추상 연산 TypedArraySetElement. 인수 obj (TypedArray ), index (Number) 및 value (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
obj .[[ContentType]] 이 bigint 이면 number 를 ? ToBigInt (value )로 둡니다.그렇지 않으면 number 를 ? ToNumber (value )로 둡니다. IsValidIntegerIndex (obj , index )가 true 이면, 다음을 수행합니다.offset 을 obj .[[ByteOffset]] 으로 둡니다.elementSize 를 TypedArrayElementSize (obj )로 둡니다.byteIndexInBuffer 를 (ℝ (index ) × elementSize ) + offset 으로 둡니다.elementType 을 TypedArrayElementType (obj )으로 둡니다.SetValueInBuffer (obj .[[ViewedArrayBuffer]] , byteIndexInBuffer , elementType , number , true , unordered )를 수행합니다.unused 를 반환합니다.
참고
이 연산은 항상 성공하는 것처럼 보이지만 TypedArray 끝을 넘어 쓰려고 하거나 분리된 ArrayBuffer를 기반으로 하는 TypedArray 에 쓰려고 하면 아무 효과도 없습니다.
10.4.5.19 IsArrayBufferViewOutOfBounds ( obj )
추상 연산 IsArrayBufferViewOutOfBounds. 인수 obj ((TypedArray 또는 DataView)). 반환값: Boolean. TypedArray 의 숫자 프로퍼티 중 하나 또는 DataView 객체의 메서드 중 하나가 기반 데이터 블록의 범위에 포함되지 않는 인덱스의 값을 참조할 수 있는지를 검사합니다. 이 추상 연산 은 상위 명세의 편의를 위해 존재합니다. 호출되면 다음 단계를 수행한다.
obj 에 [[DataView]] 내부 슬롯이 있으면, 다음을 수행합니다.viewRecord 를 MakeDataViewWithBufferWitnessRecord (obj , seq-cst )로 둡니다.IsViewOutOfBounds (viewRecord )를 반환합니다.taRecord 를 MakeTypedArrayWithBufferWitnessRecord (obj , seq-cst )로 둡니다.IsTypedArrayOutOfBounds (taRecord )를 반환합니다.
10.4.6 모듈 네임스페이스 특수 객체
모듈 네임스페이스 특수 객체 는 ECMAScript Module 에서 내보낸 바인딩을 노출하는 특수 객체 입니다(16.2.3 참조). 모듈 네임스페이스 특수 객체 의 String 키 자체 프로퍼티와 Module 에서 내보낸 바인딩 이름 사이에는 일대일 대응 관계가 있습니다. 내보낸 바인딩에는 export * 내보내기 항목을 사용하여 간접적으로 내보낸 모든 바인딩이 포함됩니다. String 값을 갖는 각 자체 프로퍼티 키 는 대응하는 내보낸 바인딩 이름의 StringValue 입니다. 이것이 모듈 네임스페이스 특수 객체 의 유일한 String 키 프로퍼티입니다. 이러한 각 프로퍼티는 속성 { [[Writable]] : true , [[Enumerable]] : true , [[Configurable]] : false }를 갖습니다. 모듈 네임스페이스 특수 객체 는 확장 가능하지 않습니다.
객체의 [[GetPrototypeOf]] , [[SetPrototypeOf]] , [[IsExtensible]] , [[PreventExtensions]] , [[GetOwnProperty]] , [[DefineOwnProperty]] , [[HasProperty]] , [[Get]] , [[Set]] , [[Delete]] 및 [[OwnPropertyKeys]] 내부 메서드가 이 절의 정의를 사용하고, 그 밖의 필수 내부 메서드가 10.1 에 있는 정의를 사용하면 해당 객체는 모듈 네임스페이스 특수 객체 입니다. 이러한 메서드는 ModuleNamespaceCreate 에서 설치됩니다.
모듈 네임스페이스 특수 객체 에는 표 29 에 정의된 내부 슬롯이 있습니다.
표 29: 모듈 네임스페이스 특수 객체 의 내부 슬롯
10.4.6.1 [[GetPrototypeOf]] ( )
a module namespace exotic object의 내부 메서드 [[GetPrototypeOf]] . 인수 없음. 반환값: 정상 완료 (값: null ). 호출되면 다음 단계를 수행한다.
null 을 반환합니다.
10.4.6.2 [[SetPrototypeOf]] ( proto )
a module namespace exotic object obj 의 내부 메서드 [[SetPrototypeOf]] . 인수 proto ((Object 또는 null )). 반환값: 정상 완료 (값: Boolean). 호출되면 다음 단계를 수행한다.
! SetImmutablePrototype (obj , proto )를 반환합니다.
10.4.6.3 [[IsExtensible]] ( )
a module namespace exotic object의 내부 메서드 [[IsExtensible]] . 인수 없음. 반환값: 정상 완료 (값: false ). 호출되면 다음 단계를 수행한다.
false 를 반환합니다.
10.4.6.4 [[PreventExtensions]] ( )
a module namespace exotic object의 내부 메서드 [[PreventExtensions]] . 인수 없음. 반환값: 정상 완료 (값: true ). 호출되면 다음 단계를 수행한다.
true 를 반환합니다.
10.4.6.5 [[GetOwnProperty]] ( propertyKey )
a module namespace exotic object obj 의 내부 메서드 [[GetOwnProperty]] . 인수 propertyKey (프로퍼티 키 ). 반환값: (정상 완료 (값: (프로퍼티 서술자 또는 undefined )) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
propertyKey 가 Symbol이면, OrdinaryGetOwnProperty (obj , propertyKey )를 반환합니다.exports 를 obj .[[Exports]] 로 둡니다.exports 에 propertyKey 가 포함되어 있지 않으면, undefined 를 반환합니다.value 를 ? obj .[[Get]] (propertyKey , obj )로 둡니다.PropertyDescriptor { [[Value]] : value , [[Writable]] : true , [[Enumerable]] : true , [[Configurable]] : false }를 반환합니다.
10.4.6.6 [[DefineOwnProperty]] ( propertyKey , propertyDesc )
a module namespace exotic object obj 의 내부 메서드 [[DefineOwnProperty]] . 인수 propertyKey (프로퍼티 키 ) 및 propertyDesc (프로퍼티 서술자 ). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
propertyKey 가 Symbol이면, ! OrdinaryDefineOwnProperty (obj , propertyKey , propertyDesc )를 반환합니다.current 를 ? obj .[[GetOwnProperty]] (propertyKey )로 둡니다.current 가 undefined 이면, false 를 반환합니다.propertyDesc 에 [[Configurable]] 필드가 있고 propertyDesc .[[Configurable]] 이 true 이면, false 를 반환합니다.propertyDesc 에 [[Enumerable]] 필드가 있고 propertyDesc .[[Enumerable]] 이 false 이면, false 를 반환합니다.IsAccessorDescriptor (propertyDesc )가 true 이면, false 를 반환합니다.propertyDesc 에 [[Writable]] 필드가 있고 propertyDesc .[[Writable]] 이 false 이면, false 를 반환합니다.propertyDesc 에 [[Value]] 필드가 있으면, SameValue (propertyDesc .[[Value]] , current .[[Value]] )를 반환합니다.true 를 반환합니다.
10.4.6.7 [[HasProperty]] ( propertyKey )
a module namespace exotic object obj 의 내부 메서드 [[HasProperty]] . 인수 propertyKey (프로퍼티 키 ). 반환값: 정상 완료 (값: Boolean). 호출되면 다음 단계를 수행한다.
propertyKey 가 Symbol이면, ! OrdinaryHasProperty (obj , propertyKey )를 반환합니다.exports 를 obj .[[Exports]] 로 둡니다.exports 에 propertyKey 가 포함되어 있으면, true 를 반환합니다.false 를 반환합니다.
10.4.6.8 [[Get]] ( propertyKey , receiver )
a module namespace exotic object obj 의 내부 메서드 [[Get]] . 인수 propertyKey (프로퍼티 키 ) 및 receiver (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
propertyKey 가 Symbol이면, 다음을 수행합니다.! OrdinaryGet (obj , propertyKey , receiver )를 반환합니다. exports 를 obj .[[Exports]] 로 둡니다.exports 에 propertyKey 가 포함되어 있지 않으면, undefined 를 반환합니다.module 을 obj .[[Module]] 로 둡니다.binding 을 module .ResolveExport (propertyKey )로 둡니다.단언 : binding 은 ResolvedBinding Record 입니다.targetModule 을 binding .[[Module]] 로 둡니다.단언 : targetModule 은 undefined 가 아닙니다.binding .[[BindingName]] 이 namespace 이면, 다음을 수행합니다.GetModuleNamespace (targetModule )를 반환합니다.targetEnv 를 targetModule .[[Environment]] 로 둡니다.targetEnv 가 empty 이면, ReferenceError 예외를 던집니다.? targetEnv .GetBindingValue (binding .[[BindingName]] , true )를 반환합니다.
참고
ResolveExport 는 부작용이 없습니다. 이 연산을 특정 exportName , resolveSet 인수 쌍으로 호출할 때마다 동일한 결과를 반환해야 합니다. 구현체는 각 모듈 네임스페이스 특수 객체 의 [[Exports]] 에 대한 ResolveExport 결과를 미리 계산하거나 캐시하도록 선택할 수 있습니다.
10.4.6.9 [[Set]] ( propertyKey , value , receiver )
a module namespace exotic object의 내부 메서드 [[Set]] . 인수 propertyKey (프로퍼티 키 ), value (ECMAScript 언어 값 ) 및 receiver (ECMAScript 언어 값 ). 반환값: 정상 완료 (값: false ). 호출되면 다음 단계를 수행한다.
false 를 반환합니다.
10.4.6.10 [[Delete]] ( propertyKey )
a module namespace exotic object obj 의 내부 메서드 [[Delete]] . 인수 propertyKey (프로퍼티 키 ). 반환값: 정상 완료 (값: Boolean). 호출되면 다음 단계를 수행한다.
propertyKey 가 Symbol이면, 다음을 수행합니다.! OrdinaryDelete (obj , propertyKey )를 반환합니다. exports 를 obj .[[Exports]] 로 둡니다.exports 에 propertyKey 가 포함되어 있으면, false 를 반환합니다.true 를 반환합니다.
10.4.6.11 [[OwnPropertyKeys]] ( )
a module namespace exotic object obj 의 내부 메서드 [[OwnPropertyKeys]] . 인수 없음. 반환값: 정상 완료 (값: 리스트 (요소: 프로퍼티 키 )). 호출되면 다음 단계를 수행한다.
exports 를 obj .[[Exports]] 로 둡니다.symbolKeys 를 OrdinaryOwnPropertyKeys (obj )로 둡니다.exports 와 symbolKeys 의 목록 연결 을 반환합니다.
10.4.6.12 ModuleNamespaceCreate ( module , exports )
추상 연산 ModuleNamespaceCreate. 인수 module (Module 레코드 ) 및 exports (리스트 (요소: String)). 반환값: module namespace 특수 객체. 새로운 모듈 네임스페이스 특수 객체 의 생성을 명시하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
단언 : module .[[Namespace]] 는 empty 입니다.internalSlotsList 를 표 29 에 나열된 내부 슬롯으로 둡니다.namespace 를 MakeBasicObject (internalSlotsList )로 둡니다.namespace 의 필수 내부 메서드를 10.4.6 에 명시된 정의로 설정합니다.namespace .[[Module]] 을 module 로 설정합니다.sortedExports 를 exports 의 요소를 사전식 코드 단위 순서 로 정렬한 요소를 갖는 List 로 둡니다.namespace .[[Exports]] 를 sortedExports 로 설정합니다.28.3 의 정의에 대응하는 namespace 의 자체 프로퍼티를 생성합니다.module .[[Namespace]] 를 namespace 로 설정합니다.namespace 를 반환합니다.
10.4.7 변경 불가능한 프로토타입 특수 객체
변경 불가능한 프로토타입 특수 객체 는 초기화된 후 변경되지 않는 [[Prototype]] 내부 슬롯을 갖는 특수 객체 입니다.
객체의 [[SetPrototypeOf]] 내부 메서드가 다음 구현을 사용하면 해당 객체는 변경 불가능한 프로토타입 특수 객체 입니다. (그 밖의 필수 내부 메서드는 해당 변경 불가능한 프로토타입 특수 객체 의 구체적인 종류에 따라 어떤 구현이든 사용할 수 있습니다.)
참고
다른 특수 객체 와 달리 변경 불가능한 프로토타입 특수 객체 에는 전용 생성 추상 연산 이 제공되지 않습니다. 이는 %Object.prototype% 과 호스트 환경 에서만 사용되며, 호스트 환경 에서는 관련 객체가 다른 방식으로도 특수 객체 일 수 있어 자체적인 전용 생성 연산이 필요하기 때문입니다.
10.4.7.1 [[SetPrototypeOf]] ( proto )
an immutable prototype exotic object obj 의 내부 메서드 [[SetPrototypeOf]] . 인수 proto ((Object 또는 null )). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
? SetImmutablePrototype (obj , proto )를 반환합니다.
10.4.7.2 SetImmutablePrototype ( obj , proto )
추상 연산 SetImmutablePrototype. 인수 obj (Object) 및 proto ((Object 또는 null )). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
current 를 ? obj .[[GetPrototypeOf]] () 로 둡니다.SameValue (proto , current )가 true 이면, true 를 반환합니다.false 를 반환합니다.
10.5 Proxy 객체 내부 메서드와 내부 슬롯
Proxy 객체는 필수 내부 메서드의 일부가 ECMAScript 코드를 사용하여 구현되는 특수 객체 입니다. 모든 Proxy 객체에는 [[ProxyHandler]] 라는 내부 슬롯이 있습니다. [[ProxyHandler]] 의 값은 프록시의 핸들러 객체 라고 하는 객체 또는 null 입니다. 핸들러 객체의 메서드(표 30 참조)는 Proxy 객체의 하나 이상의 내부 메서드 구현을 확장하는 데 사용할 수 있습니다. 모든 Proxy 객체에는 [[ProxyTarget]] 이라는 내부 슬롯도 있으며, 그 값은 객체 또는 null 입니다. 이 객체를 프록시의 대상 객체 라고 합니다.
객체의 필수 내부 메서드(해당하는 경우 [[Call]] 및 [[Construct]] 포함)가 이 절의 정의를 사용하면 해당 객체는 Proxy 특수 객체 입니다. 이러한 내부 메서드는 ProxyCreate 에서 설치됩니다.
표 30: Proxy 핸들러 메서드
내부 메서드
핸들러 메서드
[[GetPrototypeOf]]
getPrototypeOf
[[SetPrototypeOf]]
setPrototypeOf
[[IsExtensible]]
isExtensible
[[PreventExtensions]]
preventExtensions
[[GetOwnProperty]]
getOwnPropertyDescriptor
[[DefineOwnProperty]]
defineProperty
[[HasProperty]]
has
[[Get]]
get
[[Set]]
set
[[Delete]]
deleteProperty
[[OwnPropertyKeys]]
ownKeys
[[Call]]
apply
[[Construct]]
construct
Proxy 객체 내부 메서드의 구현을 제공하기 위해 핸들러 메서드를 호출하면 프록시의 대상 객체가 매개변수로 핸들러 메서드에 전달됩니다. 프록시의 핸들러 객체가 모든 필수 내부 메서드에 대응하는 메서드를 반드시 갖는 것은 아닙니다. 핸들러 객체에 내부 트랩에 대응하는 메서드가 없으면 프록시에서 내부 메서드를 호출할 때 프록시의 대상 객체에서 대응하는 내부 메서드를 호출합니다.
Proxy 객체의 [[ProxyHandler]] 및 [[ProxyTarget]] 내부 슬롯은 객체가 생성될 때 항상 초기화되며 일반적으로 수정할 수 없습니다. 일부 Proxy 객체는 나중에 해제 할 수 있는 방식으로 생성됩니다. 프록시가 해제되면 [[ProxyHandler]] 및 [[ProxyTarget]] 내부 슬롯이 null 로 설정되며, 이후 해당 Proxy 객체에서 내부 메서드를 호출하면 TypeError 예외가 던져집니다.
Proxy 객체는 임의의 ECMAScript 코드가 내부 메서드 구현을 제공할 수 있게 하므로, 핸들러 메서드가 6.1.7.3 에 정의된 불변 조건을 위반하는 Proxy 객체를 정의할 수 있습니다. 6.1.7.3 에 정의된 일부 내부 메서드 불변 조건은 필수 무결성 불변 조건입니다. 이러한 불변 조건은 이 절에 명시된 Proxy 객체 내부 메서드가 명시적으로 강제합니다. ECMAScript 구현체는 가능한 모든 불변 조건 위반 상황에서도 견고해야 합니다.
다음 알고리즘 설명에서는 obj 가 ECMAScript Proxy 객체이고, propertyKey 가 프로퍼티 키 값이며, value 가 임의의 ECMAScript 언어 값 이고, propertyDesc 가 Property Descriptor Record 라고 가정합니다.
10.5.1 [[GetPrototypeOf]] ( )
a Proxy exotic object obj 의 내부 메서드 [[GetPrototypeOf]] . 인수 없음. 반환값: (정상 완료 (값: (Object 또는 null )) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
? ValidateNonRevokedProxy (obj )를 수행합니다. target 을 obj .[[ProxyTarget]] 으로 둡니다.handler 를 obj .[[ProxyHandler]] 로 둡니다.단언 : handler 는 Object입니다.trap 을 ? GetMethod (handler , "getPrototypeOf" )로 둡니다.trap 이 undefined 이면, 다음을 수행합니다.? target .[[GetPrototypeOf]] () 를 반환합니다. handlerProto 를 ? Call (trap , handler , « target »)로 둡니다.handlerProto 가 Object도 아니고 null 도 아니면, TypeError 예외를 던집니다.extensibleTarget 을 ? IsExtensible (target )로 둡니다.extensibleTarget 이 true 이면, handlerProto 를 반환합니다.targetProto 를 ? target .[[GetPrototypeOf]] () 로 둡니다.SameValue (handlerProto , targetProto )가 false 이면, TypeError 예외를 던집니다.handlerProto 를 반환합니다.
참고
Proxy 객체의 [[GetPrototypeOf]] 는 다음 불변 조건을 강제합니다:
[[GetPrototypeOf]] 의 결과는 Object 또는 null 이어야 합니다.
대상 객체가 확장 가능하지 않으면 Proxy 객체에 적용한 [[GetPrototypeOf]] 는 Proxy 객체의 대상 객체에 적용한 [[GetPrototypeOf]] 와 같은 값을 반환해야 합니다.
10.5.2 [[SetPrototypeOf]] ( proto )
a Proxy exotic object obj 의 내부 메서드 [[SetPrototypeOf]] . 인수 proto ((Object 또는 null )). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
? ValidateNonRevokedProxy (obj )를 수행합니다. target 을 obj .[[ProxyTarget]] 으로 둡니다.handler 를 obj .[[ProxyHandler]] 로 둡니다.단언 : handler 는 Object입니다.trap 을 ? GetMethod (handler , "setPrototypeOf" )로 둡니다.trap 이 undefined 이면, 다음을 수행합니다.? target .[[SetPrototypeOf]] (proto ) 를 반환합니다. boolTrapResult 를 ToBoolean (? Call (trap , handler , « target , proto »))로 둡니다.boolTrapResult 가 false 이면, false 를 반환합니다.extensibleTarget 을 ? IsExtensible (target )로 둡니다.extensibleTarget 이 true 이면, true 를 반환합니다.targetProto 를 ? target .[[GetPrototypeOf]] () 로 둡니다.SameValue (proto , targetProto )가 false 이면, TypeError 예외를 던집니다.true 를 반환합니다.
참고
Proxy 객체의 [[SetPrototypeOf]] 는 다음 불변 조건을 강제합니다:
[[SetPrototypeOf]] 의 결과는 Boolean 값입니다.
대상 객체가 확장 가능하지 않으면 인수 값은 대상 객체에 적용한 [[GetPrototypeOf]] 의 결과와 같아야 합니다.
10.5.3 [[IsExtensible]] ( )
a Proxy exotic object obj 의 내부 메서드 [[IsExtensible]] . 인수 없음. 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
? ValidateNonRevokedProxy (obj )를 수행합니다. target 을 obj .[[ProxyTarget]] 으로 둡니다.handler 를 obj .[[ProxyHandler]] 로 둡니다.단언 : handler 는 Object입니다.trap 을 ? GetMethod (handler , "isExtensible" )로 둡니다.trap 이 undefined 이면, 다음을 수행합니다.? IsExtensible (target )을 반환합니다. boolTrapResult 를 ToBoolean (? Call (trap , handler , « target »))로 둡니다.targetResult 를 ? IsExtensible (target )로 둡니다.boolTrapResult 가 targetResult 와 다르면, TypeError 예외를 던집니다.boolTrapResult 를 반환합니다.
참고
Proxy 객체의 [[IsExtensible]] 은 다음 불변 조건을 강제합니다:
[[IsExtensible]] 의 결과는 Boolean 값입니다.
Proxy 객체에 적용한 [[IsExtensible]] 은 동일한 인수로 Proxy 객체의 대상 객체에 적용한 [[IsExtensible]] 과 같은 값을 반환해야 합니다.
10.5.4 [[PreventExtensions]] ( )
a Proxy exotic object obj 의 내부 메서드 [[PreventExtensions]] . 인수 없음. 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
? ValidateNonRevokedProxy (obj )를 수행합니다. target 을 obj .[[ProxyTarget]] 으로 둡니다.handler 를 obj .[[ProxyHandler]] 로 둡니다.단언 : handler 는 Object입니다.trap 을 ? GetMethod (handler , "preventExtensions" )로 둡니다.trap 이 undefined 이면, 다음을 수행합니다.? target .[[PreventExtensions]] () 를 반환합니다. boolTrapResult 를 ToBoolean (? Call (trap , handler , « target »))로 둡니다.boolTrapResult 가 true 이면, 다음을 수행합니다.extensibleTarget 을 ? IsExtensible (target )로 둡니다.extensibleTarget 이 true 이면, TypeError 예외를 던집니다.boolTrapResult 를 반환합니다.
참고
Proxy 객체의 [[PreventExtensions]] 는 다음 불변 조건을 강제합니다:
[[PreventExtensions]] 의 결과는 Boolean 값입니다.
Proxy 객체에 적용한 [[PreventExtensions]] 는 Proxy 객체의 대상 객체에 적용한 [[IsExtensible]] 이 false 일 때만 true 를 반환합니다.
10.5.5 [[GetOwnProperty]] ( propertyKey )
a Proxy exotic object obj 의 내부 메서드 [[GetOwnProperty]] . 인수 propertyKey (프로퍼티 키 ). 반환값: (정상 완료 (값: (프로퍼티 서술자 또는 undefined )) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
? ValidateNonRevokedProxy (obj )를 수행합니다. target 을 obj .[[ProxyTarget]] 으로 둡니다.handler 를 obj .[[ProxyHandler]] 로 둡니다.단언 : handler 는 Object입니다.trap 을 ? GetMethod (handler , "getOwnPropertyDescriptor" )로 둡니다.trap 이 undefined 이면, 다음을 수행합니다.? target .[[GetOwnProperty]] (propertyKey ) 를 반환합니다. trapResultObj 를 ? Call (trap , handler , « target , propertyKey »)로 둡니다.trapResultObj 가 Object도 아니고 undefined 도 아니면, TypeError 예외를 던집니다.targetDesc 를 ? target .[[GetOwnProperty]] (propertyKey ) 로 둡니다.trapResultObj 가 undefined 이면, 다음을 수행합니다.targetDesc 가 undefined 이면, undefined 를 반환합니다.targetDesc .[[Configurable]] 이 false 이면, TypeError 예외를 던집니다.extensibleTarget 을 ? IsExtensible (target )로 둡니다.extensibleTarget 이 false 이면, TypeError 예외를 던집니다.undefined 를 반환합니다.extensibleTarget 을 ? IsExtensible (target )로 둡니다.resultDesc 를 ? ToPropertyDescriptor (trapResultObj )로 둡니다.CompletePropertyDescriptor (resultDesc )를 수행합니다.valid 를 IsCompatiblePropertyDescriptor (extensibleTarget , resultDesc , targetDesc )로 둡니다.valid 가 false 이면, TypeError 예외를 던집니다.resultDesc .[[Configurable]] 이 false 이면, 다음을 수행합니다.targetDesc 가 undefined 이거나 targetDesc .[[Configurable]] 이 true 이면, 다음을 수행합니다.TypeError 예외를 던집니다.resultDesc 에 [[Writable]] 필드가 있고 resultDesc .[[Writable]] 이 false 이면, 다음을 수행합니다.단언 : targetDesc 에는 [[Writable]] 필드가 있습니다.targetDesc .[[Writable]] 이 true 이면, TypeError 예외를 던집니다.resultDesc 를 반환합니다.
참고
Proxy 객체의 [[GetOwnProperty]] 는 다음 불변 조건을 강제합니다:
[[GetOwnProperty]] 의 결과는 Property Descriptor 또는 undefined 여야 합니다.
대상 객체의 구성 불가능한 자체 프로퍼티로 존재하는 프로퍼티를 존재하지 않는 것으로 보고할 수 없습니다.
확장 불가능한 대상 객체의 자체 프로퍼티로 존재하는 프로퍼티를 존재하지 않는 것으로 보고할 수 없습니다.
대상 객체의 자체 프로퍼티로 존재하지 않고 대상 객체가 확장 가능하지 않으면 프로퍼티를 존재하는 것으로 보고할 수 없습니다.
대상 객체의 구성 불가능한 자체 프로퍼티로 존재하지 않는 한 프로퍼티를 구성 불가능한 것으로 보고할 수 없습니다.
대상 객체의 구성 불가능하고 쓰기 불가능한 자체 프로퍼티로 존재하지 않는 한 프로퍼티를 구성 불가능하면서 동시에 쓰기 불가능한 것으로 보고할 수 없습니다.
10.5.6 [[DefineOwnProperty]] ( propertyKey , propertyDesc )
a Proxy exotic object obj 의 내부 메서드 [[DefineOwnProperty]] . 인수 propertyKey (프로퍼티 키 ) 및 propertyDesc (프로퍼티 서술자 ). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
? ValidateNonRevokedProxy (obj )를 수행합니다. target 을 obj .[[ProxyTarget]] 으로 둡니다.handler 를 obj .[[ProxyHandler]] 로 둡니다.단언 : handler 는 Object입니다.trap 을 ? GetMethod (handler , "defineProperty" )로 둡니다.trap 이 undefined 이면, 다음을 수행합니다.? target .[[DefineOwnProperty]] (propertyKey , propertyDesc ) 를 반환합니다. propertyDescObj 를 FromPropertyDescriptor (propertyDesc )로 둡니다.boolTrapResult 를 ToBoolean (? Call (trap , handler , « target , propertyKey , propertyDescObj »))로 둡니다.boolTrapResult 가 false 이면, false 를 반환합니다.targetDesc 를 ? target .[[GetOwnProperty]] (propertyKey ) 로 둡니다.extensibleTarget 을 ? IsExtensible (target )로 둡니다.propertyDesc 에 [[Configurable]] 필드가 있고 propertyDesc .[[Configurable]] 이 false 이면, 다음을 수행합니다.settingConfigurableFalse 를 true 로 둡니다.그렇지 않으면,settingConfigurableFalse 를 false 로 둡니다. targetDesc 가 undefined 이면, 다음을 수행합니다.extensibleTarget 이 false 이면, TypeError 예외를 던집니다.settingConfigurableFalse 가 true 이면, TypeError 예외를 던집니다.그렇지 않으면,IsCompatiblePropertyDescriptor (extensibleTarget , propertyDesc , targetDesc )가 false 이면, TypeError 예외를 던집니다.settingConfigurableFalse 가 true 이고 targetDesc .[[Configurable]] 이 true 이면, TypeError 예외를 던집니다.IsDataDescriptor (targetDesc )가 true 이고, targetDesc .[[Configurable]] 이 false 이며, targetDesc .[[Writable]] 이 true 이면, 다음을 수행합니다.propertyDesc 에 [[Writable]] 필드가 있고 propertyDesc .[[Writable]] 이 false 이면, TypeError 예외를 던집니다. true 를 반환합니다.
참고
Proxy 객체의 [[DefineOwnProperty]] 는 다음 불변 조건을 강제합니다:
[[DefineOwnProperty]] 의 결과는 Boolean 값입니다.
대상 객체가 확장 가능하지 않으면 프로퍼티를 추가할 수 없습니다.
대상 객체에 대응하는 구성 불가능한 자체 프로퍼티가 존재하지 않는 한 프로퍼티를 구성 불가능하게 만들 수 없습니다.
대상 객체에 대응하는 구성 불가능하고 쓰기 불가능한 자체 프로퍼티가 존재하지 않는 한 구성 불가능한 프로퍼티를 쓰기 불가능하게 만들 수 없습니다.
프로퍼티에 대응하는 대상 객체 프로퍼티가 있으면 해당 프로퍼티의 Property Descriptor 를 [[DefineOwnProperty]] 을 사용하여 대상 객체에 적용할 때 예외를 던지지 않습니다.
10.5.7 [[HasProperty]] ( propertyKey )
a Proxy exotic object obj 의 내부 메서드 [[HasProperty]] . 인수 propertyKey (프로퍼티 키 ). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
? ValidateNonRevokedProxy (obj )를 수행합니다. target 을 obj .[[ProxyTarget]] 으로 둡니다.handler 를 obj .[[ProxyHandler]] 로 둡니다.단언 : handler 는 Object입니다.trap 을 ? GetMethod (handler , "has" )로 둡니다.trap 이 undefined 이면, 다음을 수행합니다.? target .[[HasProperty]] (propertyKey ) 를 반환합니다. boolTrapResult 를 ToBoolean (? Call (trap , handler , « target , propertyKey »))로 둡니다.boolTrapResult 가 false 이면, 다음을 수행합니다.targetDesc 를 ? target .[[GetOwnProperty]] (propertyKey ) 로 둡니다.targetDesc 가 undefined 가 아니면, 다음을 수행합니다.targetDesc .[[Configurable]] 이 false 이면, TypeError 예외를 던집니다.extensibleTarget 을 ? IsExtensible (target )로 둡니다.extensibleTarget 이 false 이면, TypeError 예외를 던집니다.boolTrapResult 를 반환합니다.
참고
Proxy 객체의 [[HasProperty]] 는 다음 불변 조건을 강제합니다:
[[HasProperty]] 의 결과는 Boolean 값입니다.
대상 객체의 구성 불가능한 자체 프로퍼티로 존재하는 프로퍼티를 존재하지 않는 것으로 보고할 수 없습니다.
대상 객체의 자체 프로퍼티로 존재하고 대상 객체가 확장 가능하지 않으면 프로퍼티를 존재하지 않는 것으로 보고할 수 없습니다.
10.5.8 [[Get]] ( propertyKey , receiver )
a Proxy exotic object obj 의 내부 메서드 [[Get]] . 인수 propertyKey (프로퍼티 키 ) 및 receiver (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
? ValidateNonRevokedProxy (obj )를 수행합니다. target 을 obj .[[ProxyTarget]] 으로 둡니다.handler 를 obj .[[ProxyHandler]] 로 둡니다.단언 : handler 는 Object입니다.trap 을 ? GetMethod (handler , "get" )로 둡니다.trap 이 undefined 이면, 다음을 수행합니다.? target .[[Get]] (propertyKey , receiver ) 를 반환합니다. trapResult 를 ? Call (trap , handler , « target , propertyKey , receiver »)로 둡니다.targetDesc 를 ? target .[[GetOwnProperty]] (propertyKey ) 로 둡니다.targetDesc 가 undefined 가 아니고 targetDesc .[[Configurable]] 이 false 이면, 다음을 수행합니다.IsDataDescriptor (targetDesc )가 true 이고 targetDesc .[[Writable]] 이 false 이면, 다음을 수행합니다.SameValue (trapResult , targetDesc .[[Value]] )가 false 이면, TypeError 예외를 던집니다.IsAccessorDescriptor (targetDesc )가 true 이고 targetDesc .[[Getter]] 가 undefined 이면, 다음을 수행합니다.trapResult 가 undefined 가 아니면, TypeError 예외를 던집니다.trapResult 를 반환합니다.
참고
Proxy 객체의 [[Get]] 은 다음 불변 조건을 강제합니다:
대상 객체의 대응하는 프로퍼티가 쓰기 불가능하고 구성 불가능한 자체 데이터 프로퍼티 이면 프로퍼티에 대해 보고하는 값은 대상 객체의 대응하는 프로퍼티 값과 같아야 합니다.
대상 객체의 대응하는 프로퍼티가 [[Getter]] 속성으로 undefined 를 갖는 구성 불가능한 자체 접근자 프로퍼티 이면 프로퍼티에 대해 보고하는 값은 undefined 여야 합니다.
10.5.9 [[Set]] ( propertyKey , value , receiver )
a Proxy exotic object obj 의 내부 메서드 [[Set]] . 인수 propertyKey (프로퍼티 키 ), value (ECMAScript 언어 값 ) 및 receiver (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
? ValidateNonRevokedProxy (obj )를 수행합니다. target 을 obj .[[ProxyTarget]] 으로 둡니다.handler 를 obj .[[ProxyHandler]] 로 둡니다.단언 : handler 는 Object입니다.trap 을 ? GetMethod (handler , "set" )로 둡니다.trap 이 undefined 이면, 다음을 수행합니다.? target .[[Set]] (propertyKey , value , receiver ) 를 반환합니다. boolTrapResult 를 ToBoolean (? Call (trap , handler , « target , propertyKey , value , receiver »))로 둡니다.boolTrapResult 가 false 이면, false 를 반환합니다.targetDesc 를 ? target .[[GetOwnProperty]] (propertyKey ) 로 둡니다.targetDesc 가 undefined 가 아니고 targetDesc .[[Configurable]] 이 false 이면, 다음을 수행합니다.IsDataDescriptor (targetDesc )가 true 이고 targetDesc .[[Writable]] 이 false 이면, 다음을 수행합니다.SameValue (value , targetDesc .[[Value]] )가 false 이면, TypeError 예외를 던집니다.IsAccessorDescriptor (targetDesc )가 true 이면, 다음을 수행합니다.targetDesc .[[Setter]] 가 undefined 이면, TypeError 예외를 던집니다.true 를 반환합니다.
참고
Proxy 객체의 [[Set]] 은 다음 불변 조건을 강제합니다:
[[Set]] 의 결과는 Boolean 값입니다.
대응하는 대상 객체 프로퍼티가 쓰기 불가능하고 구성 불가능한 자체 데이터 프로퍼티 이면 프로퍼티 값을 해당 대상 객체 프로퍼티의 값과 다른 값으로 변경할 수 없습니다.
대응하는 대상 객체 프로퍼티가 [[Setter]] 속성으로 undefined 를 갖는 구성 불가능한 자체 접근자 프로퍼티 이면 프로퍼티 값을 설정할 수 없습니다.
10.5.10 [[Delete]] ( propertyKey )
a Proxy exotic object obj 의 내부 메서드 [[Delete]] . 인수 propertyKey (프로퍼티 키 ). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
? ValidateNonRevokedProxy (obj )를 수행합니다. target 을 obj .[[ProxyTarget]] 으로 둡니다.handler 를 obj .[[ProxyHandler]] 로 둡니다.단언 : handler 는 Object입니다.trap 을 ? GetMethod (handler , "deleteProperty" )로 둡니다.trap 이 undefined 이면, 다음을 수행합니다.? target .[[Delete]] (propertyKey ) 를 반환합니다. boolTrapResult 를 ToBoolean (? Call (trap , handler , « target , propertyKey »))로 둡니다.boolTrapResult 가 false 이면, false 를 반환합니다.targetDesc 를 ? target .[[GetOwnProperty]] (propertyKey ) 로 둡니다.targetDesc 가 undefined 이면, true 를 반환합니다.targetDesc .[[Configurable]] 이 false 이면, TypeError 예외를 던집니다.extensibleTarget 을 ? IsExtensible (target )로 둡니다.extensibleTarget 이 false 이면, TypeError 예외를 던집니다.true 를 반환합니다.
참고
Proxy 객체의 [[Delete]] 는 다음 불변 조건을 강제합니다:
[[Delete]] 의 결과는 Boolean 값입니다.
대상 객체의 구성 불가능한 자체 프로퍼티로 존재하는 프로퍼티를 삭제된 것으로 보고할 수 없습니다.
대상 객체의 자체 프로퍼티로 존재하고 대상 객체가 확장 불가능하면 프로퍼티를 삭제된 것으로 보고할 수 없습니다.
10.5.11 [[OwnPropertyKeys]] ( )
a Proxy exotic object obj 의 내부 메서드 [[OwnPropertyKeys]] . 인수 없음. 반환값: (정상 완료 (값: 리스트 (요소: 프로퍼티 키 )) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
? ValidateNonRevokedProxy (obj )를 수행합니다. target 을 obj .[[ProxyTarget]] 으로 둡니다.handler 를 obj .[[ProxyHandler]] 로 둡니다.단언 : handler 는 Object입니다.trap 을 ? GetMethod (handler , "ownKeys" )로 둡니다.trap 이 undefined 이면, 다음을 수행합니다.? target .[[OwnPropertyKeys]] () 를 반환합니다. trapResultArray 를 ? Call (trap , handler , « target »)로 둡니다.trapResult 를 ? CreateListFromArrayLike (trapResultArray , property-key )로 둡니다.trapResult 에 중복 항목이 하나라도 있으면, TypeError 예외를 던집니다.extensibleTarget 을 ? IsExtensible (target )로 둡니다.targetKeys 를 ? target .[[OwnPropertyKeys]] () 로 둡니다.단언 : targetKeys 는 프로퍼티 키 의 List 입니다.단언 : targetKeys 에는 중복 항목이 없습니다.targetConfigurableKeys 를 새로운 빈 List 로 둡니다.targetNonconfigurableKeys 를 새로운 빈 List 로 둡니다.targetKeys 의 각 요소 key 에 대해 다음을 수행합니다.propertyDesc 를 ? target .[[GetOwnProperty]] (key ) 로 둡니다.propertyDesc 가 undefined 가 아니고 propertyDesc .[[Configurable]] 이 false 이면, 다음을 수행합니다.key 를 targetNonconfigurableKeys 에 추가합니다.그렇지 않으면,key 를 targetConfigurableKeys 에 추가합니다. extensibleTarget 이 true 이고 targetNonconfigurableKeys 가 비어 있으면, 다음을 수행합니다.trapResult 를 반환합니다.uncheckedResultKeys 를 trapResult 의 요소를 요소로 갖는 List 로 둡니다.targetNonconfigurableKeys 의 각 요소 key 에 대해 다음을 수행합니다.uncheckedResultKeys 에 key 가 포함되어 있지 않으면, TypeError 예외를 던집니다.uncheckedResultKeys 에서 key 를 제거합니다.extensibleTarget 이 true 이면, trapResult 를 반환합니다.targetConfigurableKeys 의 각 요소 key 에 대해 다음을 수행합니다.uncheckedResultKeys 에 key 가 포함되어 있지 않으면, TypeError 예외를 던집니다.uncheckedResultKeys 에서 key 를 제거합니다.uncheckedResultKeys 가 비어 있지 않으면, TypeError 예외를 던집니다.trapResult 를 반환합니다.
참고
Proxy 객체의 [[OwnPropertyKeys]] 는 다음 불변 조건을 강제합니다:
[[OwnPropertyKeys]] 의 결과는 List 입니다.
반환된 List 에는 중복 항목이 없습니다.
반환된 List 의 각 요소는 프로퍼티 키 입니다.
결과 List 에는 대상 객체의 모든 구성 불가능한 자체 프로퍼티 키 가 포함되어야 합니다.
대상 객체가 확장 가능하지 않으면 결과 List 에는 대상 객체의 모든 자체 프로퍼티 키 가 포함되어야 하며 다른 값은 포함되어서는 안 됩니다.
10.5.12 [[Call]] ( thisArg , argList )
a Proxy exotic object obj 의 내부 메서드 [[Call]] . 인수 thisArg (ECMAScript 언어 값 ) 및 argList (리스트 (요소: ECMAScript 언어 값 )). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
? ValidateNonRevokedProxy (obj )를 수행합니다. target 을 obj .[[ProxyTarget]] 으로 둡니다.handler 를 obj .[[ProxyHandler]] 로 둡니다.단언 : handler 는 Object입니다.trap 을 ? GetMethod (handler , "apply" )로 둡니다.trap 이 undefined 이면, 다음을 수행합니다.? Call (target , thisArg , argList )를 반환합니다. argArray 를 CreateArrayFromList (argList )로 둡니다.? Call (trap , handler , « target , thisArg , argArray »)를 반환합니다.
참고
Proxy 특수 객체 는 [[ProxyTarget]] 내부 슬롯의 초기값이 [[Call]] 내부 메서드를 갖는 객체인 경우에만 [[Call]] 내부 메서드를 갖습니다.
10.5.13 [[Construct]] ( argList , newTarget )
a Proxy exotic object obj 의 내부 메서드 [[Construct]] . 인수 argList (리스트 (요소: ECMAScript 언어 값 )) 및 newTarget (생성자 ). 반환값: (정상 완료 (값: Object) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
? ValidateNonRevokedProxy (obj )를 수행합니다. target 을 obj .[[ProxyTarget]] 으로 둡니다.단언 : IsConstructor (target )은 true 입니다.handler 를 obj .[[ProxyHandler]] 로 둡니다.단언 : handler 는 Object입니다.trap 을 ? GetMethod (handler , "construct" )로 둡니다.trap 이 undefined 이면, 다음을 수행합니다.? Construct (target , argList , newTarget )를 반환합니다. argArray 를 CreateArrayFromList (argList )로 둡니다.newObj 를 ? Call (trap , handler , « target , argArray , newTarget »)로 둡니다.newObj 가 Object가 아니면, TypeError 예외를 던집니다.newObj 를 반환합니다.
참고 1
Proxy 특수 객체 는 [[ProxyTarget]] 내부 슬롯의 초기값이 [[Construct]] 내부 메서드를 갖는 객체인 경우에만 [[Construct]] 내부 메서드를 갖습니다.
참고 2
Proxy 객체의 [[Construct]] 는 다음 불변 조건을 강제합니다:
[[Construct]] 의 결과는 Object여야 합니다.
10.5.14 ValidateNonRevokedProxy ( proxy )
추상 연산 ValidateNonRevokedProxy. 인수 proxy (Proxy 특수 객체 ). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). proxy 가 해제된 경우 TypeError 예외를 던집니다. 호출되면 다음 단계를 수행한다.
proxy .[[ProxyTarget]] 이 null 이면, TypeError 예외를 던집니다.단언 : proxy .[[ProxyHandler]] 는 null 이 아닙니다.unused 를 반환합니다.
10.5.15 ProxyCreate ( target , handler )
추상 연산 ProxyCreate. 인수 target (ECMAScript 언어 값 ) 및 handler (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: Proxy 특수 객체 ) 또는 throw 완료 ). 새로운 Proxy 객체의 생성을 명시하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
target 이 Object가 아니면 TypeError 예외를 던집니다.handler 가 Object가 아니면 TypeError 예외를 던집니다.proxy 를 MakeBasicObject (« [[ProxyHandler]] , [[ProxyTarget]] »)로 둡니다.proxy 의 필수 내부 메서드 중 [[Call]] 및 [[Construct]] 를 제외한 메서드를 10.5 에 지정된 정의로 설정합니다.IsCallable (target )이 true 이면, 다음을 수행합니다.proxy .[[Call]] 을 10.5.12 에 지정된 대로 설정합니다.IsConstructor (target )가 true 이면, 다음을 수행합니다.proxy .[[Construct]] 를 10.5.13 에 지정된 대로 설정합니다.proxy .[[ProxyTarget]] 을 target 으로 설정합니다.proxy .[[ProxyHandler]] 를 handler 로 설정합니다.proxy 를 반환합니다.
11 ECMAScript 언어: 소스 텍스트
11.1 소스 텍스트
구문
SourceCharacter ::
any Unicode code point
ECMAScript 소스 텍스트 는 유니코드 코드 포인트의 시퀀스입니다. 서로게이트 코드 포인트를 포함하여 U+0000부터 U+10FFFF까지의 모든 유니코드 코드 포인트 값은 ECMAScript 문법에서 허용되는 위치의 ECMAScript 소스 텍스트에 나타날 수 있습니다. ECMAScript 소스 텍스트를 저장하고 교환하는 데 실제로 사용되는 인코딩은 이 명세와 관련이 없습니다. 외부 소스 텍스트 인코딩과 관계없이 적합한 ECMAScript 구현체는 소스 텍스트를 각 SourceCharacter 가 하나의 유니코드 코드 포인트인 동등한 SourceCharacter 값의 시퀀스인 것처럼 처리합니다. 적합한 ECMAScript 구현체는 소스 텍스트를 정규화하거나 소스 텍스트를 정규화하는 것처럼 동작할 필요가 없습니다.
결합 문자 시퀀스의 구성 요소는 사용자가 전체 시퀀스를 하나의 문자로 생각할 수 있더라도 개별 유니코드 코드 포인트로 처리됩니다.
참고
문자열 리터럴, 정규 표현식 리터럴, 템플릿 리터럴 및 식별자에서는 유니코드 코드 포인트의 숫자 값을 명시적으로 표현하는 유니코드 이스케이프 시퀀스를 사용하여 모든 유니코드 코드 포인트를 표현할 수도 있습니다. 주석 안에서는 이러한 이스케이프 시퀀스가 실질적으로 주석의 일부로서 무시됩니다.
ECMAScript는 유니코드 이스케이프 시퀀스의 동작에서 Java 프로그래밍 언어와 다릅니다. 예를 들어 Java 프로그램에서 유니코드 이스케이프 시퀀스 \u000A가 한 줄 주석 안에 나타나면 줄 종결자로 해석되며(유니코드 코드 포인트 U+000A는 LINE FEED (LF)입니다), 따라서 다음 코드 포인트는 주석의 일부가 아닙니다. 마찬가지로 Java 프로그램의 문자열 리터럴 안에 유니코드 이스케이프 시퀀스 \u000A가 나타나면 역시 줄 종결자로 해석되며 문자열 리터럴 안에서는 허용되지 않습니다. 따라서 문자열 리터럴 값의 일부로 LINE FEED (LF)를 포함하려면 \u000A 대신 \n을 작성해야 합니다. ECMAScript 프로그램에서는 주석 안에 나타나는 유니코드 이스케이프 시퀀스를 절대로 해석하지 않으므로 주석 종료에 영향을 줄 수 없습니다. 마찬가지로 ECMAScript 프로그램의 문자열 리터럴 안에 나타나는 유니코드 이스케이프 시퀀스는 항상 리터럴에 기여하며 줄 종결자 또는 문자열 리터럴을 종료할 수 있는 코드 포인트로 해석되지 않습니다.
11.1.1 Static Semantics: UTF16EncodeCodePoint ( codePoint )
추상 연산 UTF16EncodeCodePoint. 인수 codePoint (유니코드 코드 포인트). 반환값: String. 호출되면 다음 단계를 수행한다.
단언 : 0 ≤ codePoint ≤ 0x10FFFF입니다.codePoint ≤ 0xFFFF이면, 숫자 값이 codePoint 인 코드 단위로 구성된 String 값을 반환합니다.cu1 을 숫자 값이 floor ((codePoint - 0x10000) / 0x400) + 0xD800인 코드 단위로 둡니다.cu2 를 숫자 값이 ((codePoint - 0x10000) modulo 0x400) + 0xDC00인 코드 단위로 둡니다.cu1 과 cu2 의 문자열 연결 을 반환합니다.
11.1.2 Static Semantics: CodePointsToString ( text )
추상 연산 CodePointsToString. 인수 text (a sequence of Unicode code points). 반환값: String. 6.1.4 에 설명된 대로 text 를 String 값으로 변환합니다. 호출되면 다음 단계를 수행한다.
result 를 빈 String으로 둡니다.text 의 각 코드 포인트 codePoint 에 대해 다음을 수행합니다.result 를 result 와 UTF16EncodeCodePoint (codePoint )의 문자열 연결 로 설정합니다.result 를 반환합니다.
11.1.3 Static Semantics: UTF16SurrogatePairToCodePoint ( lead , trail )
추상 연산 UTF16SurrogatePairToCodePoint. 인수 lead (코드 단위) 및 trail (코드 단위). 반환값: 코드 포인트. UTF-16 서로게이트 쌍 을 구성하는 두 코드 단위를 하나의 코드 포인트로 변환합니다. 호출되면 다음 단계를 수행한다.
단언 : lead 는 선행 서로게이트 이고 trail 은 후행 서로게이트 입니다.codePoint 를 (lead - 0xD800) × 0x400 + (trail - 0xDC00) + 0x10000으로 둡니다.코드 포인트 codePoint 를 반환합니다.
11.1.4 Static Semantics: CodePointAt ( string , position )
추상 연산 CodePointAt. 인수 string (String) 및 position (음이 아닌 정수). 반환값: 레코드 (필드: [[CodePoint]] (코드 포인트), [[CodeUnitCount]] (양의 정수), [[IsUnpairedSurrogate]] (Boolean)). 6.1.4 에 설명된 대로 string 을 UTF-16으로 인코딩된 코드 포인트의 시퀀스로 해석하고 인덱스 position 의 코드 단위에서 시작하는 하나의 코드 포인트를 읽습니다. 호출되면 다음 단계를 수행한다.
size 를 string 의 길이로 둡니다.단언 : position ≥ 0이고 position < size 입니다.first 를 string 내 인덱스 position 의 코드 단위로 둡니다.codePoint 를 숫자 값이 first 의 숫자 값인 코드 포인트로 둡니다.first 가 선행 서로게이트 도 후행 서로게이트 도 아니면, 다음을 수행합니다.Record { [[CodePoint]] : codePoint , [[CodeUnitCount]] : 1, [[IsUnpairedSurrogate]] : false }를 반환합니다.first 가 후행 서로게이트 이거나 position + 1 = size 이면, 다음을 수행합니다.Record { [[CodePoint]] : codePoint , [[CodeUnitCount]] : 1, [[IsUnpairedSurrogate]] : true }를 반환합니다.second 를 string 내 인덱스 position + 1의 코드 단위로 둡니다.second 가 후행 서로게이트 가 아니면, 다음을 수행합니다.Record { [[CodePoint]] : codePoint , [[CodeUnitCount]] : 1, [[IsUnpairedSurrogate]] : true }를 반환합니다.codePoint 를 UTF16SurrogatePairToCodePoint (first , second )로 설정합니다.Record { [[CodePoint]] : codePoint , [[CodeUnitCount]] : 2, [[IsUnpairedSurrogate]] : false }를 반환합니다.
11.1.5 Static Semantics: StringToCodePoints ( string )
추상 연산 StringToCodePoints. 인수 string (String). 반환값: 리스트 (요소: 코드 포인트). 6.1.4 에 설명된 대로 string 을 UTF-16으로 인코딩된 유니코드 텍스트로 해석하여 얻은 유니코드 코드 포인트의 시퀀스를 반환합니다. 호출되면 다음 단계를 수행한다.
codePoints 를 새로운 빈 List 로 둡니다.size 를 string 의 길이로 둡니다.position 을 0으로 둡니다.position < size 인 동안 다음을 반복합니다.codePoint 를 CodePointAt (string , position )으로 둡니다.codePoint .[[CodePoint]] 를 codePoints 에 추가합니다.position 을 position + codePoint .[[CodeUnitCount]] 로 설정합니다.codePoints 를 반환합니다.
11.1.6 Static Semantics: ParseText ( sourceText , goalSymbol )
추상 연산 ParseText. 인수 sourceText ((String 또는 a sequence of Unicode code points)) 및 goalSymbol (a nonterminal in one of the ECMAScript grammars). 반환값: (구문 분석 노드 또는 a non-empty List of SyntaxError objects). 호출되면 다음 단계를 수행한다.
sourceText 가 String이면 sourceText 를 StringToCodePoints (sourceText )로 설정합니다.goalSymbol 을 목표 기호 로 사용하여 sourceText 의 파싱을 시도하고 파싱 결과에서 모든 조기 오류 조건을 분석합니다. 구현체는 구현체 정의 방식으로 파싱과 조기 오류 감지를 서로 교차하여 수행할 수 있습니다.파싱에 성공하고 조기 오류 가 발견되지 않았으면 파싱 결과로 생성된 파스 트리의 루트에 있는 Parse Node(goalSymbol 의 인스턴스)를 반환합니다. 파싱 오류 및/또는 조기 오류 를 나타내는 하나 이상의 SyntaxError 객체의 List 를 반환합니다. 파싱 오류 또는 조기 오류 가 둘 이상 존재하면 목록에 포함되는 오류 객체의 수와 순서는 구현체 정의 이지만 최소 하나는 존재해야 합니다.
참고 1
특정 지점에 조기 오류 가 있고 그보다 뒤 지점에 구문 오류도 있는 텍스트를 생각해 보시기 바랍니다. 파싱 패스를 수행한 뒤 조기 오류 패스를 수행하는 구현체는 구문 오류를 보고하고 조기 오류 패스로 진행하지 않을 수 있습니다. 두 작업을 서로 교차하여 수행하는 구현체는 조기 오류 를 보고하고 구문 오류를 찾기 위한 작업을 진행하지 않을 수 있습니다. 세 번째 구현체는 두 오류를 모두 보고할 수 있습니다. 이러한 동작은 모두 적합합니다.
참고 2
11.2 소스 코드의 타입
ECMAScript 코드에는 네 가지 타입이 있습니다:
전역 코드 는 ECMAScript Script 로 취급되는 소스 텍스트입니다. 특정 Script 의 전역 코드에는 FunctionDeclaration , FunctionExpression , GeneratorDeclaration , GeneratorExpression , AsyncFunctionDeclaration , AsyncFunctionExpression , AsyncGeneratorDeclaration , AsyncGeneratorExpression , MethodDefinition , ArrowFunction , AsyncArrowFunction , ClassDeclaration 또는 ClassExpression 의 일부로 파싱되는 소스 텍스트는 포함되지 않습니다.
Eval 코드 는 내장 eval 함수에 제공되는 소스 텍스트입니다. 더 정확히 말하면 내장 eval 함수의 매개변수가 String이면 ECMAScript Script 로 취급됩니다. 특정 eval 호출의 eval 코드는 해당 Script 의 전역 코드 부분입니다.
함수 코드 는 ECMAScript 함수 객체 의 [[ECMAScriptCode]] 및 [[FormalParameters]] 내부 슬롯(10.2 참조)의 값을 제공하기 위해 파싱되는 소스 텍스트입니다. 특정 ECMAScript 함수의 함수 코드에는 중첩된 FunctionDeclaration , FunctionExpression , GeneratorDeclaration , GeneratorExpression , AsyncFunctionDeclaration , AsyncFunctionExpression , AsyncGeneratorDeclaration , AsyncGeneratorExpression , MethodDefinition , ArrowFunction , AsyncArrowFunction , ClassDeclaration 또는 ClassExpression 의 함수 코드로 파싱되는 소스 텍스트는 포함되지 않습니다.
또한 위에서 언급한 소스 텍스트가 다음과 같이 파싱되면:
해당 선언 또는 표현식의 BindingIdentifier (있는 경우)와 일치하는 소스 텍스트 도 대응하는 함수의 함수 코드에 포함됩니다.
모듈 코드 는 ModuleBody 로 제공되는 코드인 소스 텍스트입니다. 이는 모듈이 초기화될 때 직접 평가되는 코드입니다. 특정 모듈의 모듈 코드에는 중첩된 FunctionDeclaration , FunctionExpression , GeneratorDeclaration , GeneratorExpression , AsyncFunctionDeclaration , AsyncFunctionExpression , AsyncGeneratorDeclaration , AsyncGeneratorExpression , MethodDefinition , ArrowFunction , AsyncArrowFunction , ClassDeclaration 또는 ClassExpression 의 일부로 파싱되는 소스 텍스트는 포함되지 않습니다.
참고 1
함수 코드는 일반적으로 함수 정의(15.2 ), 화살표 함수 정의(15.3 ), 메서드 정의(15.4 ), 제너레이터 함수 정의(15.5 ), 비동기 함수 정의(15.8 ), 비동기 제너레이터 함수 정의(15.6 ) 및 비동기 화살표 함수(15.9 )의 본문으로 제공됩니다. 함수 코드는 Function 생성자 (20.2.1.1 ), GeneratorFunction 생성자 (27.6.1.1 ), AsyncFunction 생성자 (27.10.1.1 ) 및 AsyncGeneratorFunction 생성자 (27.7.1.1 )의 인수에서도 파생됩니다.
참고 2
함수 코드에 BindingIdentifier 를 포함하는 실질적인 효과는 둘러싸는 코드가 엄격 모드 코드 가 아니더라도 본문에 Use Strict 지시문 가 포함된 함수의 이름인 BindingIdentifier 에 엄격 모드 코드 의 조기 오류 가 적용된다는 것입니다.
11.2.1 지시문 프롤로그와 Use Strict 지시문
지시문 프롤로그 는 FunctionBody , ScriptBody 또는 ModuleBody 의 처음 StatementListItem 또는 ModuleItem 으로 나타나는 ExpressionStatement 중 각 ExpressionStatement 가 전체적으로 StringLiteral 토큰과 그 뒤의 세미콜론으로만 구성된 가장 긴 시퀀스입니다. 세미콜론은 명시적으로 나타나거나 자동 세미콜론 삽입(12.10 )에 의해 삽입될 수 있습니다. 지시문 프롤로그 는 빈 시퀀스일 수 있습니다.
Use Strict 지시문 은 지시문 프롤로그 안에서 StringLiteral 이 정확한 코드 포인트 시퀀스 "use strict" 또는 'use strict' 중 하나인 ExpressionStatement 입니다. Use Strict 지시문 에는 EscapeSequence 또는 LineContinuation 을 포함할 수 없습니다.
지시문 프롤로그 에는 둘 이상의 Use Strict 지시문 이 포함될 수 있습니다. 그러나 이 경우 구현체는 경고를 표시할 수 있습니다.
참고
지시문 프롤로그 의 ExpressionStatement 는 이를 포함하는 생성 규칙을 평가하는 동안 정상적으로 평가됩니다. 구현체는 Use Strict 지시문 이 아니면서 지시문 프롤로그 에 나타나는 ExpressionStatement 에 구현체별 의미를 정의할 수 있습니다. 적절한 알림 메커니즘이 존재하는 경우 구현체는 지시문 프롤로그 에서 Use Strict 지시문 이 아니며 구현체가 정의한 의미도 없는 ExpressionStatement 를 발견하면 경고를 표시해야 합니다.
11.2.2 엄격 모드 코드
ECMAScript 구문 단위는 제한 없는 모드 또는 엄격 모드 구문과 의미론(4.3.2 )을 사용하여 처리할 수 있습니다. 다음 상황에서 코드는 엄격 모드 코드 로 해석됩니다:
전역 코드 가 Use Strict 지시문 을 포함하는 지시문 프롤로그 로 시작하면 엄격 모드 코드입니다.
모듈 코드 는 항상 엄격 모드 코드입니다.
ClassDeclaration 또는 ClassExpression 의 모든 부분은 엄격 모드 코드입니다.
Eval 코드 가 Use Strict 지시문 을 포함하는 지시문 프롤로그 로 시작하거나 eval 호출이 엄격 모드 코드에 포함된 직접 eval 이면 엄격 모드 코드입니다.
연결된 FunctionDeclaration , FunctionExpression , GeneratorDeclaration , GeneratorExpression , AsyncFunctionDeclaration , AsyncFunctionExpression , AsyncGeneratorDeclaration , AsyncGeneratorExpression , MethodDefinition , ArrowFunction 또는 AsyncArrowFunction 이 엄격 모드 코드에 포함되어 있거나 함수의 [[ECMAScriptCode]] 내부 슬롯 값을 생성하는 코드가 Use Strict 지시문 을 포함하는 지시문 프롤로그 로 시작하면 함수 코드 는 엄격 모드 코드입니다.
내장 Function, Generator, AsyncFunction 및 AsyncGenerator 생성자 에 인수로 제공되는 함수 코드 는 마지막 인수가 String이고 이를 처리했을 때 Use Strict 지시문 을 포함하는 지시문 프롤로그 로 시작하는 FunctionBody 이면 엄격 모드 코드입니다.
엄격 모드 코드가 아닌 ECMAScript 코드를 비엄격 코드 라고 합니다.
11.2.2.1 Static Semantics: IsStrict ( parseNode )
추상 연산 IsStrict. 인수 parseNode (구문 분석 노드). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
parseNode 와 일치하는 소스 텍스트 가 엄격 모드 코드 이면, true 를 반환합니다.false 를 반환합니다.
11.2.3 비ECMAScript 함수
ECMAScript 구현체는 ECMAScript 소스 텍스트 가 아닌 호스트 정의 형식의 실행 가능 코드로 평가 동작이 표현되는 함수 특수 객체 의 평가를 지원할 수 있습니다. 함수 객체 가 ECMAScript 코드 안에서 정의되었는지 또는 내장 함수인지는 이러한 함수 객체 를 호출하거나 이러한 함수 객체 에 의해 호출되는 ECMAScript 코드의 관점에서는 관찰할 수 없습니다.
12 ECMAScript 언어: 어휘 문법
ECMAScript Script 또는 Module 의 소스 텍스트는 먼저 토큰, 줄 종결자, 주석 또는 공백인 입력 요소의 시퀀스로 변환됩니다. 소스 텍스트는 왼쪽에서 오른쪽으로 스캔되며, 가능한 가장 긴 코드 포인트 시퀀스를 다음 입력 요소로 반복해서 취합니다.
어휘 입력 요소를 식별하는 방식이 해당 입력 요소를 소비하는 구문 문법 문맥에 따라 달라지는 상황이 여러 가지 있습니다. 따라서 어휘 문법에는 여러 목표 기호 가 필요합니다. InputElementHashbangOrRegExp 목표는 Script 또는 Module 의 시작 부분에서 사용됩니다. InputElementRegExpOrTemplateTail 목표는 RegularExpressionLiteral , TemplateMiddle 또는 TemplateTail 이 허용되는 구문 문법 문맥에서 사용됩니다. InputElementRegExp 목표 기호 는 RegularExpressionLiteral 은 허용되지만 TemplateMiddle 과 TemplateTail 은 모두 허용되지 않는 모든 구문 문법 문맥에서 사용됩니다. InputElementTemplateTail 목표는 TemplateMiddle 또는 TemplateTail 은 허용되지만 RegularExpressionLiteral 은 허용되지 않는 모든 구문 문법 문맥에서 사용됩니다. 그 밖의 모든 문맥에서는 InputElementDiv 를 어휘 목표 기호 로 사용합니다.
참고
여러 어휘 목표를 사용하면 자동 세미콜론 삽입에 영향을 주는 어휘적 모호성이 발생하지 않습니다. 예를 들어 선행 나눗셈 또는 나눗셈 할당과 선행 RegularExpressionLiteral 이 모두 허용되는 구문 문법 문맥은 없습니다. 세미콜론 삽입(12.10 참조)은 이에 영향을 주지 않습니다. 다음과 같은 예에서:
a = b
/hi/g.exec (c).map (d);
LineTerminator 뒤의 첫 번째 비공백, 비주석 코드 포인트가 U+002F (SOLIDUS)이고 구문 문맥이 나눗셈 또는 나눗셈 할당을 허용하면 LineTerminator 에 세미콜론을 삽입하지 않습니다. 즉, 위 예제는 다음과 동일하게 해석됩니다:
a = b / hi / g.exec (c).map (d);
구문
InputElementDiv ::
WhiteSpace
LineTerminator
Comment
CommonToken
DivPunctuator
RightBracePunctuator
InputElementRegExp ::
WhiteSpace
LineTerminator
Comment
CommonToken
RightBracePunctuator
RegularExpressionLiteral
InputElementRegExpOrTemplateTail ::
WhiteSpace
LineTerminator
Comment
CommonToken
RegularExpressionLiteral
TemplateSubstitutionTail
InputElementTemplateTail ::
WhiteSpace
LineTerminator
Comment
CommonToken
DivPunctuator
TemplateSubstitutionTail
InputElementHashbangOrRegExp ::
WhiteSpace
LineTerminator
Comment
CommonToken
HashbangComment
RegularExpressionLiteral
12.1 유니코드 형식 제어 문자
유니코드 형식 제어 문자(즉, LEFT-TO-RIGHT MARK 또는 RIGHT-TO-LEFT MARK와 같은 유니코드 문자 데이터베이스의 “Cf” 범주에 속하는 문자)는 마크업 언어와 같은 상위 수준 프로토콜이 없는 경우 일정 범위의 텍스트 형식을 제어하는 데 사용하는 제어 코드입니다.
소스 텍스트에서 형식 제어 문자를 허용하면 편집과 표시가 편리해집니다. 모든 형식 제어 문자는 주석과 문자열 리터럴, 템플릿 리터럴 및 정규 표현식 리터럴 안에서 사용할 수 있습니다.
U+FEFF (ZERO WIDTH NO-BREAK SPACE)는 주로 텍스트 시작 부분에서 해당 텍스트가 유니코드임을 표시하고 텍스트의 인코딩과 바이트 순서를 감지할 수 있도록 하는 데 사용하는 형식 제어 문자입니다. 이러한 목적으로 사용하는 <ZWNBSP> 문자는 파일 연결 등의 결과로 텍스트 시작 부분 이후에도 나타날 수 있습니다. ECMAScript 소스 텍스트 에서 <ZWNBSP> 코드 포인트는 주석, 문자열 리터럴, 템플릿 리터럴 및 정규 표현식 리터럴 바깥에서는 공백 문자로 취급됩니다(12.2 참조).
12.2 공백
공백 코드 포인트는 소스 텍스트의 가독성을 높이고 토큰(더 이상 나눌 수 없는 어휘 단위)을 서로 분리하는 데 사용되지만 그 밖에는 중요하지 않습니다. 공백 코드 포인트는 임의의 두 토큰 사이와 입력의 시작 또는 끝에 나타날 수 있습니다. 공백 코드 포인트는 StringLiteral , RegularExpressionLiteral , Template 또는 TemplateSubstitutionTail 안에 나타날 수 있으며, 이 경우 리터럴 값의 일부를 구성하는 의미 있는 코드 포인트로 간주됩니다. Comment 안에도 나타날 수 있지만 그 밖의 다른 종류의 토큰 안에는 나타날 수 없습니다.
ECMAScript 공백 코드 포인트는 표 31 에 나열되어 있습니다.
표 31: 공백 코드 포인트
코드 포인트
이름
약어
U+0009
CHARACTER TABULATION
<TAB>
U+000B
LINE TABULATION
<VT>
U+000C
FORM FEED (FF)
<FF>
U+FEFF
ZERO WIDTH NO-BREAK SPACE
<ZWNBSP>
일반 범주 “Space_Separator”의 모든 코드 포인트
<USP>
참고 1
U+0020 (SPACE) 및 U+00A0 (NO-BREAK SPACE) 코드 포인트는 <USP>의 일부입니다.
참고 2
표 31 에 나열된 코드 포인트를 제외하면 ECMAScript WhiteSpace 는 유니코드 “White_Space” 프로퍼티를 갖지만 일반 범주 “Space_Separator” (“Zs”)로 분류되지 않는 모든 코드 포인트를 의도적으로 제외합니다.
구문
WhiteSpace ::
<TAB>
<VT>
<FF>
<ZWNBSP>
<USP>
12.3 줄 종결자
공백 코드 포인트와 마찬가지로 줄 종결자 코드 포인트는 소스 텍스트의 가독성을 높이고 토큰(더 이상 나눌 수 없는 어휘 단위)을 서로 분리하는 데 사용됩니다. 그러나 공백 코드 포인트와 달리 줄 종결자는 구문 문법의 동작에 일부 영향을 줍니다. 일반적으로 줄 종결자는 임의의 두 토큰 사이에 나타날 수 있지만 구문 문법에 의해 금지되는 위치도 일부 있습니다. 줄 종결자는 자동 세미콜론 삽입 과정(12.10 )에도 영향을 줍니다. 줄 종결자는 StringLiteral , Template 또는 TemplateSubstitutionTail 을 제외한 어떤 토큰 안에도 나타날 수 없습니다. <LF> 및 <CR> 줄 종결자는 LineContinuation 의 일부인 경우를 제외하면 StringLiteral 토큰 안에 나타날 수 없습니다.
줄 종결자는 MultiLineComment 안에 나타날 수 있지만 SingleLineComment 안에는 나타날 수 없습니다.
줄 종결자는 정규 표현식의 \s 클래스와 일치하는 공백 코드 포인트 집합에 포함됩니다.
ECMAScript 줄 종결자 코드 포인트는 표 32 에 나열되어 있습니다.
표 32: 줄 종결자 코드 포인트
코드 포인트
유니코드 이름
약어
U+000A
LINE FEED (LF)
<LF>
U+000D
CARRIAGE RETURN (CR)
<CR>
U+2028
LINE SEPARATOR
<LS>
U+2029
PARAGRAPH SEPARATOR
<PS>
표 32 에 있는 유니코드 코드 포인트만 줄 종결자로 취급됩니다. 그 밖의 개행 또는 줄바꿈 유니코드 코드 포인트는 줄 종결자로 취급되지 않지만 표 31 에 나열된 요구 사항을 충족하면 공백으로 취급됩니다.
구문
LineTerminator ::
<LF>
<CR>
<LS>
<PS>
LineTerminatorSequence ::
<LF>
<CR>
[lookahead ≠ <LF> ]
<LS>
<PS>
<CR>
<LF>
참고
생성 규칙
LineTerminatorSequence ::
<CR>
<LF>
은 진단에서 줄 번호를 보고할 때와 같이 전체가 하나의 줄 종결자로 동작해야 하는 코드 포인트 시퀀스와 일치합니다.
12.5 Hashbang 주석
Hashbang 주석은 위치에 민감하며 다른 종류의 주석과 마찬가지로 구문 문법의 입력 요소 스트림에서 제거됩니다.
구문
12.6 토큰
구문
CommonToken ::
IdentifierName
PrivateIdentifier
Punctuator
NumericLiteral
StringLiteral
Template
참고
12.7 이름과 키워드
IdentifierName 과 ReservedWord 는 유니코드 표준 부속서 #31, Identifier and Pattern Syntax에 제시된 기본 식별자 구문을 약간 수정하여 해석하는 토큰입니다. ReservedWord 는 IdentifierName 의 열거된 부분집합입니다. 구문 문법은 Identifier 를 ReservedWord 가 아닌 IdentifierName 으로 정의합니다. 유니코드 식별자 문법은 유니코드 표준에서 명시한 문자 프로퍼티를 기반으로 합니다. 최신 버전의 유니코드 표준에서 지정된 범주에 속하는 유니코드 코드 포인트는 모든 적합한 ECMAScript 구현체에서 해당 범주에 속하는 것으로 취급해야 합니다. ECMAScript 구현체는 이후 버전의 유니코드 표준에서 정의된 식별자 코드 포인트를 인식할 수 있습니다.
참고 1
이 표준은 특정 코드 포인트의 추가를 명시합니다. U+0024 (DOLLAR SIGN) 및 U+005F (LOW LINE)은 IdentifierName 의 어느 위치에서든 허용됩니다.
구문
PrivateIdentifier ::
#
IdentifierName
IdentifierName ::
IdentifierStart
IdentifierName
IdentifierPart
IdentifierStart ::
IdentifierStartChar
\
UnicodeEscapeSequence
IdentifierPart ::
IdentifierPartChar
\
UnicodeEscapeSequence
IdentifierStartChar ::
UnicodeIDStart
$
_
IdentifierPartChar ::
UnicodeIDContinue
$
AsciiLetter :: one of a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
UnicodeIDStart ::
any Unicode code point with the Unicode property “ID_Start”
UnicodeIDContinue ::
any Unicode code point with the Unicode property “ID_Continue”
비단말 기호 UnicodeEscapeSequence 의 정의는 12.9.4 에 제시되어 있습니다.
참고 2
참고 3
유니코드 프로퍼티 “ID_Start” 및 “ID_Continue”을 갖는 코드 포인트 집합에는 각각 유니코드 프로퍼티 “Other_ID_Start” 및 “Other_ID_Continue”을 갖는 코드 포인트가 포함됩니다.
12.7.1 식별자 이름
IdentifierName 에서는 유니코드 이스케이프 시퀀스가 허용되며, 해당 시퀀스는 UnicodeEscapeSequence 의 IdentifierCodePoint 와 같은 하나의 유니코드 코드 포인트에 기여합니다. UnicodeEscapeSequence 앞의 \는 어떤 코드 포인트에도 기여하지 않습니다. UnicodeEscapeSequence 를 사용하여 그렇지 않았다면 유효하지 않았을 코드 포인트를 IdentifierName 에 기여할 수는 없습니다. 다시 말해 \ UnicodeEscapeSequence 시퀀스를 그것이 기여하는 SourceCharacter 로 교체하더라도 그 결과는 원래 IdentifierName 과 정확히 동일한 SourceCharacter 요소 시퀀스를 갖는 유효한 IdentifierName 이어야 합니다. 이 명세에서 IdentifierName 을 해석할 때는 특정 코드 포인트를 기여하는 데 이스케이프 시퀀스가 사용되었는지 여부와 관계없이 실제 코드 포인트를 기반으로 합니다.
유니코드 표준에 따라 정규적으로 동등한 두 IdentifierName 이라도 각 UnicodeEscapeSequence 를 교체한 후 정확히 동일한 코드 포인트 시퀀스로 표현되지 않으면 같지 않습니다 .
12.7.1.1 Static Semantics: 조기 오류
IdentifierStart ::
\
UnicodeEscapeSequence
IdentifierPart ::
\
UnicodeEscapeSequence
12.7.1.2 Static Semantics: IdentifierCodePoints
구문 지향 연산 IdentifierCodePoints. 인수 없음. 반환값: 리스트 (요소: 코드 포인트). 다음 생성 규칙별로 정의된다.
IdentifierName :: IdentifierStart
codePoint 를 IdentifierStart 의 IdentifierCodePoint 로 둡니다.« codePoint »를 반환합니다.
IdentifierName ::
IdentifierName
IdentifierPart
codePoints 를 파생된 IdentifierName 의 IdentifierCodePoints 로 둡니다.codePoint 를 IdentifierPart 의 IdentifierCodePoint 로 둡니다.codePoints 와 « codePoint »의 목록 연결 을 반환합니다.
12.7.1.3 Static Semantics: IdentifierCodePoint
구문 지향 연산 IdentifierCodePoint. 인수 없음. 반환값: 코드 포인트. 다음 생성 규칙별로 정의된다.
IdentifierStart :: IdentifierStartChar
IdentifierStartChar 와 일치하는 코드 포인트를 반환합니다.
IdentifierPart :: IdentifierPartChar
IdentifierPartChar 와 일치하는 코드 포인트를 반환합니다.
UnicodeEscapeSequence ::
u
Hex4Digits
숫자 값이 Hex4Digits 의 MV인 코드 포인트를 반환합니다.
UnicodeEscapeSequence ::
u{
CodePoint
}
숫자 값이 CodePoint 의 MV인 코드 포인트를 반환합니다.
12.7.2 키워드와 예약어
키워드 는 IdentifierName 과 일치하면서 구문적 용도도 갖는 토큰입니다. 즉, 일부 구문 생성 규칙에서 fixed width 글꼴의 리터럴로 나타납니다. ECMAScript의 키워드에는 if, while, async, await 등이 있습니다.
예약어 는 식별자로 사용할 수 없는 IdentifierName 입니다. 많은 키워드가 예약어이지만 그렇지 않은 키워드도 있으며, 특정 문맥에서만 예약되는 키워드도 있습니다. if와 while은 예약어입니다. await는 async 함수와 모듈 안에서만 예약됩니다. async는 예약되지 않으며 변수 이름이나 문 레이블로 제한 없이 사용할 수 있습니다.
이 명세는 문법 생성 규칙과 조기 오류 규칙 을 조합하여 어떤 이름이 유효한 식별자이고 어떤 이름이 예약어인지 명시합니다. 아래 ReservedWord 목록의 모든 토큰은 await와 yield를 제외하면 무조건 예약됩니다. await와 yield의 예외는 매개변수화된 구문 생성 규칙을 사용하여 13.1 에 명시되어 있습니다. 마지막으로 여러 조기 오류 규칙 이 유효한 식별자의 집합을 제한합니다. 13.1.1 , 14.3.1.1 , 14.7.5.1 및 15.7.1 를 참조하시기 바랍니다. 요약하면 식별자 이름에는 다음 다섯 범주가 있습니다:
Math, window, toString, _처럼 항상 식별자로 허용되며 키워드는 아닌 이름;
아래에 나열된 ReservedWord 중 await와 yield를 제외하고 절대로 식별자로 허용되지 않는 이름;
문맥에 따라 식별자로 허용되는 이름, 즉 await와 yield;
엄격 모드 코드 에서 문맥에 따라 식별자로 허용되지 않는 이름: let, static, implements, interface, package, private, protected, public;
항상 식별자로 허용되지만 Identifier 가 허용되지 않는 특정 구문 생성 규칙의 위치에서 키워드로도 나타나는 이름: as, async, from, get, meta, of, set, target.
조건부 키워드 또는 문맥적 키워드 라는 용어는 마지막 세 범주에 속하여 일부 문맥에서는 식별자로, 다른 문맥에서는 키워드로 사용할 수 있는 키워드를 가리키는 데 사용되기도 합니다.
구문
ReservedWord :: one of await break case catch class const continue debugger default delete do else enum export extends false finally for function if import in instanceof new null return super switch this throw true try typeof var void while with yield
참고 1
5.1.5 에 따라 문법의 키워드는 특정 SourceCharacter 요소의 리터럴 시퀀스와 일치합니다. 키워드 안의 코드 포인트를 \ UnicodeEscapeSequence 로 표현할 수 없습니다.
IdentifierName 에는 \ UnicodeEscapeSequence 가 포함될 수 있지만 els\u{65}라고 작성하여 “else”라는 이름의 변수를 선언할 수는 없습니다. 13.1.1 의 조기 오류 규칙 은 예약어와 동일한 StringValue 를 갖는 식별자를 배제합니다.
참고 2
enum은 현재 이 명세에서 키워드로 사용되지 않습니다. 이는 향후 언어 확장에서 키워드로 사용하기 위해 따로 예약해 둔 미래 예약어 입니다.
마찬가지로 implements, interface, package, private, protected, public은 엄격 모드 코드 에서 미래 예약어입니다.
참고 3
arguments와 eval이라는 이름은 키워드가 아니지만 엄격 모드 코드 에서는 일부 제한을 받습니다. 13.1.1 , 8.6.4 , 15.2.1 , 15.5.1 , 15.6.1 및 15.8.1 를 참조하시기 바랍니다.
12.8 구두점
구문
Punctuator ::
OptionalChainingPunctuator
OtherPunctuator
OptionalChainingPunctuator ::
?.
[lookahead ∉ DecimalDigit ]
OtherPunctuator :: one of { ( ) [ ] . ... ; , < > <= >= == != === !== + - * % ** ++ -- << >> >>> & | ^ ! ~ && || ?? ? : = += -= *= %= **= <<= >>= >>>= &= |= ^= &&= ||= ??= =>
DivPunctuator ::
/
/=
RightBracePunctuator ::
}
12.9 리터럴
12.9.1 Null 리터럴
구문
NullLiteral ::
null
12.9.2 Boolean 리터럴
구문
BooleanLiteral ::
true
false
12.9.3 숫자 리터럴
구문
NumericLiteralSeparator ::
_
NumericLiteral ::
DecimalLiteral
DecimalBigIntegerLiteral
NonDecimalIntegerLiteral [+Sep]
NonDecimalIntegerLiteral [+Sep]
BigIntLiteralSuffix
LegacyOctalIntegerLiteral
DecimalBigIntegerLiteral ::
0
BigIntLiteralSuffix
NonZeroDigit
DecimalDigits [+Sep] opt
BigIntLiteralSuffix
NonZeroDigit
NumericLiteralSeparator
DecimalDigits [+Sep]
BigIntLiteralSuffix
NonDecimalIntegerLiteral [Sep] ::
BinaryIntegerLiteral [?Sep]
OctalIntegerLiteral [?Sep]
HexIntegerLiteral [?Sep]
BigIntLiteralSuffix ::
n
DecimalLiteral ::
DecimalIntegerLiteral
.
DecimalDigits [+Sep] opt
ExponentPart [+Sep] opt
.
DecimalDigits [+Sep]
ExponentPart [+Sep] opt
DecimalIntegerLiteral
ExponentPart [+Sep] opt
DecimalIntegerLiteral ::
DecimalDigit
NonZeroDigit
NumericLiteralSeparator opt
DecimalDigits [+Sep]
NonOctalDecimalIntegerLiteral
DecimalDigits [Sep] ::
DecimalDigit
DecimalDigits [?Sep]
DecimalDigit
[+Sep]
DecimalDigits [+Sep]
NumericLiteralSeparator
DecimalDigit
DecimalDigit :: one of 0 1 2 3 4 5 6 7 8 9
NonZeroDigit :: one of 1 2 3 4 5 6 7 8 9
ExponentPart [Sep] ::
ExponentIndicator
SignedInteger [?Sep]
ExponentIndicator :: one of e E
SignedInteger [Sep] ::
DecimalDigits [?Sep]
+
DecimalDigits [?Sep]
-
DecimalDigits [?Sep]
BinaryIntegerLiteral [Sep] ::
0b
BinaryDigits [?Sep]
0B
BinaryDigits [?Sep]
BinaryDigits [Sep] ::
BinaryDigit
BinaryDigits [?Sep]
BinaryDigit
[+Sep]
BinaryDigits [+Sep]
NumericLiteralSeparator
BinaryDigit
BinaryDigit :: one of 0 1
OctalIntegerLiteral [Sep] ::
0o
OctalDigits [?Sep]
0O
OctalDigits [?Sep]
OctalDigits [Sep] ::
OctalDigit
OctalDigits [?Sep]
OctalDigit
[+Sep]
OctalDigits [+Sep]
NumericLiteralSeparator
OctalDigit
LegacyOctalIntegerLiteral ::
0
OctalDigit
LegacyOctalIntegerLiteral
OctalDigit
NonOctalDecimalIntegerLiteral ::
0
LegacyOctalLikeDecimalDigits opt
NonOctalDigit
NonOctalDecimalIntegerLiteral
DecimalDigit
LegacyOctalLikeDecimalDigits ::
OctalDigit
LegacyOctalLikeDecimalDigits
OctalDigit
OctalDigit :: one of 0 1 2 3 4 5 6 7
NonOctalDigit :: one of 8 9
HexIntegerLiteral [Sep] ::
0x
HexDigits [?Sep]
0X
HexDigits [?Sep]
HexDigits [Sep] ::
HexDigit
HexDigits [?Sep]
HexDigit
[+Sep]
HexDigits [+Sep]
NumericLiteralSeparator
HexDigit
HexDigit :: one of 0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F
NumericLiteral 바로 뒤에 오는 SourceCharacter 는 IdentifierStart 또는 DecimalDigit 이어서는 안 됩니다.
참고
예를 들어 3in은 오류이며 두 입력 요소 3과 in이 아닙니다.
12.9.3.1 Static Semantics: 조기 오류
NumericLiteral :: LegacyOctalIntegerLiteral
DecimalIntegerLiteral :: NonOctalDecimalIntegerLiteral
IsStrict (this production)이 true 이면 Syntax Error입니다.
참고 비엄격 코드 에서 이 구문은 Legacy입니다.
12.9.3.2 Static Semantics: MV
숫자 리터럴은 Number 타입 또는 BigInt 타입 의 값을 나타냅니다.
12.9.3.3 Static Semantics: NumericValue
구문 지향 연산 NumericValue. 인수 없음. 반환값: (Number 또는 BigInt). 다음 생성 규칙별로 정의된다.
NumericLiteral :: DecimalLiteral
RoundMVResult (DecimalLiteral 의 MV)를 반환합니다.
NumericLiteral :: NonDecimalIntegerLiteral
𝔽 (NonDecimalIntegerLiteral 의 MV)를 반환합니다.
NumericLiteral :: LegacyOctalIntegerLiteral
𝔽 (LegacyOctalIntegerLiteral 의 MV)를 반환합니다.
NumericLiteral ::
NonDecimalIntegerLiteral
BigIntLiteralSuffix
NonDecimalIntegerLiteral 의 MV에 대한 BigInt 값 을 반환합니다.
DecimalBigIntegerLiteral ::
0
BigIntLiteralSuffix
0 ℤ 을 반환합니다.
DecimalBigIntegerLiteral ::
NonZeroDigit
BigIntLiteralSuffix
NonZeroDigit 의 MV에 대한 BigInt 값 을 반환합니다.
DecimalBigIntegerLiteral ::
NonZeroDigit
DecimalDigits
BigIntLiteralSuffix
NonZeroDigit
NumericLiteralSeparator
DecimalDigits
BigIntLiteralSuffix
n 을 NumericLiteralSeparator 의 모든 출현을 제외한 DecimalDigits 의 코드 포인트 수로 설정합니다.mv 를 (NonZeroDigit 의 MV × 10n ) + DecimalDigits 의 MV로 설정합니다.ℤ (mv )를 반환합니다.
12.9.4 String 리터럴
참고 1
문자열 리터럴은 작은따옴표 또는 큰따옴표로 둘러싸인 0개 이상의 유니코드 코드 포인트입니다. 유니코드 코드 포인트는 이스케이프 시퀀스로 나타낼 수도 있습니다. 닫는 따옴표 코드 포인트, U+005C (REVERSE SOLIDUS), U+000D (CARRIAGE RETURN), U+000A (LINE FEED)를 제외한 모든 코드 포인트는 문자열 리터럴에 그대로 나타날 수 있습니다. 모든 코드 포인트는 이스케이프 시퀀스의 형태로 나타날 수 있습니다. 문자열 리터럴은 ECMAScript String 값으로 평가됩니다. 이러한 String 값을 생성할 때 유니코드 코드 포인트는 11.1.1 에 정의된 대로 UTF-16으로 인코딩됩니다. 기본 다국어 평면에 속하는 코드 포인트는 문자열의 하나의 코드 단위 요소로 인코딩됩니다. 그 밖의 모든 코드 포인트는 문자열의 두 코드 단위 요소로 인코딩됩니다.
구문
StringLiteral ::
"
DoubleStringCharacters opt
"
'
SingleStringCharacters opt
'
DoubleStringCharacters ::
DoubleStringCharacter
DoubleStringCharacters opt
SingleStringCharacters ::
SingleStringCharacter
SingleStringCharacters opt
DoubleStringCharacter ::
SourceCharacter but not one of " or \ or LineTerminator
<LS>
<PS>
\
EscapeSequence
LineContinuation
SingleStringCharacter ::
SourceCharacter but not one of ' or \ or LineTerminator
<LS>
<PS>
\
EscapeSequence
LineContinuation
LineContinuation ::
\
LineTerminatorSequence
EscapeSequence ::
CharacterEscapeSequence
0
[lookahead ∉ DecimalDigit ]
LegacyOctalEscapeSequence
NonOctalDecimalEscapeSequence
HexEscapeSequence
UnicodeEscapeSequence
CharacterEscapeSequence ::
SingleEscapeCharacter
NonEscapeCharacter
SingleEscapeCharacter :: one of ' " \ b f n r t v
NonEscapeCharacter ::
SourceCharacter but not one of EscapeCharacter or LineTerminator
EscapeCharacter ::
SingleEscapeCharacter
DecimalDigit
x
u
LegacyOctalEscapeSequence ::
0
[lookahead ∈ { 8 , 9 }]
NonZeroOctalDigit
[lookahead ∉ OctalDigit ]
ZeroToThree
OctalDigit
[lookahead ∉ OctalDigit ]
FourToSeven
OctalDigit
ZeroToThree
OctalDigit
OctalDigit
NonZeroOctalDigit ::
OctalDigit but not 0
ZeroToThree :: one of 0 1 2 3
FourToSeven :: one of 4 5 6 7
NonOctalDecimalEscapeSequence :: one of 8 9
HexEscapeSequence ::
x
HexDigit
HexDigit
UnicodeEscapeSequence ::
u
Hex4Digits
u{
CodePoint
}
Hex4Digits ::
HexDigit
HexDigit
HexDigit
HexDigit
비단말 기호 HexDigit 의 정의는 12.9.3 에 제시되어 있습니다. SourceCharacter 는 11.1 에 정의되어 있습니다.
참고 2
<LF> 및 <CR>은 빈 코드 포인트 시퀀스를 생성하기 위한 LineContinuation 의 일부인 경우를 제외하면 문자열 리터럴에 나타날 수 없습니다. 문자열 리터럴의 String 값에 이들을 포함하는 올바른 방법은 \n 또는 \u000A와 같은 이스케이프 시퀀스를 사용하는 것입니다.
12.9.4.1 Static Semantics: 조기 오류
EscapeSequence ::
LegacyOctalEscapeSequence
NonOctalDecimalEscapeSequence
IsStrict (this production)이 true 이면 Syntax Error입니다.
참고 1 비엄격 코드 에서 이 구문은 Legacy입니다.
참고 2
문자열 리터럴이 둘러싸는 코드를 엄격 모드 로 만드는 Use Strict 지시문 보다 앞에 나타날 수 있으며, 구현체는 이러한 리터럴에 위 규칙을 적용하도록 주의해야 합니다. 예를 들어 다음 소스 텍스트에는 Syntax Error가 포함되어 있습니다:
function invalid ( ) { "\7" ; "use strict" ; }
12.9.4.2 Static Semantics: SV
구문 지향 연산 SV. 인수 없음. 반환값: String.
문자열 리터럴은 String 타입 의 값을 나타냅니다. SV는 문자열 리터럴의 여러 부분에 재귀적으로 적용하여 문자열 리터럴의 String 값을 생성합니다. 이 과정의 일부로 문자열 리터럴 안의 일부 유니코드 코드 포인트는 아래 또는 12.9.3 에 설명된 대로 수학적 값 을 갖는 것으로 해석됩니다.
표 33: String 단일 문자 이스케이프 시퀀스
이스케이프 시퀀스
코드 단위 값
유니코드 문자 이름
기호
\b
0x0008
BACKSPACE
<BS>
\t
0x0009
CHARACTER TABULATION
<HT>
\n
0x000A
LINE FEED (LF)
<LF>
\v
0x000B
LINE TABULATION
<VT>
\f
0x000C
FORM FEED (FF)
<FF>
\r
0x000D
CARRIAGE RETURN (CR)
<CR>
\"
0x0022
QUOTATION MARK
"
\'
0x0027
APOSTROPHE
'
\\
0x005C
REVERSE SOLIDUS
\
12.9.4.3 Static Semantics: MV
12.9.5 정규 표현식 리터럴
참고 1
정규 표현식 리터럴은 리터럴을 평가할 때마다 RegExp 객체(22.2 참조)로 변환되는 입력 요소입니다. 프로그램 안의 두 정규 표현식 리터럴은 두 리터럴의 내용이 동일하더라도 서로 ===로 비교했을 때 절대로 같은 것으로 평가되지 않는 정규 표현식 객체가 됩니다. RegExp 객체는 런타임에 new RegExp를 사용하거나 RegExp 생성자 를 함수로 호출하여 생성할 수도 있습니다(22.2.4 참조).
아래 생성 규칙은 정규 표현식 리터럴의 구문을 설명하며 입력 요소 스캐너가 정규 표현식 리터럴의 끝을 찾는 데 사용합니다. 이후 RegularExpressionBody 와 RegularExpressionFlags 를 구성하는 소스 텍스트는 더 엄격한 ECMAScript 정규 표현식 문법(22.2.1 )을 사용하여 다시 파싱됩니다.
구현체는 22.2.1 에 정의된 ECMAScript 정규 표현식 문법을 확장할 수 있지만 아래 정의된 RegularExpressionBody 및 RegularExpressionFlags 생성 규칙이나 이 생성 규칙에서 사용하는 생성 규칙을 확장해서는 안 됩니다.
구문
RegularExpressionLiteral ::
/
RegularExpressionBody
/
RegularExpressionFlags
RegularExpressionBody ::
RegularExpressionFirstChar
RegularExpressionChars
RegularExpressionChars ::
[empty]
RegularExpressionChars
RegularExpressionChar
RegularExpressionFirstChar ::
RegularExpressionNonTerminator but not one of * or \ or / or [
RegularExpressionBackslashSequence
RegularExpressionClass
RegularExpressionChar ::
RegularExpressionNonTerminator but not one of \ or / or [
RegularExpressionBackslashSequence
RegularExpressionClass
RegularExpressionBackslashSequence ::
\
RegularExpressionNonTerminator
RegularExpressionNonTerminator ::
SourceCharacter but not LineTerminator
RegularExpressionClass ::
[
RegularExpressionClassChars
]
RegularExpressionClassChars ::
[empty]
RegularExpressionClassChars
RegularExpressionClassChar
RegularExpressionClassChar ::
RegularExpressionNonTerminator but not one of ] or \
RegularExpressionBackslashSequence
RegularExpressionFlags ::
[empty]
RegularExpressionFlags
IdentifierPartChar
참고 2
정규 표현식 리터럴은 비어 있을 수 없습니다. 빈 정규 표현식 리터럴을 나타내는 대신 코드 단위 시퀀스 //는 한 줄 주석을 시작합니다. 빈 정규 표현식을 지정하려면 /(?:)/을 사용하시기 바랍니다.
12.9.5.1 Static Semantics: BodyText
구문 지향 연산 BodyText. 인수 없음. 반환값: 소스 텍스트. 다음 생성 규칙별로 정의된다.
RegularExpressionLiteral ::
/
RegularExpressionBody
/
RegularExpressionFlags
RegularExpressionBody 로 인식된 소스 텍스트를 반환합니다.
12.9.5.2 Static Semantics: FlagText
구문 지향 연산 FlagText. 인수 없음. 반환값: 소스 텍스트. 다음 생성 규칙별로 정의된다.
RegularExpressionLiteral ::
/
RegularExpressionBody
/
RegularExpressionFlags
RegularExpressionFlags 로 인식된 소스 텍스트를 반환합니다.
12.9.6 템플릿 리터럴 어휘 구성 요소
구문
Template ::
NoSubstitutionTemplate
TemplateHead
NoSubstitutionTemplate ::
`
TemplateCharacters opt
`
TemplateHead ::
`
TemplateCharacters opt
${
TemplateSubstitutionTail ::
TemplateMiddle
TemplateTail
TemplateMiddle ::
}
TemplateCharacters opt
${
TemplateTail ::
}
TemplateCharacters opt
`
TemplateCharacters ::
TemplateCharacter
TemplateCharacters opt
TemplateCharacter ::
$
[lookahead ≠ { ]
\
TemplateEscapeSequence
\
NotEscapeSequence
LineContinuation
LineTerminatorSequence
SourceCharacter but not one of ` or \ or $ or LineTerminator
TemplateEscapeSequence ::
CharacterEscapeSequence
0
[lookahead ∉ DecimalDigit ]
HexEscapeSequence
UnicodeEscapeSequence
NotEscapeSequence ::
0
DecimalDigit
DecimalDigit but not 0
x
[lookahead ∉ HexDigit ]
x
HexDigit
[lookahead ∉ HexDigit ]
u
[lookahead ∉ HexDigit ]
[lookahead ≠ { ]
u
HexDigit
[lookahead ∉ HexDigit ]
u
HexDigit
HexDigit
[lookahead ∉ HexDigit ]
u
HexDigit
HexDigit
HexDigit
[lookahead ∉ HexDigit ]
u
{
[lookahead ∉ HexDigit ]
u
{
NotCodePoint
[lookahead ∉ HexDigit ]
u
{
CodePoint
[lookahead ∉ HexDigit ]
[lookahead ≠ } ]
NotCodePoint ::
HexDigits [~Sep]
but only if the MV of HexDigits > 0x10FFFF
CodePoint ::
HexDigits [~Sep]
but only if the MV of HexDigits ≤ 0x10FFFF
참고
12.9.6.1 Static Semantics: TV
구문 지향 연산 TV. 인수 없음. 반환값: (String 또는 undefined ). 템플릿 리터럴 구성 요소는 TV에 의해 String 타입 의 값으로 해석됩니다. TV는 템플릿 객체의 인덱스 구성 요소(일반적으로 템플릿 값이라고 부릅니다)를 구성하는 데 사용됩니다. TV에서는 이스케이프 시퀀스를 해당 이스케이프 시퀀스가 나타내는 유니코드 코드 포인트의 UTF-16 코드 단위로 교체합니다.
12.9.6.2 Static Semantics: TRV
구문 지향 연산 TRV. 인수 없음. 반환값: String. 템플릿 리터럴 구성 요소는 TRV에 의해 String 타입 의 값으로 해석됩니다. TRV는 템플릿 객체의 원시 구성 요소(일반적으로 템플릿 원시 값이라고 부릅니다)를 구성하는 데 사용됩니다. TRV는 TV 와 유사하지만 TRV에서는 이스케이프 시퀀스를 리터럴에 나타난 그대로 해석한다는 차이가 있습니다.
NoSubstitutionTemplate ::
`
`
의 TRV는 빈 String입니다.
TemplateHead ::
`
${
의 TRV는 빈 String입니다.
TemplateMiddle ::
}
${
의 TRV는 빈 String입니다.
TemplateTail ::
}
`
의 TRV는 빈 String입니다.
TemplateCharacters ::
TemplateCharacter
TemplateCharacters
의 TRV는 TemplateCharacter 의 TRV와 TemplateCharacters 의 TRV의 문자열 연결 입니다.
TemplateCharacter :: SourceCharacter but not one of ` or \ or $ or LineTerminator
의 TRV는 SourceCharacter 와 일치하는 코드 포인트에 UTF16EncodeCodePoint 를 수행한 결과입니다.
TemplateCharacter :: $
의 TRV는 코드 단위 0x0024 (DOLLAR SIGN)로 구성된 String 값입니다.
TemplateCharacter ::
\
TemplateEscapeSequence
의 TRV는 코드 단위 0x005C (REVERSE SOLIDUS)와 TemplateEscapeSequence 의 TRV의 문자열 연결 입니다.
TemplateCharacter ::
\
NotEscapeSequence
의 TRV는 코드 단위 0x005C (REVERSE SOLIDUS)와 NotEscapeSequence 의 TRV의 문자열 연결 입니다.
TemplateEscapeSequence :: 0
의 TRV는 코드 단위 0x0030 (DIGIT ZERO)으로 구성된 String 값입니다.
NotEscapeSequence ::
0
DecimalDigit
의 TRV는 코드 단위 0x0030 (DIGIT ZERO)과 DecimalDigit 의 TRV의 문자열 연결 입니다.
NotEscapeSequence ::
x
[lookahead ∉ HexDigit ]
의 TRV는 코드 단위 0x0078 (LATIN SMALL LETTER X)로 구성된 String 값입니다.
NotEscapeSequence ::
x
HexDigit
[lookahead ∉ HexDigit ]
의 TRV는 코드 단위 0x0078 (LATIN SMALL LETTER X)과 HexDigit 의 TRV의 문자열 연결 입니다.
NotEscapeSequence ::
u
[lookahead ∉ HexDigit ]
[lookahead ≠ { ]
의 TRV는 코드 단위 0x0075 (LATIN SMALL LETTER U)로 구성된 String 값입니다.
NotEscapeSequence ::
u
HexDigit
[lookahead ∉ HexDigit ]
의 TRV는 코드 단위 0x0075 (LATIN SMALL LETTER U)와 HexDigit 의 TRV의 문자열 연결 입니다.
NotEscapeSequence ::
u
HexDigit
HexDigit
[lookahead ∉ HexDigit ]
의 TRV는 코드 단위 0x0075 (LATIN SMALL LETTER U), 첫 번째 HexDigit 의 TRV 및 두 번째 HexDigit 의 TRV의 문자열 연결 입니다.
NotEscapeSequence ::
u
HexDigit
HexDigit
HexDigit
[lookahead ∉ HexDigit ]
의 TRV는 코드 단위 0x0075 (LATIN SMALL LETTER U), 첫 번째 HexDigit 의 TRV, 두 번째 HexDigit 의 TRV 및 세 번째 HexDigit 의 TRV의 문자열 연결 입니다.
NotEscapeSequence ::
u
{
[lookahead ∉ HexDigit ]
의 TRV는 코드 단위 0x0075 (LATIN SMALL LETTER U)와 코드 단위 0x007B (LEFT CURLY BRACKET)의 문자열 연결 입니다.
NotEscapeSequence ::
u
{
NotCodePoint
[lookahead ∉ HexDigit ]
의 TRV는 코드 단위 0x0075 (LATIN SMALL LETTER U), 코드 단위 0x007B (LEFT CURLY BRACKET) 및 NotCodePoint 의 TRV의 문자열 연결 입니다.
NotEscapeSequence ::
u
{
CodePoint
[lookahead ∉ HexDigit ]
[lookahead ≠ } ]
의 TRV는 코드 단위 0x0075 (LATIN SMALL LETTER U), 코드 단위 0x007B (LEFT CURLY BRACKET) 및 CodePoint 의 TRV의 문자열 연결 입니다.
DecimalDigit :: one of 0 1 2 3 4 5 6 7 8 9
의 TRV는 이 생성 규칙과 일치하는 하나의 코드 포인트에 UTF16EncodeCodePoint 를 수행한 결과입니다.
CharacterEscapeSequence :: NonEscapeCharacter
의 TRV는 NonEscapeCharacter 의 SV 입니다.
SingleEscapeCharacter :: one of ' " \ b f n r t v
의 TRV는 이 생성 규칙과 일치하는 하나의 코드 포인트에 UTF16EncodeCodePoint 를 수행한 결과입니다.
HexEscapeSequence ::
x
HexDigit
HexDigit
의 TRV는 코드 단위 0x0078 (LATIN SMALL LETTER X), 첫 번째 HexDigit 의 TRV 및 두 번째 HexDigit 의 TRV의 문자열 연결 입니다.
UnicodeEscapeSequence ::
u
Hex4Digits
의 TRV는 코드 단위 0x0075 (LATIN SMALL LETTER U)와 Hex4Digits 의 TRV의 문자열 연결 입니다.
UnicodeEscapeSequence ::
u{
CodePoint
}
의 TRV는 코드 단위 0x0075 (LATIN SMALL LETTER U), 코드 단위 0x007B (LEFT CURLY BRACKET), CodePoint 의 TRV 및 코드 단위 0x007D (RIGHT CURLY BRACKET)의 문자열 연결 입니다.
Hex4Digits ::
HexDigit
HexDigit
HexDigit
HexDigit
의 TRV는 첫 번째 HexDigit 의 TRV, 두 번째 HexDigit 의 TRV, 세 번째 HexDigit 의 TRV 및 네 번째 HexDigit 의 TRV의 문자열 연결 입니다.
HexDigits ::
HexDigits
HexDigit
의 TRV는 HexDigits 의 TRV와 HexDigit 의 TRV의 문자열 연결 입니다.
HexDigit :: one of 0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F
의 TRV는 이 생성 규칙과 일치하는 하나의 코드 포인트에 UTF16EncodeCodePoint 를 수행한 결과입니다.
LineContinuation ::
\
LineTerminatorSequence
의 TRV는 코드 단위 0x005C (REVERSE SOLIDUS)와 LineTerminatorSequence 의 TRV의 문자열 연결 입니다.
LineTerminatorSequence :: <LF>
의 TRV는 코드 단위 0x000A (LINE FEED)로 구성된 String 값입니다.
LineTerminatorSequence :: <CR>
의 TRV는 코드 단위 0x000A (LINE FEED)로 구성된 String 값입니다.
LineTerminatorSequence :: <LS>
의 TRV는 코드 단위 0x2028 (LINE SEPARATOR)로 구성된 String 값입니다.
LineTerminatorSequence :: <PS>
의 TRV는 코드 단위 0x2029 (PARAGRAPH SEPARATOR)로 구성된 String 값입니다.
LineTerminatorSequence ::
<CR>
<LF>
의 TRV는 코드 단위 0x000A (LINE FEED)로 구성된 String 값입니다.
참고
TV 는 LineContinuation 의 코드 단위를 제외하지만 TRV는 이를 포함합니다. <CR><LF> 및 <CR> LineTerminatorSequence 는 TV 와 TRV 모두에서 <LF>로 정규화됩니다. <CR> 또는 <CR><LF> 시퀀스를 포함하려면 명시적인 TemplateEscapeSequence 가 필요합니다.
12.10 자동 세미콜론 삽입
대부분의 ECMAScript 문과 선언은 세미콜론으로 끝나야 합니다. 이러한 세미콜론은 항상 소스 텍스트에 명시적으로 나타날 수 있습니다. 그러나 편의를 위해 특정 상황에서는 소스 텍스트에서 이러한 세미콜론을 생략할 수 있습니다. 이러한 상황은 해당 위치에서 소스 코드 토큰 스트림에 세미콜론이 자동으로 삽입된다고 설명합니다.
12.10.1 자동 세미콜론 삽입 규칙
다음 규칙에서 “토큰”은 12 절에 설명된 현재 어휘 목표 기호 를 사용하여 결정된 실제로 인식된 어휘 토큰을 의미합니다.
세미콜론 삽입에는 세 가지 기본 규칙이 있습니다:
소스 텍스트를 왼쪽에서 오른쪽으로 파싱하는 동안 문법의 어떤 생성 규칙에서도 허용되지 않는 토큰(문제 토큰 이라고 합니다)을 만났을 때 다음 조건 중 하나 이상이 참이면 문제 토큰 앞에 세미콜론이 자동으로 삽입됩니다:
문제 토큰과 이전 토큰 사이에 최소 하나의 LineTerminator 가 있습니다.
문제 토큰이 }입니다.
이전 토큰이 )이고 삽입된 세미콜론이 do-while 문(14.7.2 )을 종료하는 세미콜론으로 파싱됩니다.
소스 텍스트를 왼쪽에서 오른쪽으로 파싱하는 동안 입력 토큰 스트림의 끝에 도달했고 파서가 입력 토큰 스트림을 목표 비단말 기호의 단일 인스턴스로 파싱할 수 없으면 입력 스트림 끝에 세미콜론이 자동으로 삽입됩니다.
소스 텍스트를 왼쪽에서 오른쪽으로 파싱하는 동안 문법의 어떤 생성 규칙에서는 허용되는 토큰을 만났지만 해당 생성 규칙이 제한된 생성 규칙 이고 그 토큰이 제한된 생성 규칙 안에서 주석 “[no LineTerminator here]” 바로 뒤의 단말 또는 비단말에 대한 첫 번째 토큰이 되며(따라서 이러한 토큰을 제한 토큰이라고 합니다), 제한 토큰과 이전 토큰 사이에 최소 하나의 LineTerminator 가 있으면 제한 토큰 앞에 세미콜론이 자동으로 삽입됩니다.
그러나 앞의 규칙에는 이를 우선하는 추가 조건이 있습니다. 삽입된 세미콜론이 빈 문으로 파싱되거나 for 문의 헤더에 있는 두 세미콜론 중 하나가 되는 경우(14.7.4 참조)에는 세미콜론을 절대로 자동으로 삽입하지 않습니다.
참고
문법에서 제한된 생성 규칙은 다음뿐입니다:
UpdateExpression [Yield, Await] :
LeftHandSideExpression [?Yield, ?Await]
[no LineTerminator here]
++
LeftHandSideExpression [?Yield, ?Await]
[no LineTerminator here]
--
UsingDeclaration [In, Yield, Await] :
using
[no LineTerminator here]
BindingList [?In, ?Yield, ?Await, ~Pattern]
;
ContinueStatement [Yield, Await] :
continue
;
continue
[no LineTerminator here]
LabelIdentifier [?Yield, ?Await]
;
BreakStatement [Yield, Await] :
break
;
break
[no LineTerminator here]
LabelIdentifier [?Yield, ?Await]
;
ReturnStatement [Yield, Await] :
return
;
return
[no LineTerminator here]
Expression [+In, ?Yield, ?Await]
;
ThrowStatement [Yield, Await] :
throw
[no LineTerminator here]
Expression [+In, ?Yield, ?Await]
;
YieldExpression [In, Await] :
yield
yield
[no LineTerminator here]
AssignmentExpression [?In, +Yield, ?Await]
yield
[no LineTerminator here]
*
AssignmentExpression [?In, +Yield, ?Await]
ArrowFunction [In, Yield, Await] :
ArrowParameters [?Yield, ?Await]
[no LineTerminator here]
=>
ConciseBody [?In]
AsyncFunctionDeclaration [Yield, Await, Default] :
async
[no LineTerminator here]
function
BindingIdentifier [?Yield, ?Await]
(
FormalParameters [~Yield, +Await]
)
{
AsyncFunctionBody
}
[+Default]
async
[no LineTerminator here]
function
(
FormalParameters [~Yield, +Await]
)
{
AsyncFunctionBody
}
AsyncFunctionExpression :
async
[no LineTerminator here]
function
BindingIdentifier [~Yield, +Await] opt
(
FormalParameters [~Yield, +Await]
)
{
AsyncFunctionBody
}
AsyncMethod [Yield, Await] :
async
[no LineTerminator here]
ClassElementName [?Yield, ?Await]
(
UniqueFormalParameters [~Yield, +Await]
)
{
AsyncFunctionBody
}
AsyncGeneratorDeclaration [Yield, Await, Default] :
async
[no LineTerminator here]
function
*
BindingIdentifier [?Yield, ?Await]
(
FormalParameters [+Yield, +Await]
)
{
AsyncGeneratorBody
}
[+Default]
async
[no LineTerminator here]
function
*
(
FormalParameters [+Yield, +Await]
)
{
AsyncGeneratorBody
}
AsyncGeneratorExpression :
async
[no LineTerminator here]
function
*
BindingIdentifier [+Yield, +Await] opt
(
FormalParameters [+Yield, +Await]
)
{
AsyncGeneratorBody
}
AsyncGeneratorMethod [Yield, Await] :
async
[no LineTerminator here]
*
ClassElementName [?Yield, ?Await]
(
UniqueFormalParameters [+Yield, +Await]
)
{
AsyncGeneratorBody
}
AsyncArrowFunction [In, Yield, Await] :
async
[no LineTerminator here]
AsyncArrowBindingIdentifier [?Yield]
[no LineTerminator here]
=>
AsyncConciseBody [?In]
CoverCallExpressionAndAsyncArrowHead [?Yield, ?Await]
[no LineTerminator here]
=>
AsyncConciseBody [?In]
AsyncArrowHead :
async
[no LineTerminator here]
ArrowFormalParameters [~Yield, +Await]
이러한 제한된 생성 규칙의 실질적인 효과는 다음과 같습니다:
파서가 후위 연산자로 취급할 위치에서 ++ 또는 -- 토큰을 만났고 이전 토큰과 ++ 또는 -- 토큰 사이에 최소 하나의 LineTerminator 가 있으면 ++ 또는 -- 토큰 앞에 세미콜론이 자동으로 삽입됩니다.
using 토큰을 만났고 IdentifierName 토큰 전에 LineTerminator 를 만나면 using 토큰 뒤에 세미콜론이 자동으로 삽입됩니다.
continue, break, return, throw 또는 yield 토큰을 만났고 다음 토큰 전에 LineTerminator 를 만나면 continue, break, return, throw 또는 yield 토큰 뒤에 세미콜론이 자동으로 삽입됩니다.
화살표 함수의 매개변수 뒤에서 => 토큰 전에 LineTerminator 가 나타나면 세미콜론이 자동으로 삽입되고 구두점으로 인해 구문 오류가 발생합니다.
async 토큰 뒤에서 function, IdentifierName 또는 ( 토큰 전에 LineTerminator 가 나타나면 세미콜론이 자동으로 삽입되고 async 토큰은 뒤따르는 토큰과 같은 표현식 또는 클래스 요소의 일부로 취급되지 않습니다.
async 토큰 뒤에서 * 토큰 전에 LineTerminator 가 나타나면 세미콜론이 자동으로 삽입되고 구두점으로 인해 구문 오류가 발생합니다.
이에 따라 ECMAScript 프로그래머에게 실질적으로 권장되는 사항은 다음과 같습니다:
후위 ++ 또는 -- 연산자는 피연산자와 같은 줄에 두어야 합니다.
using 선언의 BindingList 는 using 토큰과 같은 줄에서 시작해야 합니다.
return 또는 throw 문의 Expression 이나 yield 표현식의 AssignmentExpression 은 return, throw 또는 yield 토큰과 같은 줄에서 시작해야 합니다.
break 또는 continue 문의 LabelIdentifier 는 break 또는 continue 토큰과 같은 줄에 있어야 합니다.
화살표 함수 매개변수의 끝과 =>는 같은 줄에 있어야 합니다.
비동기 함수 또는 메서드 앞의 async 토큰은 바로 뒤의 토큰과 같은 줄에 있어야 합니다.
12.10.2 자동 세미콜론 삽입의 예
이 절은 비규범적입니다.
다음 소스
{ 1 2 } 3
는 자동 세미콜론 삽입 규칙을 적용해도 ECMAScript 문법에서 유효한 문장이 아닙니다. 반면 다음 소스
{ 1
2 } 3
역시 유효한 ECMAScript 문장은 아니지만 자동 세미콜론 삽입에 의해 다음과 같이 변환됩니다:
{ 1
;2 ;} 3 ;
이는 유효한 ECMAScript 문장입니다.
다음 소스
for (a; b
)
는 유효한 ECMAScript 문장이 아니며 세미콜론이 for 문의 헤더에 필요하므로 자동 세미콜론 삽입에 의해 변경되지 않습니다. 자동 세미콜론 삽입은 for 문의 헤더에 있는 두 세미콜론 중 하나를 절대로 삽입하지 않습니다.
다음 소스
return
a + b
는 자동 세미콜론 삽입에 의해 다음과 같이 변환됩니다:
return ;
a + b;
참고 1
LineTerminator 가 표현식 a + b와 토큰 return을 분리하므로 표현식 a + b는 return 문이 반환할 값으로 취급되지 않습니다.
다음 소스
a = b
++c
는 자동 세미콜론 삽입에 의해 다음과 같이 변환됩니다:
a = b;
++c;
참고 2
b와 ++ 사이에 LineTerminator 가 있으므로 토큰 ++는 변수 b에 적용되는 후위 연산자로 취급되지 않습니다.
다음 소스
if (a > b)
else c = d
는 유효한 ECMAScript 문장이 아니며 해당 지점에서 문법의 어떤 생성 규칙도 적용되지 않지만 자동으로 삽입된 세미콜론이 빈 문으로 파싱되므로 else 토큰 앞에 자동 세미콜론을 삽입해도 변경되지 않습니다.
다음 소스
a = b + c
(d + e).print ()
는 자동 세미콜론 삽입에 의해 변환되지 않습니다 . 두 번째 줄을 시작하는 괄호로 둘러싸인 표현식을 함수 호출의 인수 목록으로 해석할 수 있기 때문입니다:
a = b + c (d + e).print ()
할당문이 여는 괄호로 시작해야 하는 경우 프로그래머는 자동 세미콜론 삽입에 의존하는 대신 이전 문의 끝에 명시적인 세미콜론을 작성하는 것이 좋습니다.
12.10.3 자동 세미콜론 삽입의 흥미로운 사례
이 절은 비규범적입니다.
ECMAScript 프로그램은 자동 세미콜론 삽입에 의존하여 세미콜론을 거의 사용하지 않는 스타일로 작성할 수 있습니다. 위에서 설명했듯이 모든 개행에 세미콜론이 삽입되는 것은 아니며 자동 세미콜론 삽입은 줄 종결자를 사이에 둔 여러 토큰에 의존할 수 있습니다.
ECMAScript에 새로운 구문 기능이 추가되면 추가 문법 생성 규칙이 도입될 수 있으며, 이로 인해 앞에서 자동 세미콜론 삽입에 의존하던 줄이 파싱될 때 다른 문법 생성 규칙으로 변경될 수 있습니다.
이 절에서는 앞에 있는 소스 텍스트에 따라 세미콜론이 삽입될 수도 있고 삽입되지 않을 수도 있는 위치의 자동 세미콜론 삽입을 흥미로운 사례로 간주합니다. 이 절의 나머지 부분에서는 이 버전의 ECMAScript에서 자동 세미콜론 삽입의 여러 흥미로운 사례를 설명합니다.
12.10.3.1 Statement List에서 자동 세미콜론 삽입의 흥미로운 사례
StatementList 에서는 많은 StatementListItem 이 세미콜론으로 끝나며, 이러한 세미콜론은 자동 세미콜론 삽입을 사용하여 생략할 수 있습니다. 위 규칙의 결과로 표현식을 끝내는 줄의 끝에서는 다음 줄이 다음 중 하나로 시작하면 세미콜론이 필요합니다:
12.10.3.2 자동 세미콜론 삽입과 “[no LineTerminator here]” 사례
이 절은 비규범적입니다.
ECMAScript에는 “[no LineTerminator here]”를 포함하는 문법 생성 규칙이 있습니다. 이러한 생성 규칙은 때때로 문법에서 선택적 피연산자를 제공하는 수단입니다. 이러한 위치에 LineTerminator 를 도입하면 선택적 피연산자가 없는 문법 생성 규칙을 사용하게 되어 소스 텍스트의 문법 생성 규칙이 변경됩니다.
이 절의 나머지 부분에서는 이 버전의 ECMAScript에서 “[no LineTerminator here]”를 사용하는 여러 생성 규칙을 설명합니다.
12.10.3.2.1 선택적 피연산자와 “[no LineTerminator here]”를 갖는 문법 생성 규칙 목록
13 ECMAScript 언어: 표현식
13.1 식별자
구문
IdentifierReference [Yield, Await] :
Identifier
[~Yield]
yield
[~Await]
await
BindingIdentifier [Yield, Await] :
Identifier
yield
await
LabelIdentifier [Yield, Await] :
Identifier
[~Yield]
yield
[~Await]
await
Identifier :
IdentifierName but not ReservedWord
참고
yield와 await는 다음과 같은 경우 자동 세미콜론 삽입을 금지하기 위해 문법에서는 BindingIdentifier 로 허용되고 아래의 정적 의미론 에서 금지됩니다.
let
await 0 ;
13.1.1 Static Semantics: 조기 오류
BindingIdentifier : Identifier
IdentifierReference : yield
BindingIdentifier : yield
LabelIdentifier : yield
IsStrict (this production)이 true 이면 Syntax Error입니다.
IdentifierReference : await
BindingIdentifier : await
LabelIdentifier : await
BindingIdentifier [Yield, Await] : yield
이 생성 규칙에 [Yield] 매개변수가 있으면 Syntax Error입니다.
BindingIdentifier [Yield, Await] : await
이 생성 규칙에 [Await] 매개변수가 있으면 Syntax Error입니다.
IdentifierReference [Yield, Await] : Identifier
BindingIdentifier [Yield, Await] : Identifier
LabelIdentifier [Yield, Await] : Identifier
Identifier : IdentifierName but not ReservedWord
참고
IdentifierName 의 StringValue 는 IdentifierName 안의 모든 유니코드 이스케이프 시퀀스를 정규화하므로, 이러한 이스케이프를 사용하여 코드 포인트 시퀀스가 ReservedWord 와 같은 Identifier 를 작성할 수 없습니다.
13.1.2 Static Semantics: StringValue
구문 지향 연산 StringValue. 인수 없음. 반환값: String. 다음 생성 규칙별로 정의된다.
IdentifierName ::
IdentifierStart
IdentifierName
IdentifierPart
nameUnescaped 를 IdentifierName 의 IdentifierCodePoints 로 둡니다.CodePointsToString (nameUnescaped )을 반환합니다.
IdentifierReference : yield
BindingIdentifier : yield
LabelIdentifier : yield
"yield" 를 반환합니다.
IdentifierReference : await
BindingIdentifier : await
LabelIdentifier : await
"await" 를 반환합니다.
Identifier : IdentifierName but not ReservedWord
IdentifierName 의 StringValue 를 반환합니다.
PrivateIdentifier ::
#
IdentifierName
0x0023 (NUMBER SIGN)과 IdentifierName 의 StringValue 의 문자열 연결 을 반환합니다.
ModuleExportName : StringLiteral
StringLiteral 의 SV 를 반환합니다.
13.1.3 Runtime Semantics: 평가
IdentifierReference : Identifier
? ResolveBinding (Identifier 의 StringValue )을 반환합니다.
IdentifierReference : yield
? ResolveBinding ("yield" )를 반환합니다.
IdentifierReference : await
? ResolveBinding ("await" )를 반환합니다.
참고 1
IdentifierReference 를 평가한 결과는 항상 Reference 타입의 값입니다.
참고 2
비엄격 코드 에서는 키워드 yield를 식별자로 사용할 수 있습니다. IdentifierReference 를 평가하면 yield가 Identifier 인 것처럼 그 바인딩을 해석합니다. 조기 오류 제한은 이러한 평가가 비엄격 코드 에서만 발생할 수 있도록 보장합니다.
13.2 기본 표현식
구문
PrimaryExpression [Yield, Await] :
this
IdentifierReference [?Yield, ?Await]
Literal
ArrayLiteral [?Yield, ?Await]
ObjectLiteral [?Yield, ?Await]
FunctionExpression
ClassExpression [?Yield, ?Await]
GeneratorExpression
AsyncFunctionExpression
AsyncGeneratorExpression
RegularExpressionLiteral
TemplateLiteral [?Yield, ?Await, ~Tagged]
CoverParenthesizedExpressionAndArrowParameterList [?Yield, ?Await]
CoverParenthesizedExpressionAndArrowParameterList [Yield, Await] :
(
)
(
Expression [+In, ?Yield, ?Await]
,opt
)
(
...
BindingIdentifier [?Yield, ?Await]
)
(
...
BindingPattern [?Yield, ?Await]
)
(
Expression [+In, ?Yield, ?Await]
,
...
BindingIdentifier [?Yield, ?Await]
)
(
Expression [+In, ?Yield, ?Await]
,
...
BindingPattern [?Yield, ?Await]
)
보충 구문
다음 생성 규칙의 인스턴스를 처리할 때
PrimaryExpression [Yield, Await] : CoverParenthesizedExpressionAndArrowParameterList [?Yield, ?Await]
CoverParenthesizedExpressionAndArrowParameterList 의 해석은 다음 문법을 사용하여 구체화됩니다:
ParenthesizedExpression [Yield, Await] :
(
Expression [+In, ?Yield, ?Await]
)
13.2.1 this 키워드
13.2.1.1 Runtime Semantics: 평가
PrimaryExpression : this
? ResolveThisBinding ()을 반환합니다.
13.2.2 식별자 참조
IdentifierReference 에 대해서는 13.1 를 참조하시기 바랍니다.
13.2.3 리터럴
구문
Literal :
NullLiteral
BooleanLiteral
NumericLiteral
StringLiteral
13.2.3.1 Runtime Semantics: 평가
Literal : NullLiteral
null 을 반환합니다.
Literal : BooleanLiteral
BooleanLiteral 이 토큰 false이면 false 를 반환합니다.BooleanLiteral 이 토큰 true이면 true 를 반환합니다.
Literal : NumericLiteral
12.9.3 에 정의된 NumericLiteral 의 NumericValue 를 반환합니다.
Literal : StringLiteral
12.9.4.2 에 정의된 StringLiteral 의 SV 를 반환합니다.
13.2.4 Array 이니셜라이저
참고
ArrayLiteral 은 대괄호 안에 배열 요소를 나타내는 0개 이상의 표현식 목록을 사용하여 Array의 초기화를 설명하는 표현식입니다. 요소가 반드시 리터럴일 필요는 없으며 배열 이니셜라이저가 평가될 때마다 평가됩니다.
Array 요소는 요소 목록의 시작, 중간 또는 끝에서 생략될 수 있습니다. 요소 목록에서 쉼표 앞에 AssignmentExpression 이 없는 경우(즉, 목록 시작의 쉼표 또는 다른 쉼표 뒤의 쉼표) 누락된 배열 요소는 Array의 길이에 기여하고 뒤따르는 요소의 인덱스를 증가시킵니다. 생략된 배열 요소는 정의되지 않습니다. 배열 끝에서 요소가 생략된 경우 그 요소는 Array의 길이에 기여하지 않습니다.
구문
ArrayLiteral [Yield, Await] :
[
Elision opt
]
[
ElementList [?Yield, ?Await]
]
[
ElementList [?Yield, ?Await]
,
Elision opt
]
ElementList [Yield, Await] :
Elision opt
AssignmentExpression [+In, ?Yield, ?Await]
Elision opt
SpreadElement [?Yield, ?Await]
ElementList [?Yield, ?Await]
,
Elision opt
AssignmentExpression [+In, ?Yield, ?Await]
ElementList [?Yield, ?Await]
,
Elision opt
SpreadElement [?Yield, ?Await]
Elision :
,
Elision
,
SpreadElement [Yield, Await] :
...
AssignmentExpression [+In, ?Yield, ?Await]
13.2.4.1 Runtime Semantics: ArrayAccumulation
구문 지향 연산 ArrayAccumulation. 인수 array (Array) 및 nextIndex (정수 ). 반환값: (정상 완료 (값: 정수 ) 또는 중도 완료). 다음 생성 규칙별로 정의된다.
Elision : ,
length 를 nextIndex + 1로 둡니다.? Set (array , "length" , 𝔽 (length ), true )를 수행합니다. 참고 : 위 단계는 length 가 232 - 1을 초과하면 예외를 던집니다.length 를 반환합니다.
Elision :
Elision
,
인수 array 및 (nextIndex + 1)을 사용한 Elision 의 ? ArrayAccumulation 을 반환합니다.
ElementList :
Elision opt
AssignmentExpression
Elision 이 존재하면, 다음을 수행합니다.nextIndex 를 인수 array 및 nextIndex 를 사용한 Elision 의 ? ArrayAccumulation 으로 설정합니다.initResult 를 AssignmentExpression 의 ? Evaluation 으로 둡니다.initValue 를 ? GetValue (initResult )로 둡니다.! CreateDataPropertyOrThrow (array , ! ToString (𝔽 (nextIndex )), initValue )를 수행합니다. nextIndex + 1을 반환합니다.
ElementList :
Elision opt
SpreadElement
Elision 이 존재하면, 다음을 수행합니다.nextIndex 를 인수 array 및 nextIndex 를 사용한 Elision 의 ? ArrayAccumulation 으로 설정합니다.인수 array 및 nextIndex 를 사용한 SpreadElement 의 ? ArrayAccumulation 을 반환합니다.
ElementList :
ElementList
,
Elision opt
AssignmentExpression
nextIndex 를 인수 array 및 nextIndex 를 사용한 파생된 ElementList 의 ? ArrayAccumulation 으로 설정합니다.Elision 이 존재하면, 다음을 수행합니다.nextIndex 를 인수 array 및 nextIndex 를 사용한 Elision 의 ? ArrayAccumulation 으로 설정합니다.initResult 를 AssignmentExpression 의 ? Evaluation 으로 둡니다.initValue 를 ? GetValue (initResult )로 둡니다.! CreateDataPropertyOrThrow (array , ! ToString (𝔽 (nextIndex )), initValue )를 수행합니다. nextIndex + 1을 반환합니다.
ElementList :
ElementList
,
Elision opt
SpreadElement
nextIndex 를 인수 array 및 nextIndex 를 사용한 파생된 ElementList 의 ? ArrayAccumulation 으로 설정합니다.Elision 이 존재하면, 다음을 수행합니다.nextIndex 를 인수 array 및 nextIndex 를 사용한 Elision 의 ? ArrayAccumulation 으로 설정합니다.인수 array 및 nextIndex 를 사용한 SpreadElement 의 ? ArrayAccumulation 을 반환합니다.
SpreadElement :
...
AssignmentExpression
spreadRef 를 AssignmentExpression 의 ? Evaluation 으로 둡니다.spreadObj 를 ? GetValue (spreadRef )로 둡니다.iteratorRecord 를 ? GetIterator (spreadObj , sync )로 둡니다.다음을 반복합니다.next 를 ? IteratorStepValue (iteratorRecord )로 둡니다.next 가 done 이면 nextIndex 를 반환합니다.! CreateDataPropertyOrThrow (array , ! ToString (𝔽 (nextIndex )), next )를 수행합니다. nextIndex 를 nextIndex + 1로 설정합니다.
참고
표준 내장 Array 프로토타입 객체 가 [[Set]] 을 사용한 새로운 자체 프로퍼티 생성을 방해하는 방식으로 수정되었더라도 배열에 자체 프로퍼티가 정의되도록 보장하기 위해 CreateDataPropertyOrThrow 를 사용합니다.
13.2.4.2 Runtime Semantics: 평가
ArrayLiteral :
[
Elision opt
]
array 를 ! ArrayCreate (0)으로 둡니다.Elision 이 존재하면, 다음을 수행합니다.인수 array 및 0을 사용한 Elision 의 ? ArrayAccumulation 을 수행합니다. array 를 반환합니다.
ArrayLiteral :
[
ElementList
]
array 를 ! ArrayCreate (0)으로 둡니다.인수 array 및 0을 사용한 ElementList 의 ? ArrayAccumulation 을 수행합니다. array 를 반환합니다.
ArrayLiteral :
[
ElementList
,
Elision opt
]
array 를 ! ArrayCreate (0)으로 둡니다.nextIndex 를 인수 array 및 0을 사용한 ElementList 의 ? ArrayAccumulation 으로 둡니다.Elision 이 존재하면, 다음을 수행합니다.인수 array 및 nextIndex 를 사용한 Elision 의 ? ArrayAccumulation 을 수행합니다. array 를 반환합니다.
13.2.5 Object 이니셜라이저
참고 1
객체 이니셜라이저는 리터럴과 유사한 형식으로 작성되어 Object의 초기화를 설명하는 표현식입니다. 중괄호 안에 프로퍼티 키 와 연결된 값의 쌍을 0개 이상 나열합니다. 값은 반드시 리터럴일 필요가 없으며 객체 이니셜라이저가 평가될 때마다 평가됩니다.
구문
ObjectLiteral [Yield, Await] :
{
}
{
PropertyDefinitionList [?Yield, ?Await]
,opt
}
PropertyDefinitionList [Yield, Await] :
PropertyDefinition [?Yield, ?Await]
PropertyDefinitionList [?Yield, ?Await]
,
PropertyDefinition [?Yield, ?Await]
PropertyDefinition [Yield, Await] :
IdentifierReference [?Yield, ?Await]
CoverInitializedName [?Yield, ?Await]
PropertyName [?Yield, ?Await]
:
AssignmentExpression [+In, ?Yield, ?Await]
MethodDefinition [?Yield, ?Await]
...
AssignmentExpression [+In, ?Yield, ?Await]
PropertyName [Yield, Await] :
LiteralPropertyName
ComputedPropertyName [?Yield, ?Await]
LiteralPropertyName :
IdentifierName
StringLiteral
NumericLiteral
ComputedPropertyName [Yield, Await] :
[
AssignmentExpression [+In, ?Yield, ?Await]
]
CoverInitializedName [Yield, Await] :
IdentifierReference [?Yield, ?Await]
Initializer [+In, ?Yield, ?Await]
Initializer [In, Yield, Await] :
=
AssignmentExpression [?In, ?Yield, ?Await]
참고 2
참고 3
CoverInitializedName 의 의미는 다음 절을 참조하시기 바랍니다.
13.2.5.1 Static Semantics: 조기 오류
ObjectLiteral :
{
PropertyDefinitionList
,opt
}
참고 1
PropertyDefinition : MethodDefinition
PropertyDefinition : CoverInitializedName
참고 2
이 명세의 다른 위치에는 특정 상황에서 LeftHandSideExpression 이 AssignmentPattern 을 포괄해야 한다고 요구하는 조기 오류 규칙 이 있습니다. 따라서 ObjectLiteral 은 ObjectAssignmentPattern 의 커버 문법 역할을 합니다. CoverInitializedName 생성 규칙은 AssignmentProperty 를 완전히 포괄하는 데 필요하지만 실제 객체 이니셜라이저 안에서는 유효하지 않습니다.
구체적으로 실제 ObjectLiteral 이 예상되는 문맥에서는 위 조기 오류 규칙 이 CoverInitializedName 사용을 방지합니다. 그러나 ObjectLiteral 이 커버 문법으로 사용되는 경우 “포괄해야 한다”의 의미론에 따라 ObjectLiteral 안의 Parse Node에는 조기 오류 규칙 이 적용되지 않으므로 CoverInitializedName 이 허용됩니다.
예를 들어 다음을 생각해 보시기 바랍니다:
let o = {f = 1 };
{f = 1}은 CoverInitializedName 을 갖는 ObjectLiteral 로 파싱되며 이 조기 오류 규칙 에 의해 Syntax Error가 발생합니다.
반대로 다음을 생각해 보시기 바랍니다:
({f = 1 } = {f : 2 });
여기에서도 {f = 1}은 처음에는 CoverInitializedName 을 갖는 ObjectLiteral 로 파싱되지만 AssignmentExpression 의 LeftHandSideExpression 이므로 AssignmentPattern 을 포괄해야 합니다 . 따라서 ObjectLiteral 과 CoverInitializedName 에는 조기 오류 규칙 이 적용되지 않습니다. 대신 {f = 1}은 AssignmentProperty 를 갖는 ObjectAssignmentPattern 으로 다시 파싱되며 Syntax Error가 없습니다.
13.2.5.2 Static Semantics: IsComputedPropertyKey
구문 지향 연산 IsComputedPropertyKey. 인수 없음. 반환값: Boolean. 다음 생성 규칙별로 정의된다.
PropertyName : LiteralPropertyName
false 를 반환합니다.
PropertyName : ComputedPropertyName
true 를 반환합니다.
13.2.5.3 Static Semantics: PropertyDefinitionNodes
구문 지향 연산 PropertyDefinitionNodes. 인수 없음. 반환값: 리스트 (요소: 구문 분석 노드 ). 다음 생성 규칙별로 정의된다.
ObjectLiteral :
{
}
새로운 빈 List 를 반환합니다.
PropertyDefinitionList : PropertyDefinition
« PropertyDefinition »을 반환합니다.
PropertyDefinitionList :
PropertyDefinitionList
,
PropertyDefinition
head 를 파생된 PropertyDefinitionList 의 PropertyDefinitionNodes 로 둡니다.head 와 « PropertyDefinition »의 목록 연결 을 반환합니다.
13.2.5.4 Static Semantics: PropertyNameList
구문 지향 연산 PropertyNameList. 인수 없음. 반환값: 리스트 (요소: String). 다음 생성 규칙별로 정의된다.
PropertyDefinitionList : PropertyDefinition
propertyName 을 PropertyDefinition 의 PropName 으로 둡니다.propertyName 이 empty 이면 새로운 빈 List 를 반환합니다.« propertyName »을 반환합니다.
PropertyDefinitionList :
PropertyDefinitionList
,
PropertyDefinition
list 를 PropertyDefinitionList 의 PropertyNameList 로 둡니다.propertyName 을 PropertyDefinition 의 PropName 으로 둡니다.propertyName 이 empty 이면 list 를 반환합니다.list 와 « propertyName »의 목록 연결 을 반환합니다.
13.2.5.5 Runtime Semantics: 평가
ObjectLiteral :
{
}
OrdinaryObjectCreate (%Object.prototype% )를 반환합니다.
ObjectLiteral :
{
PropertyDefinitionList
,opt
}
obj 를 OrdinaryObjectCreate (%Object.prototype% )로 둡니다.인수 obj 를 사용한 PropertyDefinitionList 의 ? PropertyDefinitionEvaluation 을 수행합니다. obj 를 반환합니다.
LiteralPropertyName : IdentifierName
IdentifierName 의 StringValue 를 반환합니다.
LiteralPropertyName : StringLiteral
StringLiteral 의 SV 를 반환합니다.
LiteralPropertyName : NumericLiteral
number 를 NumericLiteral 의 NumericValue 로 둡니다.! ToString (number )을 반환합니다.
ComputedPropertyName :
[
AssignmentExpression
]
exprValue 를 AssignmentExpression 의 ? Evaluation 으로 둡니다.propertyName 을 ? GetValue (exprValue )로 둡니다.? ToPropertyKey (propertyName )를 반환합니다.
13.2.5.6 Runtime Semantics: PropertyDefinitionEvaluation
구문 지향 연산 PropertyDefinitionEvaluation. 인수 obj (Object). 반환값: (정상 완료 (값: unused ) 또는 중도 완료). 다음 생성 규칙별로 정의된다.
PropertyDefinitionList :
PropertyDefinitionList
,
PropertyDefinition
인수 obj 를 사용한 PropertyDefinitionList 의 ? PropertyDefinitionEvaluation 을 수행합니다. 인수 obj 를 사용한 PropertyDefinition 의 ? PropertyDefinitionEvaluation 을 수행합니다. unused 를 반환합니다.
PropertyDefinition :
...
AssignmentExpression
exprValue 를 AssignmentExpression 의 ? Evaluation 으로 둡니다.fromValue 를 ? GetValue (exprValue )로 둡니다.excludedNames 를 새로운 빈 List 로 둡니다.? CopyDataProperties (obj , fromValue , excludedNames )를 수행합니다. unused 를 반환합니다.
PropertyDefinition : IdentifierReference
propertyName 을 IdentifierReference 의 StringValue 로 둡니다.exprValue 를 IdentifierReference 의 ? Evaluation 으로 둡니다.propertyValue 를 ? GetValue (exprValue )로 둡니다.단언 : obj 는 구성 불가능한 프로퍼티가 없는 일반 확장 가능 객체입니다.! CreateDataPropertyOrThrow (obj , propertyName , propertyValue )를 수행합니다. unused 를 반환합니다.
PropertyDefinition :
PropertyName
:
AssignmentExpression
propertyKey 를 PropertyName 의 ? Evaluation 으로 둡니다.이 PropertyDefinition 이 ParseJSON 을 위해 평가되는 Script 안에 포함되어 있으면(ParseJSON 의 6 단계 참조), 다음을 수행합니다.isProtoSetter 를 false 로 둡니다. 그렇지 않고 propertyKey 가 "__proto__" 이며 PropertyName 의 IsComputedPropertyKey 가 false 이면, 다음을 수행합니다.isProtoSetter 를 true 로 둡니다. 그렇지 않으면,isProtoSetter 를 false 로 둡니다. IsAnonymousFunctionDefinition (AssignmentExpression )이 true 이고 isProtoSetter 가 false 이면, 다음을 수행합니다.propertyValue 를 인수 propertyKey 를 사용한 AssignmentExpression 의 ? NamedEvaluation 으로 둡니다.그렇지 않으면,exprValueRef 를 AssignmentExpression 의 ? Evaluation 으로 둡니다.propertyValue 를 ? GetValue (exprValueRef )로 둡니다. isProtoSetter 가 true 이면, 다음을 수행합니다.propertyValue 가 Object이거나 propertyValue 가 null 이면, 다음을 수행합니다.! obj .[[SetPrototypeOf]] (propertyValue ) 를 수행합니다. unused 를 반환합니다.단언 : obj 는 구성 불가능한 프로퍼티가 없는 일반 확장 가능 객체입니다.! CreateDataPropertyOrThrow (obj , propertyKey , propertyValue )를 수행합니다. unused 를 반환합니다.
PropertyDefinition : MethodDefinition
result 를 인수 obj 및 true 를 사용한 MethodDefinition 의 ? MethodDefinitionEvaluation 으로 둡니다.단언 : result 는 empty 입니다.unused 를 반환합니다.
13.2.6 함수 정의 표현식
PrimaryExpression : FunctionExpression
에 대해서는 15.2 를 참조하시기 바랍니다.
PrimaryExpression : GeneratorExpression
에 대해서는 15.5 를 참조하시기 바랍니다.
PrimaryExpression : ClassExpression
에 대해서는 15.7 를 참조하시기 바랍니다.
PrimaryExpression : AsyncFunctionExpression
에 대해서는 15.8 를 참조하시기 바랍니다.
PrimaryExpression : AsyncGeneratorExpression
에 대해서는 15.6 를 참조하시기 바랍니다.
13.2.7 정규 표현식 리터럴
구문
12.9.5 를 참조하시기 바랍니다.
13.2.7.1 Static Semantics: 조기 오류
PrimaryExpression : RegularExpressionLiteral
13.2.7.2 Static Semantics: IsValidRegularExpressionLiteral ( literal )
추상 연산 IsValidRegularExpressionLiteral. 인수 literal (a RegularExpressionLiteral Parse Node). 반환값: Boolean. 인수가 유효한 정규 표현식 리터럴인지 결정합니다. 호출되면 다음 단계를 수행한다.
flags 를 literal 의 FlagText 로 둡니다.flags 에 d, g, i, m, s, u, v, y 이외의 코드 포인트가 하나라도 포함되어 있으면 false 를 반환합니다.flags 에 같은 코드 포인트가 두 번 이상 포함되어 있으면 false 를 반환합니다.flags 에 u가 포함되어 있으면 u 를 true 로 둡니다. 그렇지 않으면 u 를 false 로 둡니다.flags 에 v가 포함되어 있으면 v 를 true 로 둡니다. 그렇지 않으면 v 를 false 로 둡니다.patternText 를 literal 의 BodyText 로 둡니다.u 가 false 이고 v 가 false 이면, 다음을 수행합니다.stringValue 를 CodePointsToString (patternText )으로 둡니다.patternText 를 stringValue 의 각 16비트 요소를 유니코드 BMP 코드 포인트로 해석하여 얻은 코드 포인트 시퀀스로 설정합니다. 요소에는 UTF-16 디코딩을 적용하지 않습니다.parseResult 를 ParsePattern (patternText , u , v )로 둡니다.parseResult 가 Parse Node이면 true 를 반환합니다.false 를 반환합니다.
13.2.7.3 Runtime Semantics: 평가
PrimaryExpression : RegularExpressionLiteral
pattern 을 CodePointsToString (RegularExpressionLiteral 의 BodyText )으로 둡니다.flags 를 CodePointsToString (RegularExpressionLiteral 의 FlagText )로 둡니다.! RegExpCreate (pattern , flags )를 반환합니다.
13.2.8 템플릿 리터럴
구문
TemplateLiteral [Yield, Await, Tagged] :
NoSubstitutionTemplate
SubstitutionTemplate [?Yield, ?Await]
SubstitutionTemplate [Yield, Await] :
TemplateHead
Expression [+In, ?Yield, ?Await]
TemplateSpans [?Yield, ?Await]
TemplateSpans [Yield, Await] :
TemplateTail
TemplateMiddleList [?Yield, ?Await]
TemplateTail
TemplateMiddleList [Yield, Await] :
TemplateMiddle
Expression [+In, ?Yield, ?Await]
TemplateMiddleList [?Yield, ?Await]
TemplateMiddle
Expression [+In, ?Yield, ?Await]
13.2.8.1 Static Semantics: 조기 오류
TemplateLiteral [Yield, Await, Tagged] : NoSubstitutionTemplate
TemplateLiteral [Yield, Await, Tagged] : SubstitutionTemplate [?Yield, ?Await]
13.2.8.2 Static Semantics: TemplateStrings
구문 지향 연산 TemplateStrings. 인수 escapes ((raw 또는 cooked )). 반환값: 리스트 (요소: (String 또는 undefined )). 다음 생성 규칙별로 정의된다.
TemplateLiteral : NoSubstitutionTemplate
« TemplateString (NoSubstitutionTemplate , escapes ) »를 반환합니다.
SubstitutionTemplate :
TemplateHead
Expression
TemplateSpans
head 를 « TemplateString (TemplateHead , escapes ) »로 둡니다.tail 을 인수 escapes 를 사용한 TemplateSpans 의 TemplateStrings 로 둡니다.head 와 tail 의 목록 연결 을 반환합니다.
TemplateSpans : TemplateTail
« TemplateString (TemplateTail , escapes ) »를 반환합니다.
TemplateSpans :
TemplateMiddleList
TemplateTail
middle 을 인수 escapes 를 사용한 TemplateMiddleList 의 TemplateStrings 로 둡니다.tail 을 « TemplateString (TemplateTail , escapes ) »로 둡니다.middle 과 tail 의 목록 연결 을 반환합니다.
TemplateMiddleList :
TemplateMiddle
Expression
« TemplateString (TemplateMiddle , escapes ) »를 반환합니다.
TemplateMiddleList :
TemplateMiddleList
TemplateMiddle
Expression
front 를 인수 escapes 를 사용한 TemplateMiddleList 의 TemplateStrings 로 둡니다.last 를 « TemplateString (TemplateMiddle , escapes ) »로 둡니다.front 와 last 의 목록 연결 을 반환합니다.
13.2.8.3 Static Semantics: TemplateString ( templateToken , escapes )
추상 연산 TemplateString. 인수 templateToken ((a NoSubstitutionTemplate Parse Node, a TemplateHead Parse Node, a TemplateMiddle Parse Node 또는 a TemplateTail Parse Node)) 및 escapes ((raw 또는 cooked )). 반환값: (String 또는 undefined ). 호출되면 다음 단계를 수행한다.
escapes 가 raw 이면 templateToken 의 TRV 를 반환합니다.templateToken 의 TV 를 반환합니다.
참고
이 연산은 escapes 가 raw 이고 templateToken 에 NotEscapeSequence 가 포함되어 있으면 undefined 를 반환합니다. 그 밖의 모든 경우에는 String을 반환합니다.
13.2.8.4 GetTemplateObject ( templateLiteral )
추상 연산 GetTemplateObject. 인수 templateLiteral (구문 분석 노드). 반환값: Array. 호출되면 다음 단계를 수행한다.
realm 을 현재 Realm Record 로 둡니다.templateRegistry 를 realm .[[TemplateMap]] 으로 둡니다.templateRegistry 의 각 요소 element 에 대해 다음을 수행합니다.element .[[Site]] 가 templateLiteral 과 같은 Parse Node이면, 다음을 수행합니다.element .[[Array]] 를 반환합니다.rawStrings 를 인수 raw 를 사용한 templateLiteral 의 TemplateStrings 로 둡니다.단언 : rawStrings 는 String의 List 입니다.cookedStrings 를 인수 cooked 를 사용한 templateLiteral 의 TemplateStrings 로 둡니다.count 를 List cookedStrings 의 요소 수로 둡니다.단언 : count ≤ 232 - 1입니다.template 을 ! ArrayCreate (count )로 둡니다.rawObj 를 ! ArrayCreate (count )로 둡니다.index 를 0으로 둡니다.index < count 인 동안 다음을 반복합니다.propertyKey 를 ! ToString (𝔽 (index ))으로 둡니다.cookedValue 를 cookedStrings [index ]로 둡니다.! DefinePropertyOrThrow (template , propertyKey , PropertyDescriptor { [[Value]] : cookedValue , [[Writable]] : false , [[Enumerable]] : true , [[Configurable]] : false })를 수행합니다. rawValue 를 String 값 rawStrings [index ]로 둡니다.! DefinePropertyOrThrow (rawObj , propertyKey , PropertyDescriptor { [[Value]] : rawValue , [[Writable]] : false , [[Enumerable]] : true , [[Configurable]] : false })를 수행합니다. index 를 index + 1로 설정합니다.! SetIntegrityLevel (rawObj , frozen )을 수행합니다. ! DefinePropertyOrThrow (template , "raw" , PropertyDescriptor { [[Value]] : rawObj , [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false })를 수행합니다. ! SetIntegrityLevel (template , frozen )을 수행합니다. Record { [[Site]] : templateLiteral , [[Array]] : template }를 realm .[[TemplateMap]] 에 추가합니다.template 을 반환합니다.
참고 1
템플릿 객체 생성은 비정상 완료 를 발생시킬 수 없습니다.
참고 2
realm 의 프로그램 코드에 있는 각 TemplateLiteral 은 태그된 Template(13.2.8.6 )을 평가할 때 사용하는 고유한 템플릿 객체와 연결됩니다. 템플릿 객체는 동결되며 특정 태그된 Template을 평가할 때마다 동일한 템플릿 객체를 사용합니다. 템플릿 객체를 TemplateLiteral 을 처음 평가할 때 지연 생성할지 아니면 최초 평가 전에 미리 생성할지는 ECMAScript 코드에서 관찰할 수 없는 구현 선택입니다.
참고 3
이 명세의 향후 판에서는 템플릿 객체의 열거 불가능한 추가 프로퍼티를 정의할 수 있습니다.
13.2.8.5 Runtime Semantics: SubstitutionEvaluation
구문 지향 연산 SubstitutionEvaluation. 인수 없음. 반환값: (정상 완료 (값: 리스트 (요소: ECMAScript 언어 값 )) 또는 중도 완료). 다음 생성 규칙별로 정의된다.
TemplateSpans : TemplateTail
새로운 빈 List 를 반환합니다.
TemplateSpans :
TemplateMiddleList
TemplateTail
TemplateMiddleList 의 ? SubstitutionEvaluation 을 반환합니다.
TemplateMiddleList :
TemplateMiddle
Expression
subRef 를 Expression 의 ? Evaluation 으로 둡니다.sub 를 ? GetValue (subRef )로 둡니다.« sub »를 반환합니다.
TemplateMiddleList :
TemplateMiddleList
TemplateMiddle
Expression
preceding 을 TemplateMiddleList 의 ? SubstitutionEvaluation 으로 둡니다.nextRef 를 Expression 의 ? Evaluation 으로 둡니다.next 를 ? GetValue (nextRef )로 둡니다.preceding 과 « next »의 목록 연결 을 반환합니다.
13.2.8.6 Runtime Semantics: 평가
TemplateLiteral : NoSubstitutionTemplate
12.9.6 에 정의된 NoSubstitutionTemplate 의 TV 를 반환합니다.
SubstitutionTemplate :
TemplateHead
Expression
TemplateSpans
head 를 12.9.6 에 정의된 TemplateHead 의 TV 로 둡니다.subRef 를 Expression 의 ? Evaluation 으로 둡니다.sub 를 ? GetValue (subRef )로 둡니다.middle 을 ? ToString (sub )으로 둡니다.tail 을 TemplateSpans 의 ? Evaluation 으로 둡니다.head , middle 및 tail 의 문자열 연결 을 반환합니다.
참고 1
Expression 값에 적용되는 문자열 변환 의미론은 + 연산자보다 String.prototype.concat과 유사합니다.
TemplateSpans : TemplateTail
12.9.6 에 정의된 TemplateTail 의 TV 를 반환합니다.
TemplateSpans :
TemplateMiddleList
TemplateTail
head 를 TemplateMiddleList 의 ? Evaluation 으로 둡니다.tail 을 12.9.6 에 정의된 TemplateTail 의 TV 로 둡니다.head 와 tail 의 문자열 연결 을 반환합니다.
TemplateMiddleList :
TemplateMiddle
Expression
head 를 12.9.6 에 정의된 TemplateMiddle 의 TV 로 둡니다.subRef 를 Expression 의 ? Evaluation 으로 둡니다.sub 를 ? GetValue (subRef )로 둡니다.middle 을 ? ToString (sub )으로 둡니다.head 와 middle 의 문자열 연결 을 반환합니다.
참고 2
Expression 값에 적용되는 문자열 변환 의미론은 + 연산자보다 String.prototype.concat과 유사합니다.
TemplateMiddleList :
TemplateMiddleList
TemplateMiddle
Expression
rest 를 TemplateMiddleList 의 ? Evaluation 으로 둡니다.middle 을 12.9.6 에 정의된 TemplateMiddle 의 TV 로 둡니다.subRef 를 Expression 의 ? Evaluation 으로 둡니다.sub 를 ? GetValue (subRef )로 둡니다.last 를 ? ToString (sub )으로 둡니다.rest , middle 및 last 의 문자열 연결 을 반환합니다.
참고 3
Expression 값에 적용되는 문자열 변환 의미론은 + 연산자보다 String.prototype.concat과 유사합니다.
13.2.9 그룹화 연산자
13.2.9.1 Static Semantics: 조기 오류
PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList
13.2.9.2 Runtime Semantics: 평가
PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList
expr 을 CoverParenthesizedExpressionAndArrowParameterList 가 포괄하는 ParenthesizedExpression 로 둡니다.expr 의 ? Evaluation 을 반환합니다.
ParenthesizedExpression :
(
Expression
)
Expression 의 ? Evaluation 을 반환합니다. 이는 Reference 타입일 수 있습니다.
참고
이 알고리즘은 Expression 의 Evaluation 에 GetValue 를 적용하지 않습니다. 주된 이유는 delete 및 typeof와 같은 연산자를 괄호로 둘러싸인 표현식에 적용할 수 있도록 하기 위해서입니다.
13.3 좌변 표현식
구문
MemberExpression [Yield, Await] :
PrimaryExpression [?Yield, ?Await]
MemberExpression [?Yield, ?Await]
[
Expression [+In, ?Yield, ?Await]
]
MemberExpression [?Yield, ?Await]
.
IdentifierName
MemberExpression [?Yield, ?Await]
TemplateLiteral [?Yield, ?Await, +Tagged]
SuperProperty [?Yield, ?Await]
MetaProperty
new
MemberExpression [?Yield, ?Await]
Arguments [?Yield, ?Await]
MemberExpression [?Yield, ?Await]
.
PrivateIdentifier
SuperProperty [Yield, Await] :
super
[
Expression [+In, ?Yield, ?Await]
]
super
.
IdentifierName
MetaProperty :
NewTarget
ImportMeta
NewTarget :
new
.
target
ImportMeta :
import
.
meta
NewExpression [Yield, Await] :
MemberExpression [?Yield, ?Await]
new
NewExpression [?Yield, ?Await]
CallExpression [Yield, Await] :
CoverCallExpressionAndAsyncArrowHead [?Yield, ?Await]
SuperCall [?Yield, ?Await]
ImportCall [?Yield, ?Await]
CallExpression [?Yield, ?Await]
Arguments [?Yield, ?Await]
CallExpression [?Yield, ?Await]
[
Expression [+In, ?Yield, ?Await]
]
CallExpression [?Yield, ?Await]
.
IdentifierName
CallExpression [?Yield, ?Await]
TemplateLiteral [?Yield, ?Await, +Tagged]
CallExpression [?Yield, ?Await]
.
PrivateIdentifier
SuperCall [Yield, Await] :
super
Arguments [?Yield, ?Await]
ImportCall [Yield, Await] :
import
(
AssignmentExpression [+In, ?Yield, ?Await]
,opt
)
import
(
AssignmentExpression [+In, ?Yield, ?Await]
,
AssignmentExpression [+In, ?Yield, ?Await]
,opt
)
Arguments [Yield, Await] :
(
)
(
ArgumentList [?Yield, ?Await]
,opt
)
ArgumentList [Yield, Await] :
AssignmentExpression [+In, ?Yield, ?Await]
...
AssignmentExpression [+In, ?Yield, ?Await]
ArgumentList [?Yield, ?Await]
,
AssignmentExpression [+In, ?Yield, ?Await]
ArgumentList [?Yield, ?Await]
,
...
AssignmentExpression [+In, ?Yield, ?Await]
OptionalExpression [Yield, Await] :
MemberExpression [?Yield, ?Await]
OptionalChain [?Yield, ?Await]
CallExpression [?Yield, ?Await]
OptionalChain [?Yield, ?Await]
OptionalExpression [?Yield, ?Await]
OptionalChain [?Yield, ?Await]
OptionalChain [Yield, Await] :
?.
Arguments [?Yield, ?Await]
?.
[
Expression [+In, ?Yield, ?Await]
]
?.
IdentifierName
?.
TemplateLiteral [?Yield, ?Await, +Tagged]
?.
PrivateIdentifier
OptionalChain [?Yield, ?Await]
Arguments [?Yield, ?Await]
OptionalChain [?Yield, ?Await]
[
Expression [+In, ?Yield, ?Await]
]
OptionalChain [?Yield, ?Await]
.
IdentifierName
OptionalChain [?Yield, ?Await]
TemplateLiteral [?Yield, ?Await, +Tagged]
OptionalChain [?Yield, ?Await]
.
PrivateIdentifier
LeftHandSideExpression [Yield, Await] :
NewExpression [?Yield, ?Await]
CallExpression [?Yield, ?Await]
OptionalExpression [?Yield, ?Await]
보충 구문
다음 생성 규칙의 인스턴스를 처리할 때
CallExpression : CoverCallExpressionAndAsyncArrowHead
CoverCallExpressionAndAsyncArrowHead 의 해석은 다음 문법을 사용하여 구체화됩니다:
CallMemberExpression [Yield, Await] :
MemberExpression [?Yield, ?Await]
Arguments [?Yield, ?Await]
13.3.1 정적 의미론
13.3.1.1 Static Semantics: 조기 오류
OptionalChain :
?.
TemplateLiteral
OptionalChain
TemplateLiteral
참고
이 생성 규칙은 자동 세미콜론 삽입 규칙(12.10 )이 다음 코드에 적용되는 것을 방지하기 위해 존재합니다:
a?.b
`c`
즉, 이를 두 개의 유효한 문으로 해석하지 않도록 합니다. 목적은 선택적 체인이 없는 유사한 코드와 일관성을 유지하는 것입니다:
a.b
`c`
이는 유효한 문이며 자동 세미콜론 삽입이 적용되지 않습니다.
ImportMeta :
import
.
meta
13.3.2 프로퍼티 접근자
참고
프로퍼티에는 다음과 같은 점 표기법을 사용하여 이름으로 접근할 수 있습니다:
또는 다음과 같은 대괄호 표기법을 사용합니다:
점 표기법은 다음 구문 변환으로 설명할 수 있습니다:
의 동작은 다음과 동일합니다.
마찬가지로
의 동작은 다음과 동일합니다.
여기서 <identifier-name-string >은 IdentifierName 의 StringValue 입니다.
13.3.2.1 Runtime Semantics: 평가
MemberExpression :
MemberExpression
[
Expression
]
baseRef 를 MemberExpression 의 ? Evaluation 으로 둡니다.baseValue 를 ? GetValue (baseRef )로 둡니다.strict 를 IsStrict (this MemberExpression )로 둡니다.? EvaluatePropertyAccessWithExpressionKey (baseValue , Expression , strict )를 반환합니다.
MemberExpression :
MemberExpression
.
IdentifierName
baseRef 를 MemberExpression 의 ? Evaluation 으로 둡니다.baseValue 를 ? GetValue (baseRef )로 둡니다.strict 를 IsStrict (this MemberExpression )로 둡니다.EvaluatePropertyAccessWithIdentifierKey (baseValue , IdentifierName , strict )를 반환합니다.
MemberExpression :
MemberExpression
.
PrivateIdentifier
baseRef 를 MemberExpression 의 ? Evaluation 으로 둡니다.baseValue 를 ? GetValue (baseRef )로 둡니다.fieldNameString 을 PrivateIdentifier 의 StringValue 로 둡니다.MakePrivateReference (baseValue , fieldNameString )를 반환합니다.
CallExpression :
CallExpression
[
Expression
]
baseRef 를 CallExpression 의 ? Evaluation 으로 둡니다.baseValue 를 ? GetValue (baseRef )로 둡니다.strict 를 IsStrict (this CallExpression )로 둡니다.? EvaluatePropertyAccessWithExpressionKey (baseValue , Expression , strict )를 반환합니다.
CallExpression :
CallExpression
.
IdentifierName
baseRef 를 CallExpression 의 ? Evaluation 으로 둡니다.baseValue 를 ? GetValue (baseRef )로 둡니다.strict 를 IsStrict (this CallExpression )로 둡니다.EvaluatePropertyAccessWithIdentifierKey (baseValue , IdentifierName , strict )를 반환합니다.
CallExpression :
CallExpression
.
PrivateIdentifier
baseRef 를 CallExpression 의 ? Evaluation 으로 둡니다.baseValue 를 ? GetValue (baseRef )로 둡니다.fieldNameString 을 PrivateIdentifier 의 StringValue 로 둡니다.MakePrivateReference (baseValue , fieldNameString )를 반환합니다.
13.3.3 EvaluatePropertyAccessWithExpressionKey ( baseValue , expr , strict )
추상 연산 EvaluatePropertyAccessWithExpressionKey. 인수 baseValue (ECMAScript 언어 값 ), expr (an Expression Parse Node) 및 strict (Boolean). 반환값: (정상 완료 (값: Reference 레코드 ) 또는 중도 완료). 호출되면 다음 단계를 수행한다.
propertyNameRef 를 expr 의 ? Evaluation 으로 둡니다.propertyNameValue 를 ? GetValue (propertyNameRef )로 둡니다.참고 : 대부분의 경우 이 단계 직후 propertyNameValue 에 ToPropertyKey 를 수행합니다. 그러나 a[b] = c의 경우에는 c를 평가한 후까지 수행하지 않습니다.Reference Record { [[Base]] : baseValue , [[ReferencedName]] : propertyNameValue , [[Strict]] : strict , [[ThisValue]] : empty }를 반환합니다.
13.3.4 EvaluatePropertyAccessWithIdentifierKey ( baseValue , identifierName , strict )
추상 연산 EvaluatePropertyAccessWithIdentifierKey. 인수 baseValue (ECMAScript 언어 값 ), identifierName (an IdentifierName Parse Node) 및 strict (Boolean). 반환값: Reference 레코드 . 호출되면 다음 단계를 수행한다.
propertyNameString 을 identifierName 의 StringValue 로 둡니다.Reference Record { [[Base]] : baseValue , [[ReferencedName]] : propertyNameString , [[Strict]] : strict , [[ThisValue]] : empty }를 반환합니다.
13.3.5 new 연산자
13.3.5.1 Runtime Semantics: 평가
NewExpression :
new
NewExpression
? EvaluateNew (NewExpression , empty )을 반환합니다.
MemberExpression :
new
MemberExpression
Arguments
? EvaluateNew (MemberExpression , Arguments )를 반환합니다.
13.3.5.1.1 EvaluateNew ( constructExpr , argumentsNode )
추상 연산 EvaluateNew. 인수 constructExpr ((a NewExpression Parse Node 또는 a MemberExpression Parse Node)) 및 argumentsNode ((empty 또는 an Arguments Parse Node)). 반환값: (정상 완료 (값: Object) 또는 중도 완료). 호출되면 다음 단계를 수행한다.
ref 를 constructExpr 의 ? Evaluation 으로 둡니다.ctor 를 ? GetValue (ref )로 둡니다.argumentsNode 가 empty 이면, 다음을 수행합니다.argList 를 새로운 빈 List 로 둡니다.그렇지 않으면,argList 를 argumentsNode 의 ? ArgumentListEvaluation 으로 둡니다. IsConstructor (ctor )가 false 이면 TypeError 예외를 던집니다.? Construct (ctor , argList )를 반환합니다.
13.3.6 함수 호출
13.3.6.1 Runtime Semantics: 평가
CallExpression : CoverCallExpressionAndAsyncArrowHead
expr 을 CoverCallExpressionAndAsyncArrowHead 가 포괄하는 CallMemberExpression 로 둡니다.memberExpr 을 expr 의 MemberExpression 로 둡니다.args 를 expr 의 Arguments 로 둡니다.ref 를 memberExpr 의 ? Evaluation 으로 둡니다.func 를 ? GetValue (ref )로 둡니다.ref 가 Reference Record 이고 IsPropertyReference (ref )가 false 이며 ref .[[ReferencedName]] 이 "eval" 이면, 다음을 수행합니다.SameValue (func , %eval% )가 true 이면, 다음을 수행합니다.argList 를 args 의 ? ArgumentListEvaluation 으로 둡니다.argList 에 요소가 없으면 undefined 를 반환합니다.evalArg 를 argList 의 첫 번째 요소로 둡니다.IsStrict (this CallExpression )가 true 이면 strictCaller 를 true 로 둡니다. 그렇지 않으면 strictCaller 를 false 로 둡니다.? PerformEval (evalArg , strictCaller , true )를 반환합니다. thisCall 을 이 CallExpression 로 둡니다.tailCall 을 IsInTailPosition (thisCall )으로 둡니다.? EvaluateCall (func , ref , args , tailCall )을 반환합니다.
6.a.v 단계를 실행하는 CallExpression 평가는 직접 eval 입니다.
CallExpression :
CallExpression
Arguments
ref 를 CallExpression 의 ? Evaluation 으로 둡니다.func 를 ? GetValue (ref )로 둡니다.thisCall 을 이 CallExpression 로 둡니다.tailCall 을 IsInTailPosition (thisCall )으로 둡니다.? EvaluateCall (func , ref , Arguments , tailCall )을 반환합니다.
13.3.6.2 EvaluateCall ( func , thisValueRef , argumentListNode , tailPosition )
추상 연산 EvaluateCall. 인수 func (ECMAScript 언어 값 ), thisValueRef ((ECMAScript 언어 값 또는 Reference 레코드 )), argumentListNode (구문 분석 노드) 및 tailPosition (Boolean). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 중도 완료). 호출되면 다음 단계를 수행한다.
thisValueRef 가 Reference Record 이면, 다음을 수행합니다.IsPropertyReference (thisValueRef )가 true 이면, 다음을 수행합니다.thisValue 를 GetThisValue (thisValueRef )로 둡니다.그렇지 않으면,refEnv 를 thisValueRef .[[Base]] 로 둡니다.단언 : refEnv 는 Environment Record 입니다.thisValue 를 refEnv .WithBaseObject ()로 둡니다. 그렇지 않으면,thisValue 를 undefined 로 둡니다. argList 를 argumentListNode 의 ? ArgumentListEvaluation 으로 둡니다.func 가 Object가 아니면 TypeError 예외를 던집니다.IsCallable (func )이 false 이면 TypeError 예외를 던집니다.tailPosition 이 true 이면 PrepareForTailCall ()을 수행합니다.? Call (func , thisValue , argList )을 반환합니다.
13.3.7 super 키워드
13.3.7.1 Runtime Semantics: 평가
SuperProperty :
super
[
Expression
]
envRecord 를 GetThisEnvironment ()로 둡니다.actualThis 를 ? envRecord .GetThisBinding ()으로 둡니다.propertyNameRef 를 Expression 의 ? Evaluation 으로 둡니다.propertyNameValue 를 ? GetValue (propertyNameRef )로 둡니다.strict 를 IsStrict (this SuperProperty )로 둡니다.참고 : 대부분의 경우 이 단계 직후 propertyNameValue 에 ToPropertyKey 를 수행합니다. 그러나 super[b] = c의 경우에는 c를 평가한 후까지 수행하지 않습니다.MakeSuperPropertyReference (actualThis , propertyNameValue , strict )를 반환합니다.
SuperProperty :
super
.
IdentifierName
envRecord 를 GetThisEnvironment ()로 둡니다.actualThis 를 ? envRecord .GetThisBinding ()으로 둡니다.propertyKey 를 IdentifierName 의 StringValue 로 둡니다.strict 를 IsStrict (this SuperProperty )로 둡니다.MakeSuperPropertyReference (actualThis , propertyKey , strict )를 반환합니다.
SuperCall :
super
Arguments
newTarget 을 GetNewTarget ()으로 둡니다.단언 : newTarget 은 constructor입니다.superCtor 를 GetSuperConstructor ()로 둡니다.argList 를 Arguments 의 ? ArgumentListEvaluation 으로 둡니다.IsConstructor (superCtor )가 false 이면 TypeError 예외를 던집니다.result 를 ? Construct (superCtor , argList , newTarget )로 둡니다.thisER 을 GetThisEnvironment ()로 둡니다.단언 : thisER 은 Function Environment Record 입니다.? BindThisValue (thisER , result )를 수행합니다. funcObj 를 thisER .[[FunctionObject]] 로 둡니다.단언 : funcObj 는 ECMAScript 함수 객체 입니다.? InitializeInstanceElements (result , funcObj )를 수행합니다. result 를 반환합니다.
13.3.7.2 GetSuperConstructor ( )
추상 연산 GetSuperConstructor. 인수 없음. 반환값: (Object 또는 null ). 호출되면 다음 단계를 수행한다.
envRecord 를 GetThisEnvironment ()로 둡니다.단언 : envRecord 는 Function Environment Record 입니다.activeFunc 를 envRecord .[[FunctionObject]] 로 둡니다.단언 : activeFunc 는 ECMAScript 함수 객체 입니다.superCtor 를 ! activeFunc .[[GetPrototypeOf]] ()로 둡니다.superCtor 를 반환합니다.
13.3.7.3 MakeSuperPropertyReference ( actualThis , propertyKey , strict )
추상 연산 MakeSuperPropertyReference. 인수 actualThis (ECMAScript 언어 값 ), propertyKey (ECMAScript 언어 값 ) 및 strict (Boolean). 반환값: Super Reference 레코드 . 호출되면 다음 단계를 수행한다.
envRecord 를 GetThisEnvironment ()로 둡니다.단언 : envRecord .HasSuperBinding ()은 true 입니다.단언 : envRecord 는 Function Environment Record 입니다.baseValue 를 GetSuperBase (envRecord )로 둡니다.Reference Record { [[Base]] : baseValue , [[ReferencedName]] : propertyKey , [[Strict]] : strict , [[ThisValue]] : actualThis }를 반환합니다.
13.3.8 인수 목록
참고
인수 목록을 평가하면 값의 List 가 생성됩니다.
13.3.8.1 Runtime Semantics: ArgumentListEvaluation
구문 지향 연산 ArgumentListEvaluation. 인수 없음. 반환값: (정상 완료 (값: 리스트 (요소: ECMAScript 언어 값 )) 또는 중도 완료). 다음 생성 규칙별로 정의된다.
Arguments :
(
)
새로운 빈 List 를 반환합니다.
ArgumentList : AssignmentExpression
ref 를 AssignmentExpression 의 ? Evaluation 으로 둡니다.arg 를 ? GetValue (ref )로 둡니다.« arg »를 반환합니다.
ArgumentList :
...
AssignmentExpression
list 를 새로운 빈 List 로 둡니다.spreadRef 를 AssignmentExpression 의 ? Evaluation 으로 둡니다.spreadObj 를 ? GetValue (spreadRef )로 둡니다.iteratorRecord 를 ? GetIterator (spreadObj , sync )로 둡니다.다음을 반복합니다.next 를 ? IteratorStepValue (iteratorRecord )로 둡니다.next 가 done 이면 list 를 반환합니다.next 를 list 에 추가합니다.
ArgumentList :
ArgumentList
,
AssignmentExpression
precedingArgs 를 ArgumentList 의 ? ArgumentListEvaluation 으로 둡니다.ref 를 AssignmentExpression 의 ? Evaluation 으로 둡니다.arg 를 ? GetValue (ref )로 둡니다.precedingArgs 와 « arg »의 목록 연결 을 반환합니다.
ArgumentList :
ArgumentList
,
...
AssignmentExpression
precedingArgs 를 ArgumentList 의 ? ArgumentListEvaluation 으로 둡니다.spreadRef 를 AssignmentExpression 의 ? Evaluation 으로 둡니다.iteratorRecord 를 ? GetIterator (? GetValue (spreadRef ), sync )로 둡니다.다음을 반복합니다.next 를 ? IteratorStepValue (iteratorRecord )로 둡니다.next 가 done 이면 precedingArgs 를 반환합니다.next 를 precedingArgs 에 추가합니다.
TemplateLiteral : NoSubstitutionTemplate
templateLiteral 을 이 TemplateLiteral 로 둡니다.siteObj 를 GetTemplateObject (templateLiteral )로 둡니다.« siteObj »를 반환합니다.
TemplateLiteral : SubstitutionTemplate
templateLiteral 을 이 TemplateLiteral 로 둡니다.siteObj 를 GetTemplateObject (templateLiteral )로 둡니다.remaining 을 SubstitutionTemplate 의 ? ArgumentListEvaluation 으로 둡니다.« siteObj »와 remaining 의 목록 연결 을 반환합니다.
SubstitutionTemplate :
TemplateHead
Expression
TemplateSpans
firstSubRef 를 Expression 의 ? Evaluation 으로 둡니다.firstSub 를 ? GetValue (firstSubRef )로 둡니다.restSub 를 TemplateSpans 의 ? SubstitutionEvaluation 으로 둡니다.단언 : restSub 는 비어 있을 수도 있는 List 입니다.« firstSub »와 restSub 의 목록 연결 을 반환합니다.
13.3.9 선택적 체인
참고 선택적 체인은 하나 이상의 프로퍼티 접근 및 함수 호출로 구성된 체인이며, 그 첫 번째 항목은 토큰 ?.로 시작합니다.
13.3.9.1 Runtime Semantics: 평가
OptionalExpression :
MemberExpression
OptionalChain
baseRef 를 MemberExpression 의 ? Evaluation 으로 둡니다.baseValue 를 ? GetValue (baseRef )로 둡니다.baseValue 가 undefined 또는 null 이면, 다음을 수행합니다.undefined 를 반환합니다.인수 baseValue 및 baseRef 를 사용한 OptionalChain 의 ? ChainEvaluation 을 반환합니다.
OptionalExpression :
CallExpression
OptionalChain
baseRef 를 CallExpression 의 ? Evaluation 으로 둡니다.baseValue 를 ? GetValue (baseRef )로 둡니다.baseValue 가 undefined 또는 null 이면, 다음을 수행합니다.undefined 를 반환합니다.인수 baseValue 및 baseRef 를 사용한 OptionalChain 의 ? ChainEvaluation 을 반환합니다.
OptionalExpression :
OptionalExpression
OptionalChain
baseRef 를 OptionalExpression 의 ? Evaluation 으로 둡니다.baseValue 를 ? GetValue (baseRef )로 둡니다.baseValue 가 undefined 또는 null 이면, 다음을 수행합니다.undefined 를 반환합니다.인수 baseValue 및 baseRef 를 사용한 OptionalChain 의 ? ChainEvaluation 을 반환합니다.
13.3.9.2 Runtime Semantics: ChainEvaluation
구문 지향 연산 ChainEvaluation. 인수 baseValue (ECMAScript 언어 값 ) 및 baseRef ((ECMAScript 언어 값 또는 Reference 레코드 )). 반환값: (정상 완료 (값: (ECMAScript 언어 값 또는 Reference 레코드 )) 또는 중도 완료). 다음 생성 규칙별로 정의된다.
OptionalChain :
?.
Arguments
thisChain 을 이 OptionalChain 로 둡니다.tailCall 을 IsInTailPosition (thisChain )으로 둡니다.? EvaluateCall (baseValue , baseRef , Arguments , tailCall )을 반환합니다.
OptionalChain :
?.
[
Expression
]
strict 를 IsStrict (this OptionalChain )로 둡니다.? EvaluatePropertyAccessWithExpressionKey (baseValue , Expression , strict )를 반환합니다.
OptionalChain :
?.
IdentifierName
strict 를 IsStrict (this OptionalChain )로 둡니다.EvaluatePropertyAccessWithIdentifierKey (baseValue , IdentifierName , strict )를 반환합니다.
OptionalChain :
?.
PrivateIdentifier
fieldNameString 을 PrivateIdentifier 의 StringValue 로 둡니다.MakePrivateReference (baseValue , fieldNameString )를 반환합니다.
OptionalChain :
OptionalChain
Arguments
optionalChain 을 OptionalChain 로 둡니다.newRef 를 인수 baseValue 및 baseRef 를 사용한 optionalChain 의 ? ChainEvaluation 으로 둡니다.newValue 를 ? GetValue (newRef )로 둡니다.thisChain 을 이 OptionalChain 로 둡니다.tailCall 을 IsInTailPosition (thisChain )으로 둡니다.? EvaluateCall (newValue , newRef , Arguments , tailCall )을 반환합니다.
OptionalChain :
OptionalChain
[
Expression
]
optionalChain 을 OptionalChain 로 둡니다.newRef 를 인수 baseValue 및 baseRef 를 사용한 optionalChain 의 ? ChainEvaluation 으로 둡니다.newValue 를 ? GetValue (newRef )로 둡니다.strict 를 IsStrict (this OptionalChain )로 둡니다.? EvaluatePropertyAccessWithExpressionKey (newValue , Expression , strict )를 반환합니다.
OptionalChain :
OptionalChain
.
IdentifierName
optionalChain 을 OptionalChain 로 둡니다.newRef 를 인수 baseValue 및 baseRef 를 사용한 optionalChain 의 ? ChainEvaluation 으로 둡니다.newValue 를 ? GetValue (newRef )로 둡니다.strict 를 IsStrict (this OptionalChain )로 둡니다.EvaluatePropertyAccessWithIdentifierKey (newValue , IdentifierName , strict )를 반환합니다.
OptionalChain :
OptionalChain
.
PrivateIdentifier
optionalChain 을 OptionalChain 로 둡니다.newRef 를 인수 baseValue 및 baseRef 를 사용한 optionalChain 의 ? ChainEvaluation 으로 둡니다.newValue 를 ? GetValue (newRef )로 둡니다.fieldNameString 을 PrivateIdentifier 의 StringValue 로 둡니다.MakePrivateReference (newValue , fieldNameString )를 반환합니다.
13.3.10 Import 호출
13.3.10.1 Runtime Semantics: 평가
ImportCall :
import
(
AssignmentExpression
,opt
)
? EvaluateImportCall (AssignmentExpression )을 반환합니다.
ImportCall :
import
(
AssignmentExpression
,
AssignmentExpression
,opt
)
? EvaluateImportCall (첫 번째 AssignmentExpression , 두 번째 AssignmentExpression )을 반환합니다.
13.3.10.2 EvaluateImportCall ( specifierExpr [ , optionsExpr ] )
추상 연산 EvaluateImportCall. 인수 specifierExpr (구문 분석 노드) 및 선택적 인수 optionsExpr (구문 분석 노드). 반환값: (정상 완료 (값: Promise) 또는 중도 완료). 호출되면 다음 단계를 수행한다.
referrer 를 GetActiveScriptOrModule ()로 둡니다.referrer 가 null 이면 referrer 를 현재 Realm Record 로 설정합니다.specifierRef 를 specifierExpr 의 ? Evaluation 으로 둡니다.specifier 를 ? GetValue (specifierRef )로 둡니다.optionsExpr 이 존재하면, 다음을 수행합니다.optionsRef 를 optionsExpr 의 ? Evaluation 으로 둡니다.options 를 ? GetValue (optionsRef )로 둡니다.그렇지 않으면,options 를 undefined 로 둡니다. promiseCapability 를 ! NewPromiseCapability (%Promise% )로 둡니다.specifierString 을 Completion (ToString (specifier ))으로 둡니다.IfAbruptRejectPromise (specifierString , promiseCapability ).attrs 를 새로운 빈 List 로 둡니다.options 가 undefined 가 아니면, 다음을 수행합니다.options 가 Object가 아니면, 다음을 수행합니다.! Call (promiseCapability .[[Reject]] , undefined , « 새로 생성된 TypeError 객체 »)를 수행합니다. promiseCapability .[[Promise]] 를 반환합니다.attrsObj 를 Completion (Get (options , "with" ))로 둡니다.IfAbruptRejectPromise (attrsObj , promiseCapability ).attrsObj 가 undefined 가 아니면, 다음을 수행합니다.attrsObj 가 Object가 아니면, 다음을 수행합니다.! Call (promiseCapability .[[Reject]] , undefined , « 새로 생성된 TypeError 객체 »)를 수행합니다. promiseCapability .[[Promise]] 를 반환합니다.entries 를 Completion (EnumerableOwnProperties (attrsObj , key+value ))로 둡니다.IfAbruptRejectPromise (entries , promiseCapability ).entries 의 각 요소 entry 에 대해 다음을 수행합니다.key 를 ! Get (entry , "0" )으로 둡니다.value 를 ! Get (entry , "1" )로 둡니다.key 가 String이면, 다음을 수행합니다.value 가 String이 아니면, 다음을 수행합니다.! Call (promiseCapability .[[Reject]] , undefined , « 새로 생성된 TypeError 객체 »)를 수행합니다. promiseCapability .[[Promise]] 를 반환합니다.ImportAttribute Record { [[Key]] : key , [[Value]] : value }를 attrs 에 추가합니다.AllImportAttributesSupported (attrs )가 false 이면, 다음을 수행합니다.! Call (promiseCapability .[[Reject]] , undefined , « 새로 생성된 TypeError 객체 »)를 수행합니다. promiseCapability .[[Promise]] 를 반환합니다.각 [[Key]] 필드의 값을 UTF-16 코드 단위 값의 시퀀스로 취급하여 해당 [[Key]] 필드의 사전식 순서에 따라 attrs 를 정렬합니다. 참고 : 호스트 가 속성이 열거되는 순서를 기반으로 동작을 변경하는 것이 금지되어 있다는 점에서만 이 정렬을 관찰할 수 있습니다. moduleRequest 를 새로운 ModuleRequest Record { [[Specifier]] : specifierString , [[Attributes]] : attrs }로 둡니다.HostLoadImportedModule (referrer , moduleRequest , empty , promiseCapability )을 수행합니다.promiseCapability .[[Promise]] 를 반환합니다.
13.3.10.3 ContinueDynamicImport ( promiseCapability , moduleCompletion )
추상 연산 ContinueDynamicImport. 인수 promiseCapability (PromiseCapability 레코드 ) 및 moduleCompletion ((정상 완료 (값: Module 레코드 ) 또는 throw 완료 )). 반환값: unused . import() 호출로 처음 시작된 동적 가져오기 과정을 완료하고, 해당 호출이 반환한 Promise를 적절히 이행하거나 거부합니다. 호출되면 다음 단계를 수행한다.
moduleCompletion 이 비정상 완료 이면, 다음을 수행합니다.! Call (promiseCapability .[[Reject]] , undefined , « moduleCompletion .[[Value]] »)를 수행합니다. unused 를 반환합니다.module 을 moduleCompletion .[[Value]] 로 둡니다.loadPromise 를 module .LoadRequestedModules ()로 둡니다.rejectedClosure 를 매개변수 (reason )를 갖고 promiseCapability 을 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:! Call (promiseCapability .[[Reject]] , undefined , « reason »)를 수행합니다. NormalCompletion (undefined )을 반환합니다.onRejected 를 CreateBuiltinFunction (rejectedClosure , 1, "" , « »)로 둡니다.linkAndEvaluateClosure 를 매개변수가 없고 module , promiseCapability 및 onRejected 를 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:link 를 Completion (module .Link ())으로 둡니다.link 가 비정상 완료 이면, 다음을 수행합니다.! Call (promiseCapability .[[Reject]] , undefined , « link .[[Value]] »)를 수행합니다. NormalCompletion (undefined )을 반환합니다.evaluatePromise 를 module .Evaluate ()로 둡니다.fulfilledClosure 를 매개변수가 없고 module 및 promiseCapability 을 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:namespace 를 GetModuleNamespace (module )로 둡니다.! Call (promiseCapability .[[Resolve]] , undefined , « namespace »)를 수행합니다. NormalCompletion (undefined )을 반환합니다.onFulfilled 를 CreateBuiltinFunction (fulfilledClosure , 0, "" , « »)로 둡니다.PerformPromiseThen (evaluatePromise , onFulfilled , onRejected )을 수행합니다.unused 를 반환합니다.linkAndEvaluate 를 CreateBuiltinFunction (linkAndEvaluateClosure , 0, "" , « »)로 둡니다.PerformPromiseThen (loadPromise , linkAndEvaluate , onRejected )을 수행합니다.unused 를 반환합니다.
13.3.11 태그된 템플릿
참고
태그된 템플릿은 호출의 인수가 TemplateLiteral (13.2.8 )에서 파생되는 함수 호출입니다. 실제 인수에는 템플릿 객체(13.2.8.4 )와 TemplateLiteral 안에 삽입된 표현식을 평가하여 생성된 값이 포함됩니다.
13.3.11.1 Runtime Semantics: 평가
MemberExpression :
MemberExpression
TemplateLiteral
tagRef 를 MemberExpression 의 ? Evaluation 으로 둡니다.tagFunc 를 ? GetValue (tagRef )로 둡니다.thisCall 을 이 MemberExpression 로 둡니다.tailCall 을 IsInTailPosition (thisCall )으로 둡니다.? EvaluateCall (tagFunc , tagRef , TemplateLiteral , tailCall )을 반환합니다.
CallExpression :
CallExpression
TemplateLiteral
tagRef 를 CallExpression 의 ? Evaluation 으로 둡니다.tagFunc 를 ? GetValue (tagRef )로 둡니다.thisCall 을 이 CallExpression 로 둡니다.tailCall 을 IsInTailPosition (thisCall )으로 둡니다.? EvaluateCall (tagFunc , tagRef , TemplateLiteral , tailCall )을 반환합니다.
13.3.12 메타 프로퍼티
13.3.12.1 Runtime Semantics: 평가
NewTarget :
new
.
target
GetNewTarget ()을 반환합니다.
ImportMeta :
import
.
meta
module 을 GetActiveScriptOrModule ()로 둡니다.단언 : module 은 Source Text Module Record 입니다.importMeta 를 module .[[ImportMeta]] 로 둡니다.importMeta 가 empty 이면, 다음을 수행합니다.importMeta 를 OrdinaryObjectCreate (null )로 설정합니다.importMetaValues 를 HostGetImportMetaProperties (module )로 둡니다.importMetaValues 의 각 Record { [[Key]] , [[Value]] } entry 에 대해 다음을 수행합니다.! CreateDataPropertyOrThrow (importMeta , entry .[[Key]] , entry .[[Value]] )를 수행합니다. HostFinalizeImportMeta (importMeta , module )를 수행합니다.module .[[ImportMeta]] 를 importMeta 로 설정합니다.importMeta 를 반환합니다.단언 : importMeta 는 Object입니다.importMeta 를 반환합니다.
13.3.12.1.1 HostGetImportMetaProperties ( moduleRecord )
호스트 정의 추상 연산 HostGetImportMetaProperties. 인수 moduleRecord (Module 레코드 ). 반환값: 리스트 (요소: 레코드 (필드: [[Key]] (프로퍼티 키 ), [[Value]] (ECMAScript 언어 값 ))). 호스트 가 import.meta에서 반환하는 객체에 사용할 프로퍼티 키 와 값을 제공할 수 있도록 합니다.
HostGetImportMetaProperties의 기본 구현은 새로운 빈 List 를 반환합니다.
13.3.12.1.2 HostFinalizeImportMeta ( importMeta , moduleRecord )
호스트 정의 추상 연산 HostFinalizeImportMeta. 인수 importMeta (Object) 및 moduleRecord (Module 레코드 ). 반환값: unused . 호스트 가 import.meta에서 반환하는 객체를 준비하기 위해 모든 특수 연산을 수행할 수 있도록 합니다.
대부분의 호스트 는 HostGetImportMetaProperties 만 정의하고 HostFinalizeImportMeta는 기본 동작 그대로 둘 수 있습니다. 그러나 HostFinalizeImportMeta는 객체가 ECMAScript 코드에 노출되기 전에 이를 직접 조작해야 하는 호스트 를 위한 “탈출구”를 제공합니다.
HostFinalizeImportMeta의 기본 구현은 unused 를 반환합니다.
13.4 갱신 표현식
구문
UpdateExpression [Yield, Await] :
LeftHandSideExpression [?Yield, ?Await]
LeftHandSideExpression [?Yield, ?Await]
[no LineTerminator here]
++
LeftHandSideExpression [?Yield, ?Await]
[no LineTerminator here]
--
++
UnaryExpression [?Yield, ?Await]
--
UnaryExpression [?Yield, ?Await]
13.4.1 Static Semantics: 조기 오류
UpdateExpression :
LeftHandSideExpression
++
LeftHandSideExpression
--
UpdateExpression :
++
UnaryExpression
--
UnaryExpression
13.4.2 후위 증가 연산자
13.4.2.1 Runtime Semantics: 평가
UpdateExpression :
LeftHandSideExpression
++
lhs 를 LeftHandSideExpression 의 ? Evaluation 으로 둡니다.LeftHandSideExpression 의 AssignmentTargetType 이 web-compat 이면 ReferenceError 예외를 던집니다.oldValue 를 ? ToNumeric (? GetValue (lhs ))로 둡니다.oldValue 가 Number이면, 다음을 수행합니다.newValue 를 Number::add (oldValue , 1 𝔽 )로 둡니다.그렇지 않으면,단언 : oldValue 는 BigInt입니다.newValue 를 BigInt::add (oldValue , 1 ℤ )로 둡니다. ? PutValue (lhs , newValue )를 수행합니다. oldValue 를 반환합니다.
13.4.3 후위 감소 연산자
13.4.3.1 Runtime Semantics: 평가
UpdateExpression :
LeftHandSideExpression
--
lhs 를 LeftHandSideExpression 의 ? Evaluation 으로 둡니다.LeftHandSideExpression 의 AssignmentTargetType 이 web-compat 이면 ReferenceError 예외를 던집니다.oldValue 를 ? ToNumeric (? GetValue (lhs ))로 둡니다.oldValue 가 Number이면, 다음을 수행합니다.newValue 를 Number::subtract (oldValue , 1 𝔽 )로 둡니다.그렇지 않으면,단언 : oldValue 는 BigInt입니다.newValue 를 BigInt::subtract (oldValue , 1 ℤ )로 둡니다. ? PutValue (lhs , newValue )를 수행합니다. oldValue 를 반환합니다.
13.4.4 전위 증가 연산자
13.4.4.1 Runtime Semantics: 평가
UpdateExpression :
++
UnaryExpression
expr 을 UnaryExpression 의 ? Evaluation 으로 둡니다.UnaryExpression 의 AssignmentTargetType 이 web-compat 이면 ReferenceError 예외를 던집니다.oldValue 를 ? ToNumeric (? GetValue (expr ))로 둡니다.oldValue 가 Number이면, 다음을 수행합니다.newValue 를 Number::add (oldValue , 1 𝔽 )로 둡니다.그렇지 않으면,단언 : oldValue 는 BigInt입니다.newValue 를 BigInt::add (oldValue , 1 ℤ )로 둡니다. ? PutValue (expr , newValue )를 수행합니다. newValue 를 반환합니다.
13.4.5 전위 감소 연산자
13.4.5.1 Runtime Semantics: 평가
UpdateExpression :
--
UnaryExpression
expr 을 UnaryExpression 의 ? Evaluation 으로 둡니다.UnaryExpression 의 AssignmentTargetType 이 web-compat 이면 ReferenceError 예외를 던집니다.oldValue 를 ? ToNumeric (? GetValue (expr ))로 둡니다.oldValue 가 Number이면, 다음을 수행합니다.newValue 를 Number::subtract (oldValue , 1 𝔽 )로 둡니다.그렇지 않으면,단언 : oldValue 는 BigInt입니다.newValue 를 BigInt::subtract (oldValue , 1 ℤ )로 둡니다. ? PutValue (expr , newValue )를 수행합니다. newValue 를 반환합니다.
13.5 단항 연산자
구문
UnaryExpression [Yield, Await] :
UpdateExpression [?Yield, ?Await]
delete
UnaryExpression [?Yield, ?Await]
void
UnaryExpression [?Yield, ?Await]
typeof
UnaryExpression [?Yield, ?Await]
+
UnaryExpression [?Yield, ?Await]
-
UnaryExpression [?Yield, ?Await]
~
UnaryExpression [?Yield, ?Await]
!
UnaryExpression [?Yield, ?Await]
[+Await]
CoverAwaitExpressionAndAwaitUsingDeclarationHead [?Yield]
CoverAwaitExpressionAndAwaitUsingDeclarationHead [Yield] :
await
UnaryExpression [?Yield, +Await]
보충 구문
다음 생성 규칙의 인스턴스를 처리할 때
UnaryExpression : CoverAwaitExpressionAndAwaitUsingDeclarationHead
CoverAwaitExpressionAndAwaitUsingDeclarationHead 의 해석은 다음 문법을 사용하여 구체화됩니다:
AwaitExpression [Yield] :
await
UnaryExpression [?Yield, +Await]
13.5.1 delete 연산자
13.5.1.1 Static Semantics: 조기 오류
UnaryExpression :
delete
UnaryExpression
참고
마지막 규칙은 첫 번째 규칙을 재귀적으로 적용하기 때문에 delete (((foo)))와 같은 표현식이 조기 오류 를 생성함을 의미합니다.
13.5.1.2 Runtime Semantics: 평가
UnaryExpression :
delete
UnaryExpression
ref 를 UnaryExpression 의 ? Evaluation 으로 둡니다.ref 가 Reference Record 가 아니면 true 를 반환합니다.IsUnresolvableReference (ref )가 true 이면, 다음을 수행합니다.단언 : ref .[[Strict]] 은 false 입니다.true 를 반환합니다.IsPropertyReference (ref )가 true 이면, 다음을 수행합니다.단언 : IsPrivateReference (ref )는 false 입니다.IsSuperReference (ref )가 true 이면 ReferenceError 예외를 던집니다.baseObj 를 ? ToObject (ref .[[Base]] )로 둡니다.ref .[[ReferencedName]] 이 프로퍼티 키 가 아니면, 다음을 수행합니다.ref .[[ReferencedName]] 을 ? ToPropertyKey (ref .[[ReferencedName]] )로 설정합니다.deleteStatus 를 ? baseObj .[[Delete]] (ref .[[ReferencedName]] ) 로 둡니다.deleteStatus 가 false 이고 ref .[[Strict]] 이 true 이면 TypeError 예외를 던집니다.deleteStatus 를 반환합니다.base 를 ref .[[Base]] 로 둡니다.단언 : base 는 Environment Record 입니다.? base .DeleteBinding (ref .[[ReferencedName]] ) 을 반환합니다.
참고 1
delete 연산자가 엄격 모드 코드 안에 나타날 때 그 UnaryExpression 이 변수, 함수 인수 또는 함수 이름에 대한 직접 참조이면 SyntaxError 예외가 던져집니다. 또한 delete 연산자가 엄격 모드 코드 안에 나타나고 삭제할 프로퍼티의 속성이 { [[Configurable]] : false }이거나 다른 이유로 삭제할 수 없으면 TypeError 예외가 던져집니다.
참고 2
4.c 단계에서 생성될 수 있는 객체는 위 추상 연산 과 일반 객체 [[Delete]] 내부 메서드 바깥에서는 접근할 수 없습니다. 구현체는 실제로 해당 객체를 생성하지 않도록 선택할 수 있습니다.
13.5.2 void 연산자
13.5.2.1 Runtime Semantics: 평가
UnaryExpression :
void
UnaryExpression
expr 을 UnaryExpression 의 ? Evaluation 으로 둡니다.? GetValue (expr )를 수행합니다. undefined 를 반환합니다.
참고
값을 사용하지 않더라도 관찰 가능한 부작용이 있을 수 있으므로 GetValue 를 호출해야 합니다.
13.5.3 typeof 연산자
13.5.3.1 Runtime Semantics: 평가
UnaryExpression :
typeof
UnaryExpression
value 를 UnaryExpression 의 ? Evaluation 으로 둡니다.value 가 Reference Record 이면, 다음을 수행합니다.IsUnresolvableReference (value )가 true 이면 "undefined" 를 반환합니다.value 를 ? GetValue (value )로 설정합니다.value 가 undefined 이면 "undefined" 를 반환합니다.value 가 null 이면 "object" 를 반환합니다.value 가 String이면 "string" 을 반환합니다.value 가 Symbol이면 "symbol" 을 반환합니다.value 가 Boolean이면 "boolean" 을 반환합니다.value 가 Number이면 "number" 를 반환합니다.value 가 BigInt이면 "bigint" 를 반환합니다.단언 : value 는 Object입니다.Normative Optional
호스트 가 웹 브라우저이거나 그 밖의 방식으로 [[IsHTMLDDA]] 내부 슬롯 을 지원하면, 다음을 수행합니다.value 에 [[IsHTMLDDA]] 내부 슬롯이 있으면 "undefined" 를 반환합니다.value 에 [[Call]] 내부 메서드가 있으면 "function" 을 반환합니다."object" 를 반환합니다.
13.5.4 단항 + 연산자
참고
단항 + 연산자는 피연산자를 Number 타입 으로 변환합니다.
13.5.4.1 Runtime Semantics: 평가
UnaryExpression :
+
UnaryExpression
expr 을 UnaryExpression 의 ? Evaluation 으로 둡니다.? ToNumber (? GetValue (expr ))를 반환합니다.
13.5.5 단항 - 연산자
참고
단항 - 연산자는 피연산자를 숫자 값으로 변환한 다음 부호를 반전합니다. +0 𝔽 의 부호를 반전하면 -0 𝔽 이 되고, -0 𝔽 의 부호를 반전하면 +0 𝔽 이 됩니다.
13.5.5.1 Runtime Semantics: 평가
UnaryExpression :
-
UnaryExpression
expr 을 UnaryExpression 의 ? Evaluation 으로 둡니다.oldValue 를 ? ToNumeric (? GetValue (expr ))로 둡니다.oldValue 가 Number이면 Number::unaryMinus (oldValue )를 반환합니다.단언 : oldValue 는 BigInt입니다.BigInt::unaryMinus (oldValue )를 반환합니다.
13.5.6 비트 NOT 연산자 ( ~ )
13.5.6.1 Runtime Semantics: 평가
UnaryExpression :
~
UnaryExpression
expr 을 UnaryExpression 의 ? Evaluation 으로 둡니다.oldValue 를 ? ToNumeric (? GetValue (expr ))로 둡니다.oldValue 가 Number이면 Number::bitwiseNOT (oldValue )을 반환합니다.단언 : oldValue 는 BigInt입니다.BigInt::bitwiseNOT (oldValue )을 반환합니다.
13.5.7 논리 NOT 연산자 ( ! )
13.5.7.1 Runtime Semantics: 평가
UnaryExpression :
!
UnaryExpression
expr 을 UnaryExpression 의 ? Evaluation 으로 둡니다.oldValue 를 ToBoolean (? GetValue (expr ))로 둡니다.oldValue 가 true 이면 false 를 반환합니다.true 를 반환합니다.
13.6 지수 연산자
구문
ExponentiationExpression [Yield, Await] :
UnaryExpression [?Yield, ?Await]
UpdateExpression [?Yield, ?Await]
**
ExponentiationExpression [?Yield, ?Await]
13.6.1 Runtime Semantics: 평가
ExponentiationExpression :
UpdateExpression
**
ExponentiationExpression
? EvaluateStringOrNumericBinaryExpression (UpdateExpression , **, ExponentiationExpression )을 반환합니다.
13.7 곱셈 연산자
구문
MultiplicativeExpression [Yield, Await] :
ExponentiationExpression [?Yield, ?Await]
MultiplicativeExpression [?Yield, ?Await]
MultiplicativeOperator
ExponentiationExpression [?Yield, ?Await]
MultiplicativeOperator : one of * / %
참고
* 연산자는 곱셈을 수행하여 피연산자의 곱을 생성합니다.
/ 연산자는 나눗셈을 수행하여 피연산자의 몫을 생성합니다.
% 연산자는 암묵적인 나눗셈에서 피연산자의 나머지를 생성합니다.
13.7.1 Runtime Semantics: 평가
MultiplicativeExpression :
MultiplicativeExpression
MultiplicativeOperator
ExponentiationExpression
opText 를 MultiplicativeOperator 와 일치하는 소스 텍스트 로 둡니다.? EvaluateStringOrNumericBinaryExpression (MultiplicativeExpression , opText , ExponentiationExpression )을 반환합니다.
13.8 가산 연산자
구문
AdditiveExpression [Yield, Await] :
MultiplicativeExpression [?Yield, ?Await]
AdditiveExpression [?Yield, ?Await]
+
MultiplicativeExpression [?Yield, ?Await]
AdditiveExpression [?Yield, ?Await]
-
MultiplicativeExpression [?Yield, ?Await]
13.8.1 덧셈 연산자 ( + )
참고
덧셈 연산자는 문자열 연결 또는 숫자 덧셈을 수행합니다.
13.8.1.1 Runtime Semantics: 평가
AdditiveExpression :
AdditiveExpression
+
MultiplicativeExpression
? EvaluateStringOrNumericBinaryExpression (AdditiveExpression , +, MultiplicativeExpression )을 반환합니다.
13.8.2 뺄셈 연산자 ( - )
참고
- 연산자는 뺄셈을 수행하여 피연산자의 차를 생성합니다.
13.8.2.1 Runtime Semantics: 평가
AdditiveExpression :
AdditiveExpression
-
MultiplicativeExpression
? EvaluateStringOrNumericBinaryExpression (AdditiveExpression , -, MultiplicativeExpression )을 반환합니다.
13.9 비트 시프트 연산자
구문
ShiftExpression [Yield, Await] :
AdditiveExpression [?Yield, ?Await]
ShiftExpression [?Yield, ?Await]
<<
AdditiveExpression [?Yield, ?Await]
ShiftExpression [?Yield, ?Await]
>>
AdditiveExpression [?Yield, ?Await]
ShiftExpression [?Yield, ?Await]
>>>
AdditiveExpression [?Yield, ?Await]
13.9.1 왼쪽 시프트 연산자 ( << )
참고
왼쪽 피연산자에 대해 오른쪽 피연산자가 지정한 양만큼 비트 단위 왼쪽 시프트 연산을 수행합니다.
13.9.1.1 Runtime Semantics: 평가
ShiftExpression :
ShiftExpression
<<
AdditiveExpression
? EvaluateStringOrNumericBinaryExpression (ShiftExpression , <<, AdditiveExpression )을 반환합니다.
13.9.2 부호 있는 오른쪽 시프트 연산자 ( >> )
참고
왼쪽 피연산자에 대해 오른쪽 피연산자가 지정한 양만큼 부호를 채우는 비트 단위 오른쪽 시프트 연산을 수행합니다.
13.9.2.1 Runtime Semantics: 평가
ShiftExpression :
ShiftExpression
>>
AdditiveExpression
? EvaluateStringOrNumericBinaryExpression (ShiftExpression , >>, AdditiveExpression )을 반환합니다.
13.9.3 부호 없는 오른쪽 시프트 연산자 ( >>> )
참고
왼쪽 피연산자에 대해 오른쪽 피연산자가 지정한 양만큼 0을 채우는 비트 단위 오른쪽 시프트 연산을 수행합니다.
13.9.3.1 Runtime Semantics: 평가
ShiftExpression :
ShiftExpression
>>>
AdditiveExpression
? EvaluateStringOrNumericBinaryExpression (ShiftExpression , >>>, AdditiveExpression )을 반환합니다.
13.10 관계 연산자
참고 1
관계 연산자를 평가한 결과는 항상 Boolean 타입 이며, 연산자가 나타내는 관계가 두 피연산자 사이에서 성립하는지를 나타냅니다.
구문
RelationalExpression [In, Yield, Await] :
ShiftExpression [?Yield, ?Await]
RelationalExpression [?In, ?Yield, ?Await]
<
ShiftExpression [?Yield, ?Await]
RelationalExpression [?In, ?Yield, ?Await]
>
ShiftExpression [?Yield, ?Await]
RelationalExpression [?In, ?Yield, ?Await]
<=
ShiftExpression [?Yield, ?Await]
RelationalExpression [?In, ?Yield, ?Await]
>=
ShiftExpression [?Yield, ?Await]
RelationalExpression [?In, ?Yield, ?Await]
instanceof
ShiftExpression [?Yield, ?Await]
[+In]
RelationalExpression [+In, ?Yield, ?Await]
in
ShiftExpression [?Yield, ?Await]
[+In]
PrivateIdentifier
in
ShiftExpression [?Yield, ?Await]
참고 2
[In] 문법 매개변수는 관계 표현식의 in 연산자와 for 문의 in 연산자를 혼동하지 않도록 하기 위해 필요합니다.
13.10.1 Runtime Semantics: 평가
RelationalExpression :
RelationalExpression
<
ShiftExpression
leftRef 를 RelationalExpression 의 ? Evaluation 으로 둡니다.leftValue 를 ? GetValue (leftRef )로 둡니다.rightRef 를 ShiftExpression 의 ? Evaluation 으로 둡니다.rightValue 를 ? GetValue (rightRef )로 둡니다.result 를 ? IsLessThan (leftValue , rightValue , true )로 둡니다.result 가 undefined 이면 false 를 반환합니다.result 를 반환합니다.
RelationalExpression :
RelationalExpression
>
ShiftExpression
leftRef 를 RelationalExpression 의 ? Evaluation 으로 둡니다.leftValue 를 ? GetValue (leftRef )로 둡니다.rightRef 를 ShiftExpression 의 ? Evaluation 으로 둡니다.rightValue 를 ? GetValue (rightRef )로 둡니다.result 를 ? IsLessThan (rightValue , leftValue , false )로 둡니다.result 가 undefined 이면 false 를 반환합니다.result 를 반환합니다.
RelationalExpression :
RelationalExpression
<=
ShiftExpression
leftRef 를 RelationalExpression 의 ? Evaluation 으로 둡니다.leftValue 를 ? GetValue (leftRef )로 둡니다.rightRef 를 ShiftExpression 의 ? Evaluation 으로 둡니다.rightValue 를 ? GetValue (rightRef )로 둡니다.result 를 ? IsLessThan (rightValue , leftValue , false )로 둡니다.result 가 true 또는 undefined 이면 false 를 반환합니다.true 를 반환합니다.
RelationalExpression :
RelationalExpression
>=
ShiftExpression
leftRef 를 RelationalExpression 의 ? Evaluation 으로 둡니다.leftValue 를 ? GetValue (leftRef )로 둡니다.rightRef 를 ShiftExpression 의 ? Evaluation 으로 둡니다.rightValue 를 ? GetValue (rightRef )로 둡니다.result 를 ? IsLessThan (leftValue , rightValue , true )로 둡니다.result 가 true 또는 undefined 이면 false 를 반환합니다.true 를 반환합니다.
RelationalExpression :
RelationalExpression
instanceof
ShiftExpression
leftRef 를 RelationalExpression 의 ? Evaluation 으로 둡니다.leftValue 를 ? GetValue (leftRef )로 둡니다.rightRef 를 ShiftExpression 의 ? Evaluation 으로 둡니다.rightValue 를 ? GetValue (rightRef )로 둡니다.? InstanceofOperator (leftValue , rightValue )를 반환합니다.
RelationalExpression :
RelationalExpression
in
ShiftExpression
leftRef 를 RelationalExpression 의 ? Evaluation 으로 둡니다.leftValue 를 ? GetValue (leftRef )로 둡니다.rightRef 를 ShiftExpression 의 ? Evaluation 으로 둡니다.rightValue 를 ? GetValue (rightRef )로 둡니다.rightValue 가 Object가 아니면 TypeError 예외를 던집니다.? HasProperty (rightValue , ? ToPropertyKey (leftValue ))를 반환합니다.
RelationalExpression :
PrivateIdentifier
in
ShiftExpression
privateIdentifier 를 PrivateIdentifier 의 StringValue 로 둡니다.rightRef 를 ShiftExpression 의 ? Evaluation 으로 둡니다.rightValue 를 ? GetValue (rightRef )로 둡니다.rightValue 가 Object가 아니면 TypeError 예외를 던집니다.privateEnv 를 실행 중인 실행 컨텍스트 의 PrivateEnvironment로 둡니다.단언 : privateEnv 는 null 이 아닙니다.privateName 을 ResolvePrivateIdentifier (privateEnv , privateIdentifier )로 둡니다.PrivateElementFind (rightValue , privateName )이 empty 이면 false 를 반환합니다.true 를 반환합니다.
13.10.2 InstanceofOperator ( value , target )
추상 연산 InstanceofOperator. 인수 value (ECMAScript 언어 값 ) 및 target (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). target 의 %Symbol.hasInstance% 메서드를 참조하거나, 해당 메서드가 없으면 target 의 "prototype" 프로퍼티 값이 value 의 프로토타입 체인에 존재하는지를 결정하여 value 가 target 의 인스턴스인지 판별하는 일반 알고리즘을 구현합니다. 호출되면 다음 단계를 수행한다.
target 이 Object가 아니면 TypeError 예외를 던집니다.instOfHandler 를 ? GetMethod (target , %Symbol.hasInstance% )로 둡니다.instOfHandler 가 undefined 가 아니면, 다음을 수행합니다.ToBoolean (? Call (instOfHandler , target , « value »))을 반환합니다.IsCallable (target )이 false 이면 TypeError 예외를 던집니다.? OrdinaryHasInstance (target , value )를 반환합니다.
참고
4 및 5 단계는 instanceof 연산자의 의미론을 정의하는 데 %Symbol.hasInstance% 메서드를 사용하지 않았던 이전 ECMAScript 판과의 호환성을 제공합니다. 객체가 %Symbol.hasInstance% 를 정의하거나 상속하지 않으면 기본 instanceof 의미론을 사용합니다.
13.11 동등 연산자
참고
동등 연산자를 평가한 결과는 항상 Boolean 타입 이며, 연산자가 나타내는 관계가 두 피연산자 사이에서 성립하는지를 나타냅니다.
구문
EqualityExpression [In, Yield, Await] :
RelationalExpression [?In, ?Yield, ?Await]
EqualityExpression [?In, ?Yield, ?Await]
==
RelationalExpression [?In, ?Yield, ?Await]
EqualityExpression [?In, ?Yield, ?Await]
!=
RelationalExpression [?In, ?Yield, ?Await]
EqualityExpression [?In, ?Yield, ?Await]
===
RelationalExpression [?In, ?Yield, ?Await]
EqualityExpression [?In, ?Yield, ?Await]
!==
RelationalExpression [?In, ?Yield, ?Await]
13.11.1 Runtime Semantics: 평가
EqualityExpression :
EqualityExpression
==
RelationalExpression
leftRef 를 EqualityExpression 의 ? Evaluation 으로 둡니다.leftValue 를 ? GetValue (leftRef )로 둡니다.rightRef 를 RelationalExpression 의 ? Evaluation 으로 둡니다.rightValue 를 ? GetValue (rightRef )로 둡니다.? IsLooselyEqual (rightValue , leftValue )을 반환합니다.
EqualityExpression :
EqualityExpression
!=
RelationalExpression
leftRef 를 EqualityExpression 의 ? Evaluation 으로 둡니다.leftValue 를 ? GetValue (leftRef )로 둡니다.rightRef 를 RelationalExpression 의 ? Evaluation 으로 둡니다.rightValue 를 ? GetValue (rightRef )로 둡니다.result 를 ? IsLooselyEqual (rightValue , leftValue )로 둡니다.result 가 true 이면 false 를 반환합니다.true 를 반환합니다.
EqualityExpression :
EqualityExpression
===
RelationalExpression
leftRef 를 EqualityExpression 의 ? Evaluation 으로 둡니다.leftValue 를 ? GetValue (leftRef )로 둡니다.rightRef 를 RelationalExpression 의 ? Evaluation 으로 둡니다.rightValue 를 ? GetValue (rightRef )로 둡니다.IsStrictlyEqual (rightValue , leftValue )을 반환합니다.
EqualityExpression :
EqualityExpression
!==
RelationalExpression
leftRef 를 EqualityExpression 의 ? Evaluation 으로 둡니다.leftValue 를 ? GetValue (leftRef )로 둡니다.rightRef 를 RelationalExpression 의 ? Evaluation 으로 둡니다.rightValue 를 ? GetValue (rightRef )로 둡니다.result 를 IsStrictlyEqual (rightValue , leftValue )로 둡니다.result 가 true 이면 false 를 반환합니다.true 를 반환합니다.
참고 1
동등 연산자는 다음 불변 조건을 유지합니다:
A != B는 !(A == B)와 동등합니다.
A와 B의 평가 순서를 제외하면 A == B는 B == A와 동등합니다.
참고 2
동등 연산자는 항상 추이적인 것은 아닙니다. 예를 들어 각각 같은 String 값을 나타내는 서로 다른 두 String 객체가 있을 수 있습니다. 각 String 객체는 == 연산자에 의해 해당 String 값과 같다고 간주되지만 두 String 객체는 서로 같지 않습니다. 예:
new String("a") == "a" 및 "a" == new String("a")는 모두 true 입니다.
new String("a") == new String("a")는 false 입니다.
참고 3
String 비교는 코드 단위 값 시퀀스에 대한 단순 동등성 검사를 사용합니다. 유니코드 명세에 정의된 문자 또는 문자열 동등성과 정렬 순서 에 대한 더 복잡하고 의미 지향적인 정의를 사용하려고 시도하지 않습니다. 따라서 유니코드 표준에 따라 정규적으로 같은 String 값도 서로 같지 않은 것으로 판정될 수 있습니다. 사실상 이 알고리즘은 두 String이 이미 정규화된 형식이라고 가정합니다.
13.12 이항 비트 연산자
구문
BitwiseANDExpression [In, Yield, Await] :
EqualityExpression [?In, ?Yield, ?Await]
BitwiseANDExpression [?In, ?Yield, ?Await]
&
EqualityExpression [?In, ?Yield, ?Await]
BitwiseXORExpression [In, Yield, Await] :
BitwiseANDExpression [?In, ?Yield, ?Await]
BitwiseXORExpression [?In, ?Yield, ?Await]
^
BitwiseANDExpression [?In, ?Yield, ?Await]
BitwiseORExpression [In, Yield, Await] :
BitwiseXORExpression [?In, ?Yield, ?Await]
BitwiseORExpression [?In, ?Yield, ?Await]
|
BitwiseXORExpression [?In, ?Yield, ?Await]
13.12.1 Runtime Semantics: 평가
BitwiseANDExpression :
BitwiseANDExpression
&
EqualityExpression
? EvaluateStringOrNumericBinaryExpression (BitwiseANDExpression , &, EqualityExpression )을 반환합니다.
BitwiseXORExpression :
BitwiseXORExpression
^
BitwiseANDExpression
? EvaluateStringOrNumericBinaryExpression (BitwiseXORExpression , ^, BitwiseANDExpression )을 반환합니다.
BitwiseORExpression :
BitwiseORExpression
|
BitwiseXORExpression
? EvaluateStringOrNumericBinaryExpression (BitwiseORExpression , |, BitwiseXORExpression )을 반환합니다.
13.13 이항 논리 연산자
구문
LogicalANDExpression [In, Yield, Await] :
BitwiseORExpression [?In, ?Yield, ?Await]
LogicalANDExpression [?In, ?Yield, ?Await]
&&
BitwiseORExpression [?In, ?Yield, ?Await]
LogicalORExpression [In, Yield, Await] :
LogicalANDExpression [?In, ?Yield, ?Await]
LogicalORExpression [?In, ?Yield, ?Await]
||
LogicalANDExpression [?In, ?Yield, ?Await]
CoalesceExpression [In, Yield, Await] :
CoalesceExpressionHead [?In, ?Yield, ?Await]
??
BitwiseORExpression [?In, ?Yield, ?Await]
CoalesceExpressionHead [In, Yield, Await] :
CoalesceExpression [?In, ?Yield, ?Await]
BitwiseORExpression [?In, ?Yield, ?Await]
ShortCircuitExpression [In, Yield, Await] :
LogicalORExpression [?In, ?Yield, ?Await]
CoalesceExpression [?In, ?Yield, ?Await]
참고
&& 또는 || 연산자가 생성하는 값은 반드시 Boolean 타입 일 필요는 없습니다. 생성되는 값은 항상 두 피연산자 표현식 중 하나의 값입니다.
13.13.1 Runtime Semantics: 평가
LogicalANDExpression :
LogicalANDExpression
&&
BitwiseORExpression
leftRef 를 LogicalANDExpression 의 ? Evaluation 으로 둡니다.leftValue 를 ? GetValue (leftRef )로 둡니다.ToBoolean (leftValue )이 false 이면 leftValue 를 반환합니다.rightRef 를 BitwiseORExpression 의 ? Evaluation 으로 둡니다.? GetValue (rightRef )를 반환합니다.
LogicalORExpression :
LogicalORExpression
||
LogicalANDExpression
leftRef 를 LogicalORExpression 의 ? Evaluation 으로 둡니다.leftValue 를 ? GetValue (leftRef )로 둡니다.ToBoolean (leftValue )이 true 이면 leftValue 를 반환합니다.rightRef 를 LogicalANDExpression 의 ? Evaluation 으로 둡니다.? GetValue (rightRef )를 반환합니다.
CoalesceExpression :
CoalesceExpressionHead
??
BitwiseORExpression
leftRef 를 CoalesceExpressionHead 의 ? Evaluation 으로 둡니다.leftValue 를 ? GetValue (leftRef )로 둡니다.leftValue 가 undefined 도 null 도 아니면 leftValue 를 반환합니다.rightRef 를 BitwiseORExpression 의 ? Evaluation 으로 둡니다.? GetValue (rightRef )를 반환합니다.
13.14 조건 연산자 ( ? : )
구문
ConditionalExpression [In, Yield, Await] :
ShortCircuitExpression [?In, ?Yield, ?Await]
ShortCircuitExpression [?In, ?Yield, ?Await]
?
AssignmentExpression [+In, ?Yield, ?Await]
:
AssignmentExpression [?In, ?Yield, ?Await]
참고
ECMAScript의 ConditionalExpression 문법은 두 번째 하위 표현식을 Expression 로 허용하지만 세 번째 표현식은 ConditionalExpression 로 제한하는 C 및 Java의 문법과 약간 다릅니다. ECMAScript에서 이렇게 다른 이유는 조건문의 어느 분기에서도 할당 표현식을 사용할 수 있도록 하고, 가운데 표현식에 쉼표 표현식을 사용하는 혼란스럽고 실용성이 매우 낮은 경우를 제거하기 위해서입니다.
13.14.1 Runtime Semantics: 평가
ConditionalExpression :
ShortCircuitExpression
?
AssignmentExpression
:
AssignmentExpression
leftRef 를 ShortCircuitExpression 의 ? Evaluation 으로 둡니다.leftValue 를 ToBoolean (? GetValue (leftRef ))로 둡니다.leftValue 가 true 이면, 다음을 수행합니다.trueRef 를 첫 번째 AssignmentExpression 의 ? Evaluation 으로 둡니다.? GetValue (trueRef )를 반환합니다. falseRef 를 두 번째 AssignmentExpression 의 ? Evaluation 으로 둡니다.? GetValue (falseRef )를 반환합니다.
13.15 할당 연산자
구문
AssignmentExpression [In, Yield, Await] :
ConditionalExpression [?In, ?Yield, ?Await]
[+Yield]
YieldExpression [?In, ?Await]
ArrowFunction [?In, ?Yield, ?Await]
AsyncArrowFunction [?In, ?Yield, ?Await]
LeftHandSideExpression [?Yield, ?Await]
=
AssignmentExpression [?In, ?Yield, ?Await]
LeftHandSideExpression [?Yield, ?Await]
AssignmentOperator
AssignmentExpression [?In, ?Yield, ?Await]
LeftHandSideExpression [?Yield, ?Await]
&&=
AssignmentExpression [?In, ?Yield, ?Await]
LeftHandSideExpression [?Yield, ?Await]
||=
AssignmentExpression [?In, ?Yield, ?Await]
LeftHandSideExpression [?Yield, ?Await]
??=
AssignmentExpression [?In, ?Yield, ?Await]
AssignmentOperator : one of *= /= %= += -= <<= >>= >>>= &= ^= |= **=
13.15.1 Static Semantics: 조기 오류
AssignmentExpression :
LeftHandSideExpression
=
AssignmentExpression
AssignmentExpression :
LeftHandSideExpression
AssignmentOperator
AssignmentExpression
AssignmentExpression :
LeftHandSideExpression
&&=
AssignmentExpression
LeftHandSideExpression
||=
AssignmentExpression
LeftHandSideExpression
??=
AssignmentExpression
13.15.2 Runtime Semantics: 평가
AssignmentExpression :
LeftHandSideExpression
=
AssignmentExpression
LeftHandSideExpression 이 ObjectLiteral 도 ArrayLiteral 도 아니면, 다음을 수행합니다.leftRef 를 LeftHandSideExpression 의 ? Evaluation 으로 둡니다.LeftHandSideExpression 의 AssignmentTargetType 이 web-compat 이면 ReferenceError 예외를 던집니다.IsAnonymousFunctionDefinition (AssignmentExpression )이 true 이고 LeftHandSideExpression 의 IsIdentifierRef 가 true 이면, 다음을 수행합니다.lhs 를 LeftHandSideExpression 의 StringValue 로 둡니다.rightValue 를 인수 lhs 를 사용한 AssignmentExpression 의 ? NamedEvaluation 으로 둡니다.그렇지 않으면,rightRef 를 AssignmentExpression 의 ? Evaluation 으로 둡니다.rightValue 를 ? GetValue (rightRef )로 둡니다. ? PutValue (leftRef , rightValue )를 수행합니다. rightValue 를 반환합니다.assignmentPattern 을 LeftHandSideExpression 이 포괄하는 AssignmentPattern 으로 둡니다.rightRef 를 AssignmentExpression 의 ? Evaluation 으로 둡니다.rightValue 를 ? GetValue (rightRef )로 둡니다.인수 rightValue 를 사용한 assignmentPattern 의 ? DestructuringAssignmentEvaluation 을 수행합니다. rightValue 를 반환합니다.
AssignmentExpression :
LeftHandSideExpression
AssignmentOperator
AssignmentExpression
leftRef 를 LeftHandSideExpression 의 ? Evaluation 으로 둡니다.LeftHandSideExpression 의 AssignmentTargetType 이 web-compat 이면 ReferenceError 예외를 던집니다.leftValue 를 ? GetValue (leftRef )로 둡니다.rightRef 를 AssignmentExpression 의 ? Evaluation 으로 둡니다.rightValue 를 ? GetValue (rightRef )로 둡니다.assignmentOpText 를 AssignmentOperator 와 일치하는 소스 텍스트 로 둡니다.opText 를 다음 표에서 assignmentOpText 와 연결된 유니코드 코드 포인트 시퀀스로 둡니다:
assignmentOpText opText
**= **
*= *
/= /
%= %
+= +
-= -
<<= <<
>>= >>
>>>= >>>
&= &
^= ^
|= |
result 를 ? ApplyStringOrNumericBinaryOperator (leftValue , opText , rightValue )로 둡니다.? PutValue (leftRef , result )를 수행합니다. result 를 반환합니다.
AssignmentExpression :
LeftHandSideExpression
&&=
AssignmentExpression
leftRef 를 LeftHandSideExpression 의 ? Evaluation 으로 둡니다.leftValue 를 ? GetValue (leftRef )로 둡니다.ToBoolean (leftValue )이 false 이면 leftValue 를 반환합니다.IsAnonymousFunctionDefinition (AssignmentExpression )이 true 이고 LeftHandSideExpression 의 IsIdentifierRef 가 true 이면, 다음을 수행합니다.lhs 를 LeftHandSideExpression 의 StringValue 로 둡니다.rightValue 를 인수 lhs 를 사용한 AssignmentExpression 의 ? NamedEvaluation 으로 둡니다.그렇지 않으면,rightRef 를 AssignmentExpression 의 ? Evaluation 으로 둡니다.rightValue 를 ? GetValue (rightRef )로 둡니다. ? PutValue (leftRef , rightValue )를 수행합니다. rightValue 를 반환합니다.
AssignmentExpression :
LeftHandSideExpression
||=
AssignmentExpression
leftRef 를 LeftHandSideExpression 의 ? Evaluation 으로 둡니다.leftValue 를 ? GetValue (leftRef )로 둡니다.ToBoolean (leftValue )이 true 이면 leftValue 를 반환합니다.IsAnonymousFunctionDefinition (AssignmentExpression )이 true 이고 LeftHandSideExpression 의 IsIdentifierRef 가 true 이면, 다음을 수행합니다.lhs 를 LeftHandSideExpression 의 StringValue 로 둡니다.rightValue 를 인수 lhs 를 사용한 AssignmentExpression 의 ? NamedEvaluation 으로 둡니다.그렇지 않으면,rightRef 를 AssignmentExpression 의 ? Evaluation 으로 둡니다.rightValue 를 ? GetValue (rightRef )로 둡니다. ? PutValue (leftRef , rightValue )를 수행합니다. rightValue 를 반환합니다.
AssignmentExpression :
LeftHandSideExpression
??=
AssignmentExpression
leftRef 를 LeftHandSideExpression 의 ? Evaluation 으로 둡니다.leftValue 를 ? GetValue (leftRef )로 둡니다.leftValue 가 undefined 도 null 도 아니면 leftValue 를 반환합니다.IsAnonymousFunctionDefinition (AssignmentExpression )이 true 이고 LeftHandSideExpression 의 IsIdentifierRef 가 true 이면, 다음을 수행합니다.lhs 를 LeftHandSideExpression 의 StringValue 로 둡니다.rightValue 를 인수 lhs 를 사용한 AssignmentExpression 의 ? NamedEvaluation 으로 둡니다.그렇지 않으면,rightRef 를 AssignmentExpression 의 ? Evaluation 으로 둡니다.rightValue 를 ? GetValue (rightRef )로 둡니다. ? PutValue (leftRef , rightValue )를 수행합니다. rightValue 를 반환합니다.
참고
이 표현식이 엄격 모드 코드 안에 나타날 때 1.e , 3 , 2 , 2 , 2 단계의 leftRef 가 해석 불가능한 참조이면 런타임 오류입니다. 이 경우 ReferenceError 예외를 던집니다. 또한 9 , 6 , 6 , 6 단계의 leftRef 가 속성 값 { [[Writable]] : false }를 갖는 데이터 프로퍼티 , 속성 값 { [[Setter]] : undefined }를 갖는 접근자 프로퍼티 , 또는 IsExtensible 술어가 false 를 반환하는 객체의 존재하지 않는 프로퍼티에 대한 참조이면 런타임 오류입니다. 이러한 경우에는 TypeError 예외를 던집니다.
13.15.3 ApplyStringOrNumericBinaryOperator ( leftValue , opText , rightValue )
추상 연산 ApplyStringOrNumericBinaryOperator. 인수 leftValue (ECMAScript 언어 값 ), opText ((**, *, /, %, +, -, <<, >>, >>>, &, ^ 또는 |)) 및 rightValue (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: (String, BigInt 또는 Number)) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
opText 가 +이면, 다음을 수행합니다.leftPrimitive 를 ? ToPrimitive (leftValue )로 둡니다.rightPrimitive 를 ? ToPrimitive (rightValue )로 둡니다.leftPrimitive 가 String이거나 rightPrimitive 가 String이면, 다음을 수행합니다.leftString 을 ? ToString (leftPrimitive )으로 둡니다.rightString 을 ? ToString (rightPrimitive )으로 둡니다.leftString 과 rightString 의 문자열 연결 을 반환합니다.leftValue 를 leftPrimitive 로 설정합니다.rightValue 를 rightPrimitive 로 설정합니다.참고 : 이 시점에서는 숫자 연산이어야 합니다.leftNumber 를 ? ToNumeric (leftValue )로 둡니다.rightNumber 를 ? ToNumeric (rightValue )로 둡니다.SameType (leftNumber , rightNumber )이 false 이면 TypeError 예외를 던집니다.leftNumber 가 BigInt이면, 다음을 수행합니다.opText 가 **이면 ? BigInt::exponentiate (leftNumber , rightNumber )를 반환합니다.opText 가 /이면 ? BigInt::divide (leftNumber , rightNumber )를 반환합니다.opText 가 %이면 ? BigInt::remainder (leftNumber , rightNumber )를 반환합니다.opText 가 >>>이면 ? BigInt::unsignedRightShift (leftNumber , rightNumber )를 반환합니다.operation 을 다음 표에서 opText 와 연결된 추상 연산 으로 둡니다:
그렇지 않으면,단언 : leftNumber 는 Number입니다.operation 을 다음 표에서 opText 와 연결된 추상 연산 으로 둡니다:
operation (leftNumber , rightNumber )을 반환합니다.
참고 1
1.a 및 1.b 단계의 ToPrimitive 호출에는 hint가 제공되지 않습니다. Date를 제외한 모든 표준 객체는 hint가 없는 경우를 number 가 제공된 것처럼 처리하며, Date는 hint가 없는 경우를 string 이 제공된 것처럼 처리합니다. 특수 객체 는 hint가 없는 경우를 다른 방식으로 처리할 수 있습니다.
참고 2
1.c 단계는 logical-and 연산 대신 logical-or 연산을 사용한다는 점에서 IsLessThan 알고리즘의 3 단계와 다릅니다.
13.15.4 EvaluateStringOrNumericBinaryExpression ( leftOperand , opText , rightOperand )
추상 연산 EvaluateStringOrNumericBinaryExpression. 인수 leftOperand (구문 분석 노드), opText ((**, *, /, %, +, -, <<, >>, >>>, &, ^ 또는 |)) 및 rightOperand (구문 분석 노드). 반환값: (정상 완료 (값: (String, BigInt 또는 Number)) 또는 중도 완료). 호출되면 다음 단계를 수행한다.
leftRef 를 leftOperand 의 ? Evaluation 으로 둡니다.leftValue 를 ? GetValue (leftRef )로 둡니다.rightRef 를 rightOperand 의 ? Evaluation 으로 둡니다.rightValue 를 ? GetValue (rightRef )로 둡니다.? ApplyStringOrNumericBinaryOperator (leftValue , opText , rightValue )를 반환합니다.
13.15.5 구조 분해 할당
보충 구문
특정 상황에서 다음 생성 규칙의 인스턴스를 처리할 때
AssignmentExpression :
LeftHandSideExpression
=
AssignmentExpression
LeftHandSideExpression 의 해석은 다음 문법을 사용하여 구체화됩니다:
AssignmentPattern [Yield, Await] :
ObjectAssignmentPattern [?Yield, ?Await]
ArrayAssignmentPattern [?Yield, ?Await]
ObjectAssignmentPattern [Yield, Await] :
{
}
{
AssignmentRestProperty [?Yield, ?Await]
}
{
AssignmentPropertyList [?Yield, ?Await]
,opt
}
{
AssignmentPropertyList [?Yield, ?Await]
,
AssignmentRestProperty [?Yield, ?Await]
}
ArrayAssignmentPattern [Yield, Await] :
[
Elision opt
AssignmentRestElement [?Yield, ?Await] opt
]
[
AssignmentElementList [?Yield, ?Await]
]
[
AssignmentElementList [?Yield, ?Await]
,
Elision opt
AssignmentRestElement [?Yield, ?Await] opt
]
AssignmentRestProperty [Yield, Await] :
...
DestructuringAssignmentTarget [?Yield, ?Await]
AssignmentPropertyList [Yield, Await] :
AssignmentProperty [?Yield, ?Await]
AssignmentPropertyList [?Yield, ?Await]
,
AssignmentProperty [?Yield, ?Await]
AssignmentElementList [Yield, Await] :
AssignmentElisionElement [?Yield, ?Await]
AssignmentElementList [?Yield, ?Await]
,
AssignmentElisionElement [?Yield, ?Await]
AssignmentElisionElement [Yield, Await] :
Elision opt
AssignmentElement [?Yield, ?Await]
AssignmentProperty [Yield, Await] :
IdentifierReference [?Yield, ?Await]
Initializer [+In, ?Yield, ?Await] opt
PropertyName [?Yield, ?Await]
:
AssignmentElement [?Yield, ?Await]
AssignmentElement [Yield, Await] :
DestructuringAssignmentTarget [?Yield, ?Await]
Initializer [+In, ?Yield, ?Await] opt
AssignmentRestElement [Yield, Await] :
...
DestructuringAssignmentTarget [?Yield, ?Await]
DestructuringAssignmentTarget [Yield, Await] :
LeftHandSideExpression [?Yield, ?Await]
13.15.5.1 Static Semantics: 조기 오류
AssignmentProperty :
IdentifierReference
Initializer opt
AssignmentRestProperty :
...
DestructuringAssignmentTarget
DestructuringAssignmentTarget : LeftHandSideExpression
13.15.5.2 Runtime Semantics: DestructuringAssignmentEvaluation
구문 지향 연산 DestructuringAssignmentEvaluation. 인수 value (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: unused ) 또는 중도 완료). 다음 생성 규칙별로 정의된다.
ObjectAssignmentPattern :
{
}
? RequireObjectCoercible (value )를 수행합니다. unused 를 반환합니다.
ObjectAssignmentPattern :
{
AssignmentPropertyList
,opt
}
? RequireObjectCoercible (value )를 수행합니다. 인수 value 를 사용한 AssignmentPropertyList 의 ? PropertyDestructuringAssignmentEvaluation 을 수행합니다. unused 를 반환합니다.
ObjectAssignmentPattern :
{
AssignmentRestProperty
}
? RequireObjectCoercible (value )를 수행합니다. excludedNames 를 새로운 빈 List 로 둡니다.인수 value 및 excludedNames 를 사용한 AssignmentRestProperty 의 ? RestDestructuringAssignmentEvaluation 을 반환합니다.
ObjectAssignmentPattern :
{
AssignmentPropertyList
,
AssignmentRestProperty
}
? RequireObjectCoercible (value )를 수행합니다. excludedNames 를 인수 value 를 사용한 AssignmentPropertyList 의 ? PropertyDestructuringAssignmentEvaluation 으로 둡니다.인수 value 및 excludedNames 를 사용한 AssignmentRestProperty 의 ? RestDestructuringAssignmentEvaluation 을 반환합니다.
ArrayAssignmentPattern :
[
]
iteratorRecord 를 ? GetIterator (value , sync )로 둡니다.? IteratorClose (iteratorRecord , NormalCompletion (unused ))를 반환합니다.
ArrayAssignmentPattern :
[
Elision
]
iteratorRecord 를 ? GetIterator (value , sync )로 둡니다.result 를 Completion (인수 iteratorRecord 를 사용한 Elision 의 IteratorDestructuringAssignmentEvaluation )로 둡니다.iteratorRecord .[[Done]] 이 false 이면 ? IteratorClose (iteratorRecord , result )를 반환합니다.result 를 반환합니다.
ArrayAssignmentPattern :
[
Elision opt
AssignmentRestElement
]
iteratorRecord 를 ? GetIterator (value , sync )로 둡니다.Elision 이 존재하면, 다음을 수행합니다.status 를 Completion (인수 iteratorRecord 를 사용한 Elision 의 IteratorDestructuringAssignmentEvaluation )로 둡니다.status 가 비정상 완료 이면, 다음을 수행합니다.단언 : iteratorRecord .[[Done]] 은 true 입니다.? status 를 반환합니다. result 를 Completion (인수 iteratorRecord 를 사용한 AssignmentRestElement 의 IteratorDestructuringAssignmentEvaluation )로 둡니다.iteratorRecord .[[Done]] 이 false 이면 ? IteratorClose (iteratorRecord , result )를 반환합니다.result 를 반환합니다.
ArrayAssignmentPattern :
[
AssignmentElementList
]
iteratorRecord 를 ? GetIterator (value , sync )로 둡니다.result 를 Completion (인수 iteratorRecord 를 사용한 AssignmentElementList 의 IteratorDestructuringAssignmentEvaluation )로 둡니다.iteratorRecord .[[Done]] 이 false 이면 ? IteratorClose (iteratorRecord , result )를 반환합니다.result 를 반환합니다.
ArrayAssignmentPattern :
[
AssignmentElementList
,
Elision opt
AssignmentRestElement opt
]
iteratorRecord 를 ? GetIterator (value , sync )로 둡니다.status 를 Completion (인수 iteratorRecord 를 사용한 AssignmentElementList 의 IteratorDestructuringAssignmentEvaluation )로 둡니다.status 가 비정상 완료 이면, 다음을 수행합니다.iteratorRecord .[[Done]] 이 false 이면 ? IteratorClose (iteratorRecord , status )를 반환합니다.? status 를 반환합니다. Elision 이 존재하면, 다음을 수행합니다.status 를 Completion (인수 iteratorRecord 를 사용한 Elision 의 IteratorDestructuringAssignmentEvaluation )으로 설정합니다.status 가 비정상 완료 이면, 다음을 수행합니다.단언 : iteratorRecord .[[Done]] 은 true 입니다.? status 를 반환합니다. AssignmentRestElement 가 존재하면, 다음을 수행합니다.status 를 Completion (인수 iteratorRecord 를 사용한 AssignmentRestElement 의 IteratorDestructuringAssignmentEvaluation )으로 설정합니다.iteratorRecord .[[Done]] 이 false 이면 ? IteratorClose (iteratorRecord , status )를 반환합니다.? status 를 반환합니다.
13.15.5.3 Runtime Semantics: PropertyDestructuringAssignmentEvaluation
구문 지향 연산 PropertyDestructuringAssignmentEvaluation. 인수 value (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: 리스트 (요소: 프로퍼티 키 )) 또는 중도 완료). 구조 분해된 모든 프로퍼티 키 의 목록을 수집합니다. 다음 생성 규칙별로 정의된다.
AssignmentPropertyList :
AssignmentPropertyList
,
AssignmentProperty
propertyNames 를 인수 value 를 사용한 AssignmentPropertyList 의 ? PropertyDestructuringAssignmentEvaluation 으로 둡니다.nextNames 를 인수 value 를 사용한 AssignmentProperty 의 ? PropertyDestructuringAssignmentEvaluation 으로 둡니다.propertyNames 와 nextNames 의 목록 연결 을 반환합니다.
AssignmentProperty :
IdentifierReference
Initializer opt
propertyName 을 IdentifierReference 의 StringValue 로 둡니다.leftRef 를 ? ResolveBinding (propertyName )으로 둡니다.value 를 ? GetV (value , propertyName )로 설정합니다.Initializer 가 존재하고 value 가 undefined 이면, 다음을 수행합니다.IsAnonymousFunctionDefinition (Initializer )이 true 이면, 다음을 수행합니다.value 를 인수 propertyName 을 사용한 Initializer 의 ? NamedEvaluation 으로 설정합니다.그렇지 않으면,defaultValue 를 Initializer 의 ? Evaluation 으로 둡니다.value 를 ? GetValue (defaultValue )로 설정합니다. ? PutValue (leftRef , value )를 수행합니다. « propertyName »을 반환합니다.
AssignmentProperty :
PropertyName
:
AssignmentElement
name 을 PropertyName 의 ? Evaluation 으로 둡니다.인수 value 및 name 을 사용한 AssignmentElement 의 ? KeyedDestructuringAssignmentEvaluation 을 수행합니다. « name »을 반환합니다.
13.15.5.4 Runtime Semantics: RestDestructuringAssignmentEvaluation
구문 지향 연산 RestDestructuringAssignmentEvaluation. 인수 value (ECMAScript 언어 값 ) 및 excludedNames (리스트 (요소: 프로퍼티 키 )). 반환값: (정상 완료 (값: unused ) 또는 중도 완료). 다음 생성 규칙별로 정의된다.
AssignmentRestProperty :
...
DestructuringAssignmentTarget
leftRef 를 DestructuringAssignmentTarget 의 ? Evaluation 으로 둡니다.restObj 를 OrdinaryObjectCreate (%Object.prototype% )로 둡니다.? CopyDataProperties (restObj , value , excludedNames )를 수행합니다. ? PutValue (leftRef , restObj )를 반환합니다.
13.15.5.5 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
구문 지향 연산 IteratorDestructuringAssignmentEvaluation. 인수 iteratorRecord (Iterator 레코드 ). 반환값: (정상 완료 (값: unused ) 또는 중도 완료). 다음 생성 규칙별로 정의된다.
AssignmentElementList : AssignmentElisionElement
인수 iteratorRecord 를 사용한 AssignmentElisionElement 의 ? IteratorDestructuringAssignmentEvaluation 을 반환합니다.
AssignmentElementList :
AssignmentElementList
,
AssignmentElisionElement
인수 iteratorRecord 를 사용한 AssignmentElementList 의 ? IteratorDestructuringAssignmentEvaluation 을 수행합니다. 인수 iteratorRecord 를 사용한 AssignmentElisionElement 의 ? IteratorDestructuringAssignmentEvaluation 을 반환합니다.
AssignmentElisionElement : AssignmentElement
인수 iteratorRecord 를 사용한 AssignmentElement 의 ? IteratorDestructuringAssignmentEvaluation 을 반환합니다.
AssignmentElisionElement :
Elision
AssignmentElement
인수 iteratorRecord 를 사용한 Elision 의 ? IteratorDestructuringAssignmentEvaluation 을 수행합니다. 인수 iteratorRecord 를 사용한 AssignmentElement 의 ? IteratorDestructuringAssignmentEvaluation 을 반환합니다.
Elision : ,
iteratorRecord .[[Done]] 이 false 이면, 다음을 수행합니다.? IteratorStep (iteratorRecord )을 수행합니다. unused 를 반환합니다.
Elision :
Elision
,
인수 iteratorRecord 를 사용한 Elision 의 ? IteratorDestructuringAssignmentEvaluation 을 수행합니다. iteratorRecord .[[Done]] 이 false 이면, 다음을 수행합니다.? IteratorStep (iteratorRecord )을 수행합니다. unused 를 반환합니다.
AssignmentElement :
DestructuringAssignmentTarget
Initializer opt
DestructuringAssignmentTarget 이 ObjectLiteral 도 ArrayLiteral 도 아니면, 다음을 수행합니다.leftRef 를 DestructuringAssignmentTarget 의 ? Evaluation 으로 둡니다.value 를 undefined 로 둡니다.iteratorRecord .[[Done]] 이 false 이면, 다음을 수행합니다.next 를 ? IteratorStepValue (iteratorRecord )로 둡니다.next 가 done 이 아니면, 다음을 수행합니다.value 를 next 로 설정합니다.Initializer 가 존재하고 value 가 undefined 이면, 다음을 수행합니다.IsAnonymousFunctionDefinition (Initializer )이 true 이고 DestructuringAssignmentTarget 의 IsIdentifierRef 가 true 이면, 다음을 수행합니다.target 을 DestructuringAssignmentTarget 의 StringValue 로 둡니다.value 를 인수 target 을 사용한 Initializer 의 ? NamedEvaluation 으로 설정합니다.그렇지 않으면,defaultValue 를 Initializer 의 ? Evaluation 으로 둡니다.value 를 ? GetValue (defaultValue )로 설정합니다. DestructuringAssignmentTarget 이 ObjectLiteral 또는 ArrayLiteral 이면, 다음을 수행합니다.nestedAssignmentPattern 을 DestructuringAssignmentTarget 이 포괄하는 AssignmentPattern 으로 둡니다.인수 value 를 사용한 nestedAssignmentPattern 의 ? DestructuringAssignmentEvaluation 을 반환합니다. ? PutValue (leftRef , value )를 반환합니다.
참고
구조 분해 패턴이 아닌 DestructuringAssignmentTarget 을 반복자에 접근하거나 Initializer 를 평가하기 전에 평가하여 왼쪽에서 오른쪽으로의 평가 순서를 유지합니다.
AssignmentRestElement :
...
DestructuringAssignmentTarget
DestructuringAssignmentTarget 이 ObjectLiteral 도 ArrayLiteral 도 아니면, 다음을 수행합니다.leftRef 를 DestructuringAssignmentTarget 의 ? Evaluation 으로 둡니다.array 를 ! ArrayCreate (0)으로 둡니다.n 을 0으로 둡니다.iteratorRecord .[[Done]] 이 false 인 동안 다음을 반복합니다.next 를 ? IteratorStepValue (iteratorRecord )로 둡니다.next 가 done 이 아니면, 다음을 수행합니다.! CreateDataPropertyOrThrow (array , ! ToString (𝔽 (n )), next )를 수행합니다. n 을 n + 1로 설정합니다.DestructuringAssignmentTarget 이 ObjectLiteral 도 ArrayLiteral 도 아니면, 다음을 수행합니다.? PutValue (leftRef , array )를 반환합니다. nestedAssignmentPattern 을 DestructuringAssignmentTarget 이 포괄하는 AssignmentPattern 으로 둡니다.인수 array 를 사용한 nestedAssignmentPattern 의 ? DestructuringAssignmentEvaluation 을 반환합니다.
13.15.5.6 Runtime Semantics: KeyedDestructuringAssignmentEvaluation
구문 지향 연산 KeyedDestructuringAssignmentEvaluation. 인수 value (ECMAScript 언어 값 ) 및 propertyName (프로퍼티 키 ). 반환값: (정상 완료 (값: unused ) 또는 중도 완료). 다음 생성 규칙별로 정의된다.
AssignmentElement :
DestructuringAssignmentTarget
Initializer opt
DestructuringAssignmentTarget 이 ObjectLiteral 도 ArrayLiteral 도 아니면, 다음을 수행합니다.leftRef 를 DestructuringAssignmentTarget 의 ? Evaluation 으로 둡니다.value 를 ? GetV (value , propertyName )로 설정합니다.Initializer 가 존재하고 value 가 undefined 이면, 다음을 수행합니다.IsAnonymousFunctionDefinition (Initializer )이 true 이고 DestructuringAssignmentTarget 의 IsIdentifierRef 가 true 이면, 다음을 수행합니다.target 을 DestructuringAssignmentTarget 의 StringValue 로 둡니다.rhsValue 를 인수 target 을 사용한 Initializer 의 ? NamedEvaluation 으로 둡니다.그렇지 않으면,defaultValue 를 Initializer 의 ? Evaluation 으로 둡니다.rhsValue 를 ? GetValue (defaultValue )로 둡니다. 그렇지 않으면,rhsValue 를 value 로 둡니다. DestructuringAssignmentTarget 이 ObjectLiteral 또는 ArrayLiteral 이면, 다음을 수행합니다.assignmentPattern 을 DestructuringAssignmentTarget 이 포괄하는 AssignmentPattern 으로 둡니다.인수 rhsValue 를 사용한 assignmentPattern 의 ? DestructuringAssignmentEvaluation 을 반환합니다. ? PutValue (leftRef , rhsValue )를 반환합니다.
13.16 쉼표 연산자 ( , )
구문
Expression [In, Yield, Await] :
AssignmentExpression [?In, ?Yield, ?Await]
Expression [?In, ?Yield, ?Await]
,
AssignmentExpression [?In, ?Yield, ?Await]
13.16.1 Runtime Semantics: 평가
Expression :
Expression
,
AssignmentExpression
leftRef 를 Expression 의 ? Evaluation 으로 둡니다.? GetValue (leftRef )를 수행합니다. rightRef 를 AssignmentExpression 의 ? Evaluation 으로 둡니다.? GetValue (rightRef )를 반환합니다.
참고
값을 사용하지 않더라도 관찰 가능한 부작용이 있을 수 있으므로 GetValue 를 호출해야 합니다.
14 ECMAScript 언어: 문과 선언
구문
Statement [Yield, Await, Return] :
BlockStatement [?Yield, ?Await, ?Return]
VariableStatement [?Yield, ?Await]
EmptyStatement
ExpressionStatement [?Yield, ?Await]
IfStatement [?Yield, ?Await, ?Return]
BreakableStatement [?Yield, ?Await, ?Return]
ContinueStatement [?Yield, ?Await]
BreakStatement [?Yield, ?Await]
[+Return]
ReturnStatement [?Yield, ?Await]
WithStatement [?Yield, ?Await, ?Return]
LabelledStatement [?Yield, ?Await, ?Return]
ThrowStatement [?Yield, ?Await]
TryStatement [?Yield, ?Await, ?Return]
DebuggerStatement
Declaration [Yield, Await] :
HoistableDeclaration [?Yield, ?Await, ~Default]
ClassDeclaration [?Yield, ?Await, ~Default]
LexicalDeclaration [+In, ?Yield, ?Await]
HoistableDeclaration [Yield, Await, Default] :
FunctionDeclaration [?Yield, ?Await, ?Default]
GeneratorDeclaration [?Yield, ?Await, ?Default]
AsyncFunctionDeclaration [?Yield, ?Await, ?Default]
AsyncGeneratorDeclaration [?Yield, ?Await, ?Default]
BreakableStatement [Yield, Await, Return] :
IterationStatement [?Yield, ?Await, ?Return]
SwitchStatement [?Yield, ?Await, ?Return]
14.1 문 의미론
14.1.1 Runtime Semantics: 평가
HoistableDeclaration :
GeneratorDeclaration
AsyncFunctionDeclaration
AsyncGeneratorDeclaration
empty 를 반환합니다.
HoistableDeclaration : FunctionDeclaration
FunctionDeclaration 의 ? Evaluation 을 반환합니다.
BreakableStatement :
IterationStatement
SwitchStatement
newLabelSet 을 새로운 빈 List 로 둡니다.인수 newLabelSet 을 사용한 이 BreakableStatement 의 ? LabelledEvaluation 을 반환합니다.
14.2 블록
구문
BlockStatement [Yield, Await, Return] :
Block [?Yield, ?Await, ?Return]
Block [Yield, Await, Return] :
{
StatementList [?Yield, ?Await, ?Return] opt
}
StatementList [Yield, Await, Return] :
StatementListItem [?Yield, ?Await, ?Return]
StatementList [?Yield, ?Await, ?Return]
StatementListItem [?Yield, ?Await, ?Return]
StatementListItem [Yield, Await, Return] :
Statement [?Yield, ?Await, ?Return]
Declaration [?Yield, ?Await]
14.2.1 Static Semantics: 조기 오류
Block :
{
StatementList
}
14.2.2 Runtime Semantics: 평가
Block :
{
}
empty 를 반환합니다.
Block :
{
StatementList
}
oldEnv 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.blockEnv 를 NewDeclarativeEnvironment (oldEnv )로 둡니다.BlockDeclarationInstantiation (StatementList , blockEnv )을 수행합니다.실행 중인 실행 컨텍스트 의 LexicalEnvironment를 blockEnv 로 설정합니다.blockValue 를 Completion (StatementList 의 Evaluation )으로 둡니다.blockValue 를 Completion (DisposeResources (blockEnv .[[DisposableResourceStack]] , blockValue ))으로 설정합니다.실행 중인 실행 컨텍스트 의 LexicalEnvironment를 oldEnv 로 설정합니다.? blockValue 를 반환합니다.
참고 1
제어가 어떤 방식으로 Block 을 벗어나더라도 LexicalEnvironment는 항상 이전 상태로 복원됩니다.
StatementList :
StatementList
StatementListItem
sl 을 StatementList 의 ? Evaluation 으로 둡니다.s 를 Completion (StatementListItem 의 Evaluation )으로 둡니다.? UpdateEmpty (s , sl )을 반환합니다.
참고 2
StatementList 의 값은 StatementList 에서 값을 생성하는 마지막 항목의 값입니다. 예를 들어 다음 eval 함수 호출은 모두 값 1을 반환합니다:
eval ("1;;;;;" )
eval ("1;{}" )
eval ("1;var a;" )
14.2.3 BlockDeclarationInstantiation ( code , envRecord )
추상 연산 BlockDeclarationInstantiation. 인수 code (구문 분석 노드) 및 envRecord (Declarative Environment 레코드 ). 반환값: unused . code 는 블록 본문에 대응하는 Parse Node입니다. envRecord 는 바인딩을 생성할 Environment Record 입니다.
참고
Block 또는 CaseBlock 이 평가될 때 새로운 Declarative Environment Record 가 생성되고 블록 안에서 선언된 각 블록 스코프 변수, 상수, 함수 또는 클래스에 대한 바인딩이 해당 Environment Record 에 인스턴스화됩니다.
호출되면 다음 단계를 수행합니다:
decls 를 code 의 LexicallyScopedDeclarations 로 둡니다.privateEnv 를 실행 중인 실행 컨텍스트 의 PrivateEnvironment로 둡니다.decls 의 각 요소 decl 에 대해 다음을 수행합니다.decl 의 BoundNames 의 각 요소 name 에 대해 다음을 수행합니다.decl 의 IsConstantDeclaration 이 true 이면, 다음을 수행합니다.! envRecord .CreateImmutableBinding (name , true )를 수행합니다. 그렇지 않으면,Normative Optional
호스트 가 웹 브라우저이거나 그 밖의 방식으로 블록 수준 함수 선언의 웹 레거시 호환성 의미론 을 지원하면, 다음을 수행합니다.! envRecord .HasBinding (name )이 false 이면, 다음을 수행합니다.! envRecord .CreateMutableBinding (name , false )를 수행합니다. 그렇지 않으면,! envRecord .CreateMutableBinding (name , false )를 수행합니다. decl 이 FunctionDeclaration , GeneratorDeclaration , AsyncFunctionDeclaration 또는 AsyncGeneratorDeclaration 중 하나이면, 다음을 수행합니다.funcName 을 decl 의 BoundNames 의 유일한 요소로 둡니다.funcObj 를 인수 envRecord 및 privateEnv 를 사용한 decl 의 InstantiateFunctionObject 로 둡니다.Normative Optional
호스트 가 웹 브라우저이거나 그 밖의 방식으로 블록 수준 함수 선언의 웹 레거시 호환성 의미론 을 지원하면, 다음을 수행합니다.envRecord 에서 funcName 에 대한 바인딩이 초기화되지 않은 바인딩이면, 다음을 수행합니다.! envRecord .InitializeBinding (funcName , funcObj )를 수행합니다. 그렇지 않으면,단언 : decl 은 FunctionDeclaration 입니다.! envRecord .SetMutableBinding (funcName , funcObj , false )를 수행합니다. 그렇지 않으면,! envRecord .InitializeBinding (funcName , funcObj )를 수행합니다. unused 를 반환합니다.
14.3 선언과 Variable 문
14.3.1 Let, Const, Using 및 Await Using 선언
참고
let, const, using 및 await using 선언은 실행 중인 실행 컨텍스트 의 LexicalEnvironment를 스코프로 하는 변수를 정의합니다. 변수는 이를 포함하는 Environment Record 가 인스턴스화될 때 생성되지만 변수의 LexicalBinding 이 평가되기 전까지는 어떤 방식으로도 접근할 수 없습니다. Initializer 를 갖는 LexicalBinding 이 정의한 변수에는 변수가 생성될 때가 아니라 LexicalBinding 이 평가될 때 해당 Initializer 의 AssignmentExpression 값이 할당됩니다. let 선언의 LexicalBinding 에 Initializer 가 없으면 LexicalBinding 이 평가될 때 변수에 undefined 값이 할당됩니다.
구문
LexicalDeclaration [In, Yield, Await] :
LetOrConst
BindingList [?In, ?Yield, ?Await, +Pattern]
;
UsingDeclaration [?In, ?Yield, ?Await]
[+Await]
AwaitUsingDeclaration [?In, ?Yield]
LetOrConst :
let
const
UsingDeclaration [In, Yield, Await] :
using
[no LineTerminator here]
BindingList [?In, ?Yield, ?Await, ~Pattern]
;
AwaitUsingDeclaration [In, Yield] :
CoverAwaitExpressionAndAwaitUsingDeclarationHead [?Yield]
[no LineTerminator here]
BindingList [?In, ?Yield, +Await, ~Pattern]
;
BindingList [In, Yield, Await, Pattern] :
LexicalBinding [?In, ?Yield, ?Await, ?Pattern]
BindingList [?In, ?Yield, ?Await, ?Pattern]
,
LexicalBinding [?In, ?Yield, ?Await, ?Pattern]
LexicalBinding [In, Yield, Await, Pattern] :
BindingIdentifier [?Yield, ?Await]
Initializer [?In, ?Yield, ?Await] opt
[+Pattern]
BindingPattern [?Yield, ?Await]
Initializer [?In, ?Yield, ?Await]
보충 구문
다음 생성 규칙의 인스턴스를 처리할 때
AwaitUsingDeclaration :
CoverAwaitExpressionAndAwaitUsingDeclarationHead
BindingList
;
CoverAwaitExpressionAndAwaitUsingDeclarationHead 의 해석은 다음 문법을 사용하여 구체화됩니다:
AwaitUsingDeclarationHead :
await
[no LineTerminator here]
using
14.3.1.1 Static Semantics: 조기 오류
LexicalDeclaration :
LetOrConst
BindingList
;
UsingDeclaration :
using
BindingList
;
AwaitUsingDeclaration :
CoverAwaitExpressionAndAwaitUsingDeclarationHead
BindingList
;
LexicalBinding :
BindingIdentifier
Initializer opt
14.3.1.2 Runtime Semantics: 평가
LexicalDeclaration :
LetOrConst
BindingList
;
인수 normal 을 사용한 BindingList 의 ? BindingEvaluation 을 수행합니다. empty 를 반환합니다.
UsingDeclaration :
using
BindingList
;
인수 sync-dispose 를 사용한 BindingList 의 ? BindingEvaluation 을 수행합니다. empty 를 반환합니다.
AwaitUsingDeclaration :
CoverAwaitExpressionAndAwaitUsingDeclarationHead
BindingList
;
인수 async-dispose 를 사용한 BindingList 의 ? BindingEvaluation 을 수행합니다. empty 를 반환합니다.
14.3.1.3 Runtime Semantics: BindingEvaluation
구문 지향 연산 BindingEvaluation. 인수 kind ((normal , sync-dispose 또는 async-dispose )). 반환값: (정상 완료 (값: unused ) 또는 중도 완료). 다음 생성 규칙별로 정의된다.
BindingList :
BindingList
,
LexicalBinding
인수 kind 를 사용한 파생된 BindingList 의 ? BindingEvaluation 을 수행합니다. 인수 kind 를 사용한 LexicalBinding 의 ? BindingEvaluation 을 반환합니다.
LexicalBinding : BindingIdentifier
단언 : kind 는 normal 입니다.lhs 를 ! ResolveBinding (BindingIdentifier 의 StringValue )으로 둡니다.! InitializeReferencedBinding (lhs , undefined )를 수행합니다. unused 를 반환합니다.
참고
정적 의미론 규칙은 이 형태의 LexicalBinding 이 const, using 또는 await using 선언에서 절대로 발생하지 않도록 보장합니다.
LexicalBinding :
BindingIdentifier
Initializer
name 을 BindingIdentifier 의 StringValue 로 둡니다.lhs 를 ! ResolveBinding (name )으로 둡니다.IsAnonymousFunctionDefinition (Initializer )이 true 이면, 다음을 수행합니다.value 를 인수 name 을 사용한 Initializer 의 ? NamedEvaluation 으로 둡니다.그렇지 않으면,rhs 를 Initializer 의 ? Evaluation 으로 둡니다.value 를 ? GetValue (rhs )로 둡니다. kind 가 normal 이 아니면, 다음을 수행합니다.단언 : IsUnresolvableReference (lhs )는 false 입니다.base 를 lhs .[[Base]] 로 둡니다.단언 : base 는 Declarative Environment Record 입니다.? AddDisposableResource (base .[[DisposableResourceStack]] , value , kind )를 수행합니다. ? InitializeReferencedBinding (lhs , value )를 수행합니다. unused 를 반환합니다.
LexicalBinding :
BindingPattern
Initializer
단언 : kind 는 normal 입니다.rhs 를 Initializer 의 ? Evaluation 으로 둡니다.value 를 ? GetValue (rhs )로 둡니다.envRecord 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.인수 value 및 envRecord 를 사용한 BindingPattern 의 ? BindingInitialization 을 반환합니다.
14.3.2 Variable 문
참고
var 문은 실행 중인 실행 컨텍스트 의 VariableEnvironment를 스코프로 하는 변수를 선언합니다. var 변수는 이를 포함하는 Environment Record 가 인스턴스화될 때 생성되고 생성 시 undefined 로 초기화됩니다. 어떤 VariableEnvironment의 스코프 안에서도 동일한 BindingIdentifier 가 둘 이상의 VariableDeclaration 에 나타날 수 있지만, 이러한 선언은 전체적으로 하나의 변수만 정의합니다. Initializer 를 갖는 VariableDeclaration 이 정의한 변수에는 변수가 생성될 때가 아니라 VariableDeclaration 이 실행될 때 해당 Initializer 의 AssignmentExpression 값이 할당됩니다.
구문
VariableStatement [Yield, Await] :
var
VariableDeclarationList [+In, ?Yield, ?Await]
;
VariableDeclarationList [In, Yield, Await] :
VariableDeclaration [?In, ?Yield, ?Await]
VariableDeclarationList [?In, ?Yield, ?Await]
,
VariableDeclaration [?In, ?Yield, ?Await]
VariableDeclaration [In, Yield, Await] :
BindingIdentifier [?Yield, ?Await]
Initializer [?In, ?Yield, ?Await] opt
BindingPattern [?Yield, ?Await]
Initializer [?In, ?Yield, ?Await]
14.3.2.1 Runtime Semantics: 평가
VariableStatement :
var
VariableDeclarationList
;
VariableDeclarationList 의 ? Evaluation 을 수행합니다.empty 를 반환합니다.
VariableDeclarationList :
VariableDeclarationList
,
VariableDeclaration
VariableDeclarationList 의 ? Evaluation 을 수행합니다.VariableDeclaration 의 ? Evaluation 을 반환합니다.
VariableDeclaration : BindingIdentifier
empty 를 반환합니다.
VariableDeclaration :
BindingIdentifier
Initializer
name 을 BindingIdentifier 의 StringValue 로 둡니다.lhs 를 ? ResolveBinding (name )으로 둡니다.IsAnonymousFunctionDefinition (Initializer )이 true 이면, 다음을 수행합니다.value 를 인수 name 을 사용한 Initializer 의 ? NamedEvaluation 으로 둡니다.그렇지 않으면,rhs 를 Initializer 의 ? Evaluation 으로 둡니다.value 를 ? GetValue (rhs )로 둡니다. ? PutValue (lhs , value )를 수행합니다. empty 를 반환합니다.
참고
VariableDeclaration 이 with 문 안에 중첩되어 있고 VariableDeclaration 의 BindingIdentifier 가 with 문의 Object Environment Record 의 바인딩 객체 프로퍼티 이름 과 같으면, 5 단계는 Identifier 의 VariableEnvironment 바인딩에 할당하는 대신 해당 프로퍼티에 value 를 할당합니다.
VariableDeclaration :
BindingPattern
Initializer
rhs 를 Initializer 의 ? Evaluation 으로 둡니다.rightValue 를 ? GetValue (rhs )로 둡니다.인수 rightValue 및 undefined 를 사용한 BindingPattern 의 ? BindingInitialization 을 반환합니다.
14.3.3 구조 분해 바인딩 패턴
구문
BindingPattern [Yield, Await] :
ObjectBindingPattern [?Yield, ?Await]
ArrayBindingPattern [?Yield, ?Await]
ObjectBindingPattern [Yield, Await] :
{
}
{
BindingRestProperty [?Yield, ?Await]
}
{
BindingPropertyList [?Yield, ?Await]
,opt
}
{
BindingPropertyList [?Yield, ?Await]
,
BindingRestProperty [?Yield, ?Await]
}
ArrayBindingPattern [Yield, Await] :
[
Elision opt
BindingRestElement [?Yield, ?Await] opt
]
[
BindingElementList [?Yield, ?Await]
]
[
BindingElementList [?Yield, ?Await]
,
Elision opt
BindingRestElement [?Yield, ?Await] opt
]
BindingRestProperty [Yield, Await] :
...
BindingIdentifier [?Yield, ?Await]
BindingPropertyList [Yield, Await] :
BindingProperty [?Yield, ?Await]
BindingPropertyList [?Yield, ?Await]
,
BindingProperty [?Yield, ?Await]
BindingElementList [Yield, Await] :
BindingElisionElement [?Yield, ?Await]
BindingElementList [?Yield, ?Await]
,
BindingElisionElement [?Yield, ?Await]
BindingElisionElement [Yield, Await] :
Elision opt
BindingElement [?Yield, ?Await]
BindingProperty [Yield, Await] :
SingleNameBinding [?Yield, ?Await]
PropertyName [?Yield, ?Await]
:
BindingElement [?Yield, ?Await]
BindingElement [Yield, Await] :
SingleNameBinding [?Yield, ?Await]
BindingPattern [?Yield, ?Await]
Initializer [+In, ?Yield, ?Await] opt
SingleNameBinding [Yield, Await] :
BindingIdentifier [?Yield, ?Await]
Initializer [+In, ?Yield, ?Await] opt
BindingRestElement [Yield, Await] :
...
BindingIdentifier [?Yield, ?Await]
...
BindingPattern [?Yield, ?Await]
14.3.3.1 Runtime Semantics: PropertyBindingInitialization
구문 지향 연산 PropertyBindingInitialization. 인수 value (ECMAScript 언어 값 ) 및 envRecord (Environment Record 또는 undefined ). 반환값: 프로퍼티 키 의 List 를 포함하는 정상 완료 또는 비정상 완료 . 바인딩된 모든 프로퍼티 이름 의 목록을 수집합니다. 다음 생성 규칙별로 정의된다.
BindingPropertyList :
BindingPropertyList
,
BindingProperty
boundNames 를 인수 value 및 envRecord 를 사용한 BindingPropertyList 의 ? PropertyBindingInitialization 으로 둡니다.nextNames 를 인수 value 및 envRecord 를 사용한 BindingProperty 의 ? PropertyBindingInitialization 으로 둡니다.boundNames 와 nextNames 의 목록 연결 을 반환합니다.
BindingProperty : SingleNameBinding
name 을 SingleNameBinding 의 BoundNames 의 유일한 요소로 둡니다.인수 value , envRecord 및 name 을 사용한 SingleNameBinding 의 ? KeyedBindingInitialization 을 수행합니다. « name »을 반환합니다.
BindingProperty :
PropertyName
:
BindingElement
propertyKey 를 PropertyName 의 ? Evaluation 으로 둡니다.인수 value , envRecord 및 propertyKey 를 사용한 BindingElement 의 ? KeyedBindingInitialization 을 수행합니다. « propertyKey »를 반환합니다.
14.3.3.2 Runtime Semantics: RestBindingInitialization
구문 지향 연산 RestBindingInitialization. 인수 value (ECMAScript 언어 값 ), envRecord (Environment Record 또는 undefined ) 및 excludedNames (프로퍼티 키 의 List ). 반환값: unused 를 포함하는 정상 완료 또는 비정상 완료 . 다음 생성 규칙별로 정의된다.
BindingRestProperty :
...
BindingIdentifier
lhs 를 ? ResolveBinding (BindingIdentifier 의 StringValue , envRecord )으로 둡니다.restObj 를 OrdinaryObjectCreate (%Object.prototype% )로 둡니다.? CopyDataProperties (restObj , value , excludedNames )를 수행합니다. envRecord 가 undefined 이면 ? PutValue (lhs , restObj )를 반환합니다.? InitializeReferencedBinding (lhs , restObj )을 반환합니다.
14.3.3.3 Runtime Semantics: KeyedBindingInitialization
구문 지향 연산 KeyedBindingInitialization. 인수 value (ECMAScript 언어 값 ), envRecord (Environment Record 또는 undefined ) 및 propertyName (프로퍼티 키 ). 반환값: unused 를 포함하는 정상 완료 또는 비정상 완료 .
참고
envRecord 에 undefined 를 전달하면 초기화 값을 할당하는 데 PutValue 연산을 사용해야 함을 나타냅니다. 이는 비엄격 함수 의 형식 매개변수 목록에서 발생합니다. 이 경우 같은 이름을 갖는 여러 매개변수의 가능성을 처리하기 위해 형식 매개변수 바인딩을 미리 초기화합니다.
다음 생성 규칙별로 정의된다.
BindingElement :
BindingPattern
Initializer opt
value 를 ? GetV (value , propertyName )로 설정합니다.Initializer 가 존재하고 value 가 undefined 이면, 다음을 수행합니다.defaultValue 를 Initializer 의 ? Evaluation 으로 둡니다.value 를 ? GetValue (defaultValue )로 설정합니다.인수 value 및 envRecord 를 사용한 BindingPattern 의 ? BindingInitialization 을 반환합니다.
SingleNameBinding :
BindingIdentifier
Initializer opt
name 을 BindingIdentifier 의 StringValue 로 둡니다.lhs 를 ? ResolveBinding (name , envRecord )으로 둡니다.value 를 ? GetV (value , propertyName )로 설정합니다.Initializer 가 존재하고 value 가 undefined 이면, 다음을 수행합니다.IsAnonymousFunctionDefinition (Initializer )이 true 이면, 다음을 수행합니다.value 를 인수 name 을 사용한 Initializer 의 ? NamedEvaluation 으로 설정합니다.그렇지 않으면,defaultValue 를 Initializer 의 ? Evaluation 으로 둡니다.value 를 ? GetValue (defaultValue )로 설정합니다. envRecord 가 undefined 이면 ? PutValue (lhs , value )를 반환합니다.? InitializeReferencedBinding (lhs , value )를 반환합니다.
14.4 빈 문
구문
EmptyStatement :
;
14.4.1 Runtime Semantics: 평가
EmptyStatement : ;
empty 를 반환합니다.
14.5 표현식 문
구문
ExpressionStatement [Yield, Await] :
[lookahead ∉ { { , function , async
[no LineTerminator here]
function , class , let
[ }]
Expression [+In, ?Yield, ?Await]
;
참고
ExpressionStatement 은 U+007B (LEFT CURLY BRACKET)로 시작할 수 없습니다. 그렇게 하면 Block 과 모호해질 수 있기 때문입니다. ExpressionStatement 은 function 또는 class 키워드 로 시작할 수 없습니다. 그렇게 하면 FunctionDeclaration , GeneratorDeclaration 또는 ClassDeclaration 과 모호해지기 때문입니다. ExpressionStatement 은 async function으로 시작할 수 없습니다. 그렇게 하면 AsyncFunctionDeclaration 또는 AsyncGeneratorDeclaration 과 모호해지기 때문입니다. ExpressionStatement 은 두 토큰 시퀀스 let [로 시작할 수 없습니다. 그렇게 하면 첫 번째 LexicalBinding 이 ArrayBindingPattern 인 let LexicalDeclaration 과 모호해지기 때문입니다.
14.5.1 Runtime Semantics: 평가
ExpressionStatement :
Expression
;
exprRef 를 Expression 의 ? Evaluation 으로 둡니다.? GetValue (exprRef )를 반환합니다.
14.6 if 문
구문
IfStatement [Yield, Await, Return] :
if
(
Expression [+In, ?Yield, ?Await]
)
Statement [?Yield, ?Await, ?Return]
else
Statement [?Yield, ?Await, ?Return]
if
(
Expression [+In, ?Yield, ?Await]
)
Statement [?Yield, ?Await, ?Return]
[lookahead ≠ else ]
참고 lookahead 제한 [lookahead ≠ else]는 고전적인 “dangling else” 문제를 일반적인 방식으로 해결합니다. 즉, 연결할 if를 선택하는 것이 그 밖에는 모호할 때 else는 후보 if 중 가장 가까운(가장 안쪽의) if와 연결됩니다.
14.6.1 Static Semantics: 조기 오류
IfStatement :
if
(
Expression
)
Statement
else
Statement
IfStatement :
if
(
Expression
)
Statement
참고
B.3.1 에 명시된 확장을 구현한 경우에만 이 규칙을 적용할 필요가 있습니다.
14.6.2 Runtime Semantics: 평가
IfStatement :
if
(
Expression
)
Statement
else
Statement
exprRef 를 Expression 의 ? Evaluation 으로 둡니다.exprValue 를 ToBoolean (? GetValue (exprRef ))로 둡니다.exprValue 가 true 이면, 다음을 수행합니다.stmtCompletion 을 Completion (첫 번째 Statement 의 Evaluation )으로 둡니다.그렇지 않으면,stmtCompletion 을 Completion (두 번째 Statement 의 Evaluation )으로 둡니다. ? UpdateEmpty (stmtCompletion , undefined )를 반환합니다.
IfStatement :
if
(
Expression
)
Statement
exprRef 를 Expression 의 ? Evaluation 으로 둡니다.exprValue 를 ToBoolean (? GetValue (exprRef ))로 둡니다.exprValue 가 false 이면 undefined 를 반환합니다.stmtCompletion 을 Completion (Statement 의 Evaluation )으로 둡니다.? UpdateEmpty (stmtCompletion , undefined )를 반환합니다.
14.7 반복문
구문
IterationStatement [Yield, Await, Return] :
DoWhileStatement [?Yield, ?Await, ?Return]
WhileStatement [?Yield, ?Await, ?Return]
ForStatement [?Yield, ?Await, ?Return]
ForInOfStatement [?Yield, ?Await, ?Return]
14.7.1 의미론
14.7.1.1 LoopContinues ( completion , labelSet )
추상 연산 LoopContinues. 인수 completion (Completion 레코드 ) 및 labelSet (String의 List ). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
completion 이 정상 완료 이면 true 를 반환합니다.completion 이 continue 완료 가 아니면 false 를 반환합니다.completion .[[Target]] 이 empty 이면 true 를 반환합니다.labelSet 에 completion .[[Target]] 이 포함되어 있으면 true 를 반환합니다.false 를 반환합니다.
참고
14.7.1.2 Runtime Semantics: LoopEvaluation
구문 지향 연산 LoopEvaluation. 인수 labelSet (String의 List ). 반환값: ECMAScript 언어 값 을 포함하는 정상 완료 또는 비정상 완료 . 다음 생성 규칙별로 정의된다.
IterationStatement : DoWhileStatement
인수 labelSet 을 사용한 DoWhileStatement 의 ? DoWhileLoopEvaluation 을 반환합니다.
IterationStatement : WhileStatement
인수 labelSet 을 사용한 WhileStatement 의 ? WhileLoopEvaluation 을 반환합니다.
IterationStatement : ForStatement
인수 labelSet 을 사용한 ForStatement 의 ? ForLoopEvaluation 을 반환합니다.
IterationStatement : ForInOfStatement
인수 labelSet 을 사용한 ForInOfStatement 의 ? ForInOfLoopEvaluation 을 반환합니다.
14.7.2 do-while 문
구문
DoWhileStatement [Yield, Await, Return] :
do
Statement [?Yield, ?Await, ?Return]
while
(
Expression [+In, ?Yield, ?Await]
)
;
14.7.2.1 Static Semantics: 조기 오류
DoWhileStatement :
do
Statement
while
(
Expression
)
;
참고
B.3.1 에 명시된 확장을 구현한 경우에만 이 규칙을 적용할 필요가 있습니다.
14.7.2.2 Runtime Semantics: DoWhileLoopEvaluation
구문 지향 연산 DoWhileLoopEvaluation. 인수 labelSet (String의 List ). 반환값: ECMAScript 언어 값 을 포함하는 정상 완료 또는 비정상 완료 . 다음 생성 규칙별로 정의된다.
DoWhileStatement :
do
Statement
while
(
Expression
)
;
iterationResult 를 undefined 로 둡니다.다음을 반복합니다.stmtResult 를 Completion (Statement 의 Evaluation )으로 둡니다.LoopContinues (stmtResult , labelSet )가 false 이면 ? UpdateEmpty (stmtResult , iterationResult )를 반환합니다.stmtResult .[[Value]] 가 empty 가 아니면 iterationResult 를 stmtResult .[[Value]] 로 설정합니다.exprRef 를 Expression 의 ? Evaluation 으로 둡니다.exprValue 를 ? GetValue (exprRef )로 둡니다.ToBoolean (exprValue )이 false 이면 iterationResult 를 반환합니다.
14.7.3 while 문
구문
WhileStatement [Yield, Await, Return] :
while
(
Expression [+In, ?Yield, ?Await]
)
Statement [?Yield, ?Await, ?Return]
14.7.3.1 Static Semantics: 조기 오류
WhileStatement :
while
(
Expression
)
Statement
참고
B.3.1 에 명시된 확장을 구현한 경우에만 이 규칙을 적용할 필요가 있습니다.
14.7.3.2 Runtime Semantics: WhileLoopEvaluation
구문 지향 연산 WhileLoopEvaluation. 인수 labelSet (String의 List ). 반환값: ECMAScript 언어 값 을 포함하는 정상 완료 또는 비정상 완료 . 다음 생성 규칙별로 정의된다.
WhileStatement :
while
(
Expression
)
Statement
iterationResult 를 undefined 로 둡니다.다음을 반복합니다.exprRef 를 Expression 의 ? Evaluation 으로 둡니다.exprValue 를 ? GetValue (exprRef )로 둡니다.ToBoolean (exprValue )이 false 이면 iterationResult 를 반환합니다.stmtResult 를 Completion (Statement 의 Evaluation )으로 둡니다.LoopContinues (stmtResult , labelSet )가 false 이면 ? UpdateEmpty (stmtResult , iterationResult )를 반환합니다.stmtResult .[[Value]] 가 empty 가 아니면 iterationResult 를 stmtResult .[[Value]] 로 설정합니다.
14.7.4 for 문
구문
ForStatement [Yield, Await, Return] :
for
(
[lookahead ≠ let
[ ]
Expression [~In, ?Yield, ?Await] opt
;
Expression [+In, ?Yield, ?Await] opt
;
Expression [+In, ?Yield, ?Await] opt
)
Statement [?Yield, ?Await, ?Return]
for
(
var
VariableDeclarationList [~In, ?Yield, ?Await]
;
Expression [+In, ?Yield, ?Await] opt
;
Expression [+In, ?Yield, ?Await] opt
)
Statement [?Yield, ?Await, ?Return]
for
(
LexicalDeclaration [~In, ?Yield, ?Await]
Expression [+In, ?Yield, ?Await] opt
;
Expression [+In, ?Yield, ?Await] opt
)
Statement [?Yield, ?Await, ?Return]
14.7.4.1 Static Semantics: 조기 오류
ForStatement :
for
(
Expression opt
;
Expression opt
;
Expression opt
)
Statement
for
(
var
VariableDeclarationList
;
Expression opt
;
Expression opt
)
Statement
for
(
LexicalDeclaration
Expression opt
;
Expression opt
)
Statement
참고
B.3.1 에 명시된 확장을 구현한 경우에만 이 규칙을 적용할 필요가 있습니다.
ForStatement :
for
(
LexicalDeclaration
Expression opt
;
Expression opt
)
Statement
14.7.4.2 Runtime Semantics: ForLoopEvaluation
구문 지향 연산 ForLoopEvaluation. 인수 labelSet (String의 List ). 반환값: ECMAScript 언어 값 을 포함하는 정상 완료 또는 비정상 완료 . 다음 생성 규칙별로 정의된다.
ForStatement :
for
(
Expression opt
;
Expression opt
;
Expression opt
)
Statement
첫 번째 Expression 이 존재하면, 다음을 수행합니다.exprRef 를 첫 번째 Expression 의 ? Evaluation 으로 둡니다.? GetValue (exprRef )를 수행합니다. 두 번째 Expression 이 존재하면 test 를 두 번째 Expression 로 둡니다. 그렇지 않으면 test 를 empty 로 둡니다. 세 번째 Expression 이 존재하면 increment 를 세 번째 Expression 로 둡니다. 그렇지 않으면 increment 를 empty 로 둡니다. ? ForBodyEvaluation (test , increment , Statement , « », labelSet )을 반환합니다.
ForStatement :
for
(
var
VariableDeclarationList
;
Expression opt
;
Expression opt
)
Statement
VariableDeclarationList 의 ? Evaluation 을 수행합니다.첫 번째 Expression 이 존재하면 test 를 첫 번째 Expression 로 둡니다. 그렇지 않으면 test 를 empty 로 둡니다. 두 번째 Expression 이 존재하면 increment 를 두 번째 Expression 로 둡니다. 그렇지 않으면 increment 를 empty 로 둡니다. ? ForBodyEvaluation (test , increment , Statement , « », labelSet )을 반환합니다.
ForStatement :
for
(
LexicalDeclaration
Expression opt
;
Expression opt
)
Statement
oldEnv 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.loopEnv 를 NewDeclarativeEnvironment (oldEnv )로 둡니다.isConst 를 LexicalDeclaration 의 IsConstantDeclaration 으로 둡니다.boundNames 를 LexicalDeclaration 의 BoundNames 로 둡니다.boundNames 의 각 요소 name 에 대해 다음을 수행합니다.isConst 가 true 이면, 다음을 수행합니다.! loopEnv .CreateImmutableBinding (name , true )를 수행합니다. 그렇지 않으면,! loopEnv .CreateMutableBinding (name , false )를 수행합니다. 실행 중인 실행 컨텍스트 의 LexicalEnvironment를 loopEnv 로 설정합니다.forDecl 을 Completion (LexicalDeclaration 의 Evaluation )으로 둡니다.forDecl 이 비정상 완료 이면, 다음을 수행합니다.forDecl 을 Completion (DisposeResources (loopEnv .[[DisposableResourceStack]] , forDecl ))으로 설정합니다.단언 : forDecl 은 비정상 완료 입니다.실행 중인 실행 컨텍스트 의 LexicalEnvironment를 oldEnv 로 설정합니다.? forDecl 을 반환합니다. isConst 가 false 이면 perIterationLets 를 boundNames 로 둡니다. 그렇지 않으면 perIterationLets 를 새로운 빈 List 로 둡니다.첫 번째 Expression 이 존재하면 test 를 첫 번째 Expression 로 둡니다. 그렇지 않으면 test 를 empty 로 둡니다. 두 번째 Expression 이 존재하면 increment 를 두 번째 Expression 로 둡니다. 그렇지 않으면 increment 를 empty 로 둡니다. bodyResult 를 Completion (ForBodyEvaluation (test , increment , Statement , perIterationLets , labelSet ))으로 둡니다.bodyResult 를 Completion (DisposeResources (loopEnv .[[DisposableResourceStack]] , bodyResult ))으로 설정합니다.단언 : bodyResult 가 정상 완료 이면 bodyResult .[[Value]] 는 empty 가 아닙니다.실행 중인 실행 컨텍스트 의 LexicalEnvironment를 oldEnv 로 설정합니다.? bodyResult 를 반환합니다.
14.7.4.3 ForBodyEvaluation ( test , increment , stmt , perIterationBindings , labelSet )
추상 연산 ForBodyEvaluation. 인수 test (Expression Parse Node 또는 empty ), increment (Expression Parse Node 또는 empty ), stmt (Statement Parse Node), perIterationBindings (String의 List ) 및 labelSet (String의 List ). 반환값: ECMAScript 언어 값 을 포함하는 정상 완료 또는 비정상 완료 . 호출되면 다음 단계를 수행한다.
iterationResult 를 undefined 로 둡니다.? CreatePerIterationEnvironment (perIterationBindings )를 수행합니다. 다음을 반복합니다.test 가 empty 가 아니면, 다음을 수행합니다.testRef 를 test 의 ? Evaluation 으로 둡니다.testValue 를 ? GetValue (testRef )로 둡니다.ToBoolean (testValue )이 false 이면 iterationResult 를 반환합니다.result 를 Completion (stmt 의 Evaluation )으로 둡니다.LoopContinues (result , labelSet )가 false 이면 ? UpdateEmpty (result , iterationResult )를 반환합니다.result .[[Value]] 가 empty 가 아니면 iterationResult 를 result .[[Value]] 로 설정합니다.? CreatePerIterationEnvironment (perIterationBindings )를 수행합니다. increment 가 empty 가 아니면, 다음을 수행합니다.incrementRef 를 increment 의 ? Evaluation 으로 둡니다.? GetValue (incrementRef )를 수행합니다.
14.7.4.4 CreatePerIterationEnvironment ( perIterationBindings )
추상 연산 CreatePerIterationEnvironment. 인수 perIterationBindings (String의 List ). 반환값: unused 를 포함하는 정상 완료 또는 throw 완료 . 호출되면 다음 단계를 수행한다.
perIterationBindings 에 요소가 하나라도 있으면, 다음을 수행합니다.lastIterationEnv 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.outer 를 lastIterationEnv .[[OuterEnv]] 로 둡니다.단언 : outer 는 null 이 아닙니다.thisIterationEnv 를 NewDeclarativeEnvironment (outer )로 둡니다.perIterationBindings 의 각 요소 name 에 대해 다음을 수행합니다.! thisIterationEnv .CreateMutableBinding (name , false )를 수행합니다. lastValue 를 ? lastIterationEnv .GetBindingValue (name , true )로 둡니다.! thisIterationEnv .InitializeBinding (name , lastValue )를 수행합니다. 실행 중인 실행 컨텍스트 의 LexicalEnvironment를 thisIterationEnv 로 설정합니다.unused 를 반환합니다.
14.7.5 for-in, for-of 및 for-await-of 문
구문
ForInOfStatement [Yield, Await, Return] :
for
(
[lookahead ≠ let
[ ]
LeftHandSideExpression [?Yield, ?Await]
in
Expression [+In, ?Yield, ?Await]
)
Statement [?Yield, ?Await, ?Return]
for
(
var
ForBinding [?Yield, ?Await, +Pattern]
in
Expression [+In, ?Yield, ?Await]
)
Statement [?Yield, ?Await, ?Return]
for
(
ForDeclaration [?Yield, ?Await, ~Using]
in
Expression [+In, ?Yield, ?Await]
)
Statement [?Yield, ?Await, ?Return]
for
(
[lookahead ∉ { let , async
of }]
LeftHandSideExpression [?Yield, ?Await]
of
AssignmentExpression [+In, ?Yield, ?Await]
)
Statement [?Yield, ?Await, ?Return]
for
(
var
ForBinding [?Yield, ?Await, +Pattern]
of
AssignmentExpression [+In, ?Yield, ?Await]
)
Statement [?Yield, ?Await, ?Return]
for
(
[lookahead ≠ using
of ]
ForDeclaration [?Yield, ?Await, +Using]
of
AssignmentExpression [+In, ?Yield, ?Await]
)
Statement [?Yield, ?Await, ?Return]
[+Await]
for
await
(
[lookahead ≠ let ]
LeftHandSideExpression [?Yield, ?Await]
of
AssignmentExpression [+In, ?Yield, ?Await]
)
Statement [?Yield, ?Await, ?Return]
[+Await]
for
await
(
var
ForBinding [?Yield, ?Await, +Pattern]
of
AssignmentExpression [+In, ?Yield, ?Await]
)
Statement [?Yield, ?Await, ?Return]
[+Await]
for
await
(
[lookahead ≠ using
of ]
ForDeclaration [?Yield, ?Await, +Using]
of
AssignmentExpression [+In, ?Yield, ?Await]
)
Statement [?Yield, ?Await, ?Return]
ForDeclaration [Yield, Await, Using] :
LetOrConst
ForBinding [?Yield, ?Await, +Pattern]
[+Using]
using
[no LineTerminator here]
ForBinding [?Yield, ?Await, ~Pattern]
[+Using, +Await]
await
[no LineTerminator here]
using
[no LineTerminator here]
ForBinding [?Yield, +Await, ~Pattern]
ForBinding [Yield, Await, Pattern] :
BindingIdentifier [?Yield, ?Await]
[+Pattern]
BindingPattern [?Yield, ?Await]
참고
14.7.5.1 Static Semantics: 조기 오류
ForInOfStatement :
for
(
LeftHandSideExpression
in
Expression
)
Statement
for
(
var
ForBinding
in
Expression
)
Statement
for
(
ForDeclaration
in
Expression
)
Statement
for
(
LeftHandSideExpression
of
AssignmentExpression
)
Statement
for
(
var
ForBinding
of
AssignmentExpression
)
Statement
for
(
ForDeclaration
of
AssignmentExpression
)
Statement
for
await
(
LeftHandSideExpression
of
AssignmentExpression
)
Statement
for
await
(
var
ForBinding
of
AssignmentExpression
)
Statement
for
await
(
ForDeclaration
of
AssignmentExpression
)
Statement
참고
B.3.1 에 명시된 확장을 구현한 경우에만 이 규칙을 적용할 필요가 있습니다.
ForInOfStatement :
for
(
LeftHandSideExpression
in
Expression
)
Statement
for
(
LeftHandSideExpression
of
AssignmentExpression
)
Statement
for
await
(
LeftHandSideExpression
of
AssignmentExpression
)
Statement
ForInOfStatement :
for
(
ForDeclaration
in
Expression
)
Statement
for
(
ForDeclaration
of
AssignmentExpression
)
Statement
for
await
(
ForDeclaration
of
AssignmentExpression
)
Statement
14.7.5.2 Static Semantics: IsDestructuring
구문 지향 연산 IsDestructuring. 인수 없음. 반환값: Boolean. 다음 생성 규칙별로 정의된다.
MemberExpression : PrimaryExpression
PrimaryExpression 이 ObjectLiteral 또는 ArrayLiteral 이면 true 를 반환합니다.false 를 반환합니다.
MemberExpression :
MemberExpression
[
Expression
]
MemberExpression
.
IdentifierName
MemberExpression
TemplateLiteral
SuperProperty
MetaProperty
new
MemberExpression
Arguments
MemberExpression
.
PrivateIdentifier
NewExpression :
new
NewExpression
LeftHandSideExpression :
CallExpression
OptionalExpression
false 를 반환합니다.
ForDeclaration :
LetOrConst
ForBinding
ForBinding 의 IsDestructuring 을 반환합니다.
ForBinding : BindingIdentifier
false 를 반환합니다.
ForBinding : BindingPattern
true 를 반환합니다.
참고
14.7.5.3 Runtime Semantics: ForDeclarationBindingInitialization
구문 지향 연산 ForDeclarationBindingInitialization. 인수 value (ECMAScript 언어 값 ) 및 envRecord (Environment 레코드 ). 반환값: unused 를 포함하는 정상 완료 또는 비정상 완료 . 다음 생성 규칙별로 정의된다.
ForDeclaration :
LetOrConst
ForBinding
인수 value 및 envRecord 를 사용한 ForBinding 의 ? BindingInitialization 을 반환합니다.
ForDeclaration :
using
ForBinding
await
using
ForBinding
SyntaxError 예외를 던집니다.
14.7.5.4 Runtime Semantics: ForDeclarationBindingInstantiation
구문 지향 연산 ForDeclarationBindingInstantiation. 인수 envRecord (Declarative Environment 레코드 ). 반환값: unused . 다음 생성 규칙별로 정의된다.
ForDeclaration :
LetOrConst
ForBinding
ForBinding 의 BoundNames 의 각 요소 name 에 대해 다음을 수행합니다.LetOrConst 의 IsConstantDeclaration 이 true 이면, 다음을 수행합니다.! envRecord .CreateImmutableBinding (name , true )를 수행합니다. 그렇지 않으면,! envRecord .CreateMutableBinding (name , false )를 수행합니다. unused 를 반환합니다.
ForDeclaration :
using
ForBinding
await
using
ForBinding
ForBinding 의 BoundNames 의 각 요소 name 에 대해 다음을 수행합니다.! envRecord .CreateImmutableBinding (name , true )를 수행합니다. unused 를 반환합니다.
14.7.5.5 Runtime Semantics: ForInOfLoopEvaluation
구문 지향 연산 ForInOfLoopEvaluation. 인수 labelSet (String의 List ). 반환값: ECMAScript 언어 값 을 포함하는 정상 완료 또는 비정상 완료 . 다음 생성 규칙별로 정의된다.
ForInOfStatement :
for
(
LeftHandSideExpression
in
Expression
)
Statement
keyResult 를 ? ForIn/OfHeadEvaluation (« », Expression , enumerate )으로 둡니다.? ForIn/OfBodyEvaluation (LeftHandSideExpression , Statement , keyResult , enumerate , assignment , labelSet )을 반환합니다.
ForInOfStatement :
for
(
var
ForBinding
in
Expression
)
Statement
keyResult 를 ? ForIn/OfHeadEvaluation (« », Expression , enumerate )으로 둡니다.? ForIn/OfBodyEvaluation (ForBinding , Statement , keyResult , enumerate , var-binding , labelSet )을 반환합니다.
ForInOfStatement :
for
(
ForDeclaration
in
Expression
)
Statement
keyResult 를 ? ForIn/OfHeadEvaluation (ForDeclaration 의 BoundNames , Expression , enumerate )으로 둡니다.? ForIn/OfBodyEvaluation (ForDeclaration , Statement , keyResult , enumerate , lexical-binding , labelSet )을 반환합니다.
ForInOfStatement :
for
(
LeftHandSideExpression
of
AssignmentExpression
)
Statement
keyResult 를 ? ForIn/OfHeadEvaluation (« », AssignmentExpression , iterate )으로 둡니다.? ForIn/OfBodyEvaluation (LeftHandSideExpression , Statement , keyResult , iterate , assignment , labelSet )을 반환합니다.
ForInOfStatement :
for
(
var
ForBinding
of
AssignmentExpression
)
Statement
keyResult 를 ? ForIn/OfHeadEvaluation (« », AssignmentExpression , iterate )으로 둡니다.? ForIn/OfBodyEvaluation (ForBinding , Statement , keyResult , iterate , var-binding , labelSet )을 반환합니다.
ForInOfStatement :
for
(
ForDeclaration
of
AssignmentExpression
)
Statement
keyResult 를 ? ForIn/OfHeadEvaluation (ForDeclaration 의 BoundNames , AssignmentExpression , iterate )으로 둡니다.? ForIn/OfBodyEvaluation (ForDeclaration , Statement , keyResult , iterate , lexical-binding , labelSet )을 반환합니다.
ForInOfStatement :
for
await
(
LeftHandSideExpression
of
AssignmentExpression
)
Statement
keyResult 를 ? ForIn/OfHeadEvaluation (« », AssignmentExpression , async-iterate )으로 둡니다.? ForIn/OfBodyEvaluation (LeftHandSideExpression , Statement , keyResult , iterate , assignment , labelSet , async )을 반환합니다.
ForInOfStatement :
for
await
(
var
ForBinding
of
AssignmentExpression
)
Statement
keyResult 를 ? ForIn/OfHeadEvaluation (« », AssignmentExpression , async-iterate )으로 둡니다.? ForIn/OfBodyEvaluation (ForBinding , Statement , keyResult , iterate , var-binding , labelSet , async )을 반환합니다.
ForInOfStatement :
for
await
(
ForDeclaration
of
AssignmentExpression
)
Statement
keyResult 를 ? ForIn/OfHeadEvaluation (ForDeclaration 의 BoundNames , AssignmentExpression , async-iterate )으로 둡니다.? ForIn/OfBodyEvaluation (ForDeclaration , Statement , keyResult , iterate , lexical-binding , labelSet , async )을 반환합니다.
참고
14.7.5.6 ForIn/OfHeadEvaluation ( uninitializedBoundNames , expr , iterationKind )
추상 연산 ForIn/OfHeadEvaluation. 인수 uninitializedBoundNames (리스트 (요소: String)), expr ((an Expression Parse Node 또는 an AssignmentExpression Parse Node)) 및 iterationKind ((enumerate , iterate 또는 async-iterate )). 반환값: (정상 완료 (값: Iterator 레코드 ) 또는 중도 완료). 호출되면 다음 단계를 수행한다.
oldEnv 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.uninitializedBoundNames 가 비어 있지 않으면, 다음을 수행합니다.단언 : uninitializedBoundNames 에는 중복 항목이 없습니다.newEnv 를 NewDeclarativeEnvironment (oldEnv )로 둡니다.uninitializedBoundNames 의 각 String name 에 대해 다음을 수행합니다.! newEnv .CreateMutableBinding (name , false )를 수행합니다. 실행 중인 실행 컨텍스트 의 LexicalEnvironment를 newEnv 로 설정합니다.exprRef 를 Completion (expr 의 Evaluation )으로 둡니다.실행 중인 실행 컨텍스트 의 LexicalEnvironment를 oldEnv 로 설정합니다.exprValue 를 ? GetValue (? exprRef )로 둡니다.iterationKind 가 enumerate 이면, 다음을 수행합니다.exprValue 가 undefined 또는 null 이면, 다음을 수행합니다.Completion Record { [[Type]] : break , [[Value]] : empty , [[Target]] : empty }를 반환합니다.obj 를 ! ToObject (exprValue )로 둡니다.iterator 를 EnumerateObjectProperties (obj )로 둡니다.nextMethod 를 ! GetV (iterator , "next" )로 둡니다.Iterator Record { [[Iterator]] : iterator , [[NextMethod]] : nextMethod , [[Done]] : false }를 반환합니다.단언 : iterationKind 는 iterate 또는 async-iterate 입니다.iterationKind 가 async-iterate 이면 iteratorKind 를 async 로 둡니다.그렇지 않으면 iteratorKind 를 sync 로 둡니다. ? GetIterator (exprValue , iteratorKind )를 반환합니다.
14.7.5.7 ForIn/OfBodyEvaluation ( lhs , stmt , iteratorRecord , iterationKind , lhsKind , labelSet [ , iteratorKind ] )
추상 연산 ForIn/OfBodyEvaluation. 인수 lhs (구문 분석 노드), stmt (a Statement Parse Node), iteratorRecord (Iterator 레코드 ), iterationKind ((enumerate 또는 iterate )), lhsKind ((assignment , var-binding 또는 lexical-binding )) 및 labelSet (리스트 (요소: String)) 및 선택적 인수 iteratorKind ((sync 또는 async )). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 중도 완료). 호출되면 다음 단계를 수행한다.
iteratorKind 가 존재하지 않으면 iteratorKind 를 sync 로 설정합니다.oldEnv 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.iterationResult 를 undefined 로 둡니다.lhsKind 가 lexical-binding 이면, 다음을 수행합니다.단언 : lhs 는 ForDeclaration 입니다.lhs 의 IsAwaitUsingDeclaration 이 true 이면, 다음을 수행합니다.declKind 를 async-dispose 로 둡니다.그렇지 않고 lhs 의 IsUsingDeclaration 이 true 이면, 다음을 수행합니다.declKind 를 sync-dispose 로 둡니다. 그렇지 않으면,declKind 를 normal 로 둡니다. 그렇지 않으면,declKind 를 normal 로 둡니다. destructuring 을 lhs 의 IsDestructuring 으로 둡니다.destructuring 이 true 이고 lhsKind 가 assignment 이면, 다음을 수행합니다.단언 : lhs 는 LeftHandSideExpression 입니다.assignmentPattern 을 lhs 가 포괄하는 AssignmentPattern 으로 둡니다.다음을 반복합니다.nextResult 를 ? Call (iteratorRecord .[[NextMethod]] , iteratorRecord .[[Iterator]] )로 둡니다.iteratorKind 가 async 이면 nextResult 를 ? Await (nextResult )로 설정합니다.nextResult 가 Object가 아니면 TypeError 예외를 던집니다.done 을 ? IteratorComplete (nextResult )로 둡니다.done 이 true 이면 iterationResult 를 반환합니다.nextValue 를 ? IteratorValue (nextResult )로 둡니다.lhsKind 가 assignment 또는 var-binding 이면, 다음을 수행합니다.destructuring 이 true 이면, 다음을 수행합니다.lhsKind 가 assignment 이면, 다음을 수행합니다.status 를 Completion (인수 nextValue 를 사용한 assignmentPattern 의 DestructuringAssignmentEvaluation )으로 둡니다.그렇지 않으면,단언 : lhsKind 는 var-binding 입니다.단언 : lhs 는 ForBinding 입니다.status 를 Completion (인수 nextValue 및 undefined 를 사용한 lhs 의 BindingInitialization )으로 둡니다. 그렇지 않으면,lhsRef 를 Completion (lhs 의 Evaluation )으로 둡니다. (반복해서 평가될 수 있습니다.)lhsKind 가 assignment 이고 lhs 의 AssignmentTargetType 이 web-compat 이면 ReferenceError 예외를 던집니다.lhsRef 가 비정상 완료 이면, 다음을 수행합니다.status 를 lhsRef 로 둡니다.그렇지 않으면,status 를 Completion (PutValue (lhsRef .[[Value]] , nextValue ))으로 둡니다. iterationEnv 를 undefined 로 둡니다.그렇지 않으면,단언 : lhsKind 는 lexical-binding 입니다.단언 : lhs 는 ForDeclaration 입니다.iterationEnv 를 NewDeclarativeEnvironment (oldEnv )로 둡니다.인수 iterationEnv 를 사용한 lhs 의 ForDeclarationBindingInstantiation 을 수행합니다. 실행 중인 실행 컨텍스트 의 LexicalEnvironment를 iterationEnv 로 설정합니다.destructuring 이 true 이면, 다음을 수행합니다.status 를 Completion (인수 nextValue 및 iterationEnv 를 사용한 lhs 의 ForDeclarationBindingInitialization )으로 둡니다.그렇지 않으면,단언 : lhs 는 하나의 이름을 바인딩합니다.lhsName 을 lhs 의 BoundNames 의 유일한 요소로 둡니다.lhsRef 를 ! ResolveBinding (lhsName )으로 둡니다.declKind 가 normal 이 아니면, 다음을 수행합니다.단언 : IsUnresolvableReference (lhsRef )는 false 입니다.base 를 lhsRef .[[Base]] 로 둡니다.단언 : base 는 Declarative Environment Record 입니다.status 를 Completion (AddDisposableResource (base .[[DisposableResourceStack]] , nextValue , declKind ))으로 둡니다.그렇지 않으면,status 를 NormalCompletion (unused )으로 둡니다. status 가 정상 완료 이면, 다음을 수행합니다.status 를 Completion (InitializeReferencedBinding (lhsRef , nextValue ))으로 설정합니다. status 가 비정상 완료 이면, 다음을 수행합니다.iterationEnv 가 undefined 가 아니면, 다음을 수행합니다.status 를 Completion (DisposeResources (iterationEnv .[[DisposableResourceStack]] , status ))으로 설정합니다.단언 : status 는 비정상 완료 입니다.실행 중인 실행 컨텍스트 의 LexicalEnvironment를 oldEnv 로 설정합니다.iterationKind 가 enumerate 이면 ? status 를 반환합니다.단언 : iterationKind 는 iterate 입니다.iteratorKind 가 async 이면 ? AsyncIteratorClose (iteratorRecord , status )를 반환합니다.? IteratorClose (iteratorRecord , status )를 반환합니다. result 를 Completion (stmt 의 Evaluation )으로 둡니다.iterationEnv 가 undefined 가 아니면, 다음을 수행합니다.result 를 Completion (DisposeResources (iterationEnv .[[DisposableResourceStack]] , result ))으로 설정합니다.실행 중인 실행 컨텍스트 의 LexicalEnvironment를 oldEnv 로 설정합니다.LoopContinues (result , labelSet )가 false 이면, 다음을 수행합니다.status 를 Completion (UpdateEmpty (result , iterationResult ))으로 설정합니다.iterationKind 가 enumerate 이면 ? status 를 반환합니다.단언 : iterationKind 는 iterate 입니다.iteratorKind 가 async 이면 ? AsyncIteratorClose (iteratorRecord , status )를 반환합니다.? IteratorClose (iteratorRecord , status )를 반환합니다. result .[[Value]] 가 empty 가 아니면 iterationResult 를 result .[[Value]] 로 설정합니다.
14.7.5.8 Runtime Semantics: 평가
BindingIdentifier :
Identifier
yield
await
name 을 BindingIdentifier 의 StringValue 로 둡니다.? ResolveBinding (name )을 반환합니다.
14.7.5.9 EnumerateObjectProperties ( obj )
추상 연산 EnumerateObjectProperties. 인수 obj (Object). 반환값: 반복자 객체. 호출되면 다음 단계를 수행한다.
next 메서드가 obj 의 열거 가능한 프로퍼티 중 String 값 키를 모두 순회하는 반복자 객체를 반환합니다. 반복자 객체는 ECMAScript 코드에서 절대로 직접 접근할 수 없습니다. 프로퍼티 열거의 메커니즘과 순서는 명시되지 않지만 아래에 명시된 규칙을 따라야 합니다.
반복자의 throw 및 return 메서드는 null 이며 절대로 호출되지 않습니다. 반복자의 next 메서드는 객체 프로퍼티를 처리하여 해당 프로퍼티 키 를 반복자 값으로 반환할지 결정합니다. 반환되는 프로퍼티 키 에는 Symbol인 키가 포함되지 않습니다. 대상 객체의 프로퍼티는 열거 중에 삭제될 수 있습니다. 반복자의 next 메서드가 처리하기 전에 삭제된 프로퍼티는 무시됩니다. 열거 중 대상 객체에 새로운 프로퍼티가 추가되더라도 현재 진행 중인 열거에서 새로 추가된 프로퍼티가 처리된다는 보장은 없습니다. 어떤 프로퍼티 이름 도 하나의 열거에서 반복자의 next 메서드에 의해 두 번 이상 반환되지 않습니다.
대상 객체의 프로퍼티 열거에는 해당 프로토타입, 프로토타입의 프로토타입 등의 프로퍼티를 재귀적으로 열거하는 것도 포함됩니다. 그러나 프로토타입의 프로퍼티가 반복자의 next 메서드에 의해 이미 처리된 프로퍼티와 같은 이름이면 처리하지 않습니다. 프로토타입 객체의 프로퍼티가 이미 처리되었는지를 결정할 때 [[Enumerable]] 속성 값은 고려하지 않습니다. 프로토타입 객체의 열거 가능한 프로퍼티 이름 은 해당 프로토타입 객체를 인수로 전달하여 EnumerateObjectProperties를 호출해 얻어야 합니다. EnumerateObjectProperties는 대상 객체의 자체 프로퍼티 키 를 [[OwnPropertyKeys]] 내부 메서드를 호출하여 얻어야 합니다. 대상 객체의 프로퍼티 속성은 [[GetOwnProperty]] 내부 메서드를 호출하여 얻어야 합니다.
또한 obj 와 그 프로토타입 체인의 모든 객체가 Proxy 특수 객체 , TypedArray , 모듈 네임스페이스 특수 객체 또는 구현체가 제공하는 특수 객체 가 아닌 경우, 다음 중 하나가 발생하기 전까지 반복자는 CreateForInIterator (obj )가 제공하는 반복자처럼 동작해야 합니다:
obj 또는 그 프로토타입 체인의 객체에 있는 [[Prototype]] 내부 슬롯 값이 변경되는 경우,
obj 또는 그 프로토타입 체인의 객체에서 프로퍼티가 제거되는 경우,
obj 의 프로토타입 체인의 객체에 프로퍼티가 추가되는 경우, 또는
obj 또는 그 프로토타입 체인의 객체에 있는 프로퍼티의 [[Enumerable]] 속성 값이 변경되는 경우.
참고 1
ECMAScript 구현체는 14.7.5.10.2.1 의 알고리즘을 직접 구현할 필요가 없습니다. 앞 단락의 제약 조건 중 하나가 위반되지 않는 한 해당 알고리즘의 동작과 달라지지 않는 어떤 구현이든 선택할 수 있습니다.
다음은 이러한 규칙을 준수하는 ECMAScript 제너레이터 함수의 참고 용 정의입니다:
function * EnumerateObjectProperties (obj) {
const visited = new Set ();
for (const key of Reflect .ownKeys (obj)) {
if (typeof key === "symbol" ) continue ;
const desc = Reflect .getOwnPropertyDescriptor (obj, key);
if (desc) {
visited.add (key);
if (desc.enumerable ) yield key;
}
}
const proto = Reflect .getPrototypeOf (obj);
if (proto === null ) return ;
for (const protoKey of EnumerateObjectProperties (proto)) {
if (!visited.has (protoKey)) yield protoKey;
}
}
참고 2
구현체가
CreateForInIterator 와 동작을 일치시킬 필요가 없는
특수 객체 의 목록은 구현체들이 역사적으로 이러한 경우에는 동작이 달랐고 그 밖의 모든 경우에는 일치했기 때문에 선택되었습니다.
14.7.5.10 For-In 반복자 객체
For-In 반복자 는 특정 객체에 대한 특정 반복을 나타내는 객체입니다. For-In 반복자 객체는 ECMAScript 코드에서 절대로 직접 접근할 수 없으며 EnumerateObjectProperties 의 동작을 설명하기 위해서만 존재합니다.
14.7.5.10.1 CreateForInIterator ( obj )
추상 연산 CreateForInIterator. 인수 obj (Object). 반환값: For-In 반복자 . obj 의 자체 및 상속된 열거 가능한 문자열 프로퍼티를 특정 순서로 반복하는 For-In 반복자 객체를 생성하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
iterator 를 OrdinaryObjectCreate (%ForInIteratorPrototype% , « [[Object]] , [[ObjectWasVisited]] , [[VisitedKeys]] , [[RemainingKeys]] »)로 둡니다.iterator .[[Object]] 을 obj 로 설정합니다.iterator .[[ObjectWasVisited]] 를 false 로 설정합니다.iterator .[[VisitedKeys]] 를 새로운 빈 List 로 설정합니다.iterator .[[RemainingKeys]] 를 새로운 빈 List 로 설정합니다.iterator 를 반환합니다.
14.7.5.10.2 %ForInIteratorPrototype% 객체
%ForInIteratorPrototype% 객체는:
14.7.5.10.2.1 %ForInIteratorPrototype%.next ( )
iterator 를 this 값으로 둡니다.단언 : iterator 는 Object입니다.단언 : iterator 에는 For-In 반복자 인스턴스의 모든 내부 슬롯(14.7.5.10.3 )이 있습니다.obj 를 iterator .[[Object]] 로 둡니다.다음을 반복합니다.iterator .[[ObjectWasVisited]] 가 false 이면, 다음을 수행합니다.keys 를 ? obj .[[OwnPropertyKeys]] () 로 둡니다.keys 의 각 요소 key 에 대해 다음을 수행합니다.key 가 String이면, 다음을 수행합니다.key 를 iterator .[[RemainingKeys]] 에 추가합니다.iterator .[[ObjectWasVisited]] 를 true 로 설정합니다.iterator .[[RemainingKeys]] 가 비어 있지 않은 동안 다음을 반복합니다.key 를 iterator .[[RemainingKeys]] 의 첫 번째 요소로 둡니다.iterator .[[RemainingKeys]] 에서 첫 번째 요소를 제거합니다.iterator .[[VisitedKeys]] 에 key 가 포함되어 있지 않으면, 다음을 수행합니다.propertyDesc 를 ? obj .[[GetOwnProperty]] (key ) 로 둡니다.propertyDesc 가 undefined 가 아니면, 다음을 수행합니다.key 를 iterator .[[VisitedKeys]] 에 추가합니다.propertyDesc .[[Enumerable]] 이 true 이면 CreateIteratorResultObject (key , false )를 반환합니다.obj 를 ? obj .[[GetPrototypeOf]] () 로 설정합니다.iterator .[[Object]] 을 obj 로 설정합니다.iterator .[[ObjectWasVisited]] 를 false 로 설정합니다.obj 가 null 이면 CreateIteratorResultObject (undefined , true )를 반환합니다.
14.7.5.10.3 For-In 반복자 인스턴스의 프로퍼티
For-In 반복자 인스턴스는 %ForInIteratorPrototype% 내재 객체에서 프로퍼티를 상속하는 일반 객체 입니다. For-In 반복자 인스턴스는 처음에 표 34 에 나열된 내부 슬롯을 갖도록 생성됩니다.
표 34: For-In 반복자 인스턴스의 내부 슬롯
내부 슬롯
타입
설명
[[Object]]
Object
프로퍼티를 반복 중인 Object 값입니다.
[[ObjectWasVisited]]
Boolean
반복자가 [[Object]] 에서 [[OwnPropertyKeys]] 를 호출했으면 true , 그렇지 않으면 false 입니다.
[[VisitedKeys]]
String의 List
지금까지 이 반복자가 내보낸 값입니다.
[[RemainingKeys]]
String의 List
프로토타입의 프로퍼티를 반복하기 전에(프로토타입이 null 이 아닌 경우) 현재 객체에 대해 아직 내보내야 하는 값입니다.
14.8 continue 문
구문
ContinueStatement [Yield, Await] :
continue
;
continue
[no LineTerminator here]
LabelIdentifier [?Yield, ?Await]
;
14.8.1 Static Semantics: 조기 오류
ContinueStatement :
continue
;
continue
LabelIdentifier
;
14.8.2 Runtime Semantics: 평가
ContinueStatement :
continue
;
Completion Record { [[Type]] : continue , [[Value]] : empty , [[Target]] : empty }를 반환합니다.
ContinueStatement :
continue
LabelIdentifier
;
label 을 LabelIdentifier 의 StringValue 로 둡니다.Completion Record { [[Type]] : continue , [[Value]] : empty , [[Target]] : label }를 반환합니다.
14.9 break 문
구문
BreakStatement [Yield, Await] :
break
;
break
[no LineTerminator here]
LabelIdentifier [?Yield, ?Await]
;
14.9.1 Static Semantics: 조기 오류
BreakStatement :
break
;
14.9.2 Runtime Semantics: 평가
BreakStatement :
break
;
Completion Record { [[Type]] : break , [[Value]] : empty , [[Target]] : empty }를 반환합니다.
BreakStatement :
break
LabelIdentifier
;
label 을 LabelIdentifier 의 StringValue 로 둡니다.Completion Record { [[Type]] : break , [[Value]] : empty , [[Target]] : label }를 반환합니다.
14.10 return 문
구문
ReturnStatement [Yield, Await] :
return
;
return
[no LineTerminator here]
Expression [+In, ?Yield, ?Await]
;
참고
return 문은 함수 실행을 중지시키며 대부분의 경우 호출자에게 값을 반환합니다. Expression 을 생략하면 반환 값은 undefined 입니다. 그렇지 않으면 반환 값은 Expression 의 값입니다. 주변 문맥에 따라 return 문이 실제로 호출자에게 값을 반환하지 않을 수도 있습니다. 예를 들어 try 블록에서 return 문의 Completion Record 는 finally 블록을 평가하는 동안 다른 Completion Record 로 교체될 수 있습니다.
14.10.1 Runtime Semantics: 평가
ReturnStatement :
return
;
ReturnCompletion (undefined )을 반환합니다.
ReturnStatement :
return
Expression
;
exprRef 를 Expression 의 ? Evaluation 으로 둡니다.exprValue 를 ? GetValue (exprRef )로 둡니다.GetGeneratorKind ()가 async 이면 exprValue 를 ? Await (exprValue )로 설정합니다.ReturnCompletion (exprValue )을 반환합니다.
14.11 with 문
참고 1
새로운 ECMAScript 코드에서는 레거시 with 문의 사용을 권장하지 않습니다. 구조 분해 할당 과 같이 엄격 모드 코드 와 비엄격 코드 모두에서 허용되는 대안을 고려하시기 바랍니다.
구문
WithStatement [Yield, Await, Return] :
with
(
Expression [+In, ?Yield, ?Await]
)
Statement [?Yield, ?Await, ?Return]
참고 2
with 문은 계산된 객체에 대한 Object Environment Record 를 실행 중인 실행 컨텍스트 의 렉시컬 환경에 추가합니다. 그런 다음 이 확장된 렉시컬 환경을 사용하여 문을 실행합니다. 마지막으로 원래 렉시컬 환경을 복원합니다.
14.11.1 Static Semantics: 조기 오류
WithStatement :
with
(
Expression
)
Statement
참고
B.3.1 에 명시된 확장을 구현한 경우에만 두 번째 규칙을 적용할 필요가 있습니다.
14.11.2 Runtime Semantics: 평가
WithStatement :
with
(
Expression
)
Statement
value 를 Expression 의 ? Evaluation 으로 둡니다.obj 를 ? ToObject (? GetValue (value ))로 둡니다.oldEnv 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.newEnv 를 NewObjectEnvironment (obj , true , oldEnv )로 둡니다.실행 중인 실행 컨텍스트 의 LexicalEnvironment를 newEnv 로 설정합니다.stmtCompletion 을 Completion (Statement 의 Evaluation )으로 둡니다.실행 중인 실행 컨텍스트 의 LexicalEnvironment를 oldEnv 로 설정합니다.? UpdateEmpty (stmtCompletion , undefined )를 반환합니다.
참고
제어가 포함된 Statement 을 정상적으로 벗어나든 어떤 형태의 비정상 완료 또는 예외로 벗어나든 LexicalEnvironment는 항상 이전 상태로 복원됩니다.
14.12 switch 문
구문
SwitchStatement [Yield, Await, Return] :
switch
(
Expression [+In, ?Yield, ?Await]
)
CaseBlock [?Yield, ?Await, ?Return]
CaseBlock [Yield, Await, Return] :
{
CaseClauses [?Yield, ?Await, ?Return] opt
}
{
CaseClauses [?Yield, ?Await, ?Return] opt
DefaultClause [?Yield, ?Await, ?Return]
CaseClauses [?Yield, ?Await, ?Return] opt
}
CaseClauses [Yield, Await, Return] :
CaseClause [?Yield, ?Await, ?Return]
CaseClauses [?Yield, ?Await, ?Return]
CaseClause [?Yield, ?Await, ?Return]
CaseClause [Yield, Await, Return] :
case
Expression [+In, ?Yield, ?Await]
:
StatementList [?Yield, ?Await, ?Return] opt
DefaultClause [Yield, Await, Return] :
default
:
StatementList [?Yield, ?Await, ?Return] opt
14.12.1 Static Semantics: 조기 오류
SwitchStatement :
switch
(
Expression
)
CaseBlock
CaseClause :
case
Expression
:
StatementList
DefaultClause :
default
:
StatementList
14.12.2 Runtime Semantics: CaseBlockEvaluation
구문 지향 연산 CaseBlockEvaluation. 인수 input (ECMAScript 언어 값 ). 반환값: ECMAScript 언어 값 을 포함하는 정상 완료 또는 비정상 완료 . 다음 생성 규칙별로 정의된다.
CaseBlock :
{
}
undefined 를 반환합니다.
CaseBlock :
{
CaseClauses
}
resultValue 를 undefined 로 둡니다.caseClauses 를 소스 텍스트 순서로 된 CaseClauses 의 CaseClause 항목 List 로 둡니다.found 를 false 로 둡니다.caseClauses 의 각 CaseClause clause 에 대해 다음을 수행합니다.found 가 false 이면, 다음을 수행합니다.found 를 ? CaseClauseIsSelected (clause , input )로 설정합니다.found 가 true 이면, 다음을 수행합니다.completion 을 Completion (clause 의 Evaluation )으로 둡니다.completion .[[Value]] 가 empty 가 아니면 resultValue 를 completion .[[Value]] 로 설정합니다.completion 이 비정상 완료 이면 ? UpdateEmpty (completion , resultValue )를 반환합니다.resultValue 를 반환합니다.
CaseBlock :
{
CaseClauses opt
DefaultClause
CaseClauses opt
}
resultValue 를 undefined 로 둡니다.첫 번째 CaseClauses 가 존재하면, 다음을 수행합니다.caseClauses 를 소스 텍스트 순서로 된 첫 번째 CaseClauses 의 CaseClause 항목 List 로 둡니다. 그렇지 않으면,caseClauses 를 새로운 빈 List 로 둡니다. found 를 false 로 둡니다.caseClauses 의 각 CaseClause clause 에 대해 다음을 수행합니다.found 가 false 이면, 다음을 수행합니다.found 를 ? CaseClauseIsSelected (clause , input )로 설정합니다.found 가 true 이면, 다음을 수행합니다.completion 을 Completion (clause 의 Evaluation )으로 둡니다.completion .[[Value]] 가 empty 가 아니면 resultValue 를 completion .[[Value]] 로 설정합니다.completion 이 비정상 완료 이면 ? UpdateEmpty (completion , resultValue )를 반환합니다.foundInB 를 false 로 둡니다.두 번째 CaseClauses 가 존재하면, 다음을 수행합니다.secondCaseClauses 를 소스 텍스트 순서로 된 두 번째 CaseClauses 의 CaseClause 항목 List 로 둡니다. 그렇지 않으면,secondCaseClauses 를 새로운 빈 List 로 둡니다. found 가 false 이면, 다음을 수행합니다.secondCaseClauses 의 각 CaseClause clause 에 대해 다음을 수행합니다.foundInB 가 false 이면, 다음을 수행합니다.foundInB 를 ? CaseClauseIsSelected (clause , input )로 설정합니다.foundInB 가 true 이면, 다음을 수행합니다.completion 을 Completion (CaseClause clause 의 Evaluation )으로 둡니다.completion .[[Value]] 가 empty 가 아니면 resultValue 를 completion .[[Value]] 로 설정합니다.completion 이 비정상 완료 이면 ? UpdateEmpty (completion , resultValue )를 반환합니다.foundInB 가 true 이면 resultValue 를 반환합니다.defaultR 을 Completion (DefaultClause 의 Evaluation )으로 둡니다.defaultR .[[Value]] 가 empty 가 아니면 resultValue 를 defaultR .[[Value]] 로 설정합니다.defaultR 이 비정상 완료 이면 ? UpdateEmpty (defaultR , resultValue )를 반환합니다.참고 : 다음은 두 번째 CaseClauses 를 다시 완전히 반복하는 것입니다.secondCaseClauses 의 각 CaseClause clause 에 대해 다음을 수행합니다.completion 을 Completion (CaseClause clause 의 Evaluation )으로 둡니다.completion .[[Value]] 가 empty 가 아니면 resultValue 를 completion .[[Value]] 로 설정합니다.completion 이 비정상 완료 이면 ? UpdateEmpty (completion , resultValue )를 반환합니다.resultValue 를 반환합니다.
14.12.3 CaseClauseIsSelected ( caseClauseNode , input )
추상 연산 CaseClauseIsSelected. 인수 caseClauseNode (CaseClause Parse Node) 및 input (ECMAScript 언어 값 ). 반환값: Boolean을 포함하는 정상 완료 또는 비정상 완료 . caseClauseNode 가 input 과 일치하는지 결정합니다. 호출되면 다음 단계를 수행한다.
단언 : caseClauseNode 는 생성 규칙
CaseClause :
case
Expression
:
StatementList opt
의 인스턴스입니다.exprRef 를 caseClauseNode 의 Expression 의 ? Evaluation 으로 둡니다.clauseSelector 를 ? GetValue (exprRef )로 둡니다.IsStrictlyEqual (input , clauseSelector )을 반환합니다.
참고
이 연산은 caseClauseNode 의 StatementList (있는 경우)를 실행하지 않습니다. CaseBlock 알고리즘은 이 연산의 반환 값을 사용하여 어느 StatementList 부터 실행을 시작할지 결정합니다.
14.12.4 Runtime Semantics: 평가
SwitchStatement :
switch
(
Expression
)
CaseBlock
exprRef 를 Expression 의 ? Evaluation 으로 둡니다.switchValue 를 ? GetValue (exprRef )로 둡니다.oldEnv 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.blockEnv 를 NewDeclarativeEnvironment (oldEnv )로 둡니다.BlockDeclarationInstantiation (CaseBlock , blockEnv )을 수행합니다.실행 중인 실행 컨텍스트 의 LexicalEnvironment를 blockEnv 로 설정합니다.blockResult 를 Completion (인수 switchValue 를 사용한 CaseBlock 의 CaseBlockEvaluation )으로 둡니다.단언 : blockEnv .[[DisposableResourceStack]] 은 빈 List 입니다.실행 중인 실행 컨텍스트 의 LexicalEnvironment를 oldEnv 로 설정합니다.blockResult 를 반환합니다.
참고
제어가 어떤 방식으로 SwitchStatement 을 벗어나더라도 LexicalEnvironment는 항상 이전 상태로 복원됩니다.
CaseClause :
case
Expression
:
empty 를 반환합니다.
CaseClause :
case
Expression
:
StatementList
StatementList 의 ? Evaluation 을 반환합니다.
DefaultClause :
default
:
empty 를 반환합니다.
DefaultClause :
default
:
StatementList
StatementList 의 ? Evaluation 을 반환합니다.
14.13 레이블 문
구문
LabelledStatement [Yield, Await, Return] :
LabelIdentifier [?Yield, ?Await]
:
LabelledItem [?Yield, ?Await, ?Return]
LabelledItem [Yield, Await, Return] :
Statement [?Yield, ?Await, ?Return]
FunctionDeclaration [?Yield, ?Await, ~Default]
참고
Statement 앞에는 레이블을 붙일 수 있습니다. 레이블 문은 레이블이 있는 break 및 continue 문과 함께 사용하는 경우에만 사용됩니다. ECMAScript에는 goto 문이 없습니다. Statement 은 LabelledStatement 의 일부가 될 수 있고, 해당 LabelledStatement 자체도 다시 LabelledStatement 의 일부가 될 수 있으며 이런 식으로 계속될 수 있습니다. 이 방식으로 도입된 레이블은 개별 문의 의미론을 설명할 때 통틀어 “현재 레이블 집합”이라고 합니다.
14.13.1 Static Semantics: 조기 오류
LabelledItem : FunctionDeclaration
14.13.2 Static Semantics: IsLabelledFunction ( stmt )
추상 연산 IsLabelledFunction. 인수 stmt (Statement Parse Node). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
stmt 가 LabelledStatement 이 아니면 false 를 반환합니다.item 을 stmt 의 LabelledItem 으로 둡니다.item 이
LabelledItem : FunctionDeclaration
이면 true 를 반환합니다.subStmt 를 item 의 Statement 으로 둡니다.IsLabelledFunction (subStmt )을 반환합니다.
14.13.3 Runtime Semantics: 평가
LabelledStatement :
LabelIdentifier
:
LabelledItem
인수 « »을 사용한 이 LabelledStatement 의 ? LabelledEvaluation 을 반환합니다.
14.13.4 Runtime Semantics: LabelledEvaluation
구문 지향 연산 LabelledEvaluation. 인수 labelSet (String의 List ). 반환값: ECMAScript 언어 값 또는 empty 를 포함하는 정상 완료 또는 비정상 완료 . 다음 생성 규칙별로 정의된다.
BreakableStatement : IterationStatement
stmtResult 를 Completion (인수 labelSet 을 사용한 IterationStatement 의 LoopEvaluation )으로 둡니다.stmtResult 가 break 완료 이면, 다음을 수행합니다.stmtResult .[[Target]] 이 empty 이면, 다음을 수행합니다.stmtResult .[[Value]] 가 empty 이면 stmtResult 를 NormalCompletion (undefined )으로 설정합니다.그렇지 않으면 stmtResult 를 NormalCompletion (stmtResult .[[Value]] )으로 설정합니다. ? stmtResult 를 반환합니다.
BreakableStatement : SwitchStatement
stmtResult 를 Completion (SwitchStatement 의 Evaluation )으로 둡니다.stmtResult 가 break 완료 이면, 다음을 수행합니다.stmtResult .[[Target]] 이 empty 이면, 다음을 수행합니다.stmtResult .[[Value]] 가 empty 이면 stmtResult 를 NormalCompletion (undefined )으로 설정합니다.그렇지 않으면 stmtResult 를 NormalCompletion (stmtResult .[[Value]] )으로 설정합니다. ? stmtResult 를 반환합니다.
참고 1
LabelledStatement :
LabelIdentifier
:
LabelledItem
label 을 LabelIdentifier 의 StringValue 로 둡니다.newLabelSet 을 labelSet 과 « label »의 목록 연결 로 둡니다.stmtResult 를 Completion (인수 newLabelSet 을 사용한 LabelledItem 의 LabelledEvaluation )으로 둡니다.stmtResult 가 break 완료 이고 stmtResult .[[Target]] 이 label 이면, 다음을 수행합니다.stmtResult 를 NormalCompletion (stmtResult .[[Value]] )으로 설정합니다.? stmtResult 를 반환합니다.
LabelledItem : FunctionDeclaration
FunctionDeclaration 의 ? Evaluation 을 반환합니다.
Statement :
BlockStatement
VariableStatement
EmptyStatement
ExpressionStatement
IfStatement
ContinueStatement
BreakStatement
ReturnStatement
WithStatement
ThrowStatement
TryStatement
DebuggerStatement
Statement 의 ? Evaluation 을 반환합니다.
참고 2
LabelledEvaluation에 특별한 의미론을 갖는 Statement 의 생성 규칙은 BreakableStatement 과 LabelledStatement 두 가지뿐입니다.
14.14 throw 문
구문
ThrowStatement [Yield, Await] :
throw
[no LineTerminator here]
Expression [+In, ?Yield, ?Await]
;
14.14.1 Runtime Semantics: 평가
ThrowStatement :
throw
Expression
;
exprRef 를 Expression 의 ? Evaluation 으로 둡니다.exprValue 를 ? GetValue (exprRef )로 둡니다.exprValue 를 던집니다.
14.15 try 문
구문
TryStatement [Yield, Await, Return] :
try
Block [?Yield, ?Await, ?Return]
Catch [?Yield, ?Await, ?Return]
try
Block [?Yield, ?Await, ?Return]
Finally [?Yield, ?Await, ?Return]
try
Block [?Yield, ?Await, ?Return]
Catch [?Yield, ?Await, ?Return]
Finally [?Yield, ?Await, ?Return]
Catch [Yield, Await, Return] :
catch
(
CatchParameter [?Yield, ?Await]
)
Block [?Yield, ?Await, ?Return]
catch
Block [?Yield, ?Await, ?Return]
Finally [Yield, Await, Return] :
finally
Block [?Yield, ?Await, ?Return]
CatchParameter [Yield, Await] :
BindingIdentifier [?Yield, ?Await]
BindingPattern [?Yield, ?Await]
참고
try 문은 런타임 오류 또는 throw 문과 같은 예외 상황이 발생할 수 있는 코드 블록을 둘러쌉니다. catch 절은 예외 처리 코드를 제공합니다. catch 절이 예외를 포착하면 해당 CatchParameter 는 그 예외에 바인딩됩니다.
14.15.1 Static Semantics: 조기 오류
Catch :
catch
(
CatchParameter
)
Block
14.15.2 Runtime Semantics: CatchClauseEvaluation
구문 지향 연산 CatchClauseEvaluation. 인수 thrownValue (ECMAScript 언어 값 ). 반환값: ECMAScript 언어 값 또는 empty 를 포함하는 정상 완료 또는 비정상 완료 . 다음 생성 규칙별로 정의된다.
Catch :
catch
(
CatchParameter
)
Block
oldEnv 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.catchEnv 를 NewDeclarativeEnvironment (oldEnv )로 둡니다.CatchParameter 의 BoundNames 의 각 요소 argName 에 대해 다음을 수행합니다.! catchEnv .CreateMutableBinding (argName , false )를 수행합니다. 실행 중인 실행 컨텍스트 의 LexicalEnvironment를 catchEnv 로 설정합니다.status 를 Completion (인수 thrownValue 및 catchEnv 를 사용한 CatchParameter 의 BindingInitialization )으로 둡니다.status 가 비정상 완료 이면, 다음을 수행합니다.실행 중인 실행 컨텍스트 의 LexicalEnvironment를 oldEnv 로 설정합니다.? status 를 반환합니다. blockCompletion 을 Completion (Block 의 Evaluation )으로 둡니다.실행 중인 실행 컨텍스트 의 LexicalEnvironment를 oldEnv 로 설정합니다.? blockCompletion 을 반환합니다.
Catch :
catch
Block
Block 의 ? Evaluation 을 반환합니다.
참고
제어가 어떤 방식으로 Block 을 벗어나더라도 LexicalEnvironment는 항상 이전 상태로 복원됩니다.
14.15.3 Runtime Semantics: 평가
TryStatement :
try
Block
Catch
blockResult 를 Completion (Block 의 Evaluation )으로 둡니다.blockResult 가 throw 완료 이면 catchResult 를 Completion (인수 blockResult .[[Value]] 를 사용한 Catch 의 CatchClauseEvaluation )으로 둡니다.그렇지 않으면 catchResult 를 blockResult 로 둡니다. ? UpdateEmpty (catchResult , undefined )를 반환합니다.
TryStatement :
try
Block
Finally
blockResult 를 Completion (Block 의 Evaluation )으로 둡니다.finallyResult 를 Completion (Finally 의 Evaluation )으로 둡니다.finallyResult 가 정상 완료 이면 finallyResult 를 blockResult 로 설정합니다.? UpdateEmpty (finallyResult , undefined )를 반환합니다.
TryStatement :
try
Block
Catch
Finally
blockResult 를 Completion (Block 의 Evaluation )으로 둡니다.blockResult 가 throw 완료 이면 catchResult 를 Completion (인수 blockResult .[[Value]] 를 사용한 Catch 의 CatchClauseEvaluation )으로 둡니다.그렇지 않으면 catchResult 를 blockResult 로 둡니다. finallyResult 를 Completion (Finally 의 Evaluation )으로 둡니다.finallyResult 가 정상 완료 이면 finallyResult 를 catchResult 로 설정합니다.? UpdateEmpty (finallyResult , undefined )를 반환합니다.
14.16 debugger 문
구문
DebuggerStatement :
debugger
;
14.16.1 Runtime Semantics: 평가
참고
DebuggerStatement 을 평가하면 디버거에서 실행할 때 구현체가 중단점을 발생시킬 수 있습니다. 디버거가 없거나 활성 상태가 아니면 이 문은 관찰 가능한 효과가 없습니다.
DebuggerStatement :
debugger
;
구현체 정의 디버깅 기능을 사용할 수 있고 활성화되어 있으면, 다음을 수행합니다.구현체 정의 디버깅 동작을 수행합니다.새로운 구현체 정의 Completion Record 를 반환합니다. empty 를 반환합니다.
15 ECMAScript 언어: 함수와 클래스
참고
다양한 ECMAScript 언어 요소는 ECMAScript 함수 객체 (10.2 )를 생성합니다. 이러한 함수의 평가는 해당 [[Call]] 내부 메서드(10.2.1 )의 실행으로 시작합니다.
15.1 매개변수 목록
구문
UniqueFormalParameters [Yield, Await] :
FormalParameters [?Yield, ?Await]
FormalParameters [Yield, Await] :
[empty]
FunctionRestParameter [?Yield, ?Await]
FormalParameterList [?Yield, ?Await]
FormalParameterList [?Yield, ?Await]
,
FormalParameterList [?Yield, ?Await]
,
FunctionRestParameter [?Yield, ?Await]
FormalParameterList [Yield, Await] :
FormalParameter [?Yield, ?Await]
FormalParameterList [?Yield, ?Await]
,
FormalParameter [?Yield, ?Await]
FunctionRestParameter [Yield, Await] :
BindingRestElement [?Yield, ?Await]
FormalParameter [Yield, Await] :
BindingElement [?Yield, ?Await]
15.1.1 Static Semantics: 조기 오류
UniqueFormalParameters : FormalParameters
FormalParameters : FormalParameterList
참고
FormalParameterList 에서 동일한 BindingIdentifier 를 여러 번 사용하는 것은 단순 매개변수 목록을 가지며 엄격 모드 코드 에서 정의되지 않은 함수에만 허용됩니다.
15.1.2 Static Semantics: ContainsExpression
구문 지향 연산 ContainsExpression. 인수 없음. 반환값: Boolean. 다음 생성 규칙별로 정의된다.
ObjectBindingPattern :
{
}
{
BindingRestProperty
}
false 를 반환합니다.
ObjectBindingPattern :
{
BindingPropertyList
,
BindingRestProperty
}
BindingPropertyList 의 ContainsExpression 을 반환합니다.
ArrayBindingPattern :
[
Elision opt
]
false 를 반환합니다.
ArrayBindingPattern :
[
Elision opt
BindingRestElement
]
BindingRestElement 의 ContainsExpression 을 반환합니다.
ArrayBindingPattern :
[
BindingElementList
,
Elision opt
]
BindingElementList 의 ContainsExpression 을 반환합니다.
ArrayBindingPattern :
[
BindingElementList
,
Elision opt
BindingRestElement
]
has 를 BindingElementList 의 ContainsExpression 으로 둡니다.has 가 true 이면 true 를 반환합니다.BindingRestElement 의 ContainsExpression 을 반환합니다.
BindingPropertyList :
BindingPropertyList
,
BindingProperty
has 를 BindingPropertyList 의 ContainsExpression 으로 둡니다.has 가 true 이면 true 를 반환합니다.BindingProperty 의 ContainsExpression 을 반환합니다.
BindingElementList :
BindingElementList
,
BindingElisionElement
has 를 BindingElementList 의 ContainsExpression 으로 둡니다.has 가 true 이면 true 를 반환합니다.BindingElisionElement 의 ContainsExpression 을 반환합니다.
BindingElisionElement :
Elision opt
BindingElement
BindingElement 의 ContainsExpression 을 반환합니다.
BindingProperty :
PropertyName
:
BindingElement
has 를 PropertyName 의 IsComputedPropertyKey 로 둡니다.has 가 true 이면 true 를 반환합니다.BindingElement 의 ContainsExpression 을 반환합니다.
BindingElement :
BindingPattern
Initializer
true 를 반환합니다.
SingleNameBinding : BindingIdentifier
false 를 반환합니다.
SingleNameBinding :
BindingIdentifier
Initializer
true 를 반환합니다.
BindingRestElement :
...
BindingIdentifier
false 를 반환합니다.
BindingRestElement :
...
BindingPattern
BindingPattern 의 ContainsExpression 을 반환합니다.
FormalParameters : [empty]
false 를 반환합니다.
FormalParameters :
FormalParameterList
,
FunctionRestParameter
FormalParameterList 의 ContainsExpression 이 true 이면 true 를 반환합니다.FunctionRestParameter 의 ContainsExpression 을 반환합니다.
FormalParameterList :
FormalParameterList
,
FormalParameter
FormalParameterList 의 ContainsExpression 이 true 이면 true 를 반환합니다.FormalParameter 의 ContainsExpression 을 반환합니다.
ArrowParameters : BindingIdentifier
false 를 반환합니다.
ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList
formals 를 CoverParenthesizedExpressionAndArrowParameterList 가 포괄하는 ArrowFormalParameters 로 둡니다.formals 의 ContainsExpression 을 반환합니다.
AsyncArrowBindingIdentifier : BindingIdentifier
false 를 반환합니다.
15.1.3 Static Semantics: IsSimpleParameterList
구문 지향 연산 IsSimpleParameterList. 인수 없음. 반환값: Boolean. 다음 생성 규칙별로 정의된다.
BindingElement : BindingPattern
false 를 반환합니다.
BindingElement :
BindingPattern
Initializer
false 를 반환합니다.
SingleNameBinding : BindingIdentifier
true 를 반환합니다.
SingleNameBinding :
BindingIdentifier
Initializer
false 를 반환합니다.
FormalParameters : [empty]
true 를 반환합니다.
FormalParameters : FunctionRestParameter
false 를 반환합니다.
FormalParameters :
FormalParameterList
,
FunctionRestParameter
false 를 반환합니다.
FormalParameterList :
FormalParameterList
,
FormalParameter
FormalParameterList 의 IsSimpleParameterList 가 false 이면 false 를 반환합니다.FormalParameter 의 IsSimpleParameterList 를 반환합니다.
FormalParameter : BindingElement
BindingElement 의 IsSimpleParameterList 를 반환합니다.
ArrowParameters : BindingIdentifier
true 를 반환합니다.
ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList
formals 를 CoverParenthesizedExpressionAndArrowParameterList 가 포괄하는 ArrowFormalParameters 로 둡니다.formals 의 IsSimpleParameterList 를 반환합니다.
AsyncArrowBindingIdentifier : BindingIdentifier
true 를 반환합니다.
CoverCallExpressionAndAsyncArrowHead :
MemberExpression
Arguments
head 를 CoverCallExpressionAndAsyncArrowHead 가 포괄하는 AsyncArrowHead 로 둡니다.head 의 IsSimpleParameterList 를 반환합니다.
15.1.4 Static Semantics: HasInitializer
구문 지향 연산 HasInitializer. 인수 없음. 반환값: Boolean. 다음 생성 규칙별로 정의된다.
BindingElement : BindingPattern
false 를 반환합니다.
BindingElement :
BindingPattern
Initializer
true 를 반환합니다.
SingleNameBinding : BindingIdentifier
false 를 반환합니다.
SingleNameBinding :
BindingIdentifier
Initializer
true 를 반환합니다.
FormalParameterList :
FormalParameterList
,
FormalParameter
FormalParameterList 의 HasInitializer 가 true 이면 true 를 반환합니다.FormalParameter 의 HasInitializer 를 반환합니다.
15.1.5 Static Semantics: ExpectedArgumentCount
구문 지향 연산 ExpectedArgumentCount. 인수 없음. 반환값: 음이 아닌 정수. 다음 생성 규칙별로 정의된다.
FormalParameters :
[empty]
FunctionRestParameter
0을 반환합니다.
FormalParameters :
FormalParameterList
,
FunctionRestParameter
FormalParameterList 의 ExpectedArgumentCount 를 반환합니다.
참고
FormalParameterList 의 ExpectedArgumentCount는 나머지 매개변수 또는 Initializer가 있는 첫 번째 FormalParameter 왼쪽에 있는 FormalParameters 의 수입니다. 이니셜라이저가 없는 FormalParameter 는 이니셜라이저가 있는 첫 번째 매개변수 뒤에 나타날 수 있지만, 이러한 매개변수는 기본값이 undefined 인 선택적 매개변수로 간주됩니다.
FormalParameterList : FormalParameter
FormalParameter 의 HasInitializer 가 true 이면 0을 반환합니다.1을 반환합니다.
FormalParameterList :
FormalParameterList
,
FormalParameter
count 를 FormalParameterList 의 ExpectedArgumentCount 로 둡니다.FormalParameterList 의 HasInitializer 가 true 이거나 FormalParameter 의 HasInitializer 가 true 이면 count 를 반환합니다.count + 1을 반환합니다.
ArrowParameters : BindingIdentifier
1을 반환합니다.
ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList
formals 를 CoverParenthesizedExpressionAndArrowParameterList 가 포괄하는 ArrowFormalParameters 로 둡니다.formals 의 ExpectedArgumentCount 를 반환합니다.
PropertySetParameterList : FormalParameter
FormalParameter 의 HasInitializer 가 true 이면 0을 반환합니다.1을 반환합니다.
AsyncArrowBindingIdentifier : BindingIdentifier
1을 반환합니다.
15.2 함수 정의
구문
FunctionDeclaration [Yield, Await, Default] :
function
BindingIdentifier [?Yield, ?Await]
(
FormalParameters [~Yield, ~Await]
)
{
FunctionBody [~Yield, ~Await]
}
[+Default]
function
(
FormalParameters [~Yield, ~Await]
)
{
FunctionBody [~Yield, ~Await]
}
FunctionExpression :
function
BindingIdentifier [~Yield, ~Await] opt
(
FormalParameters [~Yield, ~Await]
)
{
FunctionBody [~Yield, ~Await]
}
FunctionBody [Yield, Await] :
FunctionStatementList [?Yield, ?Await]
FunctionStatementList [Yield, Await] :
StatementList [?Yield, ?Await, +Return] opt
15.2.1 Static Semantics: 조기 오류
FunctionDeclaration :
function
BindingIdentifier
(
FormalParameters
)
{
FunctionBody
}
function
(
FormalParameters
)
{
FunctionBody
}
FunctionExpression :
function
BindingIdentifier opt
(
FormalParameters
)
{
FunctionBody
}
참고
FunctionBody 의 LexicallyDeclaredNames 에는 var 또는 함수 선언을 사용하여 바인딩된 식별자가 포함되지 않습니다.
FunctionBody : FunctionStatementList
15.2.2 Static Semantics: FunctionBodyContainsUseStrict
구문 지향 연산 FunctionBodyContainsUseStrict. 인수 없음. 반환값: Boolean. 다음 생성 규칙별로 정의된다.
FunctionBody : FunctionStatementList
FunctionBody 의 Directive Prologue에 Use Strict Directive가 포함되어 있으면 true 를 반환합니다.false 를 반환합니다.
15.2.3 Runtime Semantics: EvaluateFunctionBody
구문 지향 연산 EvaluateFunctionBody. 인수 funcObj (ECMAScript 함수 객체) 및 argList (리스트 (요소: ECMAScript 언어 값 )). 반환값: (return 완료 또는 throw 완료 ). 다음 생성 규칙별로 정의된다.
FunctionBody : FunctionStatementList
? FunctionDeclarationInstantiation (funcObj , argList )을 수행합니다. FunctionStatementList 의 ? Evaluation 을 수행합니다.참고 : 이전 단계가 정상 완료 를 생성했다면 평가는 FunctionStatementList 의 끝을 지나 진행하여 완료된 것입니다.ReturnCompletion (undefined )을 반환합니다.
15.2.4 Runtime Semantics: InstantiateOrdinaryFunctionObject
구문 지향 연산 InstantiateOrdinaryFunctionObject. 인수 envRecord (Environment 레코드 ) 및 privateEnv ((PrivateEnvironment 레코드 또는 null )). 반환값: ECMAScript 함수 객체. 다음 생성 규칙별로 정의된다.
FunctionDeclaration :
function
BindingIdentifier
(
FormalParameters
)
{
FunctionBody
}
name 을 BindingIdentifier 의 StringValue 로 둡니다.sourceText 를 FunctionDeclaration 과 일치하는 소스 텍스트 로 둡니다.closure 를 OrdinaryFunctionCreate (%Function.prototype% , sourceText , FormalParameters , FunctionBody , non-lexical-this , envRecord , privateEnv )로 둡니다.SetFunctionName (closure , name )을 수행합니다.MakeConstructor (closure )를 수행합니다.closure 를 반환합니다.
FunctionDeclaration :
function
(
FormalParameters
)
{
FunctionBody
}
sourceText 를 FunctionDeclaration 과 일치하는 소스 텍스트 로 둡니다.closure 를 OrdinaryFunctionCreate (%Function.prototype% , sourceText , FormalParameters , FunctionBody , non-lexical-this , envRecord , privateEnv )로 둡니다.SetFunctionName (closure , "default" )를 수행합니다.MakeConstructor (closure )를 수행합니다.closure 를 반환합니다.
참고
익명 FunctionDeclaration 은 export default 선언의 일부로만 나타날 수 있으므로 해당 함수 코드 는 항상 엄격 모드 코드 입니다.
15.2.5 Runtime Semantics: InstantiateOrdinaryFunctionExpression
구문 지향 연산 InstantiateOrdinaryFunctionExpression. 선택적 인수 name ((프로퍼티 키 또는 비공개 이름 )). 반환값: ECMAScript 함수 객체. 다음 생성 규칙별로 정의된다.
FunctionExpression :
function
(
FormalParameters
)
{
FunctionBody
}
name 이 존재하지 않으면 name 을 빈 String으로 설정합니다.envRecord 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.privateEnv 를 실행 중인 실행 컨텍스트 의 PrivateEnvironment로 둡니다.sourceText 를 FunctionExpression 과 일치하는 소스 텍스트 로 둡니다.closure 를 OrdinaryFunctionCreate (%Function.prototype% , sourceText , FormalParameters , FunctionBody , non-lexical-this , envRecord , privateEnv )로 둡니다.SetFunctionName (closure , name )을 수행합니다.MakeConstructor (closure )를 수행합니다.closure 를 반환합니다.
FunctionExpression :
function
BindingIdentifier
(
FormalParameters
)
{
FunctionBody
}
단언 : name 은 존재하지 않습니다.name 을 BindingIdentifier 의 StringValue 로 설정합니다.outerEnv 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.funcEnv 를 NewDeclarativeEnvironment (outerEnv )로 둡니다.! funcEnv .CreateImmutableBinding (name , false )를 수행합니다. privateEnv 를 실행 중인 실행 컨텍스트 의 PrivateEnvironment로 둡니다.sourceText 를 FunctionExpression 과 일치하는 소스 텍스트 로 둡니다.closure 를 OrdinaryFunctionCreate (%Function.prototype% , sourceText , FormalParameters , FunctionBody , non-lexical-this , funcEnv , privateEnv )로 둡니다.SetFunctionName (closure , name )을 수행합니다.MakeConstructor (closure )를 수행합니다.! funcEnv .InitializeBinding (name , closure )를 수행합니다. closure 를 반환합니다.
참고
15.2.6 Runtime Semantics: 평가
FunctionDeclaration :
function
BindingIdentifier
(
FormalParameters
)
{
FunctionBody
}
empty 를 반환합니다.
참고 1
FunctionDeclaration :
function
(
FormalParameters
)
{
FunctionBody
}
empty 를 반환합니다.
FunctionExpression :
function
BindingIdentifier opt
(
FormalParameters
)
{
FunctionBody
}
FunctionExpression 의 InstantiateOrdinaryFunctionExpression 을 반환합니다.
참고 2
FunctionDeclaration 또는 FunctionExpression 을 사용하여 정의된 모든 함수에는 해당 함수가 생성자 로 사용될 가능성을 허용하기 위해 "prototype" 프로퍼티가 자동으로 생성됩니다.
FunctionStatementList : [empty]
undefined 를 반환합니다.
FunctionStatementList : StatementList
result 를 Completion (StatementList 의 Evaluation )으로 둡니다.env 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.단언 : env 는 Declarative Environment Record 입니다.? DisposeResources (env .[[DisposableResourceStack]] , result )를 반환합니다.
15.3 화살표 함수 정의
구문
ArrowFunction [In, Yield, Await] :
ArrowParameters [?Yield, ?Await]
[no LineTerminator here]
=>
ConciseBody [?In]
ArrowParameters [Yield, Await] :
BindingIdentifier [?Yield, ?Await]
CoverParenthesizedExpressionAndArrowParameterList [?Yield, ?Await]
ConciseBody [In] :
[lookahead ≠ { ]
ExpressionBody [?In, ~Await]
{
FunctionBody [~Yield, ~Await]
}
ExpressionBody [In, Await] :
AssignmentExpression [?In, ~Yield, ?Await]
보충 구문
다음 생성 규칙의 인스턴스를 처리할 때
ArrowParameters [Yield, Await] : CoverParenthesizedExpressionAndArrowParameterList [?Yield, ?Await]
CoverParenthesizedExpressionAndArrowParameterList 의 해석은 다음 문법을 사용하여 구체화됩니다:
ArrowFormalParameters [Yield, Await] :
(
UniqueFormalParameters [?Yield, ?Await]
)
15.3.1 Static Semantics: 조기 오류
ArrowFunction :
ArrowParameters
=>
ConciseBody
ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList
15.3.2 Static Semantics: ConciseBodyContainsUseStrict
구문 지향 연산 ConciseBodyContainsUseStrict. 인수 없음. 반환값: Boolean. 다음 생성 규칙별로 정의된다.
ConciseBody : ExpressionBody
false 를 반환합니다.
ConciseBody :
{
FunctionBody
}
FunctionBody 의 FunctionBodyContainsUseStrict 를 반환합니다.
15.3.3 Runtime Semantics: EvaluateConciseBody
구문 지향 연산 EvaluateConciseBody. 인수 funcObj (ECMAScript 함수 객체) 및 argList (리스트 (요소: ECMAScript 언어 값 )). 반환값: (return 완료 또는 throw 완료 ). 다음 생성 규칙별로 정의된다.
ConciseBody : ExpressionBody
? FunctionDeclarationInstantiation (funcObj , argList )을 수행합니다. ExpressionBody 의 ? Evaluation 을 반환합니다.
15.3.4 Runtime Semantics: InstantiateArrowFunctionExpression
구문 지향 연산 InstantiateArrowFunctionExpression. 선택적 인수 name ((프로퍼티 키 또는 비공개 이름 )). 반환값: ECMAScript 함수 객체. 다음 생성 규칙별로 정의된다.
ArrowFunction :
ArrowParameters
=>
ConciseBody
name 이 존재하지 않으면 name 을 빈 String으로 설정합니다.envRecord 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.privateEnv 를 실행 중인 실행 컨텍스트 의 PrivateEnvironment로 둡니다.sourceText 를 ArrowFunction 과 일치하는 소스 텍스트 로 둡니다.closure 를 OrdinaryFunctionCreate (%Function.prototype% , sourceText , ArrowParameters , ConciseBody , lexical-this , envRecord , privateEnv )로 둡니다.SetFunctionName (closure , name )을 수행합니다.closure 를 반환합니다.
참고
ArrowFunction 은 arguments, super, this 또는 new.target에 대한 로컬 바인딩을 정의하지 않습니다. ArrowFunction 안에서 arguments, super, this 또는 new.target에 대한 모든 참조는 렉시컬하게 둘러싸는 환경의 바인딩으로 해석되어야 합니다. 일반적으로 이는 바로 둘러싸는 함수의 Function Environment입니다. ArrowFunction 이 super에 대한 참조를 포함할 수 있더라도 5 단계에서 생성된 함수 객체 에 MakeMethod 를 수행하여 메서드로 만들지는 않습니다. super를 참조하는 ArrowFunction 은 항상 비-ArrowFunction 안에 포함되며 super를 구현하는 데 필요한 상태는 ArrowFunction 의 함수 객체 가 캡처하는 envRecord 를 통해 접근할 수 있습니다.
15.3.5 Runtime Semantics: 평가
ArrowFunction :
ArrowParameters
=>
ConciseBody
ArrowFunction 의 InstantiateArrowFunctionExpression 을 반환합니다.
ExpressionBody : AssignmentExpression
exprRef 를 AssignmentExpression 의 ? Evaluation 으로 둡니다.exprValue 를 ? GetValue (exprRef )로 둡니다.ReturnCompletion (exprValue )을 반환합니다.
15.4 메서드 정의
구문
MethodDefinition [Yield, Await] :
ClassElementName [?Yield, ?Await]
(
UniqueFormalParameters [~Yield, ~Await]
)
{
FunctionBody [~Yield, ~Await]
}
GeneratorMethod [?Yield, ?Await]
AsyncMethod [?Yield, ?Await]
AsyncGeneratorMethod [?Yield, ?Await]
get
ClassElementName [?Yield, ?Await]
(
)
{
FunctionBody [~Yield, ~Await]
}
set
ClassElementName [?Yield, ?Await]
(
PropertySetParameterList
)
{
FunctionBody [~Yield, ~Await]
}
PropertySetParameterList :
FormalParameter [~Yield, ~Await]
15.4.1 Static Semantics: 조기 오류
MethodDefinition :
ClassElementName
(
UniqueFormalParameters
)
{
FunctionBody
}
MethodDefinition :
set
ClassElementName
(
PropertySetParameterList
)
{
FunctionBody
}
15.4.2 Static Semantics: HasDirectSuper
구문 지향 연산 HasDirectSuper. 인수 없음. 반환값: Boolean. 다음 생성 규칙별로 정의된다.
MethodDefinition :
ClassElementName
(
UniqueFormalParameters
)
{
FunctionBody
}
UniqueFormalParameters Contains SuperCall 이 true 이면 true 를 반환합니다.FunctionBody Contains SuperCall 을 반환합니다.
MethodDefinition :
get
ClassElementName
(
)
{
FunctionBody
}
FunctionBody Contains SuperCall 을 반환합니다.
MethodDefinition :
set
ClassElementName
(
PropertySetParameterList
)
{
FunctionBody
}
PropertySetParameterList Contains SuperCall 이 true 이면 true 를 반환합니다.FunctionBody Contains SuperCall 을 반환합니다.
GeneratorMethod :
*
ClassElementName
(
UniqueFormalParameters
)
{
GeneratorBody
}
UniqueFormalParameters Contains SuperCall 이 true 이면 true 를 반환합니다.GeneratorBody Contains SuperCall 을 반환합니다.
AsyncGeneratorMethod :
async
*
ClassElementName
(
UniqueFormalParameters
)
{
AsyncGeneratorBody
}
UniqueFormalParameters Contains SuperCall 이 true 이면 true 를 반환합니다.AsyncGeneratorBody Contains SuperCall 을 반환합니다.
AsyncMethod :
async
ClassElementName
(
UniqueFormalParameters
)
{
AsyncFunctionBody
}
UniqueFormalParameters Contains SuperCall 이 true 이면 true 를 반환합니다.AsyncFunctionBody Contains SuperCall 을 반환합니다.
15.4.3 Static Semantics: SpecialMethod
구문 지향 연산 SpecialMethod. 인수 없음. 반환값: Boolean. 다음 생성 규칙별로 정의된다.
MethodDefinition :
ClassElementName
(
UniqueFormalParameters
)
{
FunctionBody
}
false 를 반환합니다.
MethodDefinition :
GeneratorMethod
AsyncMethod
AsyncGeneratorMethod
get
ClassElementName
(
)
{
FunctionBody
}
set
ClassElementName
(
PropertySetParameterList
)
{
FunctionBody
}
true 를 반환합니다.
15.4.4 Runtime Semantics: DefineMethod
구문 지향 연산 DefineMethod. 인수 obj (Object) 및 선택적 인수 proto (Object). 반환값: (정상 완료 (값: 레코드 (필드: [[Key]] (프로퍼티 키 ), [[Closure]] (ECMAScript 함수 객체))) 또는 중도 완료). 다음 생성 규칙별로 정의된다.
MethodDefinition :
ClassElementName
(
UniqueFormalParameters
)
{
FunctionBody
}
propertyKey 를 ClassElementName 의 ? Evaluation 으로 둡니다.envRecord 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.privateEnv 를 실행 중인 실행 컨텍스트 의 PrivateEnvironment로 둡니다.proto 가 존재하지 않으면 proto 를 %Function.prototype% 로 설정합니다.sourceText 를 MethodDefinition 과 일치하는 소스 텍스트 로 둡니다.closure 를 OrdinaryFunctionCreate (proto , sourceText , UniqueFormalParameters , FunctionBody , non-lexical-this , envRecord , privateEnv )로 둡니다.MakeMethod (closure , obj )을 수행합니다.Record { [[Key]] : propertyKey , [[Closure]] : closure }를 반환합니다.
15.4.5 Runtime Semantics: MethodDefinitionEvaluation
구문 지향 연산 MethodDefinitionEvaluation. 인수 obj (Object) 및 enumerable (Boolean). 반환값: (정상 완료 (값: (PrivateElement 또는 empty )) 또는 중도 완료). 다음 생성 규칙별로 정의된다.
MethodDefinition :
ClassElementName
(
UniqueFormalParameters
)
{
FunctionBody
}
methodDef 를 인수 obj 를 사용한 MethodDefinition 의 ? DefineMethod 로 둡니다.SetFunctionName (methodDef .[[Closure]] , methodDef .[[Key]] )을 수행합니다.? DefineMethodProperty (obj , methodDef .[[Key]] , methodDef .[[Closure]] , enumerable )을 반환합니다.
MethodDefinition :
get
ClassElementName
(
)
{
FunctionBody
}
propertyKey 를 ClassElementName 의 ? Evaluation 으로 둡니다.envRecord 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.privateEnv 를 실행 중인 실행 컨텍스트 의 PrivateEnvironment로 둡니다.sourceText 를 MethodDefinition 과 일치하는 소스 텍스트 로 둡니다.formalParamList 를 생성 규칙
FormalParameters : [empty]
의 인스턴스로 둡니다.closure 를 OrdinaryFunctionCreate (%Function.prototype% , sourceText , formalParamList , FunctionBody , non-lexical-this , envRecord , privateEnv )로 둡니다.MakeMethod (closure , obj )을 수행합니다.SetFunctionName (closure , propertyKey , "get" )을 수행합니다.propertyKey 가 Private Name 이면, 다음을 수행합니다.PrivateElement { [[Key]] : propertyKey , [[Kind]] : accessor , [[Getter]] : closure , [[Setter]] : undefined }를 반환합니다.propertyDesc 를 PropertyDescriptor { [[Getter]] : closure , [[Enumerable]] : enumerable , [[Configurable]] : true }로 둡니다.? DefinePropertyOrThrow (obj , propertyKey , propertyDesc )를 수행합니다. empty 를 반환합니다.
MethodDefinition :
set
ClassElementName
(
PropertySetParameterList
)
{
FunctionBody
}
propertyKey 를 ClassElementName 의 ? Evaluation 으로 둡니다.envRecord 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.privateEnv 를 실행 중인 실행 컨텍스트 의 PrivateEnvironment로 둡니다.sourceText 를 MethodDefinition 과 일치하는 소스 텍스트 로 둡니다.closure 를 OrdinaryFunctionCreate (%Function.prototype% , sourceText , PropertySetParameterList , FunctionBody , non-lexical-this , envRecord , privateEnv )로 둡니다.MakeMethod (closure , obj )을 수행합니다.SetFunctionName (closure , propertyKey , "set" )을 수행합니다.propertyKey 가 Private Name 이면, 다음을 수행합니다.PrivateElement { [[Key]] : propertyKey , [[Kind]] : accessor , [[Getter]] : undefined , [[Setter]] : closure }를 반환합니다.propertyDesc 를 PropertyDescriptor { [[Setter]] : closure , [[Enumerable]] : enumerable , [[Configurable]] : true }로 둡니다.? DefinePropertyOrThrow (obj , propertyKey , propertyDesc )를 수행합니다. empty 를 반환합니다.
GeneratorMethod :
*
ClassElementName
(
UniqueFormalParameters
)
{
GeneratorBody
}
propertyKey 를 ClassElementName 의 ? Evaluation 으로 둡니다.envRecord 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.privateEnv 를 실행 중인 실행 컨텍스트 의 PrivateEnvironment로 둡니다.sourceText 를 GeneratorMethod 와 일치하는 소스 텍스트 로 둡니다.closure 를 OrdinaryFunctionCreate (%GeneratorFunction.prototype% , sourceText , UniqueFormalParameters , GeneratorBody , non-lexical-this , envRecord , privateEnv )로 둡니다.MakeMethod (closure , obj )을 수행합니다.SetFunctionName (closure , propertyKey )을 수행합니다.proto 를 OrdinaryObjectCreate (%GeneratorPrototype% )로 둡니다.! DefinePropertyOrThrow (closure , "prototype" , PropertyDescriptor { [[Value]] : proto , [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : false })를 수행합니다. ? DefineMethodProperty (obj , propertyKey , closure , enumerable )을 반환합니다.
AsyncGeneratorMethod :
async
*
ClassElementName
(
UniqueFormalParameters
)
{
AsyncGeneratorBody
}
propertyKey 를 ClassElementName 의 ? Evaluation 으로 둡니다.envRecord 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.privateEnv 를 실행 중인 실행 컨텍스트 의 PrivateEnvironment로 둡니다.sourceText 를 AsyncGeneratorMethod 와 일치하는 소스 텍스트 로 둡니다.closure 를 OrdinaryFunctionCreate (%AsyncGeneratorFunction.prototype% , sourceText , UniqueFormalParameters , AsyncGeneratorBody , non-lexical-this , envRecord , privateEnv )로 둡니다.MakeMethod (closure , obj )을 수행합니다.SetFunctionName (closure , propertyKey )을 수행합니다.proto 를 OrdinaryObjectCreate (%AsyncGeneratorPrototype% )로 둡니다.! DefinePropertyOrThrow (closure , "prototype" , PropertyDescriptor { [[Value]] : proto , [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : false })를 수행합니다. ? DefineMethodProperty (obj , propertyKey , closure , enumerable )을 반환합니다.
AsyncMethod :
async
ClassElementName
(
UniqueFormalParameters
)
{
AsyncFunctionBody
}
propertyKey 를 ClassElementName 의 ? Evaluation 으로 둡니다.envRecord 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.privateEnv 를 실행 중인 실행 컨텍스트 의 PrivateEnvironment로 둡니다.sourceText 를 AsyncMethod 와 일치하는 소스 텍스트 로 둡니다.closure 를 OrdinaryFunctionCreate (%AsyncFunction.prototype% , sourceText , UniqueFormalParameters , AsyncFunctionBody , non-lexical-this , envRecord , privateEnv )로 둡니다.MakeMethod (closure , obj )을 수행합니다.SetFunctionName (closure , propertyKey )을 수행합니다.? DefineMethodProperty (obj , propertyKey , closure , enumerable )을 반환합니다.
15.5 제너레이터 함수 정의
구문
GeneratorDeclaration [Yield, Await, Default] :
function
*
BindingIdentifier [?Yield, ?Await]
(
FormalParameters [+Yield, ~Await]
)
{
GeneratorBody
}
[+Default]
function
*
(
FormalParameters [+Yield, ~Await]
)
{
GeneratorBody
}
GeneratorExpression :
function
*
BindingIdentifier [+Yield, ~Await] opt
(
FormalParameters [+Yield, ~Await]
)
{
GeneratorBody
}
GeneratorMethod [Yield, Await] :
*
ClassElementName [?Yield, ?Await]
(
UniqueFormalParameters [+Yield, ~Await]
)
{
GeneratorBody
}
GeneratorBody :
FunctionBody [+Yield, ~Await]
YieldExpression [In, Await] :
yield
yield
[no LineTerminator here]
AssignmentExpression [?In, +Yield, ?Await]
yield
[no LineTerminator here]
*
AssignmentExpression [?In, +Yield, ?Await]
참고 1
yield 바로 뒤의 구문 문맥에서는 InputElementRegExpOrTemplateTail 어휘 목표를 사용해야 합니다.
참고 2
FormalParameters 의 일부인 표현식은 결과 Generator가 재개 가능한 상태가 되기 전에 평가되므로 제너레이터 함수의 FormalParameters 안에서는 YieldExpression 을 사용할 수 없습니다.
참고 3
Generator와 관련된 추상 연산 은 27.8.3 에 정의되어 있습니다.
15.5.1 Static Semantics: 조기 오류
GeneratorMethod :
*
ClassElementName
(
UniqueFormalParameters
)
{
GeneratorBody
}
GeneratorDeclaration :
function
*
BindingIdentifier
(
FormalParameters
)
{
GeneratorBody
}
function
*
(
FormalParameters
)
{
GeneratorBody
}
GeneratorExpression :
function
*
BindingIdentifier opt
(
FormalParameters
)
{
GeneratorBody
}
15.5.2 Runtime Semantics: EvaluateGeneratorBody
구문 지향 연산 EvaluateGeneratorBody. 인수 funcObj (ECMAScript 함수 객체) 및 argList (리스트 (요소: ECMAScript 언어 값 )). 반환값: (throw 완료 또는 return 완료 ). 다음 생성 규칙별로 정의된다.
GeneratorBody : FunctionBody
? FunctionDeclarationInstantiation (funcObj , argList )을 수행합니다. gen 을 ? OrdinaryCreateFromConstructor (funcObj , "%GeneratorPrototype%" , « [[GeneratorState]] , [[GeneratorContext]] , [[GeneratorBrand]] »)로 둡니다.gen .[[GeneratorBrand]] 를 empty 로 설정합니다.gen .[[GeneratorState]] 를 suspended-start 로 설정합니다.GeneratorStart (gen , FunctionBody )를 수행합니다.ReturnCompletion (gen )을 반환합니다.
15.5.3 Runtime Semantics: InstantiateGeneratorFunctionObject
구문 지향 연산 InstantiateGeneratorFunctionObject. 인수 envRecord (Environment 레코드 ) 및 privateEnv ((PrivateEnvironment 레코드 또는 null )). 반환값: ECMAScript 함수 객체. 다음 생성 규칙별로 정의된다.
GeneratorDeclaration :
function
*
BindingIdentifier
(
FormalParameters
)
{
GeneratorBody
}
name 을 BindingIdentifier 의 StringValue 로 둡니다.sourceText 를 GeneratorDeclaration 과 일치하는 소스 텍스트 로 둡니다.closure 를 OrdinaryFunctionCreate (%GeneratorFunction.prototype% , sourceText , FormalParameters , GeneratorBody , non-lexical-this , envRecord , privateEnv )로 둡니다.SetFunctionName (closure , name )을 수행합니다.proto 를 OrdinaryObjectCreate (%GeneratorPrototype% )로 둡니다.! DefinePropertyOrThrow (closure , "prototype" , PropertyDescriptor { [[Value]] : proto , [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : false })를 수행합니다. closure 를 반환합니다.
GeneratorDeclaration :
function
*
(
FormalParameters
)
{
GeneratorBody
}
sourceText 를 GeneratorDeclaration 과 일치하는 소스 텍스트 로 둡니다.closure 를 OrdinaryFunctionCreate (%GeneratorFunction.prototype% , sourceText , FormalParameters , GeneratorBody , non-lexical-this , envRecord , privateEnv )로 둡니다.SetFunctionName (closure , "default" )를 수행합니다.proto 를 OrdinaryObjectCreate (%GeneratorPrototype% )로 둡니다.! DefinePropertyOrThrow (closure , "prototype" , PropertyDescriptor { [[Value]] : proto , [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : false })를 수행합니다. closure 를 반환합니다.
참고
익명 GeneratorDeclaration 은 export default 선언의 일부로만 나타날 수 있으므로 해당 함수 코드 는 항상 엄격 모드 코드 입니다.
15.5.4 Runtime Semantics: InstantiateGeneratorFunctionExpression
구문 지향 연산 InstantiateGeneratorFunctionExpression. 선택적 인수 name ((프로퍼티 키 또는 비공개 이름 )). 반환값: ECMAScript 함수 객체. 다음 생성 규칙별로 정의된다.
GeneratorExpression :
function
*
(
FormalParameters
)
{
GeneratorBody
}
name 이 존재하지 않으면 name 을 빈 String으로 설정합니다.envRecord 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.privateEnv 를 실행 중인 실행 컨텍스트 의 PrivateEnvironment로 둡니다.sourceText 를 GeneratorExpression 과 일치하는 소스 텍스트 로 둡니다.closure 를 OrdinaryFunctionCreate (%GeneratorFunction.prototype% , sourceText , FormalParameters , GeneratorBody , non-lexical-this , envRecord , privateEnv )로 둡니다.SetFunctionName (closure , name )을 수행합니다.proto 를 OrdinaryObjectCreate (%GeneratorPrototype% )로 둡니다.! DefinePropertyOrThrow (closure , "prototype" , PropertyDescriptor { [[Value]] : proto , [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : false })를 수행합니다. closure 를 반환합니다.
GeneratorExpression :
function
*
BindingIdentifier
(
FormalParameters
)
{
GeneratorBody
}
단언 : name 은 존재하지 않습니다.name 을 BindingIdentifier 의 StringValue 로 설정합니다.outerEnv 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.funcEnv 를 NewDeclarativeEnvironment (outerEnv )로 둡니다.! funcEnv .CreateImmutableBinding (name , false )를 수행합니다. privateEnv 를 실행 중인 실행 컨텍스트 의 PrivateEnvironment로 둡니다.sourceText 를 GeneratorExpression 과 일치하는 소스 텍스트 로 둡니다.closure 를 OrdinaryFunctionCreate (%GeneratorFunction.prototype% , sourceText , FormalParameters , GeneratorBody , non-lexical-this , funcEnv , privateEnv )로 둡니다.SetFunctionName (closure , name )을 수행합니다.proto 를 OrdinaryObjectCreate (%GeneratorPrototype% )로 둡니다.! DefinePropertyOrThrow (closure , "prototype" , PropertyDescriptor { [[Value]] : proto , [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : false })를 수행합니다. ! funcEnv .InitializeBinding (name , closure )를 수행합니다. closure 를 반환합니다.
참고
15.5.5 Runtime Semantics: 평가
GeneratorExpression :
function
*
BindingIdentifier opt
(
FormalParameters
)
{
GeneratorBody
}
GeneratorExpression 의 InstantiateGeneratorFunctionExpression 을 반환합니다.
YieldExpression : yield
? Yield (undefined )를 반환합니다.
YieldExpression :
yield
AssignmentExpression
exprRef 를 AssignmentExpression 의 ? Evaluation 으로 둡니다.value 를 ? GetValue (exprRef )로 둡니다.? Yield (value )를 반환합니다.
YieldExpression :
yield
*
AssignmentExpression
genKind 를 GetGeneratorKind ()로 둡니다.단언 : genKind 는 sync 또는 async 입니다.exprRef 를 AssignmentExpression 의 ? Evaluation 으로 둡니다.value 를 ? GetValue (exprRef )로 둡니다.iteratorRecord 를 ? GetIterator (value , genKind )로 둡니다.iterator 를 iteratorRecord .[[Iterator]] 로 둡니다.received 를 NormalCompletion (undefined )로 둡니다.다음을 반복합니다.received 가 정상 완료 이면, 다음을 수행합니다.innerResult 를 ? Call (iteratorRecord .[[NextMethod]] , iteratorRecord .[[Iterator]] , « received .[[Value]] »)로 둡니다.genKind 가 async 이면 innerResult 를 ? Await (innerResult )로 설정합니다.innerResult 가 Object가 아니면 TypeError 예외를 던집니다.done 을 ? IteratorComplete (innerResult )로 둡니다.done 이 true 이면, 다음을 수행합니다.? IteratorValue (innerResult )를 반환합니다. genKind 가 async 이면 received 를 Completion (AsyncGeneratorYield (? IteratorValue (innerResult )))으로 설정합니다.그렇지 않으면 received 를 Completion (GeneratorYield (innerResult ))으로 설정합니다. 그렇지 않고 received 가 throw 완료 이면, 다음을 수행합니다.throw 를 ? GetMethod (iterator , "throw" )로 둡니다.throw 가 undefined 가 아니면, 다음을 수행합니다.innerResult 를 ? Call (throw , iterator , « received .[[Value]] »)로 둡니다.genKind 가 async 이면 innerResult 를 ? Await (innerResult )로 설정합니다.참고 : 내부 반복자의 throw 메서드에서 발생한 예외는 전파됩니다. 내부 throw 메서드의 정상 완료 는 내부 next와 유사하게 처리됩니다.innerResult 가 Object가 아니면 TypeError 예외를 던집니다.done 을 ? IteratorComplete (innerResult )로 둡니다.done 이 true 이면, 다음을 수행합니다.? IteratorValue (innerResult )를 반환합니다. genKind 가 async 이면 received 를 Completion (AsyncGeneratorYield (? IteratorValue (innerResult )))으로 설정합니다.그렇지 않으면 received 를 Completion (GeneratorYield (innerResult ))으로 설정합니다. 그렇지 않으면,참고 : iterator 에 throw 메서드가 없으면 이 throw는 yield* 반복을 종료합니다. 그러나 먼저 iterator 가 정리할 기회를 제공해야 합니다.closeCompletion 을 NormalCompletion (empty )으로 둡니다.genKind 가 async 이면 ? AsyncIteratorClose (iteratorRecord , closeCompletion )를 수행합니다.그렇지 않으면 ? IteratorClose (iteratorRecord , closeCompletion )를 수행합니다. 참고 : 다음 단계는 yield* 프로토콜 위반, 즉 iterator 에 throw 메서드가 없음을 나타내기 위해 TypeError 를 던집니다.TypeError 예외를 던집니다. 그렇지 않으면,단언 : received 는 return 완료 입니다.return 을 ? GetMethod (iterator , "return" )으로 둡니다.return 이 undefined 이면, 다음을 수행합니다.receivedValue 를 received .[[Value]] 로 둡니다.genKind 가 async 이면, 다음을 수행합니다.receivedValue 를 ? Await (receivedValue )로 설정합니다.ReturnCompletion (receivedValue )을 반환합니다.innerReturnResult 를 ? Call (return , iterator , « received .[[Value]] »)로 둡니다.genKind 가 async 이면 innerReturnResult 를 ? Await (innerReturnResult )로 설정합니다.innerReturnResult 가 Object가 아니면 TypeError 예외를 던집니다.done 을 ? IteratorComplete (innerReturnResult )로 둡니다.done 이 true 이면, 다음을 수행합니다.returnedValue 를 ? IteratorValue (innerReturnResult )로 둡니다.ReturnCompletion (returnedValue )을 반환합니다.genKind 가 async 이면 received 를 Completion (AsyncGeneratorYield (? IteratorValue (innerReturnResult )))으로 설정합니다.그렇지 않으면 received 를 Completion (GeneratorYield (innerReturnResult ))으로 설정합니다.
15.6 비동기 제너레이터 함수 정의
구문
AsyncGeneratorDeclaration [Yield, Await, Default] :
async
[no LineTerminator here]
function
*
BindingIdentifier [?Yield, ?Await]
(
FormalParameters [+Yield, +Await]
)
{
AsyncGeneratorBody
}
[+Default]
async
[no LineTerminator here]
function
*
(
FormalParameters [+Yield, +Await]
)
{
AsyncGeneratorBody
}
AsyncGeneratorExpression :
async
[no LineTerminator here]
function
*
BindingIdentifier [+Yield, +Await] opt
(
FormalParameters [+Yield, +Await]
)
{
AsyncGeneratorBody
}
AsyncGeneratorMethod [Yield, Await] :
async
[no LineTerminator here]
*
ClassElementName [?Yield, ?Await]
(
UniqueFormalParameters [+Yield, +Await]
)
{
AsyncGeneratorBody
}
AsyncGeneratorBody :
FunctionBody [+Yield, +Await]
참고 1
FormalParameters 의 일부인 표현식은 결과 AsyncGenerator가 재개 가능한 상태가 되기 전에 평가되므로 비동기 제너레이터 함수의 FormalParameters 안에서는 YieldExpression 및 AwaitExpression 을 사용할 수 없습니다.
참고 2
AsyncGenerator와 관련된 추상 연산 은 27.9.3 에 정의되어 있습니다.
15.6.1 Static Semantics: 조기 오류
AsyncGeneratorMethod :
async
*
ClassElementName
(
UniqueFormalParameters
)
{
AsyncGeneratorBody
}
AsyncGeneratorDeclaration :
async
function
*
BindingIdentifier
(
FormalParameters
)
{
AsyncGeneratorBody
}
async
function
*
(
FormalParameters
)
{
AsyncGeneratorBody
}
AsyncGeneratorExpression :
async
function
*
BindingIdentifier opt
(
FormalParameters
)
{
AsyncGeneratorBody
}
15.6.2 Runtime Semantics: EvaluateAsyncGeneratorBody
구문 지향 연산 EvaluateAsyncGeneratorBody. 인수 funcObj (ECMAScript 함수 객체) 및 argList (리스트 (요소: ECMAScript 언어 값 )). 반환값: (throw 완료 또는 return 완료 ). 다음 생성 규칙별로 정의된다.
AsyncGeneratorBody : FunctionBody
? FunctionDeclarationInstantiation (funcObj , argList )을 수행합니다. gen 을 ? OrdinaryCreateFromConstructor (funcObj , "%AsyncGeneratorPrototype%" , « [[AsyncGeneratorState]] , [[AsyncGeneratorContext]] , [[AsyncGeneratorQueue]] , [[GeneratorBrand]] »)로 둡니다.gen .[[GeneratorBrand]] 를 empty 로 설정합니다.gen .[[AsyncGeneratorState]] 를 suspended-start 로 설정합니다.AsyncGeneratorStart (gen , FunctionBody )를 수행합니다.ReturnCompletion (gen )을 반환합니다.
15.6.3 Runtime Semantics: InstantiateAsyncGeneratorFunctionObject
구문 지향 연산 InstantiateAsyncGeneratorFunctionObject. 인수 envRecord (Environment 레코드 ) 및 privateEnv ((PrivateEnvironment 레코드 또는 null )). 반환값: ECMAScript 함수 객체. 다음 생성 규칙별로 정의된다.
AsyncGeneratorDeclaration :
async
function
*
BindingIdentifier
(
FormalParameters
)
{
AsyncGeneratorBody
}
name 을 BindingIdentifier 의 StringValue 로 둡니다.sourceText 를 AsyncGeneratorDeclaration 과 일치하는 소스 텍스트 로 둡니다.closure 를 OrdinaryFunctionCreate (%AsyncGeneratorFunction.prototype% , sourceText , FormalParameters , AsyncGeneratorBody , non-lexical-this , envRecord , privateEnv )로 둡니다.SetFunctionName (closure , name )을 수행합니다.proto 를 OrdinaryObjectCreate (%AsyncGeneratorPrototype% )로 둡니다.! DefinePropertyOrThrow (closure , "prototype" , PropertyDescriptor { [[Value]] : proto , [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : false })를 수행합니다. closure 를 반환합니다.
AsyncGeneratorDeclaration :
async
function
*
(
FormalParameters
)
{
AsyncGeneratorBody
}
sourceText 를 AsyncGeneratorDeclaration 과 일치하는 소스 텍스트 로 둡니다.closure 를 OrdinaryFunctionCreate (%AsyncGeneratorFunction.prototype% , sourceText , FormalParameters , AsyncGeneratorBody , non-lexical-this , envRecord , privateEnv )로 둡니다.SetFunctionName (closure , "default" )를 수행합니다.proto 를 OrdinaryObjectCreate (%AsyncGeneratorPrototype% )로 둡니다.! DefinePropertyOrThrow (closure , "prototype" , PropertyDescriptor { [[Value]] : proto , [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : false })를 수행합니다. closure 를 반환합니다.
참고
익명 AsyncGeneratorDeclaration 은 export default 선언의 일부로만 나타날 수 있습니다.
15.6.4 Runtime Semantics: InstantiateAsyncGeneratorFunctionExpression
구문 지향 연산 InstantiateAsyncGeneratorFunctionExpression. 선택적 인수 name ((프로퍼티 키 또는 비공개 이름 )). 반환값: ECMAScript 함수 객체. 다음 생성 규칙별로 정의된다.
AsyncGeneratorExpression :
async
function
*
(
FormalParameters
)
{
AsyncGeneratorBody
}
name 이 존재하지 않으면 name 을 빈 String으로 설정합니다.envRecord 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.privateEnv 를 실행 중인 실행 컨텍스트 의 PrivateEnvironment로 둡니다.sourceText 를 AsyncGeneratorExpression 과 일치하는 소스 텍스트 로 둡니다.closure 를 OrdinaryFunctionCreate (%AsyncGeneratorFunction.prototype% , sourceText , FormalParameters , AsyncGeneratorBody , non-lexical-this , envRecord , privateEnv )로 둡니다.SetFunctionName (closure , name )을 수행합니다.proto 를 OrdinaryObjectCreate (%AsyncGeneratorPrototype% )로 둡니다.! DefinePropertyOrThrow (closure , "prototype" , PropertyDescriptor { [[Value]] : proto , [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : false })를 수행합니다. closure 를 반환합니다.
AsyncGeneratorExpression :
async
function
*
BindingIdentifier
(
FormalParameters
)
{
AsyncGeneratorBody
}
단언 : name 은 존재하지 않습니다.name 을 BindingIdentifier 의 StringValue 로 설정합니다.outerEnv 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.funcEnv 를 NewDeclarativeEnvironment (outerEnv )로 둡니다.! funcEnv .CreateImmutableBinding (name , false )를 수행합니다. privateEnv 를 실행 중인 실행 컨텍스트 의 PrivateEnvironment로 둡니다.sourceText 를 AsyncGeneratorExpression 과 일치하는 소스 텍스트 로 둡니다.closure 를 OrdinaryFunctionCreate (%AsyncGeneratorFunction.prototype% , sourceText , FormalParameters , AsyncGeneratorBody , non-lexical-this , funcEnv , privateEnv )로 둡니다.SetFunctionName (closure , name )을 수행합니다.proto 를 OrdinaryObjectCreate (%AsyncGeneratorPrototype% )로 둡니다.! DefinePropertyOrThrow (closure , "prototype" , PropertyDescriptor { [[Value]] : proto , [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : false })를 수행합니다. ! funcEnv .InitializeBinding (name , closure )를 수행합니다. closure 를 반환합니다.
참고
15.6.5 Runtime Semantics: 평가
AsyncGeneratorExpression :
async
function
*
BindingIdentifier opt
(
FormalParameters
)
{
AsyncGeneratorBody
}
AsyncGeneratorExpression 의 InstantiateAsyncGeneratorFunctionExpression 을 반환합니다.
15.7 클래스 정의
구문
ClassDeclaration [Yield, Await, Default] :
class
BindingIdentifier [?Yield, ?Await]
ClassTail [?Yield, ?Await]
[+Default]
class
ClassTail [?Yield, ?Await]
ClassExpression [Yield, Await] :
class
BindingIdentifier [?Yield, ?Await] opt
ClassTail [?Yield, ?Await]
ClassTail [Yield, Await] :
ClassHeritage [?Yield, ?Await] opt
{
ClassBody [?Yield, ?Await] opt
}
ClassHeritage [Yield, Await] :
extends
LeftHandSideExpression [?Yield, ?Await]
ClassBody [Yield, Await] :
ClassElementList [?Yield, ?Await]
ClassElementList [Yield, Await] :
ClassElement [?Yield, ?Await]
ClassElementList [?Yield, ?Await]
ClassElement [?Yield, ?Await]
ClassElement [Yield, Await] :
MethodDefinition [?Yield, ?Await]
static
MethodDefinition [?Yield, ?Await]
FieldDefinition [?Yield, ?Await]
;
static
FieldDefinition [?Yield, ?Await]
;
ClassStaticBlock
;
FieldDefinition [Yield, Await] :
ClassElementName [?Yield, ?Await]
Initializer [+In, ?Yield, ?Await] opt
ClassElementName [Yield, Await] :
PropertyName [?Yield, ?Await]
PrivateIdentifier
ClassStaticBlock :
static
{
ClassStaticBlockBody
}
ClassStaticBlockBody :
ClassStaticBlockStatementList
ClassStaticBlockStatementList :
StatementList [~Yield, +Await, ~Return] opt
참고
15.7.1 Static Semantics: 조기 오류
ClassTail :
ClassHeritage opt
{
ClassBody
}
ClassBody : ClassElementList
ClassElement : MethodDefinition
ClassElement :
static
MethodDefinition
ClassElement :
FieldDefinition
;
ClassElement :
static
FieldDefinition
;
FieldDefinition :
ClassElementName
Initializer opt
ClassElementName : PrivateIdentifier
ClassStaticBlockBody : ClassStaticBlockStatementList
15.7.2 Static Semantics: ClassElementKind
구문 지향 연산 ClassElementKind. 인수 없음. 반환값: (constructor-method , non-constructor-method 또는 empty ). 다음 생성 규칙별로 정의된다.
ClassElement : MethodDefinition
MethodDefinition 의 PropName 이 "constructor" 이면 constructor-method 를 반환합니다.non-constructor-method 를 반환합니다.
ClassElement :
static
MethodDefinition
FieldDefinition
;
static
FieldDefinition
;
non-constructor-method 를 반환합니다.
ClassElement : ClassStaticBlock
non-constructor-method 를 반환합니다.
ClassElement : ;
empty 를 반환합니다.
15.7.3 Static Semantics: ConstructorMethod
구문 지향 연산 ConstructorMethod. 인수 없음. 반환값: (a ClassElement Parse Node 또는 empty ). 다음 생성 규칙별로 정의된다.
ClassElementList : ClassElement
ClassElement 의 ClassElementKind 가 constructor-method 이면 ClassElement 를 반환합니다.empty 를 반환합니다.
ClassElementList :
ClassElementList
ClassElement
head 를 ClassElementList 의 ConstructorMethod 로 둡니다.head 가 empty 가 아니면 head 를 반환합니다.ClassElement 의 ClassElementKind 가 constructor-method 이면 ClassElement 를 반환합니다.empty 를 반환합니다.
참고
조기 오류 규칙 은 이름이 "constructor" 인 메서드 정의가 하나만 존재하고 접근자 프로퍼티 또는 제너레이터 정의가 아니도록 보장합니다.
15.7.4 Static Semantics: IsStatic
구문 지향 연산 IsStatic. 인수 없음. 반환값: Boolean. 다음 생성 규칙별로 정의된다.
ClassElement : MethodDefinition
false 를 반환합니다.
ClassElement :
static
MethodDefinition
true 를 반환합니다.
ClassElement :
FieldDefinition
;
false 를 반환합니다.
ClassElement :
static
FieldDefinition
;
true 를 반환합니다.
ClassElement : ClassStaticBlock
true 를 반환합니다.
ClassElement : ;
false 를 반환합니다.
15.7.5 Static Semantics: NonConstructorElements
구문 지향 연산 NonConstructorElements. 인수 없음. 반환값: 리스트 (요소: ClassElement Parse Nodes ). 다음 생성 규칙별로 정의된다.
ClassElementList : ClassElement
ClassElement 의 ClassElementKind 가 non-constructor-method 이면, 다음을 수행합니다.« ClassElement »을 반환합니다. 새로운 빈 List 를 반환합니다.
ClassElementList :
ClassElementList
ClassElement
list 를 ClassElementList 의 NonConstructorElements 로 둡니다.ClassElement 의 ClassElementKind 가 non-constructor-method 이면, 다음을 수행합니다.ClassElement 를 list 에 추가합니다.list 를 반환합니다.
15.7.6 Static Semantics: PrototypePropertyNameList
구문 지향 연산 PrototypePropertyNameList. 인수 없음. 반환값: 리스트 (요소: 프로퍼티 키 ). 다음 생성 규칙별로 정의된다.
ClassElementList : ClassElement
propertyName 을 ClassElement 의 PropName 으로 둡니다.propertyName 이 empty 이면 새로운 빈 List 를 반환합니다.ClassElement 의 IsStatic 이 true 이면 새로운 빈 List 를 반환합니다.« propertyName »을 반환합니다.
ClassElementList :
ClassElementList
ClassElement
list 를 ClassElementList 의 PrototypePropertyNameList 로 둡니다.propertyName 을 ClassElement 의 PropName 으로 둡니다.propertyName 이 empty 이면 list 를 반환합니다.ClassElement 의 IsStatic 이 true 이면 list 를 반환합니다.list 와 « propertyName »의 목록 연결 을 반환합니다.
15.7.7 Static Semantics: AllPrivateIdentifiersValid
구문 지향 연산 AllPrivateIdentifiersValid. 인수 names (리스트 (요소: String)). 반환값: Boolean.
아래에 나열되지 않은 이 명세의 모든 문법 생성 규칙 대안은 암묵적으로 다음과 같은 AllPrivateIdentifiersValid 기본 정의를 갖습니다:
이 Parse Node의 각 자식 노드 child 에 대해 다음을 수행합니다.child 가 비단말 기호의 인스턴스이면, 다음을 수행합니다.인수 names 를 사용한 child 의 AllPrivateIdentifiersValid 가 false 이면 false 를 반환합니다. true 를 반환합니다.
MemberExpression :
MemberExpression
.
PrivateIdentifier
names 에 PrivateIdentifier 의 StringValue 가 포함되어 있으면, 다음을 수행합니다.인수 names 를 사용한 MemberExpression 의 AllPrivateIdentifiersValid 를 반환합니다. false 를 반환합니다.
CallExpression :
CallExpression
.
PrivateIdentifier
names 에 PrivateIdentifier 의 StringValue 가 포함되어 있으면, 다음을 수행합니다.인수 names 를 사용한 CallExpression 의 AllPrivateIdentifiersValid 를 반환합니다. false 를 반환합니다.
OptionalChain :
?.
PrivateIdentifier
names 에 PrivateIdentifier 의 StringValue 가 포함되어 있으면 true 를 반환합니다.false 를 반환합니다.
OptionalChain :
OptionalChain
.
PrivateIdentifier
names 에 PrivateIdentifier 의 StringValue 가 포함되어 있으면, 다음을 수행합니다.인수 names 를 사용한 OptionalChain 의 AllPrivateIdentifiersValid 를 반환합니다. false 를 반환합니다.
ClassBody : ClassElementList
newNames 를 names 와 ClassBody 의 PrivateBoundIdentifiers 의 목록 연결 로 둡니다.인수 newNames 를 사용한 ClassElementList 의 AllPrivateIdentifiersValid 를 반환합니다.
RelationalExpression :
PrivateIdentifier
in
ShiftExpression
names 에 PrivateIdentifier 의 StringValue 가 포함되어 있으면, 다음을 수행합니다.인수 names 를 사용한 ShiftExpression 의 AllPrivateIdentifiersValid 를 반환합니다. false 를 반환합니다.
15.7.8 Static Semantics: PrivateBoundIdentifiers
구문 지향 연산 PrivateBoundIdentifiers. 인수 없음. 반환값: 리스트 (요소: String). 다음 생성 규칙별로 정의된다.
FieldDefinition :
ClassElementName
Initializer opt
ClassElementName 의 PrivateBoundIdentifiers 를 반환합니다.
ClassElementName : PrivateIdentifier
유일한 요소가 PrivateIdentifier 의 StringValue 인 List 를 반환합니다.
ClassElementName :
PropertyName
ClassElement :
ClassStaticBlock
;
새로운 빈 List 를 반환합니다.
ClassElementList :
ClassElementList
ClassElement
names1 을 ClassElementList 의 PrivateBoundIdentifiers 로 둡니다.names2 를 ClassElement 의 PrivateBoundIdentifiers 로 둡니다.names1 과 names2 의 목록 연결 을 반환합니다.
MethodDefinition :
ClassElementName
(
UniqueFormalParameters
)
{
FunctionBody
}
get
ClassElementName
(
)
{
FunctionBody
}
set
ClassElementName
(
PropertySetParameterList
)
{
FunctionBody
}
GeneratorMethod :
*
ClassElementName
(
UniqueFormalParameters
)
{
GeneratorBody
}
AsyncMethod :
async
ClassElementName
(
UniqueFormalParameters
)
{
AsyncFunctionBody
}
AsyncGeneratorMethod :
async
*
ClassElementName
(
UniqueFormalParameters
)
{
AsyncGeneratorBody
}
ClassElementName 의 PrivateBoundIdentifiers 를 반환합니다.
15.7.9 Static Semantics: ContainsArguments
구문 지향 연산 ContainsArguments. 인수 없음. 반환값: Boolean.
아래에 나열되지 않은 이 명세의 모든 문법 생성 규칙 대안은 암묵적으로 다음과 같은 ContainsArguments 기본 정의를 갖습니다:
이 Parse Node의 각 자식 노드 child 에 대해 다음을 수행합니다.child 가 비단말 기호의 인스턴스이면, 다음을 수행합니다.child 의 ContainsArguments 가 true 이면 true 를 반환합니다. false 를 반환합니다.
IdentifierReference : Identifier
Identifier 의 StringValue 가 "arguments" 이면 true 를 반환합니다.false 를 반환합니다.
FunctionDeclaration :
function
BindingIdentifier
(
FormalParameters
)
{
FunctionBody
}
function
(
FormalParameters
)
{
FunctionBody
}
FunctionExpression :
function
BindingIdentifier opt
(
FormalParameters
)
{
FunctionBody
}
GeneratorDeclaration :
function
*
BindingIdentifier
(
FormalParameters
)
{
GeneratorBody
}
function
*
(
FormalParameters
)
{
GeneratorBody
}
GeneratorExpression :
function
*
BindingIdentifier opt
(
FormalParameters
)
{
GeneratorBody
}
AsyncGeneratorDeclaration :
async
function
*
BindingIdentifier
(
FormalParameters
)
{
AsyncGeneratorBody
}
async
function
*
(
FormalParameters
)
{
AsyncGeneratorBody
}
AsyncGeneratorExpression :
async
function
*
BindingIdentifier opt
(
FormalParameters
)
{
AsyncGeneratorBody
}
AsyncFunctionDeclaration :
async
function
BindingIdentifier
(
FormalParameters
)
{
AsyncFunctionBody
}
async
function
(
FormalParameters
)
{
AsyncFunctionBody
}
AsyncFunctionExpression :
async
function
BindingIdentifier opt
(
FormalParameters
)
{
AsyncFunctionBody
}
false 를 반환합니다.
MethodDefinition :
ClassElementName
(
UniqueFormalParameters
)
{
FunctionBody
}
get
ClassElementName
(
)
{
FunctionBody
}
set
ClassElementName
(
PropertySetParameterList
)
{
FunctionBody
}
GeneratorMethod :
*
ClassElementName
(
UniqueFormalParameters
)
{
GeneratorBody
}
AsyncGeneratorMethod :
async
*
ClassElementName
(
UniqueFormalParameters
)
{
AsyncGeneratorBody
}
AsyncMethod :
async
ClassElementName
(
UniqueFormalParameters
)
{
AsyncFunctionBody
}
ClassElementName 의 ContainsArguments 를 반환합니다.
15.7.10 Runtime Semantics: ClassFieldDefinitionEvaluation
구문 지향 연산 ClassFieldDefinitionEvaluation. 인수 homeObj (Object). 반환값: (정상 완료 (값: ClassFieldDefinition 레코드 ) 또는 중도 완료). 다음 생성 규칙별로 정의된다.
FieldDefinition :
ClassElementName
Initializer opt
name 을 ClassElementName 의 ? Evaluation 으로 둡니다.Initializer 가 존재하면, 다음을 수행합니다.formalParamList 를 생성 규칙
FormalParameters : [empty]
의 인스턴스로 둡니다.envRecord 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.privateEnv 를 실행 중인 실행 컨텍스트 의 PrivateEnvironment로 둡니다.sourceText 를 빈 유니코드 코드 포인트 시퀀스로 둡니다.initializer 를 OrdinaryFunctionCreate (%Function.prototype% , sourceText , formalParamList , Initializer , non-lexical-this , envRecord , privateEnv )로 둡니다.MakeMethod (initializer , homeObj )을 수행합니다.initializer .[[ClassFieldInitializerName]] 을 name 으로 설정합니다.그렇지 않으면,initializer 를 empty 로 둡니다. ClassFieldDefinition Record { [[Name]] : name , [[Initializer]] : initializer }를 반환합니다.
참고
initializer 를 위해 생성된 함수는 ECMAScript 코드에서 절대로 직접 접근할 수 없습니다.
15.7.11 Runtime Semantics: ClassStaticBlockDefinitionEvaluation
구문 지향 연산 ClassStaticBlockDefinitionEvaluation. 인수 homeObj (Object). 반환값: ClassStaticBlockDefinition 레코드 . 다음 생성 규칙별로 정의된다.
ClassStaticBlock :
static
{
ClassStaticBlockBody
}
lexicalEnv 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.privateEnv 를 실행 중인 실행 컨텍스트 의 PrivateEnvironment로 둡니다.sourceText 를 빈 유니코드 코드 포인트 시퀀스로 둡니다.formalParams 를 생성 규칙
FormalParameters : [empty]
의 인스턴스로 둡니다.bodyFunc 를 OrdinaryFunctionCreate (%Function.prototype% , sourceText , formalParams , ClassStaticBlockBody , non-lexical-this , lexicalEnv , privateEnv )로 둡니다.MakeMethod (bodyFunc , homeObj )을 수행합니다.ClassStaticBlockDefinition Record { [[BodyFunction]] : bodyFunc }를 반환합니다.
참고 함수 bodyFunc 는 ECMAScript 코드에서 절대로 직접 접근할 수 없습니다.
15.7.12 Runtime Semantics: EvaluateClassStaticBlockBody
구문 지향 연산 EvaluateClassStaticBlockBody. 인수 funcObj (ECMAScript 함수 객체). 반환값: (return 완료 또는 throw 완료 ). 다음 생성 규칙별로 정의된다.
ClassStaticBlockBody : ClassStaticBlockStatementList
단언 : funcObj 는 ClassStaticBlockDefinitionEvaluation 의 5 단계에서 생성된 합성 함수입니다.! FunctionDeclarationInstantiation (funcObj , « »)을 수행합니다. result 를 Completion (ClassStaticBlockStatementList 의 Evaluation )으로 둡니다.envRecord 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.단언 : envRecord 는 Declarative Environment Record 입니다.? DisposeResources (envRecord .[[DisposableResourceStack]] , result )를 수행합니다. ReturnCompletion (undefined )을 반환합니다.
15.7.13 Runtime Semantics: ClassElementEvaluation
구문 지향 연산 ClassElementEvaluation. 인수 obj (Object). 반환값: (정상 완료 (값: (ClassFieldDefinition 레코드 , ClassStaticBlockDefinition 레코드 , PrivateElement 또는 empty )) 또는 중도 완료). 다음 생성 규칙별로 정의된다.
ClassElement :
FieldDefinition
;
static
FieldDefinition
;
인수 obj 를 사용한 FieldDefinition 의 ? ClassFieldDefinitionEvaluation 을 반환합니다.
ClassElement :
MethodDefinition
static
MethodDefinition
인수 obj 및 false 를 사용한 MethodDefinition 의 ? MethodDefinitionEvaluation 을 반환합니다.
ClassElement : ClassStaticBlock
인수 obj 를 사용한 ClassStaticBlock 의 ClassStaticBlockDefinitionEvaluation 을 반환합니다.
ClassElement : ;
empty 를 반환합니다.
15.7.14 Runtime Semantics: ClassDefinitionEvaluation
구문 지향 연산 ClassDefinitionEvaluation. 인수 classBinding ((String 또는 undefined )), className ((프로퍼티 키 또는 비공개 이름 )) 및 sourceText (ECMAScript 소스 텍스트 ). 반환값: (정상 완료 (값: 함수 객체 ) 또는 중도 완료).
참고
명세를 쉽게 작성하기 위해 비공개 메서드와 접근자는 비공개 필드와 함께 클래스 인스턴스의 [[PrivateElements]] 슬롯에 포함됩니다. 그러나 어떤 객체든 특정 클래스에서 정의한 비공개 메서드와 접근자를 모두 가지거나 전혀 가지지 않습니다. 이 기능은 구현체가 각 메서드 또는 접근자를 개별적으로 추적할 필요가 없는 전략을 사용하여 비공개 메서드와 접근자를 구현할 수 있도록 설계되었습니다.
예를 들어 구현체는 인스턴스 비공개 메서드를 대응하는 Private Name 과 직접 연결하고, 각 객체에 대해 어떤 클래스 생성자 가 해당 객체를 this 값으로 사용하여 실행되었는지를 추적할 수 있습니다. 그러면 객체에서 인스턴스 비공개 메서드를 조회하는 작업은 해당 메서드를 정의한 클래스 생성자 가 그 객체를 초기화하는 데 사용되었는지 검사한 다음 Private Name 과 연결된 메서드를 반환하는 것으로 구성됩니다.
이는 비공개 필드와 다릅니다. 필드 이니셜라이저는 클래스 인스턴스화 중에 예외를 던질 수 있으므로 개별 객체에는 특정 클래스의 비공개 필드 중 일부만 존재할 수 있으며, 따라서 비공개 필드는 일반적으로 개별적으로 추적해야 합니다.
다음 생성 규칙별로 정의된다.
ClassTail :
ClassHeritage opt
{
ClassBody opt
}
envRecord 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.classEnv 를 NewDeclarativeEnvironment (envRecord )로 둡니다.classBinding 이 undefined 가 아니면, 다음을 수행합니다.! classEnv .CreateImmutableBinding (classBinding , true )를 수행합니다. outerPrivateEnv 를 실행 중인 실행 컨텍스트 의 PrivateEnvironment로 둡니다.classPrivateEnv 를 NewPrivateEnvironment (outerPrivateEnv )로 둡니다.ClassBody 가 존재하면, 다음을 수행합니다.ClassBody 의 PrivateBoundIdentifiers 에 있는 각 String description 에 대해 다음을 수행합니다.classPrivateEnv .[[Names]] 에 privateName .[[Description]] 이 description 인 Private Name privateName 이 포함되어 있으면, 다음을 수행합니다.단언 : 이는 getter/setter 쌍에 대해서만 가능합니다.그렇지 않으면,name 을 [[Description]] 이 description 인 새로운 Private Name 으로 둡니다.name 을 classPrivateEnv .[[Names]] 에 추가합니다. ClassHeritage 가 존재하지 않으면, 다음을 수행합니다.protoParent 를 %Object.prototype% 으로 둡니다.ctorParent 를 %Function.prototype% 으로 둡니다.그렇지 않으면,실행 중인 실행 컨텍스트 의 LexicalEnvironment를 classEnv 로 설정합니다.참고 : ClassHeritage 를 평가할 때 실행 중인 실행 컨텍스트 의 PrivateEnvironment는 outerPrivateEnv 입니다.superclassRef 를 Completion (Evaluation of ClassHeritage )으로 둡니다.실행 중인 실행 컨텍스트 의 LexicalEnvironment를 envRecord 로 설정합니다.superclass 를 ? GetValue (? superclassRef )로 둡니다.superclass 가 null 이면, 다음을 수행합니다.protoParent 를 null 로 둡니다.ctorParent 를 %Function.prototype% 으로 둡니다.그렇지 않고 IsConstructor (superclass )가 false 이면, 다음을 수행합니다.TypeError 예외를 던집니다. 그렇지 않으면,protoParent 를 ? Get (superclass , "prototype" )로 둡니다.protoParent 가 Object가 아니고 protoParent 가 null 도 아니면 TypeError 예외를 던집니다.ctorParent 를 superclass 로 둡니다. proto 를 OrdinaryObjectCreate (protoParent )로 둡니다.ClassBody 가 존재하지 않으면 ctor 를 empty 로 둡니다.그렇지 않으면 ctor 를 ClassBody 의 ConstructorMethod 로 둡니다. 실행 중인 실행 컨텍스트 의 LexicalEnvironment를 classEnv 로 설정합니다.실행 중인 실행 컨텍스트 의 PrivateEnvironment를 classPrivateEnv 로 설정합니다.ctor 가 empty 이면, 다음을 수행합니다.defaultCtor 를 매개변수가 없고 아무것도 캡처하지 않으며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:args 를 [[Call]] 또는 [[Construct]] 가 이 함수에 전달한 인수의 List 로 둡니다.NewTarget이 undefined 이면 TypeError 예외를 던집니다. ctorFunc 를 활성 함수 객체 로 둡니다.ctorFunc .[[ConstructorKind]] 가 derived 이면, 다음을 수행합니다.참고 : 이 분기는 constructor(...args) { super(...args); }와 유사하게 동작합니다. 가장 주목할 만한 차이는 앞서 언급한 ECMAScript 소스 텍스트 가 %Array.prototype%의 %Symbol.iterator% 메서드를 관찰 가능하게 호출하는 반면 이 함수는 호출하지 않는다는 점입니다.func 를 ! ctorFunc .[[GetPrototypeOf]] ()로 둡니다.IsConstructor (func )가 false 이면 TypeError 예외를 던집니다.result 를 ? Construct (func , args , NewTarget)로 둡니다.그렇지 않으면,참고 : 이 분기는 constructor() {}와 유사하게 동작합니다.result 를 ? OrdinaryCreateFromConstructor (NewTarget, "%Object.prototype%" )로 둡니다. ? InitializeInstanceElements (result , ctorFunc )를 수행합니다. NormalCompletion (result )을 반환합니다.ctorFunc 를 CreateBuiltinFunction (defaultCtor , 0, className , « [[ConstructorKind]] , [[SourceText]] , [[PrivateMethods]] , [[Fields]] », the current Realm Record , ctorParent )로 둡니다.그렇지 않으면,ctorInfo 를 ! DefineMethod of ctor with arguments proto and ctorParent 로 둡니다.ctorFunc 를 ctorInfo .[[Closure]] 로 둡니다.MakeClassConstructor (ctorFunc )를 수행합니다.SetFunctionName (ctorFunc , className )을 수행합니다. ctorFunc .[[SourceText]] 를 sourceText 로 설정합니다.MakeConstructor (ctorFunc , false , proto )를 수행합니다.ClassHeritage 가 존재하면 ctorFunc .[[ConstructorKind]] 를 derived 로 설정합니다.! DefineMethodProperty (proto , "constructor" , ctorFunc , false )를 수행합니다. ClassBody 가 존재하지 않으면 classElements 를 새로운 빈 List 로 둡니다.그렇지 않으면 classElements 를 ClassBody 의 NonConstructorElements 로 둡니다. instancePrivateMethods 를 새로운 빈 List 로 둡니다.staticPrivateMethods 를 새로운 빈 List 로 둡니다.instanceFields 를 새로운 빈 List 로 둡니다.staticElements 를 새로운 빈 List 로 둡니다.classElements 의 각 ClassElement classElement 에 대해 다음을 수행합니다.classElement 의 IsStatic 이 false 이면, 다음을 수행합니다.element 를 Completion (ClassElementEvaluation of classElement with argument proto )로 둡니다.그렇지 않으면,element 를 Completion (ClassElementEvaluation of classElement with argument ctorFunc )로 둡니다. element 가 abrupt completion이면, 다음을 수행합니다.실행 중인 실행 컨텍스트 의 LexicalEnvironment를 envRecord 로 설정합니다.실행 중인 실행 컨텍스트 의 PrivateEnvironment를 outerPrivateEnv 로 설정합니다.? element 를 반환합니다. element 를 ! element 로 설정합니다.element 가 PrivateElement 이면, 다음을 수행합니다.단언 : element .[[Kind]] 는 method 또는 accessor 중 하나입니다.classElement 의 IsStatic 이 false 이면 container 를 instancePrivateMethods 로 둡니다.그렇지 않으면 container 를 staticPrivateMethods 로 둡니다. container 에 existingElement .[[Key]] 가 element .[[Key]] 인 PrivateElement existingElement 가 포함되어 있으면, 다음을 수행합니다.단언 : element .[[Kind]] 와 existingElement .[[Kind]] 는 모두 accessor 입니다.element .[[Getter]] 가 undefined 이면, 다음을 수행합니다.combined 를 PrivateElement { [[Key]] : element .[[Key]] , [[Kind]] : accessor , [[Getter]] : existingElement .[[Getter]] , [[Setter]] : element .[[Setter]] }로 둡니다.그렇지 않으면,combined 를 PrivateElement { [[Key]] : element .[[Key]] , [[Kind]] : accessor , [[Getter]] : element .[[Getter]] , [[Setter]] : existingElement .[[Setter]] }로 둡니다. container 의 existingElement 를 combined 로 대체합니다.그렇지 않으면,element 를 container 에 추가합니다. 그렇지 않고 element 가 ClassFieldDefinition Record 이면, 다음을 수행합니다.classElement 의 IsStatic 이 false 이면 element 를 instanceFields 에 추가합니다.그렇지 않으면 element 를 staticElements 에 추가합니다. 그렇지 않고 element 가 ClassStaticBlockDefinition Record 이면, 다음을 수행합니다.element 를 staticElements 에 추가합니다. 그렇지 않으면,단언 : element 는 empty 입니다. 실행 중인 실행 컨텍스트 의 LexicalEnvironment를 envRecord 로 설정합니다.classBinding 이 undefined 가 아니면, 다음을 수행합니다.! classEnv .InitializeBinding (classBinding , ctorFunc )을 수행합니다. ctorFunc .[[PrivateMethods]] 를 instancePrivateMethods 로 설정합니다.ctorFunc .[[Fields]] 를 instanceFields 로 설정합니다.staticPrivateMethods 의 각 PrivateElement method 에 대해 다음을 수행합니다.! PrivateMethodOrAccessorAdd (ctorFunc , method )를 수행합니다. staticElements 의 각 요소 elementRecord 에 대해 다음을 수행합니다.elementRecord 가 ClassFieldDefinition Record 이면, 다음을 수행합니다.result 를 Completion (DefineField (ctorFunc , elementRecord ))로 둡니다.그렇지 않으면,단언 : elementRecord 는 ClassStaticBlockDefinition Record 입니다.result 를 Completion (Call (elementRecord .[[BodyFunction]] , ctorFunc ))로 둡니다. result 가 abrupt completion이면, 다음을 수행합니다.실행 중인 실행 컨텍스트 의 PrivateEnvironment를 outerPrivateEnv 로 설정합니다.? result 를 반환합니다. 실행 중인 실행 컨텍스트 의 PrivateEnvironment를 outerPrivateEnv 로 설정합니다.ctorFunc 를 반환합니다.
15.7.15 Runtime Semantics: BindingClassDeclarationEvaluation
구문 지향 연산 BindingClassDeclarationEvaluation. 인수 없음. 반환값: (정상 완료 (값: 함수 객체 ) 또는 중도 완료). 다음 생성 규칙별로 정의된다.
ClassDeclaration :
class
BindingIdentifier
ClassTail
className 을 BindingIdentifier 의 StringValue 로 둡니다.sourceText 를 ClassDeclaration 과 일치하는 소스 텍스트 로 둡니다.value 를 인수 className , className 및 sourceText 를 사용한 ClassTail 의 ? ClassDefinitionEvaluation 으로 둡니다.envRecord 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.? InitializeBoundName (className , value , envRecord )를 수행합니다. value 를 반환합니다.
ClassDeclaration :
class
ClassTail
sourceText 를 ClassDeclaration 과 일치하는 소스 텍스트 로 둡니다.인수 undefined , "default" 및 sourceText 를 사용한 ClassTail 의 ? ClassDefinitionEvaluation 을 반환합니다.
참고
ClassDeclaration :
class
ClassTail
은 ExportDeclaration 의 일부로만 나타나며 그 바인딩 설정은 해당 생성 규칙의 평가 동작의 일부로 처리됩니다. 16.2.3.7 를 참조하시기 바랍니다.
15.7.16 Runtime Semantics: 평가
ClassDeclaration :
class
BindingIdentifier
ClassTail
이 ClassDeclaration 의 ? BindingClassDeclarationEvaluation 을 수행합니다. empty 를 반환합니다.
참고
ClassExpression :
class
ClassTail
sourceText 를 ClassExpression 과 일치하는 소스 텍스트 로 둡니다.인수 undefined , 빈 String 및 sourceText 를 사용한 ClassTail 의 ? ClassDefinitionEvaluation 을 반환합니다.
ClassExpression :
class
BindingIdentifier
ClassTail
className 을 BindingIdentifier 의 StringValue 로 둡니다.sourceText 를 ClassExpression 과 일치하는 소스 텍스트 로 둡니다.인수 className , className 및 sourceText 를 사용한 ClassTail 의 ? ClassDefinitionEvaluation 을 반환합니다.
ClassElementName : PrivateIdentifier
privateIdentifier 를 PrivateIdentifier 의 StringValue 로 둡니다.privateEnvRecord 를 실행 중인 실행 컨텍스트 의 PrivateEnvironment로 둡니다.names 를 privateEnvRecord .[[Names]] 로 둡니다.단언 : names 에는 [[Description]] 이 privateIdentifier 인 Private Name 요소가 정확히 하나 있습니다.privateName 을 names 에서 [[Description]] 이 privateIdentifier 인 Private Name 으로 둡니다.privateName 을 반환합니다.
ClassStaticBlockStatementList : [empty]
undefined 를 반환합니다.
15.8 비동기 함수 정의
구문
AsyncFunctionDeclaration [Yield, Await, Default] :
async
[no LineTerminator here]
function
BindingIdentifier [?Yield, ?Await]
(
FormalParameters [~Yield, +Await]
)
{
AsyncFunctionBody
}
[+Default]
async
[no LineTerminator here]
function
(
FormalParameters [~Yield, +Await]
)
{
AsyncFunctionBody
}
AsyncFunctionExpression :
async
[no LineTerminator here]
function
BindingIdentifier [~Yield, +Await] opt
(
FormalParameters [~Yield, +Await]
)
{
AsyncFunctionBody
}
AsyncMethod [Yield, Await] :
async
[no LineTerminator here]
ClassElementName [?Yield, ?Await]
(
UniqueFormalParameters [~Yield, +Await]
)
{
AsyncFunctionBody
}
AsyncFunctionBody :
FunctionBody [~Yield, +Await]
AwaitExpression [Yield] :
await
UnaryExpression [?Yield, +Await]
참고 1
[Await] 매개변수가 존재하면 await는 AwaitExpression 의 키워드 로 파싱됩니다. 다음 문맥의 최상위에서는 [Await] 매개변수가 존재하지만 FunctionBody 와 같은 비단말 기호에 따라 일부 문맥에서는 매개변수가 존재하지 않을 수 있습니다:
Script 가 구문 목표 기호 이면 [Await] 매개변수가 존재하지 않을 때 await를 식별자로 파싱할 수 있습니다. 여기에는 다음 문맥이 포함됩니다:
참고 2
YieldExpression 과 달리 AwaitExpression 의 피연산자를 생략하면 Syntax Error입니다. 반드시 무언가를 await해야 합니다.
15.8.1 Static Semantics: 조기 오류
AsyncMethod :
async
ClassElementName
(
UniqueFormalParameters
)
{
AsyncFunctionBody
}
AsyncFunctionDeclaration :
async
function
BindingIdentifier
(
FormalParameters
)
{
AsyncFunctionBody
}
async
function
(
FormalParameters
)
{
AsyncFunctionBody
}
AsyncFunctionExpression :
async
function
BindingIdentifier opt
(
FormalParameters
)
{
AsyncFunctionBody
}
15.8.2 Runtime Semantics: InstantiateAsyncFunctionObject
구문 지향 연산 InstantiateAsyncFunctionObject. 인수 envRecord (Environment 레코드 ) 및 privateEnv ((PrivateEnvironment 레코드 또는 null )). 반환값: ECMAScript 함수 객체. 다음 생성 규칙별로 정의된다.
AsyncFunctionDeclaration :
async
function
BindingIdentifier
(
FormalParameters
)
{
AsyncFunctionBody
}
name 을 BindingIdentifier 의 StringValue 로 둡니다.sourceText 를 AsyncFunctionDeclaration 과 일치하는 소스 텍스트 로 둡니다.closure 를 OrdinaryFunctionCreate (%AsyncFunction.prototype% , sourceText , FormalParameters , AsyncFunctionBody , non-lexical-this , envRecord , privateEnv )로 둡니다.SetFunctionName (closure , name )을 수행합니다.closure 를 반환합니다.
AsyncFunctionDeclaration :
async
function
(
FormalParameters
)
{
AsyncFunctionBody
}
sourceText 를 AsyncFunctionDeclaration 과 일치하는 소스 텍스트 로 둡니다.closure 를 OrdinaryFunctionCreate (%AsyncFunction.prototype% , sourceText , FormalParameters , AsyncFunctionBody , non-lexical-this , envRecord , privateEnv )로 둡니다.SetFunctionName (closure , "default" )를 수행합니다.closure 를 반환합니다.
15.8.3 Runtime Semantics: InstantiateAsyncFunctionExpression
구문 지향 연산 InstantiateAsyncFunctionExpression. 선택적 인수 name ((프로퍼티 키 또는 비공개 이름 )). 반환값: ECMAScript 함수 객체. 다음 생성 규칙별로 정의된다.
AsyncFunctionExpression :
async
function
(
FormalParameters
)
{
AsyncFunctionBody
}
name 이 존재하지 않으면 name 을 빈 String으로 설정합니다.envRecord 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.privateEnv 를 실행 중인 실행 컨텍스트 의 PrivateEnvironment로 둡니다.sourceText 를 AsyncFunctionExpression 과 일치하는 소스 텍스트 로 둡니다.closure 를 OrdinaryFunctionCreate (%AsyncFunction.prototype% , sourceText , FormalParameters , AsyncFunctionBody , non-lexical-this , envRecord , privateEnv )로 둡니다.SetFunctionName (closure , name )을 수행합니다.closure 를 반환합니다.
AsyncFunctionExpression :
async
function
BindingIdentifier
(
FormalParameters
)
{
AsyncFunctionBody
}
단언 : name 은 존재하지 않습니다.name 을 BindingIdentifier 의 StringValue 로 설정합니다.outerEnv 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.funcEnv 를 NewDeclarativeEnvironment (outerEnv )로 둡니다.! funcEnv .CreateImmutableBinding (name , false )를 수행합니다. privateEnv 를 실행 중인 실행 컨텍스트 의 PrivateEnvironment로 둡니다.sourceText 를 AsyncFunctionExpression 과 일치하는 소스 텍스트 로 둡니다.closure 를 OrdinaryFunctionCreate (%AsyncFunction.prototype% , sourceText , FormalParameters , AsyncFunctionBody , non-lexical-this , funcEnv , privateEnv )로 둡니다.SetFunctionName (closure , name )을 수행합니다.! funcEnv .InitializeBinding (name , closure )를 수행합니다. closure 를 반환합니다.
참고
15.8.4 Runtime Semantics: EvaluateAsyncFunctionBody
구문 지향 연산 EvaluateAsyncFunctionBody. 인수 funcObj (ECMAScript 함수 객체) 및 argList (리스트 (요소: ECMAScript 언어 값 )). 반환값: return 완료 . 다음 생성 규칙별로 정의된다.
AsyncFunctionBody : FunctionBody
promiseCapability 를 ! NewPromiseCapability (%Promise% )로 둡니다.completion 을 Completion (FunctionDeclarationInstantiation (funcObj , argList ))으로 둡니다.completion 이 비정상 완료 이면, 다음을 수행합니다.! Call (promiseCapability .[[Reject]] , undefined , « completion .[[Value]] »)를 수행합니다. 그렇지 않으면,AsyncFunctionStart (promiseCapability , FunctionBody )를 수행합니다. ReturnCompletion (promiseCapability .[[Promise]] )을 반환합니다.
15.8.5 Runtime Semantics: 평가
AsyncFunctionExpression :
async
function
BindingIdentifier opt
(
FormalParameters
)
{
AsyncFunctionBody
}
AsyncFunctionExpression 의 InstantiateAsyncFunctionExpression 을 반환합니다.
UnaryExpression : CoverAwaitExpressionAndAwaitUsingDeclarationHead
expr 을 CoverAwaitExpressionAndAwaitUsingDeclarationHead 가 포괄하는 AwaitExpression 로 둡니다.expr 의 ? Evaluation 을 반환합니다.
AwaitExpression :
await
UnaryExpression
exprRef 를 UnaryExpression 의 ? Evaluation 으로 둡니다.value 를 ? GetValue (exprRef )로 둡니다.? Await (value )를 반환합니다.
15.9 비동기 화살표 함수 정의
구문
AsyncArrowFunction [In, Yield, Await] :
async
[no LineTerminator here]
AsyncArrowBindingIdentifier [?Yield]
[no LineTerminator here]
=>
AsyncConciseBody [?In]
CoverCallExpressionAndAsyncArrowHead [?Yield, ?Await]
[no LineTerminator here]
=>
AsyncConciseBody [?In]
AsyncConciseBody [In] :
[lookahead ≠ { ]
ExpressionBody [?In, +Await]
{
AsyncFunctionBody
}
AsyncArrowBindingIdentifier [Yield] :
BindingIdentifier [?Yield, +Await]
CoverCallExpressionAndAsyncArrowHead [Yield, Await] :
MemberExpression [?Yield, ?Await]
Arguments [?Yield, ?Await]
보충 구문
다음 생성 규칙의 인스턴스를 처리할 때
AsyncArrowFunction :
CoverCallExpressionAndAsyncArrowHead
=>
AsyncConciseBody
CoverCallExpressionAndAsyncArrowHead 의 해석은 다음 문법을 사용하여 구체화됩니다:
AsyncArrowHead :
async
[no LineTerminator here]
ArrowFormalParameters [~Yield, +Await]
15.9.1 Static Semantics: 조기 오류
AsyncArrowFunction :
async
AsyncArrowBindingIdentifier
=>
AsyncConciseBody
AsyncArrowFunction :
CoverCallExpressionAndAsyncArrowHead
=>
AsyncConciseBody
15.9.2 Static Semantics: AsyncConciseBodyContainsUseStrict
구문 지향 연산 AsyncConciseBodyContainsUseStrict. 인수 없음. 반환값: Boolean. 다음 생성 규칙별로 정의된다.
AsyncConciseBody : ExpressionBody
false 를 반환합니다.
AsyncConciseBody :
{
AsyncFunctionBody
}
AsyncFunctionBody 의 FunctionBodyContainsUseStrict 를 반환합니다.
15.9.3 Runtime Semantics: EvaluateAsyncConciseBody
구문 지향 연산 EvaluateAsyncConciseBody. 인수 funcObj (ECMAScript 함수 객체) 및 argList (리스트 (요소: ECMAScript 언어 값 )). 반환값: return 완료 . 다음 생성 규칙별로 정의된다.
AsyncConciseBody : ExpressionBody
promiseCapability 를 ! NewPromiseCapability (%Promise% )로 둡니다.completion 을 Completion (FunctionDeclarationInstantiation (funcObj , argList ))으로 둡니다.completion 이 비정상 완료 이면, 다음을 수행합니다.! Call (promiseCapability .[[Reject]] , undefined , « completion .[[Value]] »)를 수행합니다. 그렇지 않으면,AsyncFunctionStart (promiseCapability , ExpressionBody )를 수행합니다. ReturnCompletion (promiseCapability .[[Promise]] )을 반환합니다.
15.9.4 Runtime Semantics: InstantiateAsyncArrowFunctionExpression
구문 지향 연산 InstantiateAsyncArrowFunctionExpression. 선택적 인수 name ((프로퍼티 키 또는 비공개 이름 )). 반환값: ECMAScript 함수 객체. 다음 생성 규칙별로 정의된다.
AsyncArrowFunction :
async
AsyncArrowBindingIdentifier
=>
AsyncConciseBody
name 이 존재하지 않으면 name 을 빈 String으로 설정합니다.envRecord 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.privateEnv 를 실행 중인 실행 컨텍스트 의 PrivateEnvironment로 둡니다.sourceText 를 AsyncArrowFunction 과 일치하는 소스 텍스트 로 둡니다.params 를 AsyncArrowBindingIdentifier 로 둡니다.closure 를 OrdinaryFunctionCreate (%AsyncFunction.prototype% , sourceText , params , AsyncConciseBody , lexical-this , envRecord , privateEnv )로 둡니다.SetFunctionName (closure , name )을 수행합니다.closure 를 반환합니다.
AsyncArrowFunction :
CoverCallExpressionAndAsyncArrowHead
=>
AsyncConciseBody
name 이 존재하지 않으면 name 을 빈 String으로 설정합니다.envRecord 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.privateEnv 를 실행 중인 실행 컨텍스트 의 PrivateEnvironment로 둡니다.sourceText 를 AsyncArrowFunction 과 일치하는 소스 텍스트 로 둡니다.head 를 CoverCallExpressionAndAsyncArrowHead 가 포괄하는 AsyncArrowHead 로 둡니다.params 를 head 의 ArrowFormalParameters 로 둡니다.closure 를 OrdinaryFunctionCreate (%AsyncFunction.prototype% , sourceText , params , AsyncConciseBody , lexical-this , envRecord , privateEnv )로 둡니다.SetFunctionName (closure , name )을 수행합니다.closure 를 반환합니다.
15.9.5 Runtime Semantics: 평가
AsyncArrowFunction :
async
AsyncArrowBindingIdentifier
=>
AsyncConciseBody
CoverCallExpressionAndAsyncArrowHead
=>
AsyncConciseBody
AsyncArrowFunction 의 InstantiateAsyncArrowFunctionExpression 을 반환합니다.
15.10 꼬리 위치 호출
15.10.1 Static Semantics: IsInTailPosition ( call )
추상 연산 IsInTailPosition. 인수 call ((a CallExpression Parse Node, a MemberExpression Parse Node 또는 an OptionalChain Parse Node)). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
IsStrict (call )이 false 이면 false 를 반환합니다.call 이 FunctionBody , ConciseBody 또는 AsyncConciseBody 안에 포함되어 있지 않으면 false 를 반환합니다.body 를 call 을 가장 가깝게 포함하는 FunctionBody , ConciseBody 또는 AsyncConciseBody 로 둡니다.body 가 GeneratorBody 의 FunctionBody 이면 false 를 반환합니다.body 가 AsyncFunctionBody 의 FunctionBody 이면 false 를 반환합니다.body 가 AsyncGeneratorBody 의 FunctionBody 이면 false 를 반환합니다.body 가 AsyncConciseBody 이면 false 를 반환합니다.인수 call 을 사용한 body 의 HasCallInTailPosition 결과를 반환합니다.
참고
호출자 컨텍스트 체인을 관찰할 수 있게 하는 일반적인 비표준 언어 확장(10.2.4 참조) 때문에 꼬리 위치 호출은 엄격 모드 코드 에서만 정의됩니다.
15.10.2 Static Semantics: HasCallInTailPosition
구문 지향 연산 HasCallInTailPosition. 인수 call ((a CallExpression Parse Node, a MemberExpression Parse Node 또는 an OptionalChain Parse Node)). 반환값: Boolean.
참고 1
call 은 특정 소스 텍스트 범위를 나타내는 Parse Node입니다. 다음 알고리즘에서 call 을 다른 Parse Node와 비교하는 것은 이들이 동일한 소스 텍스트를 나타내는지 검사하는 것입니다.
참고 2
잠재적인 꼬리 위치 호출 바로 뒤에 해당 호출 결과의 GetValue 를 반환하는 동작이 있으면 역시 가능한 꼬리 위치 호출입니다. 함수 호출은 Reference Record 를 반환할 수 없으므로 이러한 GetValue 연산은 항상 실제 함수 호출 결과와 동일한 값을 반환합니다.
참고 3
다음 생성 규칙별로 정의된다.
StatementList :
StatementList
StatementListItem
has 를 인수 call 을 사용한 파생된 StatementList 의 HasCallInTailPosition 으로 둡니다.has 가 true 이면 true 를 반환합니다.파생된 StatementList 의 ContainsUsing 이 true 이면 false 를 반환합니다. 인수 call 을 사용한 StatementListItem 의 HasCallInTailPosition 을 반환합니다.
FunctionStatementList :
[empty]
StatementListItem :
Declaration
Statement :
VariableStatement
EmptyStatement
ExpressionStatement
ContinueStatement
BreakStatement
ThrowStatement
DebuggerStatement
Block :
{
}
ReturnStatement :
return
;
LabelledItem :
FunctionDeclaration
ForInOfStatement :
for
(
LeftHandSideExpression
of
AssignmentExpression
)
Statement
for
(
var
ForBinding
of
AssignmentExpression
)
Statement
for
(
ForDeclaration
of
AssignmentExpression
)
Statement
CaseBlock :
{
}
false 를 반환합니다.
IfStatement :
if
(
Expression
)
Statement
else
Statement
has 를 인수 call 을 사용한 첫 번째 Statement 의 HasCallInTailPosition 으로 둡니다.has 가 true 이면 true 를 반환합니다.인수 call 을 사용한 두 번째 Statement 의 HasCallInTailPosition 을 반환합니다.
IfStatement :
if
(
Expression
)
Statement
DoWhileStatement :
do
Statement
while
(
Expression
)
;
WhileStatement :
while
(
Expression
)
Statement
ForStatement :
for
(
Expression opt
;
Expression opt
;
Expression opt
)
Statement
for
(
var
VariableDeclarationList
;
Expression opt
;
Expression opt
)
Statement
for
(
LexicalDeclaration
Expression opt
;
Expression opt
)
Statement
ForInOfStatement :
for
(
LeftHandSideExpression
in
Expression
)
Statement
for
(
var
ForBinding
in
Expression
)
Statement
for
(
ForDeclaration
in
Expression
)
Statement
WithStatement :
with
(
Expression
)
Statement
인수 call 을 사용한 Statement 의 HasCallInTailPosition 을 반환합니다.
LabelledStatement :
LabelIdentifier
:
LabelledItem
인수 call 을 사용한 LabelledItem 의 HasCallInTailPosition 을 반환합니다.
ReturnStatement :
return
Expression
;
인수 call 을 사용한 Expression 의 HasCallInTailPosition 을 반환합니다.
SwitchStatement :
switch
(
Expression
)
CaseBlock
인수 call 을 사용한 CaseBlock 의 HasCallInTailPosition 을 반환합니다.
CaseBlock :
{
CaseClauses opt
DefaultClause
CaseClauses opt
}
has 를 false 로 둡니다.첫 번째 CaseClauses 가 존재하면 has 를 인수 call 을 사용한 첫 번째 CaseClauses 의 HasCallInTailPosition 으로 설정합니다. has 가 true 이면 true 를 반환합니다.has 를 인수 call 을 사용한 DefaultClause 의 HasCallInTailPosition 으로 설정합니다.has 가 true 이면 true 를 반환합니다.두 번째 CaseClauses 가 존재하면 has 를 인수 call 을 사용한 두 번째 CaseClauses 의 HasCallInTailPosition 으로 설정합니다. has 를 반환합니다.
CaseClauses :
CaseClauses
CaseClause
has 를 인수 call 을 사용한 CaseClauses 의 HasCallInTailPosition 으로 둡니다.has 가 true 이면 true 를 반환합니다.인수 call 을 사용한 CaseClause 의 HasCallInTailPosition 을 반환합니다.
CaseClause :
case
Expression
:
StatementList opt
DefaultClause :
default
:
StatementList opt
StatementList 가 존재하면 인수 call 을 사용한 StatementList 의 HasCallInTailPosition 을 반환합니다.false 를 반환합니다.
TryStatement :
try
Block
Catch
인수 call 을 사용한 Catch 의 HasCallInTailPosition 을 반환합니다.
TryStatement :
try
Block
Finally
try
Block
Catch
Finally
인수 call 을 사용한 Finally 의 HasCallInTailPosition 을 반환합니다.
Catch :
catch
(
CatchParameter
)
Block
인수 call 을 사용한 Block 의 HasCallInTailPosition 을 반환합니다.
AssignmentExpression :
YieldExpression
ArrowFunction
AsyncArrowFunction
LeftHandSideExpression
=
AssignmentExpression
LeftHandSideExpression
AssignmentOperator
AssignmentExpression
LeftHandSideExpression
&&=
AssignmentExpression
LeftHandSideExpression
||=
AssignmentExpression
LeftHandSideExpression
??=
AssignmentExpression
BitwiseANDExpression :
BitwiseANDExpression
&
EqualityExpression
BitwiseXORExpression :
BitwiseXORExpression
^
BitwiseANDExpression
BitwiseORExpression :
BitwiseORExpression
|
BitwiseXORExpression
EqualityExpression :
EqualityExpression
==
RelationalExpression
EqualityExpression
!=
RelationalExpression
EqualityExpression
===
RelationalExpression
EqualityExpression
!==
RelationalExpression
RelationalExpression :
RelationalExpression
<
ShiftExpression
RelationalExpression
>
ShiftExpression
RelationalExpression
<=
ShiftExpression
RelationalExpression
>=
ShiftExpression
RelationalExpression
instanceof
ShiftExpression
RelationalExpression
in
ShiftExpression
PrivateIdentifier
in
ShiftExpression
ShiftExpression :
ShiftExpression
<<
AdditiveExpression
ShiftExpression
>>
AdditiveExpression
ShiftExpression
>>>
AdditiveExpression
AdditiveExpression :
AdditiveExpression
+
MultiplicativeExpression
AdditiveExpression
-
MultiplicativeExpression
MultiplicativeExpression :
MultiplicativeExpression
MultiplicativeOperator
ExponentiationExpression
ExponentiationExpression :
UpdateExpression
**
ExponentiationExpression
UpdateExpression :
LeftHandSideExpression
++
LeftHandSideExpression
--
++
UnaryExpression
--
UnaryExpression
UnaryExpression :
delete
UnaryExpression
void
UnaryExpression
typeof
UnaryExpression
+
UnaryExpression
-
UnaryExpression
~
UnaryExpression
!
UnaryExpression
CoverAwaitExpressionAndAwaitUsingDeclarationHead
CallExpression :
SuperCall
ImportCall
CallExpression
[
Expression
]
CallExpression
.
IdentifierName
CallExpression
.
PrivateIdentifier
NewExpression :
new
NewExpression
MemberExpression :
MemberExpression
[
Expression
]
MemberExpression
.
IdentifierName
SuperProperty
MetaProperty
new
MemberExpression
Arguments
MemberExpression
.
PrivateIdentifier
PrimaryExpression :
this
IdentifierReference
Literal
ArrayLiteral
ObjectLiteral
FunctionExpression
ClassExpression
GeneratorExpression
AsyncFunctionExpression
AsyncGeneratorExpression
RegularExpressionLiteral
TemplateLiteral
false 를 반환합니다.
Expression :
AssignmentExpression
Expression
,
AssignmentExpression
인수 call 을 사용한 AssignmentExpression 의 HasCallInTailPosition 을 반환합니다.
ConditionalExpression :
ShortCircuitExpression
?
AssignmentExpression
:
AssignmentExpression
has 를 인수 call 을 사용한 첫 번째 AssignmentExpression 의 HasCallInTailPosition 으로 둡니다.has 가 true 이면 true 를 반환합니다.인수 call 을 사용한 두 번째 AssignmentExpression 의 HasCallInTailPosition 을 반환합니다.
LogicalANDExpression :
LogicalANDExpression
&&
BitwiseORExpression
인수 call 을 사용한 BitwiseORExpression 의 HasCallInTailPosition 을 반환합니다.
LogicalORExpression :
LogicalORExpression
||
LogicalANDExpression
인수 call 을 사용한 LogicalANDExpression 의 HasCallInTailPosition 을 반환합니다.
CoalesceExpression :
CoalesceExpressionHead
??
BitwiseORExpression
인수 call 을 사용한 BitwiseORExpression 의 HasCallInTailPosition 을 반환합니다.
CallExpression :
CoverCallExpressionAndAsyncArrowHead
CallExpression
Arguments
CallExpression
TemplateLiteral
이 CallExpression 이 call 이면 true 를 반환합니다. false 를 반환합니다.
OptionalExpression :
MemberExpression
OptionalChain
CallExpression
OptionalChain
OptionalExpression
OptionalChain
인수 call 을 사용한 OptionalChain 의 HasCallInTailPosition 을 반환합니다.
OptionalChain :
?.
[
Expression
]
?.
IdentifierName
?.
PrivateIdentifier
OptionalChain
[
Expression
]
OptionalChain
.
IdentifierName
OptionalChain
.
PrivateIdentifier
false 를 반환합니다.
OptionalChain :
?.
Arguments
OptionalChain
Arguments
이 OptionalChain 이 call 이면 true 를 반환합니다. false 를 반환합니다.
MemberExpression :
MemberExpression
TemplateLiteral
이 MemberExpression 이 call 이면 true 를 반환합니다. false 를 반환합니다.
PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList
expr 을 CoverParenthesizedExpressionAndArrowParameterList 가 포괄하는 ParenthesizedExpression 로 둡니다.인수 call 을 사용한 expr 의 HasCallInTailPosition 을 반환합니다.
ParenthesizedExpression :
(
Expression
)
인수 call 을 사용한 Expression 의 HasCallInTailPosition 을 반환합니다.
15.10.3 PrepareForTailCall ( )
추상 연산 PrepareForTailCall. 인수 없음. 반환값: unused . 호출되면 다음 단계를 수행한다.
단언 : 현재 실행 컨텍스트 는 이후 어떤 ECMAScript 코드 또는 내장 함수의 평가에도 사용되지 않습니다. 이 추상 연산 호출 이후의 Call 호출은 그러한 평가를 수행하기 전에 새로운 실행 컨텍스트 를 생성하고 푸시합니다.현재 실행 컨텍스트 와 연결된 모든 리소스를 폐기합니다. unused 를 반환합니다.
꼬리 위치 호출은 대상 함수를 호출하기 전에 현재 실행 중인 함수 실행 컨텍스트 와 연결된 모든 일시적 내부 리소스를 해제하거나, 대상 함수를 지원하기 위해 해당 리소스를 재사용해야 합니다.
참고
예를 들어 꼬리 위치 호출은 대상 함수의 활성화 레코드 크기가 호출 함수의 활성화 레코드 크기를 초과하는 양만큼만 구현체의 활성화 레코드 스택을 증가시켜야 합니다. 대상 함수의 활성화 레코드가 더 작으면 스택의 전체 크기는 감소해야 합니다.
16 ECMAScript 언어: 스크립트와 모듈
16.1 스크립트
구문
Script :
ScriptBody opt
ScriptBody :
StatementList [~Yield, ~Await, ~Return]
16.1.1 Static Semantics: 조기 오류
Script : ScriptBody
ScriptBody : StatementList
16.1.2 Static Semantics: ScriptIsStrict
구문 지향 연산 ScriptIsStrict. 인수 없음. 반환값: Boolean. 다음 생성 규칙별로 정의된다.
Script : ScriptBody opt
ScriptBody 가 존재하고 ScriptBody 의 Directive Prologue에 Use Strict Directive가 포함되어 있으면 true 를 반환합니다.false 를 반환합니다.
16.1.3 Runtime Semantics: 평가
Script : [empty]
undefined 를 반환합니다.
16.1.4 Script Record
Script Record 는 평가 중인 스크립트에 관한 정보를 캡슐화합니다. 각 Script Record 에는 표 35 에 나열된 필드가 포함됩니다.
표 35: Script Record 필드
16.1.5 ParseScript ( sourceText , realm , hostDefined )
추상 연산 ParseScript. 인수 sourceText ((String 또는 a sequence of Unicode code points)), realm (Realm 레코드 ) 및 hostDefined (임의의 값). 반환값: (Script 레코드 또는 a non-empty List of SyntaxError objects). sourceText 를 Script 로 파싱한 결과를 기반으로 Script Record 를 생성합니다. 호출되면 다음 단계를 수행한다.
script 를 ParseText (sourceText , Script )로 둡니다.script 가 오류의 List 이면 script 를 반환합니다.Script Record { [[Realm]] : realm , [[ECMAScriptCode]] : script , [[LoadedModules]] : « », [[HostDefined]] : hostDefined }를 반환합니다.
참고
구현체는 해당 스크립트 소스 텍스트에 ParseScript를 평가하기 전에 스크립트 소스 텍스트를 파싱하고 조기 오류 조건을 분석할 수 있습니다. 그러나 오류 보고는 이 명세가 실제로 해당 소스 텍스트에 ParseScript를 수행하는 시점까지 지연되어야 합니다.
16.1.6 ScriptEvaluation ( scriptRecord )
추상 연산 ScriptEvaluation. 인수 scriptRecord (Script 레코드 ). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 중도 완료). 호출되면 다음 단계를 수행한다.
globalEnv 를 scriptRecord .[[Realm]] .[[GlobalEnv]] 로 둡니다.scriptContext 를 새로운 ECMAScript 코드 실행 컨텍스트 로 둡니다.scriptContext 의 Function을 null 로 설정합니다.scriptContext 의 Realm 을 scriptRecord .[[Realm]] 으로 설정합니다.scriptContext 의 ScriptOrModule을 scriptRecord 로 설정합니다.scriptContext 의 VariableEnvironment를 globalEnv 로 설정합니다.scriptContext 의 LexicalEnvironment를 globalEnv 로 설정합니다.scriptContext 의 PrivateEnvironment를 null 로 설정합니다.실행 중인 실행 컨텍스트 를 일시 중단합니다.scriptContext 를 실행 컨텍스트 스택 에 푸시합니다. 이제 scriptContext 가 실행 중인 실행 컨텍스트 입니다.scriptNode 를 scriptRecord .[[ECMAScriptCode]] 로 둡니다.result 를 Completion (GlobalDeclarationInstantiation (scriptNode , globalEnv ))으로 둡니다.result 가 정상 완료 이면, 다음을 수행합니다.result 를 Completion (scriptNode 의 Evaluation )으로 설정합니다.result 가 정상 완료 이고 result .[[Value]] 가 empty 이면, 다음을 수행합니다.result 를 NormalCompletion (undefined )으로 설정합니다.scriptContext 를 일시 중단하고 실행 컨텍스트 스택 에서 제거합니다.단언 : 실행 컨텍스트 스택 은 비어 있지 않습니다.이제 실행 컨텍스트 스택 의 맨 위에 있는 컨텍스트를 실행 중인 실행 컨텍스트 로 재개합니다. ? result 를 반환합니다.
16.1.7 GlobalDeclarationInstantiation ( script , envRecord )
추상 연산 GlobalDeclarationInstantiation. 인수 script (a Script Parse Node) 및 envRecord (Global Environment 레코드 ). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). script 는 실행 컨텍스트 를 설정할 Script 입니다. envRecord 는 바인딩을 생성할 전역 환경입니다.
참고 1
스크립트를 평가하기 위한 실행 컨텍스트 가 설정될 때 선언은 현재 전역 환경에 인스턴스화됩니다. 코드에서 선언된 각 전역 바인딩이 인스턴스화됩니다.
호출되면 다음 단계를 수행합니다:
lexicalNames 를 script 의 LexicallyDeclaredNames 로 둡니다.variableNames 를 script 의 VarDeclaredNames 로 둡니다.lexicalNames 의 각 요소 name 에 대해 다음을 수행합니다.HasLexicalDeclaration (envRecord , name )이 true 이면 SyntaxError 예외를 던집니다.hasRestrictedGlobal 을 ? HasRestrictedGlobalProperty (envRecord , name )로 둡니다.참고 : 전역 var 및 function 바인딩(비엄격 직접 eval 에 의해 도입되는 바인딩 제외)은 구성 불가능하므로 제한된 전역 프로퍼티입니다.hasRestrictedGlobal 이 true 이면 SyntaxError 예외를 던집니다.variableNames 의 각 요소 name 에 대해 다음을 수행합니다.HasLexicalDeclaration (envRecord , name )이 true 이면 SyntaxError 예외를 던집니다.variableDecls 를 script 의 VarScopedDeclarations 로 둡니다.funcsToInitialize 를 새로운 빈 List 로 둡니다.declaredFuncNames 를 새로운 빈 List 로 둡니다.variableDecls 의 각 요소 variableDecl 에 대해 List 의 역순으로 다음을 수행합니다.variableDecl 이 VariableDeclaration , ForBinding 또는 BindingIdentifier 중 어느 것도 아니면, 다음을 수행합니다.단언 : variableDecl 은 FunctionDeclaration , GeneratorDeclaration , AsyncFunctionDeclaration 또는 AsyncGeneratorDeclaration 중 하나입니다.참고 : 같은 이름에 함수 선언이 여러 개 있으면 마지막 선언이 사용됩니다.funcName 을 variableDecl 의 BoundNames 의 유일한 요소로 둡니다.declaredFuncNames 에 funcName 이 포함되어 있지 않으면, 다음을 수행합니다.funcDefinable 을 ? CanDeclareGlobalFunction (envRecord , funcName )으로 둡니다.funcDefinable 이 false 이면 TypeError 예외를 던집니다.funcName 을 declaredFuncNames 에 추가합니다.variableDecl 을 funcsToInitialize 의 첫 번째 요소로 삽입합니다.declaredVariableNames 를 새로운 빈 List 로 둡니다.variableDecls 의 각 요소 variableDecl 에 대해 다음을 수행합니다.variableDecl 이 VariableDeclaration , ForBinding 또는 BindingIdentifier 중 하나이면, 다음을 수행합니다.variableDecl 의 BoundNames 의 각 String name 에 대해 다음을 수행합니다.declaredFuncNames 에 name 이 포함되어 있지 않으면, 다음을 수행합니다.variableDefinable 을 ? CanDeclareGlobalVar (envRecord , name )로 둡니다.variableDefinable 이 false 이면 TypeError 예외를 던집니다.declaredVariableNames 에 name 이 포함되어 있지 않으면, 다음을 수행합니다.name 을 declaredVariableNames 에 추가합니다.참고 : 전역 객체 가 일반 객체 이면 이 알고리즘 단계 이후에는 비정상 종료가 발생하지 않습니다. 그러나 전역 객체 가 Proxy 특수 객체 이면 다음 단계 중 일부에서 비정상 종료를 일으키는 동작을 나타낼 수 있습니다.Normative Optional
호스트 가 웹 브라우저이거나 그 밖의 방식으로 블록 수준 함수 선언의 웹 레거시 호환성 의미론 을 지원하면, 다음을 수행합니다.strict 를 script 의 ScriptIsStrict 로 둡니다.strict 가 false 이면, 다음을 수행합니다.declaredFuncOrVariableNames 를 declaredFuncNames 와 declaredVariableNames 의 목록 연결 로 둡니다.script Contains x 가 true 인 어떤 Block , CaseClause 또는 DefaultClause x 의 StatementList 에 직접 포함된 각 FunctionDeclaration funcDecl 에 대해 다음을 수행합니다.funcName 을 funcDecl 의 BindingIdentifier 의 StringValue 로 둡니다.FunctionDeclaration funcDecl 을 funcName 을 BindingIdentifier 로 갖는 VariableStatement 로 바꿔도 script 에 조기 오류 가 발생하지 않으면, 다음을 수행합니다.HasLexicalDeclaration (envRecord , funcName )이 false 이면, 다음을 수행합니다.funcDefinable 을 ? CanDeclareGlobalVar (envRecord , funcName )로 둡니다.funcDefinable 이 true 이면, 다음을 수행합니다.참고 : funcName 에 대한 var 바인딩은 여기에서 funcName 이 VarDeclaredName도 아니고 다른 FunctionDeclaration 의 이름도 아닌 경우에만 인스턴스화됩니다.declaredFuncOrVariableNames 에 funcName 이 포함되어 있지 않으면, 다음을 수행합니다.? CreateGlobalVarBinding (envRecord , funcName , false )를 수행합니다. funcName 을 declaredFuncOrVariableNames 에 추가합니다.FunctionDeclaration funcDecl 이 평가될 때 15.2.6 에 제공된 FunctionDeclaration Evaluation 알고리즘 대신 다음 단계를 수행합니다:globalEnv 를 실행 중인 실행 컨텍스트 의 VariableEnvironment로 둡니다.blockEnv 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.funcObj 를 ! blockEnv .GetBindingValue (funcName , false )로 둡니다.? globalEnv .SetMutableBinding (funcName , funcObj , false ) 를 수행합니다. unused 를 반환합니다.lexicalDecls 를 script 의 LexicallyScopedDeclarations 로 둡니다.privateEnv 를 null 로 둡니다.lexicalDecls 의 각 요소 lexicalDecl 에 대해 다음을 수행합니다.참고 : 렉시컬하게 선언된 이름은 여기에서 인스턴스화되기만 하며 초기화되지는 않습니다.lexicalDecl 의 BoundNames 의 각 요소 name 에 대해 다음을 수행합니다.lexicalDecl 의 IsConstantDeclaration 이 true 이면, 다음을 수행합니다.? envRecord .CreateImmutableBinding (name , true ) 를 수행합니다. 그렇지 않으면,? envRecord .CreateMutableBinding (name , false ) 를 수행합니다. funcsToInitialize 의 각 Parse Node funcDecl 에 대해 다음을 수행합니다.funcName 을 funcDecl 의 BoundNames 의 유일한 요소로 둡니다.funcObj 를 인수 envRecord 및 privateEnv 를 사용한 funcDecl 의 InstantiateFunctionObject 로 둡니다.? CreateGlobalFunctionBinding (envRecord , funcName , funcObj , false )를 수행합니다. declaredVariableNames 의 각 String variableName 에 대해 다음을 수행합니다.? CreateGlobalVarBinding (envRecord , variableName , false )를 수행합니다. unused 를 반환합니다.
참고 2
16.1.1 에 명시된 조기 오류 는 하나의 Script 안에 포함된 선언에서 함수/var 선언과 let/const/class 선언 사이의 이름 충돌 및 let/const/class 바인딩의 재선언을 방지합니다. 그러나 둘 이상의 Script 에 걸친 이러한 충돌과 재선언은 GlobalDeclarationInstantiation 중 런타임 오류로 검출됩니다. 그러한 오류가 하나라도 검출되면 해당 스크립트에는 어떤 바인딩도 인스턴스화되지 않습니다. 다만 전역 객체 가 Proxy 특수 객체 를 사용하여 정의된 경우 충돌 선언에 대한 런타임 검사가 신뢰할 수 없을 수 있으며, 그 결과 비정상 완료 가 발생하고 일부 전역 선언이 인스턴스화되지 않을 수 있습니다. 이런 일이 발생하면 Script 의 코드는 평가되지 않습니다.
명시적인 var 또는 함수 선언과 달리 전역 객체 에 직접 생성된 프로퍼티로 인해 생긴 전역 바인딩은 let/const/class 선언에 의해 가려질 수 있습니다.
16.2 모듈
구문
Module :
ModuleBody opt
ModuleBody :
ModuleItemList
ModuleItemList :
ModuleItem
ModuleItemList
ModuleItem
ModuleItem :
ImportDeclaration
ExportDeclaration
StatementListItem [~Yield, +Await, ~Return]
ModuleExportName :
IdentifierName
StringLiteral
16.2.1 모듈 의미론
16.2.1.1 Static Semantics: 조기 오류
ModuleBody : ModuleItemList
참고
중복 ExportedNames 규칙은 하나의 ModuleBody 안에 여러 export default ExportDeclaration 항목이 있으면 Syntax Error라는 것을 의미합니다. 충돌하거나 중복된 선언과 관련된 추가 오류 조건은 Module 을 평가하기 전에 모듈 연결 중 검사됩니다. 이러한 오류가 하나라도 검출되면 Module 은 평가되지 않습니다.
ModuleExportName : StringLiteral
16.2.1.2 Static Semantics: ImportedLocalNames ( importEntries )
추상 연산 ImportedLocalNames. 인수 importEntries (리스트 (요소: ImportEntry 레코드 )). 반환값: 리스트 (요소: String). importEntries 에 의해 정의된 모든 로컬 이름 바인딩의 List 를 생성합니다. 호출되면 다음 단계를 수행한다.
localNames 를 새로운 빈 List 로 둡니다.importEntries 의 각 ImportEntry Record importEntry 에 대해 다음을 수행합니다.importEntry .[[LocalName]] 을 localNames 에 추가합니다.localNames 를 반환합니다.
16.2.1.3 ModuleRequest Record
ModuleRequest Record 는 주어진 import 속성을 사용하여 모듈을 가져오라는 요청을 나타냅니다. 다음 필드로 구성됩니다:
표 36: ModuleRequest Record 필드
LoadedModuleRequest Record 는 결과 Module Record 와 함께 모듈을 가져오라는 요청을 나타냅니다. 표 36 표에 정의된 것과 동일한 필드에 [[Module]] 이 추가됩니다:
표 37: LoadedModuleRequest Record 필드
ImportAttribute Record 는 다음 필드로 구성됩니다:
표 38: ImportAttribute Record 필드
필드 이름
값 타입
의미
[[Key]]
a String
속성 키
[[Value]]
a String
속성 값
16.2.1.3.1 ModuleRequestsEqual ( x , y )
추상 연산 ModuleRequestsEqual. 인수 x ((ModuleRequest 레코드 또는 LoadedModuleRequest 레코드 )) 및 y ((ModuleRequest 레코드 또는 LoadedModuleRequest 레코드 )). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
x .[[Specifier]] 가 y .[[Specifier]] 와 같지 않으면 false 를 반환합니다.xAttrs 를 x .[[Attributes]] 로 둡니다.yAttrs 를 y .[[Attributes]] 로 둡니다.xAttrsCount 를 xAttrs 의 요소 수로 둡니다.yAttrsCount 를 yAttrs 의 요소 수로 둡니다.xAttrsCount ≠ yAttrsCount 이면 false 를 반환합니다.xAttrs 의 각 ImportAttribute Record xAttr 에 대해 다음을 수행합니다.xAttr .[[Key]] 가 yAttr .[[Key]] 와 같고 xAttr .[[Value]] 가 yAttr .[[Value]] 와 같은 ImportAttribute Record yAttr 이 yAttrs 에 포함되어 있지 않으면 false 를 반환합니다.true 를 반환합니다.
16.2.1.4 Static Semantics: ModuleRequests
구문 지향 연산 ModuleRequests. 인수 없음. 반환값: 리스트 (요소: ModuleRequest 레코드 ). 다음 생성 규칙별로 정의된다.
Module : [empty]
새로운 빈 List 를 반환합니다.
ModuleItemList : ModuleItem
ModuleItem 의 ModuleRequests 를 반환합니다.
ModuleItemList :
ModuleItemList
ModuleItem
requests 를 ModuleItemList 의 ModuleRequests 로 둡니다.additionalRequests 를 ModuleItem 의 ModuleRequests 로 둡니다.additionalRequests 의 각 ModuleRequest Record moduleRequest 에 대해 다음을 수행합니다.ModuleRequestsEqual (moduleRequest , otherModuleRequest )이 true 인 ModuleRequest Record otherModuleRequest 가 requests 에 포함되어 있지 않으면, 다음을 수행합니다.moduleRequest 를 requests 에 추가합니다.requests 를 반환합니다.
ModuleItem : StatementListItem
새로운 빈 List 를 반환합니다.
ImportDeclaration :
import
ImportClause
FromClause
;
specifier 를 FromClause 의 SV 로 둡니다.유일한 요소가 ModuleRequest Record { [[Specifier]] : specifier , [[Attributes]] : « » }인 List 를 반환합니다.
ImportDeclaration :
import
ImportClause
FromClause
WithClause
;
specifier 를 FromClause 의 SV 로 둡니다.attrs 를 WithClause 의 WithClauseToAttributes 로 둡니다.유일한 요소가 ModuleRequest Record { [[Specifier]] : specifier , [[Attributes]] : attrs }인 List 를 반환합니다.
ImportDeclaration :
import
ModuleSpecifier
;
specifier 를 ModuleSpecifier 의 SV 로 둡니다.유일한 요소가 ModuleRequest Record { [[Specifier]] : specifier , [[Attributes]] : « » }인 List 를 반환합니다.
ImportDeclaration :
import
ModuleSpecifier
WithClause
;
specifier 를 ModuleSpecifier 의 SV 로 둡니다.attrs 를 WithClause 의 WithClauseToAttributes 로 둡니다.유일한 요소가 ModuleRequest Record { [[Specifier]] : specifier , [[Attributes]] : attrs }인 List 를 반환합니다.
ExportDeclaration :
export
ExportFromClause
FromClause
;
specifier 를 FromClause 의 SV 로 둡니다.유일한 요소가 ModuleRequest Record { [[Specifier]] : specifier , [[Attributes]] : « » }인 List 를 반환합니다.
ExportDeclaration :
export
ExportFromClause
FromClause
WithClause
;
specifier 를 FromClause 의 SV 로 둡니다.attrs 를 WithClause 의 WithClauseToAttributes 로 둡니다.유일한 요소가 ModuleRequest Record { [[Specifier]] : specifier , [[Attributes]] : attrs }인 List 를 반환합니다.
ExportDeclaration :
export
NamedExports
;
export
VariableStatement
export
Declaration
export
default
HoistableDeclaration
export
default
ClassDeclaration
export
default
AssignmentExpression
;
새로운 빈 List 를 반환합니다.
16.2.1.5 추상 Module Record
Module Record 는 하나의 모듈이 가져오고 내보내는 항목에 관한 구조적 정보를 캡슐화합니다. 이 정보는 서로 연결된 모듈 집합의 import와 export를 연결하는 데 사용됩니다. Module Record에는 모듈을 평가할 때만 사용하는 네 개의 필드가 포함됩니다.
명세를 위한 목적으로 Module Record는 Record 명세 타입의 값이며, Module Record가 추상 클래스이고 추상 및 구체 하위 클래스를 모두 갖는 단순한 객체 지향 계층 구조에 존재한다고 생각할 수 있습니다. 이 명세는 Cyclic Module Record 라는 추상 하위 클래스와 그 구체 하위 클래스인 Source Text Module Record 를 정의합니다. 다른 명세와 구현체는 자신들이 정의한 대체 모듈 정의 기능에 대응하는 추가 Module Record 하위 클래스를 정의할 수 있습니다.
Module Record는 표 39 에 나열된 필드를 정의합니다. 모든 Module Definition 하위 클래스는 최소한 이러한 필드를 포함합니다. Module Record는 또한 표 40 의 추상 메서드 목록을 정의합니다. 모든 Module definition 하위 클래스는 이러한 추상 메서드의 구체 구현을 제공해야 합니다.
표 39: Module Record 필드
필드 이름
값 타입
의미
[[Realm]]
a Realm Record
이 모듈이 생성된 Realm 입니다.
[[Environment]]
a Module Environment Record or empty
이 모듈의 최상위 바인딩을 포함하는 Environment Record 입니다. 이 필드는 모듈이 연결될 때 설정됩니다.
[[Namespace]]
an Object or empty
이 모듈에 대해 생성된 경우 Module Namespace Object(28.3 )입니다.
[[HostDefined]]
anything (default value is undefined )
모듈에 추가 정보를 연결해야 하는 호스트 환경 에서 사용하도록 예약된 필드입니다.
표 40: Module Records 의 추상 메서드
메서드
목적
정의
LoadRequestedModules ( [ hostDefined ] )
추상 메서드 LoadRequestedModules. 선택적 인수 hostDefined (임의의 값). 반환값: Promise.
모든 종속성을 재귀적으로 로드하여 모듈을 연결할 준비를 합니다.
이 명세에서는 다음 타입에 정의가 있으며, 호스트 는 자체 정의를 갖는 추가 타입을 제공할 수 있습니다:
GetExportedNames ( [ exportStarSet ] )
추상 메서드 GetExportedNames. 선택적 인수 exportStarSet (리스트 (요소: Source Text Module 레코드 )). 반환값: 리스트 (요소: String).
이 모듈에서 직접 또는 간접으로 내보내는 모든 이름의 목록을 반환합니다.
이 메서드를 호출하기 전에 LoadRequestedModules 가 성공적으로 완료되어 있어야 합니다.
이 명세에서는 다음 타입에 정의가 있으며, 호스트 는 자체 정의를 갖는 추가 타입을 제공할 수 있습니다:
ResolveExport ( exportName [ , resolveSet ] )
추상 메서드 ResolveExport. 인수 exportName (String) 및 선택적 인수 resolveSet (리스트 (요소: 레코드 (필드: [[Module]] (Module 레코드 ), [[ExportName]] (String)))). 반환값: (ResolvedBinding 레코드 , null 또는 ambiguous ).
이 모듈에서 내보낸 이름의 바인딩을 반환합니다. 바인딩은 { [[Module]] : Module Record , [[BindingName]] : String | namespace } 형태의 ResolvedBinding Record 로 나타냅니다. export가 어떤 모듈에도 직접 바인딩이 없는 Module Namespace Object이면 [[BindingName]] 은 namespace 로 설정됩니다. 이름을 해석할 수 없으면 null 을 반환하고 여러 바인딩이 발견되면 ambiguous 를 반환합니다.
이 연산을 특정 exportName , resolveSet 쌍을 인수로 사용하여 호출할 때마다 동일한 결과를 반환해야 합니다.
이 메서드를 호출하기 전에 LoadRequestedModules 가 성공적으로 완료되어 있어야 합니다.
이 명세에서는 다음 타입에 정의가 있으며, 호스트 는 자체 정의를 갖는 추가 타입을 제공할 수 있습니다:
Link ( )
추상 메서드 Link. 인수 없음. 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ).
모든 모듈 종속성을 전이적으로 해석하고 Module Environment Record 를 생성하여 모듈을 평가할 준비를 합니다.
이 메서드를 호출하기 전에 LoadRequestedModules 가 성공적으로 완료되어 있어야 합니다.
이 명세에서는 다음 타입에 정의가 있으며, 호스트 는 자체 정의를 갖는 추가 타입을 제공할 수 있습니다:
Evaluate ( )
추상 메서드 Evaluate. 인수 없음. 반환값: Promise.
이 모듈과 그 종속성의 평가에 대한 promise를 반환합니다. 평가가 성공하거나 이미 성공적으로 평가된 경우 resolve되고, 평가 오류가 발생하거나 이미 평가에 실패한 경우 reject됩니다. promise가 reject되면 호스트 는 promise rejection을 처리하고 평가 오류를 다시 던질 것으로 예상됩니다. 이 모듈이 Cyclic Module Record 가 아닌 한 반환된 promise는 이미 settle되어 있어야 합니다.
이 메서드를 호출하기 전에 Link 가 성공적으로 완료되어 있어야 합니다.
이 명세에서는 다음 타입에 정의가 있으며, 호스트 는 자체 정의를 갖는 추가 타입을 제공할 수 있습니다:
16.2.1.5.1 EvaluateModuleSync ( module )
추상 연산 EvaluateModuleSync. 인수 module (Module 레코드 ). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 호출자가 module 의 평가가 이미 settle된 promise를 반환할 것임을 보장하는 경우 module 을 동기적으로 평가합니다. 호출되면 다음 단계를 수행한다.
단언 : module 은 Cyclic Module Record 가 아닙니다.promise 를 module .Evaluate ()로 둡니다.단언 : promise .[[PromiseState]] 는 fulfilled 또는 rejected 입니다.promise .[[PromiseState]] 가 rejected 이면, 다음을 수행합니다.promise .[[PromiseIsHandled]] 가 false 이면 HostPromiseRejectionTracker (promise , "handle" )를 수행합니다.promise .[[PromiseIsHandled]] 를 true 로 설정합니다.promise .[[PromiseResult]] 를 던집니다.unused 를 반환합니다.
16.2.1.6 Cyclic Module Record
Cyclic Module Record 는 Cyclic Module Record 타입의 하위 클래스인 다른 모듈과 종속성 순환에 참여할 수 있는 모듈에 관한 정보를 나타내는 데 사용됩니다. Cyclic Module Record 타입의 하위 클래스가 아닌 Module Record 는 Source Text Module Record 와의 종속성 순환에 참여해서는 안 됩니다.
표 39 에 정의된 필드 외에도 Cyclic Module Record 에는 표 41 에 나열된 추가 필드가 있습니다.
표 41: Cyclic Module Record 의 추가 필드
필드 이름
값 타입
의미
[[Status]]
new , unlinked , linking , linked , evaluating , evaluating-async , or evaluated
처음에는 new 입니다. 모듈이 수명 주기를 진행하면서 unlinked , linking , linked , evaluating , 경우에 따라 evaluating-async , evaluated 순서로 전이합니다. evaluating-async 는 이 모듈이 비동기 종속성 완료 시 실행 대기 중이거나 [[HasTLA]] 필드가 true 인 모듈로서 실행되었지만 최상위 완료를 기다리고 있음을 나타냅니다.
[[EvaluationError]]
a throw completion or empty
평가 중 발생한 예외를 나타내는 throw 완료 입니다. 예외가 발생하지 않았거나 [[Status]] 가 evaluated 가 아니면 empty 입니다.
[[DFSAncestorIndex]]
an integer or empty
Link 및 Evaluate 중에만 사용하는 보조 필드입니다. [[Status]] 가 linking 또는 evaluating 이면 이 값은 모듈 자체의 깊이 우선 탐색 인덱스 또는 동일한 강연결 요소에 있는 “더 앞선” 모듈의 인덱스입니다.
[[RequestedModules]]
a List of ModuleRequest Records
이 모듈의 import와 연결된 ModuleRequest Record 의 List 입니다. List 는 import가 소스 텍스트에 나타나는 순서입니다.
[[LoadedModules]]
a List of LoadedModuleRequest Records
이 Record 가 나타내는 모듈이 상대 import 속성과 함께 모듈을 가져오도록 요청하는 데 사용한 지정자 문자열에서 해석된 Module Record 로의 맵입니다. 이 목록에는 ModuleRequestsEqual (r1 , r2 )이 true 인 서로 다른 두 Record r1 과 r2 가 포함되지 않습니다.
[[CycleRoot]]
a Cyclic Module Record or empty
순환에서 처음 방문한 모듈, 즉 강연결 요소의 루트 DFS 조상입니다. 순환에 속하지 않는 모듈에서는 모듈 자신입니다. Evaluate 가 완료되면 모듈의 [[DFSAncestorIndex]] 는 해당 [[CycleRoot]] 의 깊이 우선 탐색 인덱스입니다.
[[HasTLA]]
a Boolean
이 모듈 자체가 비동기인지 여부입니다(예: 최상위 await를 포함하는 Source Text Module Record ). 비동기 종속성을 갖는다고 해서 이 필드가 true 인 것은 아닙니다. 이 필드는 모듈을 파싱한 뒤 변경되어서는 안 됩니다.
[[AsyncEvaluationOrder]]
unset , an integer, or done
이 필드는 처음에 unset 으로 설정되며 완전히 동기적인 모듈에서는 계속 unset 입니다. 모듈 자체가 비동기이거나 비동기 종속성을 갖는 경우, 16.2.1.6.1.3.4 이 대기 중인 모듈의 실행을 큐에 넣는 순서를 결정하는 정수 로 설정됩니다. 대기 중인 모듈이 성공적으로 실행되면 이 필드는 done 으로 설정됩니다.
[[TopLevelCapability]]
a PromiseCapability Record or empty
이 모듈이 어떤 순환의 [[CycleRoot]] 이고 해당 순환의 어떤 모듈에 대해 Evaluate ()가 호출되었다면, 이 필드는 전체 평가에 대한 PromiseCapability Record 를 포함합니다. Evaluate () 추상 메서드에서 반환한 Promise 객체를 settle하는 데 사용됩니다. 해당 모듈의 종속성에서는 일부 종속성에 대해 최상위 Evaluate ()가 시작된 경우를 제외하면 이 필드가 empty 입니다.
[[AsyncParentModules]]
a List of Cyclic Module Records
이 모듈 또는 종속성의 [[HasTLA]] 가 true 이고 실행이 진행 중이면 최상위 실행 작업에 대해 이 모듈의 부모 importer를 추적합니다. 이러한 부모 모듈은 이 모듈이 성공적으로 실행을 완료하기 전에는 실행을 시작하지 않습니다.
[[PendingAsyncDependencies]]
an integer or empty
이 모듈에 비동기 종속성이 있으면 이 모듈을 위해 아직 실행해야 하는 비동기 종속 모듈의 수를 추적합니다. 비동기 종속성이 있는 모듈은 이 필드가 0에 도달하고 실행 오류가 없을 때 실행됩니다.
표 40 에 정의된 메서드 외에도 Cyclic Module Record 에는 표 42 에 나열된 추가 메서드가 있습니다:
표 42: Cyclic Module Record 의 추가 추상 메서드
GraphLoadingState Record 는 모듈 그래프의 로딩 과정에 관한 정보를 포함하는 Record 입니다. HostLoadImportedModule 호출 이후 로딩을 계속하는 데 사용됩니다. 각 GraphLoadingState Record 에는 표 43 에 정의된 필드가 있습니다:
표 43: GraphLoadingState Record 필드
16.2.1.6.1 Module Record 추상 메서드의 구현
다음은 표 40 에 정의된 대응 Module Record 추상 메서드를 구현하는 Cyclic Module Record 의 구체 메서드입니다.
16.2.1.6.1.1 LoadRequestedModules ( [ hostDefined ] )
a Cyclic Module Record module 의 구체 메서드 LoadRequestedModules . 선택적 인수 hostDefined (임의의 값). 반환값: Promise. module 의 종속성 그래프에 있는 모든 Module Record 의 [[LoadedModules]] 를 채웁니다(대부분의 작업은 보조 함수 InnerModuleLoading 이 수행합니다). HostLoadImportedModule 훅에 전달되는 선택적 hostDefined 매개변수를 받습니다. 호출되면 다음 단계를 수행한다.
hostDefined 가 존재하지 않으면 hostDefined 를 empty 로 설정합니다.promiseCapability 를 ! NewPromiseCapability (%Promise% )로 둡니다.state 를 GraphLoadingState Record { [[IsLoading]] : true , [[PendingModulesCount]] : 1, [[Visited]] : « », [[PromiseCapability]] : promiseCapability , [[HostDefined]] : hostDefined }로 둡니다.InnerModuleLoading (state , module )을 수행합니다.promiseCapability .[[Promise]] 를 반환합니다.
참고
hostDefined 매개변수는 가져온 모듈을 가져오는 데 필요한 추가 정보를 전달하는 데 사용할 수 있습니다. 예를 들어 HTML은 이를 사용하여 <link rel="preload" as="..."> 태그에 올바른 fetch destination을 설정합니다.
import() 표현식은 hostDefined 매개변수를 절대로 설정하지 않습니다.
16.2.1.6.1.1.1 InnerModuleLoading ( state , module )
추상 연산 InnerModuleLoading. 인수 state (GraphLoadingState 레코드 ) 및 module (Module 레코드 ). 반환값: unused . LoadRequestedModules 가 module 의 종속성 그래프에 대한 실제 로딩 과정을 재귀적으로 수행하는 데 사용합니다. 호출되면 다음 단계를 수행한다.
단언 : state .[[IsLoading]] 은 true 입니다.module 이 Cyclic Module Record 이고 module .[[Status]] 가 new 이며 state .[[Visited]] 에 module 이 포함되어 있지 않으면, 다음을 수행합니다.module 을 state .[[Visited]] 에 추가합니다.requestedModulesCount 를 module .[[RequestedModules]] 의 요소 수로 둡니다.state .[[PendingModulesCount]] 를 state .[[PendingModulesCount]] + requestedModulesCount 로 설정합니다.module .[[RequestedModules]] 의 각 ModuleRequest Record request 에 대해 다음을 수행합니다.AllImportAttributesSupported (request .[[Attributes]] )가 false 이면, 다음을 수행합니다.error 를 ThrowCompletion (새로 생성된 SyntaxError 객체)으로 둡니다.ContinueModuleLoading (state , error )을 수행합니다.그렇지 않고 module .[[LoadedModules]] 에 ModuleRequestsEqual (record , request )이 true 인 LoadedModuleRequest Record record 가 포함되어 있으면, 다음을 수행합니다.InnerModuleLoading (state , record .[[Module]] )을 수행합니다. 그렇지 않으면,HostLoadImportedModule (module , request , state .[[HostDefined]] , state )을 수행합니다.참고 : HostLoadImportedModule 은 FinishLoadingImportedModule 을 호출하며, FinishLoadingImportedModule 은 ContinueModuleLoading 을 통해 그래프 로딩 과정에 다시 진입합니다. state .[[IsLoading]] 이 false 이면 unused 를 반환합니다.단언 : state .[[PendingModulesCount]] ≥ 1입니다.state .[[PendingModulesCount]] 를 state .[[PendingModulesCount]] - 1로 설정합니다.state .[[PendingModulesCount]] = 0이면, 다음을 수행합니다.state .[[IsLoading]] 을 false 로 설정합니다.state .[[Visited]] 의 각 Cyclic Module Record loaded 에 대해 다음을 수행합니다.loaded .[[Status]] 가 new 이면 loaded .[[Status]] 를 unlinked 로 설정합니다.! Call (state .[[PromiseCapability]] .[[Resolve]] , undefined , « undefined »)를 수행합니다. unused 를 반환합니다.
16.2.1.6.1.1.2 ContinueModuleLoading ( state , moduleCompletion )
추상 연산 ContinueModuleLoading. 인수 state (GraphLoadingState 레코드 ) 및 moduleCompletion ((정상 완료 (값: Module 레코드 ) 또는 throw 완료 )). 반환값: unused . HostLoadImportedModule 호출 후 로딩 과정에 다시 진입하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
state .[[IsLoading]] 이 false 이면 unused 를 반환합니다.moduleCompletion 이 정상 완료 이면, 다음을 수행합니다.InnerModuleLoading (state , moduleCompletion .[[Value]] )을 수행합니다.그렇지 않으면,state .[[IsLoading]] 을 false 로 설정합니다.! Call (state .[[PromiseCapability]] .[[Reject]] , undefined , « moduleCompletion .[[Value]] »)를 수행합니다. unused 를 반환합니다.
16.2.1.6.1.2 Link ( )
a Cyclic Module Record module 의 구체 메서드 Link . 인수 없음. 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 성공하면 Link 는 이 모듈의 [[Status]] 를 unlinked 에서 linked 로 전이합니다. 실패하면 예외가 던져지고 이 모듈의 [[Status]] 는 unlinked 상태로 유지됩니다. (대부분의 작업은 보조 함수 InnerModuleLinking 이 수행합니다.) 호출되면 다음 단계를 수행한다.
단언 : module .[[Status]] 는 unlinked , linked , evaluating-async 또는 evaluated 중 하나입니다.stack 을 새로운 빈 List 로 둡니다.result 를 Completion (InnerModuleLinking (module , stack , 0))으로 둡니다.result 가 비정상 완료 이면, 다음을 수행합니다.stack 의 각 Cyclic Module Record requiredModule 에 대해 다음을 수행합니다.단언 : requiredModule .[[Status]] 는 linking 입니다.requiredModule .[[Status]] 를 unlinked 로 설정합니다.단언 : module .[[Status]] 는 unlinked 입니다.? result 를 반환합니다. 단언 : module .[[Status]] 는 linked , evaluating-async 또는 evaluated 중 하나입니다.단언 : stack 은 비어 있습니다.unused 를 반환합니다.
16.2.1.6.1.2.1 InnerModuleLinking ( module , stack , index )
추상 연산 InnerModuleLinking. 인수 module (Module 레코드 ), stack (리스트 (요소: Cyclic Module 레코드 )) 및 index (음이 아닌 정수). 반환값: (정상 완료 (값: 음이 아닌 정수) 또는 throw 완료 ). Link 가 module 에 대한 실제 연결 과정을 수행하고 종속성 그래프의 다른 모든 모듈에도 재귀적으로 수행하는 데 사용합니다. stack 과 index 매개변수 및 모듈의 [[DFSAncestorIndex]] 필드는 깊이 우선 탐색(DFS)을 추적합니다. 특히 [[DFSAncestorIndex]] 는 강연결 요소(SCC)를 찾아내는 데 사용되며, 하나의 SCC에 있는 모든 모듈은 함께 linked 로 전이합니다. 호출되면 다음 단계를 수행한다.
module 이 Cyclic Module Record 가 아니면, 다음을 수행합니다.? module .Link ()를 수행합니다. index 를 반환합니다.module .[[Status]] 가 linking , linked , evaluating-async 또는 evaluated 중 하나이면, 다음을 수행합니다.index 를 반환합니다.단언 : module .[[Status]] 는 unlinked 입니다.module .[[Status]] 를 linking 으로 설정합니다.moduleIndex 를 index 로 둡니다.module .[[DFSAncestorIndex]] 를 index 로 설정합니다.index 를 index + 1로 설정합니다.module 을 stack 에 추가합니다.module .[[RequestedModules]] 의 각 ModuleRequest Record request 에 대해 다음을 수행합니다.requiredModule 을 GetImportedModule (module , request )로 둡니다.index 를 ? InnerModuleLinking (requiredModule , stack , index )으로 설정합니다.requiredModule 이 Cyclic Module Record 이면, 다음을 수행합니다.단언 : requiredModule .[[Status]] 는 linking , linked , evaluating-async 또는 evaluated 중 하나입니다.단언 : requiredModule .[[Status]] 가 linking 인 것과 stack 에 requiredModule 이 포함되어 있는 것은 동치입니다.requiredModule .[[Status]] 가 linking 이면, 다음을 수행합니다.module .[[DFSAncestorIndex]] 를 min (module .[[DFSAncestorIndex]] , requiredModule .[[DFSAncestorIndex]] )로 설정합니다.? module .InitializeEnvironment ()를 수행합니다. 단언 : module 은 stack 에 정확히 한 번 나타납니다.단언 : module .[[DFSAncestorIndex]] ≤ moduleIndex 입니다.module .[[DFSAncestorIndex]] = moduleIndex 이면, 다음을 수행합니다.done 을 false 로 둡니다.done 이 false 인 동안 다음을 반복합니다.requiredModule 을 stack 의 마지막 요소로 둡니다.stack 의 마지막 요소를 제거합니다.단언 : requiredModule 은 Cyclic Module Record 입니다.requiredModule .[[Status]] 를 linked 로 설정합니다.requiredModule 과 module 이 동일한 Module Record 이면 done 을 true 로 설정합니다.index 를 반환합니다.
16.2.1.6.1.3 Evaluate ( )
a Cyclic Module Record module 의 구체 메서드 Evaluate . 인수 없음. 반환값: Promise. Evaluate 는 이 모듈의 [[Status]] 를 linked 에서 evaluating-async 또는 evaluated 로 전이합니다. 주어진 강연결 요소의 모듈에 대해 처음 호출될 때 Evaluate 는 모듈 평가가 완료될 때 resolve되는 Promise를 생성하고 반환합니다. 이 Promise는 해당 요소의 [[CycleRoot]] 의 [[TopLevelCapability]] 필드에 저장됩니다. 이후 해당 요소의 어떤 모듈에 대해 Evaluate 를 호출해도 같은 Promise를 반환합니다. (대부분의 작업은 보조 함수 InnerModuleEvaluation 이 수행합니다.) 호출되면 다음 단계를 수행한다.
단언 : 이 Evaluate 호출은 주변 agent 안의 다른 Evaluate 호출과 동시에 발생하고 있지 않습니다.단언 : module .[[Status]] 는 linked , evaluating-async 또는 evaluated 중 하나입니다.module .[[Status]] 가 evaluating-async 또는 evaluated 이면, 다음을 수행합니다.module .[[CycleRoot]] 가 empty 가 아니면, 다음을 수행합니다.module 을 module .[[CycleRoot]] 로 설정합니다.그렇지 않으면,단언 : module .[[Status]] 는 evaluated 이고 module .[[EvaluationError]] 는 throw 완료 입니다. module .[[TopLevelCapability]] 가 empty 가 아니면, 다음을 수행합니다.module .[[TopLevelCapability]] .[[Promise]] 를 반환합니다.stack 을 새로운 빈 List 로 둡니다.promiseCapability 을 ! NewPromiseCapability (%Promise% )로 둡니다.module .[[TopLevelCapability]] 를 promiseCapability 로 설정합니다.result 를 Completion (InnerModuleEvaluation (module , stack , 0))으로 둡니다.result 가 비정상 완료 이면, 다음을 수행합니다.stack 의 각 Cyclic Module Record requiredModule 에 대해 다음을 수행합니다.단언 : requiredModule .[[Status]] 는 evaluating 입니다.requiredModule .[[Status]] 를 evaluated 로 설정합니다.requiredModule .[[EvaluationError]] 를 result 로 설정합니다.단언 : module .[[Status]] 는 evaluated 입니다.단언 : module .[[EvaluationError]] 와 result 는 동일한 Completion Record 입니다.! Call (promiseCapability .[[Reject]] , undefined , « result .[[Value]] »)를 수행합니다. 그렇지 않으면,단언 : module .[[Status]] 는 evaluating-async 또는 evaluated 입니다.단언 : module .[[EvaluationError]] 는 empty 입니다.module .[[Status]] 가 evaluated 이면, 다음을 수행합니다.단언 : module .[[AsyncEvaluationOrder]] 는 unset 또는 done 입니다.참고 : module 이 이미 평가되었고 해당 평가가 비동기였던 경우에만 module .[[AsyncEvaluationOrder]] 는 done 입니다.! Call (promiseCapability .[[Resolve]] , undefined , « undefined »)를 수행합니다. 단언 : stack 은 비어 있습니다. promiseCapability .[[Promise]] 를 반환합니다.
16.2.1.6.1.3.1 InnerModuleEvaluation ( module , stack , index )
추상 연산 InnerModuleEvaluation. 인수 module (Module 레코드 ), stack (리스트 (요소: Cyclic Module 레코드 )) 및 index (음이 아닌 정수). 반환값: (정상 완료 (값: 음이 아닌 정수) 또는 throw 완료 ). Evaluate 가 module 의 실제 평가 과정을 수행하고 종속성 그래프의 다른 모든 모듈에도 재귀적으로 수행하는 데 사용합니다. stack 과 index 매개변수 및 module 의 [[DFSAncestorIndex]] 필드는 InnerModuleLinking 과 같은 방식으로 사용됩니다. 호출되면 다음 단계를 수행한다.
module 이 Cyclic Module Record 가 아니면, 다음을 수행합니다.? EvaluateModuleSync (module )를 수행합니다. index 를 반환합니다.module .[[Status]] 가 evaluating-async 또는 evaluated 이면, 다음을 수행합니다.module .[[EvaluationError]] 가 empty 이면 index 를 반환합니다.? module .[[EvaluationError]] 를 반환합니다. module .[[Status]] 가 evaluating 이면 index 를 반환합니다.단언 : module .[[Status]] 는 linked 입니다.module .[[Status]] 를 evaluating 으로 설정합니다.moduleIndex 를 index 로 둡니다.module .[[DFSAncestorIndex]] 를 index 로 설정합니다.module .[[PendingAsyncDependencies]] 를 0으로 설정합니다.index 를 index + 1로 설정합니다.module 을 stack 에 추가합니다.module .[[RequestedModules]] 의 각 ModuleRequest Record request 에 대해 다음을 수행합니다.requiredModule 을 GetImportedModule (module , request )로 둡니다.index 를 ? InnerModuleEvaluation (requiredModule , stack , index )으로 설정합니다.requiredModule 이 Cyclic Module Record 이면, 다음을 수행합니다.단언 : requiredModule .[[Status]] 는 evaluating , evaluating-async 또는 evaluated 중 하나입니다.단언 : requiredModule .[[Status]] 가 evaluating 인 것과 stack 에 requiredModule 이 포함되어 있는 것은 동치입니다.requiredModule .[[Status]] 가 evaluating 이면, 다음을 수행합니다.module .[[DFSAncestorIndex]] 를 min (module .[[DFSAncestorIndex]] , requiredModule .[[DFSAncestorIndex]] )로 설정합니다.그렇지 않으면,requiredModule 을 requiredModule .[[CycleRoot]] 로 설정합니다.단언 : requiredModule .[[Status]] 는 evaluating-async 또는 evaluated 입니다.requiredModule .[[EvaluationError]] 가 empty 가 아니면 ? requiredModule .[[EvaluationError]] 를 반환합니다. requiredModule .[[AsyncEvaluationOrder]] 가 정수 이면, 다음을 수행합니다.module .[[PendingAsyncDependencies]] 를 module .[[PendingAsyncDependencies]] + 1로 설정합니다.module 을 requiredModule .[[AsyncParentModules]] 에 추가합니다.module .[[HasTLA]] 가 true 이거나 module .[[PendingAsyncDependencies]] > 0이면, 다음을 수행합니다.단언 : module .[[AsyncEvaluationOrder]] 는 unset 입니다.module .[[AsyncEvaluationOrder]] 를 IncrementModuleAsyncEvaluationCount ()로 설정합니다.module .[[PendingAsyncDependencies]] = 0이면 ExecuteAsyncModule (module )을 수행합니다.그렇지 않으면,? module .ExecuteModule () 를 수행합니다. 단언 : module 은 stack 에 정확히 한 번 나타납니다.단언 : module .[[DFSAncestorIndex]] ≤ moduleIndex 입니다.module .[[DFSAncestorIndex]] = moduleIndex 이면, 다음을 수행합니다.done 을 false 로 둡니다.done 이 false 인 동안 다음을 반복합니다.requiredModule 을 stack 의 마지막 요소로 둡니다.stack 의 마지막 요소를 제거합니다.단언 : requiredModule 은 Cyclic Module Record 입니다.단언 : requiredModule .[[AsyncEvaluationOrder]] 는 정수 또는 unset 입니다.requiredModule .[[AsyncEvaluationOrder]] 가 unset 이면 requiredModule .[[Status]] 를 evaluated 로 설정합니다.그렇지 않으면 requiredModule .[[Status]] 를 evaluating-async 로 설정합니다. requiredModule 과 module 이 동일한 Module Record 이면 done 을 true 로 설정합니다.requiredModule .[[CycleRoot]] 를 module 로 설정합니다.index 를 반환합니다.
참고 1
모듈은 InnerModuleEvaluation이 순회하는 동안 evaluating 입니다. 실행 완료 시에는 evaluated 가 되며, [[HasTLA]] 필드가 true 이거나 비동기 종속성이 있으면 실행 중에는 evaluating-async 입니다.
참고 2
비동기 순환이 evaluating 상태가 아닐 때 그 순환의 모듈에 의존하는 모든 모듈은 대신 [[CycleRoot]] 를 통해 순환 루트의 실행에 의존합니다. 이를 통해 순환 상태를 루트 모듈 상태를 통해 하나의 강연결 요소로 취급할 수 있습니다.
16.2.1.6.1.3.2 ExecuteAsyncModule ( module )
추상 연산 ExecuteAsyncModule. 인수 module (Cyclic Module 레코드 ). 반환값: unused . 호출되면 다음 단계를 수행한다.
단언 : module .[[Status]] 는 evaluating 또는 evaluating-async 입니다.단언 : module .[[HasTLA]] 는 true 입니다.promiseCapability 을 ! NewPromiseCapability (%Promise% )로 둡니다.fulfilledClosure 를 매개변수가 없고 module 을 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:AsyncModuleExecutionFulfilled (module )을 수행합니다.NormalCompletion (undefined )을 반환합니다.onFulfilled 를 CreateBuiltinFunction (fulfilledClosure , 0, "" , « »)로 둡니다.rejectedClosure 를 매개변수 (error )를 갖고 module 을 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:AsyncModuleExecutionRejected (module , error )를 수행합니다.NormalCompletion (undefined )을 반환합니다.onRejected 를 CreateBuiltinFunction (rejectedClosure , 0, "" , « »)로 둡니다.PerformPromiseThen (promiseCapability .[[Promise]] , onFulfilled , onRejected )을 수행합니다.! module .ExecuteModule (promiseCapability ) 를 수행합니다. unused 를 반환합니다.
16.2.1.6.1.3.3 GatherAvailableAncestors ( module , execList )
추상 연산 GatherAvailableAncestors. 인수 module (Cyclic Module 레코드 ) 및 execList (리스트 (요소: Cyclic Module 레코드 )). 반환값: unused . 호출되면 다음 단계를 수행한다.
module .[[AsyncParentModules]] 의 각 Cyclic Module Record ancestorModule 에 대해 다음을 수행합니다.execList 에 ancestorModule 이 포함되어 있지 않고 ancestorModule .[[CycleRoot]] .[[EvaluationError]] 가 empty 이면, 다음을 수행합니다.단언 : ancestorModule .[[Status]] 는 evaluating-async 입니다.단언 : ancestorModule .[[EvaluationError]] 는 empty 입니다.단언 : ancestorModule .[[AsyncEvaluationOrder]] 는 정수 입니다.단언 : ancestorModule .[[PendingAsyncDependencies]] > 0입니다.ancestorModule .[[PendingAsyncDependencies]] 를 ancestorModule .[[PendingAsyncDependencies]] - 1로 설정합니다.ancestorModule .[[PendingAsyncDependencies]] = 0이면, 다음을 수행합니다.ancestorModule 을 execList 에 추가합니다.ancestorModule .[[HasTLA]] 가 false 이면 GatherAvailableAncestors (ancestorModule , execList )을 수행합니다.unused 를 반환합니다.
참고
루트 module 의 비동기 실행이 이행되면 이 함수는 해당 완료에서 함께 동기적으로 실행할 수 있는 모듈 목록을 결정하여 execList 에 채웁니다.
16.2.1.6.1.3.4 AsyncModuleExecutionFulfilled ( module )
추상 연산 AsyncModuleExecutionFulfilled. 인수 module (Cyclic Module 레코드 ). 반환값: unused . 호출되면 다음 단계를 수행한다.
module .[[Status]] 가 evaluated 이면, 다음을 수행합니다.단언 : module .[[EvaluationError]] 는 empty 가 아닙니다.unused 를 반환합니다.단언 : module .[[Status]] 는 evaluating-async 입니다.단언 : module .[[AsyncEvaluationOrder]] 는 정수 입니다.단언 : module .[[EvaluationError]] 는 empty 입니다.module .[[AsyncEvaluationOrder]] 를 done 으로 설정합니다.module .[[Status]] 를 evaluated 로 설정합니다.module .[[TopLevelCapability]] 가 empty 가 아니면, 다음을 수행합니다.단언 : module .[[CycleRoot]] 와 module 은 동일한 Module Record 입니다.! Call (module .[[TopLevelCapability]] .[[Resolve]] , undefined , « undefined »)를 수행합니다. execList 를 새로운 빈 List 로 둡니다.GatherAvailableAncestors (module , execList )을 수행합니다.단언 : execList 의 모든 요소는 [[AsyncEvaluationOrder]] 필드가 정수 이고 [[PendingAsyncDependencies]] 필드가 0이며 [[EvaluationError]] 필드가 empty 입니다.sortedExecList 를 execList 의 요소를 [[AsyncEvaluationOrder]] 필드에 따라 오름차순으로 정렬한 List 로 둡니다.sortedExecList 의 각 Cyclic Module Record ancestorModule 에 대해 다음을 수행합니다.ancestorModule .[[Status]] 가 evaluated 이면, 다음을 수행합니다.단언 : ancestorModule .[[EvaluationError]] 는 empty 가 아닙니다.그렇지 않고 ancestorModule .[[HasTLA]] 가 true 이면, 다음을 수행합니다.ExecuteAsyncModule (ancestorModule )을 수행합니다. 그렇지 않으면,result 를 Completion (ancestorModule .ExecuteModule () )으로 둡니다.result 가 비정상 완료 이면, 다음을 수행합니다.AsyncModuleExecutionRejected (ancestorModule , result .[[Value]] )를 수행합니다.그렇지 않으면,ancestorModule .[[AsyncEvaluationOrder]] 를 done 으로 설정합니다.ancestorModule .[[Status]] 를 evaluated 로 설정합니다.ancestorModule .[[TopLevelCapability]] 가 empty 가 아니면, 다음을 수행합니다.단언 : ancestorModule .[[CycleRoot]] 와 ancestorModule 은 동일한 Module Record 입니다.! Call (ancestorModule .[[TopLevelCapability]] .[[Resolve]] , undefined , « undefined »)를 수행합니다. unused 를 반환합니다.
16.2.1.6.1.3.5 AsyncModuleExecutionRejected ( module , error )
추상 연산 AsyncModuleExecutionRejected. 인수 module (Cyclic Module 레코드 ) 및 error (ECMAScript 언어 값 ). 반환값: unused . 호출되면 다음 단계를 수행한다.
module .[[Status]] 가 evaluated 이면, 다음을 수행합니다.단언 : module .[[EvaluationError]] 는 empty 가 아닙니다.unused 를 반환합니다.단언 : module .[[Status]] 는 evaluating-async 입니다.단언 : module .[[AsyncEvaluationOrder]] 는 정수 입니다.단언 : module .[[EvaluationError]] 는 empty 입니다.module .[[EvaluationError]] 를 ThrowCompletion (error )로 설정합니다.module .[[Status]] 를 evaluated 로 설정합니다.module .[[AsyncEvaluationOrder]] 를 done 으로 설정합니다.참고 : module .[[AsyncEvaluationOrder]] 는 AsyncModuleExecutionFulfilled 와 대칭을 이루기 위해 done 으로 설정됩니다. InnerModuleEvaluation 에서는 모듈의 [[EvaluationError]] 내부 슬롯이 empty 가 아니면 해당 모듈의 [[AsyncEvaluationOrder]] 내부 슬롯 값은 사용되지 않습니다.module .[[TopLevelCapability]] 가 empty 가 아니면, 다음을 수행합니다.단언 : module .[[CycleRoot]] 와 module 은 동일한 Module Record 입니다.! Call (module .[[TopLevelCapability]] .[[Reject]] , undefined , « error »)를 수행합니다. module .[[AsyncParentModules]] 의 각 Cyclic Module Record ancestorModule 에 대해 다음을 수행합니다.AsyncModuleExecutionRejected (ancestorModule , error )를 수행합니다.unused 를 반환합니다.
16.2.1.6.2 Cyclic Module Record 그래프 예제
이 비규범적 절에서는 오류가 어떻게 발생할 수 있는지에 특히 초점을 맞추어 몇 가지 일반적인 모듈 그래프의 연결 및 평가 예를 제시합니다.
먼저 다음의 단순한 모듈 그래프를 살펴보겠습니다:
그림 2: 단순한 모듈 그래프
먼저 오류 조건이 없다고 가정하겠습니다. 호스트 가 처음 A .LoadRequestedModules ()를 호출하면 가정에 따라 성공적으로 완료되고 B 와 C 의 종속성(각각 C 와 없음)도 재귀적으로 로드한 다음 A .[[Status]] = B .[[Status]] = C .[[Status]] = unlinked 로 설정합니다. 그런 다음 호스트 가 A .Link ()를 호출하면 역시 가정에 따라 성공적으로 완료되어 A .[[Status]] = B .[[Status]] = C .[[Status]] = linked 가 됩니다. 이러한 준비 단계는 언제든 수행할 수 있습니다. 이후 호스트 가 모듈의 가능한 부작용을 발생시킬 준비가 되면 A .Evaluate ()를 호출할 수 있으며, 이는 성공적으로 완료되어 undefined 로 resolve되는 Promise를 반환하고(역시 가정에 따라) 먼저 C , 그다음 B 를 재귀적으로 평가합니다. 이 시점에서 각 모듈의 [[Status]] 는 evaluated 입니다.
그다음 A .LoadRequestedModules ()를 성공적으로 호출한 이후 연결 오류가 발생하는 경우를 살펴보겠습니다. C 의 InnerModuleLinking 은 성공하지만 그 이후 B 에서 실패하는 경우, 예를 들어 B 가 C 가 제공하지 않는 항목을 가져오려고 하면 원래의 A .Link ()는 실패하고 A 와 B 의 [[Status]] 는 모두 unlinked 로 남습니다. 그러나 C 의 [[Status]] 는 linked 가 됩니다.
마지막으로 Link ()를 성공적으로 호출한 뒤 평가 오류가 발생하는 경우를 살펴보겠습니다. C 의 InnerModuleEvaluation 은 성공하지만 그 이후 B 에서 실패하는 경우, 예를 들어 B 에 예외를 던지는 코드가 포함되어 있으면 원래의 A .Evaluate ()는 실패하여 reject된 Promise를 반환합니다. 그 결과 예외는 A 와 B 의 [[EvaluationError]] 필드 모두에 기록되고 [[Status]] 는 evaluated 가 됩니다. C 도 evaluated 가 되지만 A 와 B 와 달리 평가를 성공적으로 완료했으므로 [[EvaluationError]] 는 없는 상태로 유지됩니다. 예외를 저장함으로써 호스트 가 Evaluate () 메서드를 호출하여 A 또는 B 를 다시 사용하려 할 때마다 동일한 예외를 만나도록 보장합니다. (호스트 는 Cyclic Module Record 를 반드시 재사용해야 하는 것은 아니며, 마찬가지로 이러한 메서드가 던진 예외 객체를 노출해야 할 의무도 없습니다. 그러나 이 명세는 그러한 사용을 가능하게 합니다.)
이제 다른 종류의 오류 조건을 살펴보겠습니다:
그림 3: 해석할 수 없는 모듈이 있는 모듈 그래프
이 시나리오에서는 모듈 A 가 다른 어떤 모듈에 대한 종속성을 선언하지만 해당 모듈에 대한 Module Record 가 존재하지 않습니다. 즉, HostLoadImportedModule 이 해당 모듈을 요청받았을 때 예외와 함께 FinishLoadingImportedModule 을 호출합니다. 이는 대응 리소스가 존재하지 않거나 리소스는 존재하지만 결과 소스 텍스트를 파싱하려 할 때 ParseModule 이 몇 가지 오류를 반환하는 등 여러 이유로 발생할 수 있습니다. 호스트 는 FinishLoadingImportedModule 에 전달하는 완료를 통해 실패 원인을 노출하도록 선택할 수 있습니다. 어떤 경우든 이 예외로 인해 로딩이 실패하며 A 의 [[Status]] 는 new 상태로 유지됩니다.
여기서 로딩, 연결 및 평가 오류가 서로 다른 이유는 다음 특성 때문입니다:
평가는 부작용을 일으킬 수 있으므로 한 번만 수행해야 합니다. 따라서 실패했더라도 평가가 이미 수행되었는지 기억하는 것이 중요합니다. (오류의 경우 예외도 기억하는 것이 타당합니다. 그렇지 않으면 이후 Evaluate () 호출 때마다 새 예외를 합성해야 하기 때문입니다.)
반면 연결에는 부작용이 없으므로 실패하더라도 나중에 문제없이 다시 시도할 수 있습니다.
로딩은 호스트 와 밀접하게 상호작용하며, 일부 호스트 에서는 사용자가 실패한 로드를 다시 시도하도록 허용하는 것이 바람직할 수 있습니다(예: 일시적인 네트워크 상태 불량으로 실패한 경우).
이제 순환이 있는 모듈 그래프를 살펴보겠습니다:
그림 4: 순환 모듈 그래프
여기서는 진입점이 모듈 A 라고 가정하므로 호스트 는 A .LoadRequestedModules ()를 호출하여 진행하며, 이는 A 에 InnerModuleLoading 을 수행합니다. 이어서 B 와 C 에 InnerModuleLoading 을 호출합니다. 순환 때문에 A 에 InnerModuleLoading 이 다시 호출되지만, 이 시점에는 이 LoadRequestedModules 과정에서 A 의 종속성 로딩이 이미 시작되었으므로 아무 작업도 하지 않습니다. 그래프의 모든 모듈이 성공적으로 로드되면 해당 [[Status]] 는 동시에 new 에서 unlinked 로 전이합니다.
그다음 호스트 는 A .Link ()를 호출하며, 이는 A 에 InnerModuleLinking 을 수행합니다. 이어서 B 에 InnerModuleLinking 을 호출합니다. 순환 때문에 A 에 InnerModuleLinking 이 다시 호출되지만 이 시점에는 A .[[Status]] 가 이미 linking 이므로 아무 작업도 하지 않습니다. 제어가 A 로 돌아오고 C 에 InnerModuleLinking 이 시작될 때 B .[[Status]] 자체는 계속 linking 상태입니다. 이 호출이 C .[[Status]] 가 linked 인 상태로 반환된 후 A 와 B 는 함께 linking 에서 linked 로 전이합니다. 이들이 하나의 강연결 요소를 형성하므로 이는 의도된 동작입니다. 이 단계에서 모듈 그래프는 깊이 우선 탐색으로 순회되므로 동일한 SCC에 있는 모듈의 상태를 동시에 전이할 수 있습니다.
성공하는 경우 순환 모듈 그래프의 평가 단계에서도 이와 유사한 과정이 발생합니다.
이제 A 에 연결 오류가 있는 경우를 생각해 보겠습니다. 예를 들어 A 가 C 에 존재하지 않는 바인딩을 가져오려고 할 수 있습니다. 이 경우 A 에 대한 두 번째 InnerModuleLinking 호출에서 조기 반환되는 것을 포함하여 위 단계는 여전히 발생합니다. 그러나 원래의 A 에 대한 InnerModuleLinking 으로 되돌아오면 InitializeEnvironment 중, 정확히는 C .ResolveExport () 직후에 실패합니다. 던져진 SyntaxError 예외는 A .Link 까지 전파되며, A .Link 는 현재 자신의 stack 에 있는 모든 모듈(항상 아직 linking 상태인 모듈과 정확히 같습니다)을 재설정합니다. 따라서 A 와 B 는 모두 unlinked 가 됩니다. C 는 linked 상태로 남는다는 점에 유의하시기 바랍니다.
또는 A 에 평가 오류가 있는 경우를 생각해 보겠습니다. 예를 들어 소스 코드가 예외를 던질 수 있습니다. 이 경우 A 에 대한 두 번째 InnerModuleEvaluation 호출에서 조기 반환되는 것을 포함하여 위 단계에 대응하는 평가 시점의 과정이 여전히 발생합니다. 그러나 원래의 A 에 대한 InnerModuleEvaluation 으로 되돌아오면 가정대로 실패합니다. 던져진 예외는 A .Evaluate ()까지 전파되며, A .Evaluate ()는 현재 자신의 stack 에 있는 모든 모듈(즉, 여전히 evaluating 상태인 모듈)과 [[AsyncParentModules]] 를 통해 오류를 기록합니다. [[AsyncParentModules]] 는 AsyncModuleExecutionRejected 알고리즘을 통해 전체 종속성 그래프에서 최상위 await를 포함하거나 이에 의존하는 모듈의 체인을 형성합니다. 따라서 A 와 B 는 모두 evaluated 가 되고 예외는 A 와 B 의 [[EvaluationError]] 필드 모두에 기록되는 반면, C 는 [[EvaluationError]] 없이 evaluated 상태로 남습니다.
마지막으로 모든 모듈이 비동기적으로 완료되는 순환 모듈 그래프를 살펴보겠습니다:
그림 5: 비동기 순환 모듈 그래프
로딩과 연결은 이전과 동일하게 진행되며 모든 모듈은 [[Status]] 가 linked 로 설정된 상태가 됩니다.
A .Evaluate ()를 호출하면 A , B , D 에 InnerModuleEvaluation 이 호출되고 이들은 모두 evaluating 으로 전이합니다. 그런 다음 A 에 InnerModuleEvaluation 이 다시 호출되지만 이미 evaluating 상태이므로 아무 작업도 하지 않습니다. 이 시점에서 D .[[PendingAsyncDependencies]] 는 0이므로 ExecuteAsyncModule (D )이 호출되고 D 의 비동기 실행을 추적하는 새로운 PromiseCapability과 함께 D .ExecuteModule 을 호출합니다. B 에 대한 InnerModuleEvaluation 으로 되돌아가면서 B .[[PendingAsyncDependencies]] 를 1로, B .[[AsyncEvaluationOrder]] 를 1로 설정합니다. 원래의 A 에 대한 InnerModuleEvaluation 으로 되돌아가면서 A .[[PendingAsyncDependencies]] 를 1로 설정합니다. A 의 종속성을 순회하는 다음 반복에서 C 에 InnerModuleEvaluation 을 호출하고, 따라서 D (다시 아무 작업도 하지 않음)와 E 에도 호출합니다. E 는 종속성이 없고 순환의 일부도 아니므로 D 와 같은 방식으로 ExecuteAsyncModule (E )을 호출하고 E 는 즉시 스택에서 제거됩니다. 다시 C 에 대한 InnerModuleEvaluation 으로 되돌아가 C .[[AsyncEvaluationOrder]] 를 3으로 설정합니다. 이제 A 의 종속성 순회를 끝내고 A .[[AsyncEvaluationOrder]] 를 4로 설정한 다음 전체 강연결 요소를 스택에서 제거하여 모든 모듈을 한꺼번에 evaluating-async 로 전이합니다. 이 시점의 모듈 필드는 표 44 과 같습니다.
표 44: 초기 Evaluate () 호출 후의 모듈 필드
필드
모듈
A
B
C
D
E
[[DFSAncestorIndex]]
0
0
0
0
4
[[Status]]
evaluating-async
evaluating-async
evaluating-async
evaluating-async
evaluating-async
[[AsyncEvaluationOrder]]
4
1
3
0
2
[[AsyncParentModules]]
« »
« A »
« A »
« B , C »
« C »
[[PendingAsyncDependencies]]
2 (B and C )
1 (D )
2 (D and E )
0
0
E 가 먼저 실행을 끝낸다고 가정하겠습니다. 이때 AsyncModuleExecutionFulfilled 가 호출되고 E .[[Status]] 는 evaluated 로 설정되며 C .[[PendingAsyncDependencies]] 는 1로 감소합니다. 갱신된 모듈 필드는 표 45 와 같습니다.
표 45: 모듈 E 의 실행이 끝난 후의 모듈 필드
필드
모듈
C
E
[[DFSAncestorIndex]]
0
4
[[Status]]
evaluating-async
evaluated
[[AsyncEvaluationOrder]]
3
done
[[AsyncParentModules]]
« A »
« C »
[[PendingAsyncDependencies]]
1 (D )
0
다음으로 D 가 실행을 끝냅니다(여전히 실행 중인 유일한 모듈이었습니다). 이때 AsyncModuleExecutionFulfilled 가 다시 호출되고 D .[[Status]] 는 evaluated 로 설정됩니다. 실행할 수 있는 조상은 B ([[AsyncEvaluationOrder]] 가 1)와 C ([[AsyncEvaluationOrder]] 가 3)이므로 B 가 먼저 처리됩니다. B .[[PendingAsyncDependencies]] 는 0으로 감소하고 ExecuteAsyncModule 이 B 에 호출되어 실행을 시작합니다. C .[[PendingAsyncDependencies]] 도 0으로 감소하고 C 도 실행을 시작합니다(B 에 await가 포함되어 있다면 B 와 병렬로 실행될 수 있습니다). 갱신된 모듈 필드는 표 46 과 같습니다.
표 46: 모듈 D 의 실행이 끝난 후의 모듈 필드
필드
모듈
B
C
D
[[DFSAncestorIndex]]
0
0
0
[[Status]]
evaluating-async
evaluating-async
evaluated
[[AsyncEvaluationOrder]]
1
3
done
[[AsyncParentModules]]
« A »
« A »
« B , C »
[[PendingAsyncDependencies]]
0
0
0
다음으로 C 가 실행을 끝낸다고 가정하겠습니다. 이때 AsyncModuleExecutionFulfilled 가 다시 호출되고 C .[[Status]] 는 evaluated 로 설정되며 A .[[PendingAsyncDependencies]] 는 1로 감소합니다. 갱신된 모듈 필드는 표 47 와 같습니다.
표 47: 모듈 C 의 실행이 끝난 후의 모듈 필드
필드
모듈
A
C
[[DFSAncestorIndex]]
0
0
[[Status]]
evaluating-async
evaluated
[[AsyncEvaluationOrder]]
4
done
[[AsyncParentModules]]
« »
« A »
[[PendingAsyncDependencies]]
1 (B )
0
그다음 B 가 실행을 끝냅니다. 이때 AsyncModuleExecutionFulfilled 가 다시 호출되고 B .[[Status]] 는 evaluated 로 설정됩니다. A .[[PendingAsyncDependencies]] 는 0으로 감소하므로 ExecuteAsyncModule 이 호출되어 실행을 시작합니다. 갱신된 모듈 필드는 표 48 와 같습니다.
표 48: 모듈 B 의 실행이 끝난 후의 모듈 필드
필드
모듈
A
B
[[DFSAncestorIndex]]
0
0
[[Status]]
evaluating-async
evaluated
[[AsyncEvaluationOrder]]
4
done
[[AsyncParentModules]]
« »
« A »
[[PendingAsyncDependencies]]
0
0
마지막으로 A 가 실행을 끝냅니다. 이때 AsyncModuleExecutionFulfilled 가 다시 호출되고 A .[[Status]] 는 evaluated 로 설정됩니다. 이 시점에서 A .[[TopLevelCapability]] 의 Promise(A .Evaluate ()가 반환했던 Promise)가 resolve되며 이 모듈 그래프의 처리가 끝납니다. 갱신된 모듈 필드는 표 49 과 같습니다.
표 49: 모듈 A 의 실행이 끝난 후의 모듈 필드
필드
모듈
A
[[DFSAncestorIndex]]
0
[[Status]]
evaluated
[[AsyncEvaluationOrder]]
done
[[AsyncParentModules]]
« »
[[PendingAsyncDependencies]]
0
또는 B 가 실행을 끝내기 전에 C 의 실행이 실패하여 오류를 반환하는 실패 사례를 생각해 보겠습니다. 이때 AsyncModuleExecutionRejected 가 호출되고 C .[[Status]] 는 evaluated 로, C .[[EvaluationError]] 는 해당 오류로 설정됩니다. 그런 다음 각 AsyncParentModules에 AsyncModuleExecutionRejected 를 수행하여 이 오류를 모든 AsyncParentModules에 전파합니다. 갱신된 모듈 필드는 표 50 과 같습니다.
표 50: 모듈 C 가 오류와 함께 완료된 후의 모듈 필드
필드
모듈
A
C
[[DFSAncestorIndex]]
0
0
[[Status]]
evaluated
evaluated
[[AsyncEvaluationOrder]]
done
done
[[AsyncParentModules]]
« »
« A »
[[PendingAsyncDependencies]]
1 (B )
0
[[EvaluationError]]
empty
C 's evaluation error
C 가 C 의 오류를 사용하여 A 에 AsyncModuleExecutionRejected 를 호출하므로 A 는 C 와 동일한 오류로 reject됩니다. A .[[Status]] 는 evaluated 로 설정됩니다. 이 시점에서 A .[[TopLevelCapability]] 의 Promise(A .Evaluate ()가 반환했던 Promise)는 reject됩니다. 갱신된 모듈 필드는 표 51 과 같습니다.
표 51: 모듈 A 가 reject된 후의 모듈 필드
필드
모듈
A
[[DFSAncestorIndex]]
0
[[Status]]
evaluated
[[AsyncEvaluationOrder]]
done
[[AsyncParentModules]]
« »
[[PendingAsyncDependencies]]
0
[[EvaluationError]]
C 's Evaluation Error
그다음 B 가 오류 없이 실행을 끝냅니다. 이때 AsyncModuleExecutionFulfilled 가 다시 호출되고 B .[[Status]] 는 evaluated 로 설정됩니다. B 에 GatherAvailableAncestors 가 호출됩니다. 그러나 A .[[CycleRoot]] 는 A 이며 평가 오류를 갖고 있으므로 반환되는 sortedExecList 에는 추가되지 않고 AsyncModuleExecutionFulfilled 는 추가 처리 없이 반환합니다. 이후 B 를 가져오는 모든 importer는 순환 루트 A 에 설정된 C 의 평가 오류에서 B .[[CycleRoot]] .[[EvaluationError]] 의 rejection을 해석합니다. 갱신된 모듈 필드는 표 52 와 같습니다.
표 52: 오류가 발생하는 그래프에서 모듈 B 의 실행이 끝난 후의 모듈 필드
필드
모듈
A
B
[[DFSAncestorIndex]]
0
0
[[Status]]
evaluated
evaluated
[[AsyncEvaluationOrder]]
4
1
[[AsyncParentModules]]
« »
« A »
[[PendingAsyncDependencies]]
0
0
[[EvaluationError]]
C 's Evaluation Error
empty
16.2.1.7 Source Text Module Record
Source Text Module Record 는 목표 기호 Module 을 사용하여 파싱한 ECMAScript 소스 텍스트 (11 )로 정의된 모듈에 관한 정보를 나타내는 데 사용됩니다. 그 필드에는 모듈이 가져오고 내보내는 이름에 관한 요약 정보가 포함되며, 구체 메서드는 이러한 요약 정보를 사용하여 모듈을 연결하고 평가합니다.
Source Text Module Record 는 추상 Module Record 타입의 다른 하위 클래스와 함께 모듈 그래프에 존재할 수 있으며 Cyclic Module Record 타입의 다른 하위 클래스와 순환에 참여할 수 있습니다.
표 41 에 정의된 필드 외에도 Source Text Module Record 에는 표 53 에 나열된 추가 필드가 있습니다. 이러한 각 필드는 처음 ParseModule 에서 설정됩니다.
표 53: Source Text Module Record 의 추가 필드
ImportEntry Record 는 하나의 선언적 import에 관한 정보를 요약하는 Record 입니다. 각 ImportEntry Record 에는 표 54 에 정의된 필드가 있습니다:
표 54: ImportEntry Record 필드
참고 1
표 55 는 구문적 import 형식을 나타내는 데 사용되는 ImportEntry Record 필드의 예를 제공합니다:
표 55 (참고 ): Import 형식과 ImportEntry Record 의 대응
Import 문 형식
[[ModuleRequest]]
[[ImportName]]
[[LocalName]]
import v from "mod";
"mod"
"default"
"v"
import * as ns from "mod";
"mod"
namespace
"ns"
import {x} from "mod";
"mod"
"x"
"x"
import {x as v} from "mod";
"mod"
"x"
"v"
import "mod";
ImportEntry Record 는 생성되지 않습니다.
ExportEntry Record 는 하나의 선언적 export에 관한 정보를 요약하는 Record 입니다. 각 ExportEntry Record 에는 표 56 에 정의된 필드가 있습니다:
표 56: ExportEntry Record 필드
참고 2
표 57 는 구문적 export 형식을 나타내는 데 사용되는 ExportEntry Record 필드의 예를 제공합니다:
표 57 (참고 ): Export 형식과 ExportEntry Record 의 대응
Export 문 형식
[[ExportName]]
[[ModuleRequest]]
[[ImportName]]
[[LocalName]]
export var v;
"v"
null
null
"v"
export default function f() {}
"default"
null
null
"f"
export default function () {}
"default"
null
null
"*default*"
export default 42;
"default"
null
null
"*default*"
export {x};
"x"
null
null
"x"
export {v as x};
"x"
null
null
"v"
export {x} from "mod";
"x"
"mod"
"x"
null
export {v as x} from "mod";
"x"
"mod"
"v"
null
export * from "mod";
null
"mod"
all-but-default
null
export * as ns from "mod";
"ns"
"mod"
namespace
null
다음 정의는 Source Text Module Record 에 필요한 구체 메서드와 그 밖의 추상 연산 을 명시합니다.
16.2.1.7.1 ParseModule ( sourceText , realm , hostDefined )
추상 연산 ParseModule. 인수 sourceText ((String 또는 a sequence of Unicode code points)), realm (Realm 레코드 ) 및 hostDefined (임의의 값). 반환값: (Source Text Module 레코드 또는 a non-empty List of SyntaxError objects). sourceText 를 Module 로 파싱한 결과를 기반으로 Source Text Module Record 를 생성합니다. 호출되면 다음 단계를 수행한다.
body 를 ParseText (sourceText , Module )로 둡니다.body 가 오류의 List 이면 body 를 반환합니다.requestedModules 를 body 의 ModuleRequests 로 둡니다.importEntries 를 body 의 ImportEntries 로 둡니다.importedBoundNames 를 ImportedLocalNames (importEntries )로 둡니다.indirectExportEntries 를 새로운 빈 List 로 둡니다.localExportEntries 를 새로운 빈 List 로 둡니다.starExportEntries 를 새로운 빈 List 로 둡니다.exportEntries 를 body 의 ExportEntries 로 둡니다.exportEntries 의 각 ExportEntry Record exportEntry 에 대해 다음을 수행합니다.exportEntry .[[ModuleRequest]] 가 null 이면, 다음을 수행합니다.importedBoundNames 에 exportEntry .[[LocalName]] 이 포함되어 있지 않으면, 다음을 수행합니다.exportEntry 를 localExportEntries 에 추가합니다.그렇지 않으면,참고 : 원래 다른 모듈에서 가져온 바인딩 또는 네임스페이스 객체를 내보낼 때 ExportEntry Record 는 바인딩 또는 네임스페이스 객체를 가져온 뒤 내보낸 것이 아니라 원래 모듈에서 직접 다시 내보냈다면 갖게 되었을 형식과 일치하도록 다시 작성됩니다. 이를 통해 export * from을 통해 동일한 이름으로 같은 바인딩 또는 네임스페이스를 두 번 내보내 발생하는 충돌을 Source Text Module Record의 ResolveExport 구체 메서드 의 9.e.iii 단계에서 모호한 것으로 취급하지 않고 무시할 수 있습니다.importEntry 를 [[LocalName]] 이 exportEntry .[[LocalName]] 인 importEntries 의 요소로 둡니다.ExportEntry Record { [[ModuleRequest]] : importEntry .[[ModuleRequest]] , [[ImportName]] : importEntry .[[ImportName]] , [[LocalName]] : null , [[ExportName]] : exportEntry .[[ExportName]] }를 indirectExportEntries 에 추가합니다. 그렇지 않고 exportEntry .[[ImportName]] 이 all-but-default 이면, 다음을 수행합니다.단언 : exportEntry .[[ExportName]] 은 null 입니다.exportEntry 를 starExportEntries 에 추가합니다. 그렇지 않으면,exportEntry 를 indirectExportEntries 에 추가합니다. async 를 body Contains await로 둡니다.Source Text Module Record { [[Realm]] : realm , [[Environment]] : empty , [[Namespace]] : empty , [[CycleRoot]] : empty , [[HasTLA]] : async , [[AsyncEvaluationOrder]] : unset , [[TopLevelCapability]] : empty , [[AsyncParentModules]] : « », [[PendingAsyncDependencies]] : empty , [[Status]] : new , [[EvaluationError]] : empty , [[HostDefined]] : hostDefined , [[ECMAScriptCode]] : body , [[Context]] : empty , [[ImportMeta]] : empty , [[RequestedModules]] : requestedModules , [[LoadedModules]] : « », [[ImportEntries]] : importEntries , [[LocalExportEntries]] : localExportEntries , [[IndirectExportEntries]] : indirectExportEntries , [[StarExportEntries]] : starExportEntries , [[DFSAncestorIndex]] : empty }를 반환합니다.
참고
구현체는 해당 모듈 소스 텍스트에 ParseModule을 평가하기 전에 모듈 소스 텍스트를 파싱하고 조기 오류 조건을 분석할 수 있습니다. 그러나 오류 보고는 이 명세가 실제로 해당 소스 텍스트에 ParseModule을 수행하는 시점까지 지연되어야 합니다.
16.2.1.7.2 Module Record 추상 메서드의 구현
다음은 표 40 에 정의된 대응 Module Record 추상 메서드를 구현하는 Source Text Module Record 의 구체 메서드입니다.
16.2.1.7.2.1 GetExportedNames ( [ exportStarSet ] )
a Source Text Module Record module 의 구체 메서드 GetExportedNames . 선택적 인수 exportStarSet (리스트 (요소: Source Text Module 레코드 )). 반환값: 리스트 (요소: String). 호출되면 다음 단계를 수행한다.
단언 : module .[[Status]] 는 new 가 아닙니다.exportStarSet 이 존재하지 않으면 exportStarSet 을 새로운 빈 List 로 설정합니다.exportStarSet 에 module 이 포함되어 있으면, 다음을 수행합니다.단언 : export * 순환의 시작점에 도달했습니다.새로운 빈 List 를 반환합니다. module 을 exportStarSet 에 추가합니다.exportedNames 를 새로운 빈 List 로 둡니다.module .[[LocalExportEntries]] 의 각 ExportEntry Record exportEntry 에 대해 다음을 수행합니다.단언 : module 은 이 export에 대한 직접 바인딩을 제공합니다.단언 : exportEntry .[[ExportName]] 은 null 이 아닙니다.exportEntry .[[ExportName]] 을 exportedNames 에 추가합니다.module .[[IndirectExportEntries]] 의 각 ExportEntry Record exportEntry 에 대해 다음을 수행합니다.단언 : module 은 이 export를 위해 특정 바인딩을 가져옵니다.단언 : exportEntry .[[ExportName]] 은 null 이 아닙니다.exportEntry .[[ExportName]] 을 exportedNames 에 추가합니다.module .[[StarExportEntries]] 의 각 ExportEntry Record exportEntry 에 대해 다음을 수행합니다.단언 : exportEntry .[[ModuleRequest]] 는 null 이 아닙니다.requestedModule 을 GetImportedModule (module , exportEntry .[[ModuleRequest]] )로 둡니다.starNames 를 requestedModule .GetExportedNames (exportStarSet )로 둡니다.starNames 의 각 요소 name 에 대해 다음을 수행합니다.name 이 "default" 가 아니면, 다음을 수행합니다.exportedNames 에 name 이 포함되어 있지 않으면, 다음을 수행합니다.name 을 exportedNames 에 추가합니다.exportedNames 를 반환합니다.
참고
GetExportedNames 는 모호한 star export 바인딩을 가진 이름을 걸러내거나 이에 대해 예외를 던지지 않습니다.
16.2.1.7.2.2 ResolveExport ( exportName [ , resolveSet ] )
a Source Text Module Record module 의 구체 메서드 ResolveExport . 인수 exportName (String) 및 선택적 인수 resolveSet (리스트 (요소: 레코드 (필드: [[Module]] (Module 레코드 ), [[ExportName]] (String)))). 반환값: (ResolvedBinding 레코드 , null 또는 ambiguous ).
ResolveExport 는 가져온 바인딩을 실제 정의 모듈 및 로컬 바인딩 이름으로 해석하려고 합니다. 정의 모듈은 이 메서드를 호출한 Module Record 가 나타내는 모듈일 수도 있고, 해당 모듈이 가져오는 다른 모듈일 수도 있습니다. 매개변수 resolveSet 은 해석되지 않은 순환 import/export 경로를 검출하는 데 사용됩니다. 이미 resolveSet 에 있는 특정 Module Record 와 exportName 으로 구성된 쌍에 도달하면 import 순환이 발생한 것입니다. ResolveExport 를 재귀적으로 호출하기 전에 module 과 exportName 으로 구성된 쌍을 resolveSet 에 추가합니다.
정의 모듈을 찾으면 ResolvedBinding Record { [[Module]] , [[BindingName]] }을 반환합니다. 이 Record 는 로컬 바인딩이 없는 네임스페이스 export인 경우를 제외하고 원래 요청한 export의 해석된 바인딩을 식별합니다. 이 경우 [[BindingName]] 은 namespace 로 설정됩니다. 정의를 찾지 못했거나 요청이 순환인 것으로 확인되면 null 을 반환합니다. 요청이 모호한 것으로 확인되면 ambiguous 를 반환합니다.
호출되면 다음 단계를 수행한다.
단언 : module .[[Status]] 는 new 가 아닙니다.resolveSet 이 존재하지 않으면 resolveSet 을 새로운 빈 List 로 설정합니다.resolveSet 의 각 Record { [[Module]] , [[ExportName]] } record 에 대해 다음을 수행합니다.module 과 record .[[Module]] 이 동일한 Module Record 이고 exportName 이 record .[[ExportName]] 과 같으면, 다음을 수행합니다.단언 : 이는 순환 import 요청입니다.null 을 반환합니다.Record { [[Module]] : module , [[ExportName]] : exportName }을 resolveSet 에 추가합니다.module .[[LocalExportEntries]] 의 각 ExportEntry Record exportEntry 에 대해 다음을 수행합니다.exportEntry .[[ExportName]] 이 exportName 과 같으면, 다음을 수행합니다.단언 : module 은 이 export에 대한 직접 바인딩을 제공합니다.ResolvedBinding Record { [[Module]] : module , [[BindingName]] : exportEntry .[[LocalName]] }을 반환합니다.module .[[IndirectExportEntries]] 의 각 ExportEntry Record exportEntry 에 대해 다음을 수행합니다.exportEntry .[[ExportName]] 이 exportName 과 같으면, 다음을 수행합니다.단언 : exportEntry .[[ModuleRequest]] 는 null 이 아닙니다.importedModule 을 GetImportedModule (module , exportEntry .[[ModuleRequest]] )로 둡니다.exportEntry .[[ImportName]] 이 namespace 이면, 다음을 수행합니다.단언 : module 은 이 export에 대한 직접 바인딩을 제공하지 않습니다.ResolvedBinding Record { [[Module]] : importedModule , [[BindingName]] : namespace }을 반환합니다.단언 : module 은 이 export를 위해 특정 바인딩을 가져옵니다.단언 : exportEntry .[[ImportName]] 은 String입니다.importedModule .ResolveExport (exportEntry .[[ImportName]] , resolveSet )를 반환합니다.exportName 이 "default" 이면, 다음을 수행합니다.단언 : 이 모듈은 default export를 명시적으로 정의하지 않았습니다.null 을 반환합니다.참고 : default export는 export * from "mod" 선언에서 제공할 수 없습니다.starResolution 을 null 로 둡니다.module .[[StarExportEntries]] 의 각 ExportEntry Record exportEntry 에 대해 다음을 수행합니다.단언 : exportEntry .[[ModuleRequest]] 는 null 이 아닙니다.importedModule 을 GetImportedModule (module , exportEntry .[[ModuleRequest]] )로 둡니다.resolution 을 importedModule .ResolveExport (exportName , resolveSet )로 둡니다.resolution 이 ambiguous 이면 ambiguous 를 반환합니다.resolution 이 null 이 아니면, 다음을 수행합니다.단언 : resolution 은 ResolvedBinding Record 입니다.starResolution 이 null 이면, 다음을 수행합니다.starResolution 을 resolution 으로 설정합니다.그렇지 않으면,단언 : 요청한 이름을 포함하는 * export가 둘 이상 있습니다.resolution .[[Module]] 과 starResolution .[[Module]] 이 동일한 Module Record 가 아니면 ambiguous 를 반환합니다.resolution .[[BindingName]] 이 starResolution .[[BindingName]] 과 같지 않으면 ambiguous 를 반환합니다. starResolution 을 반환합니다.
16.2.1.7.3 Cyclic Module Record 추상 메서드의 구현
다음은 표 42 에 정의된 대응 Cyclic Module Record 추상 메서드를 구현하는 Source Text Module Record 의 구체 메서드입니다.
16.2.1.7.3.1 InitializeEnvironment ( )
a Source Text Module Record module 의 구체 메서드 InitializeEnvironment . 인수 없음. 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
module .[[IndirectExportEntries]] 의 각 ExportEntry Record exportEntry 에 대해 다음을 수행합니다.단언 : exportEntry .[[ExportName]] 은 null 이 아닙니다.resolution 을 module .ResolveExport (exportEntry .[[ExportName]] )로 둡니다.resolution 이 null 또는 ambiguous 중 하나이면 SyntaxError 예외를 던집니다.단언 : resolution 은 ResolvedBinding Record 입니다.단언 : module 의 모든 이름 있는 export는 해석 가능합니다.realm 을 module .[[Realm]] 으로 둡니다.단언 : realm 은 undefined 가 아닙니다.envRecord 를 NewModuleEnvironment (realm .[[GlobalEnv]] )로 둡니다.module .[[Environment]] 를 envRecord 로 설정합니다.module .[[ImportEntries]] 의 각 ImportEntry Record importEntry 에 대해 다음을 수행합니다.importedModule 을 GetImportedModule (module , importEntry .[[ModuleRequest]] )로 둡니다.importEntry .[[ImportName]] 이 namespace 이면, 다음을 수행합니다.namespace 를 GetModuleNamespace (importedModule )로 둡니다.! envRecord .CreateImmutableBinding (importEntry .[[LocalName]] , true )를 수행합니다. ! envRecord .InitializeBinding (importEntry .[[LocalName]] , namespace )를 수행합니다. 그렇지 않으면,단언 : importEntry .[[ImportName]] 은 String입니다.resolution 을 importedModule .ResolveExport (importEntry .[[ImportName]] )로 둡니다.resolution 이 null 또는 ambiguous 중 하나이면 SyntaxError 예외를 던집니다.resolution .[[BindingName]] 이 namespace 이면, 다음을 수행합니다.namespace 를 GetModuleNamespace (resolution .[[Module]] )로 둡니다.! envRecord .CreateImmutableBinding (importEntry .[[LocalName]] , true )를 수행합니다. ! envRecord .InitializeBinding (importEntry .[[LocalName]] , namespace )를 수행합니다. 그렇지 않으면,CreateImportBinding (envRecord , importEntry .[[LocalName]] , resolution .[[Module]] , resolution .[[BindingName]] )을 수행합니다. moduleContext 를 새로운 ECMAScript 코드 실행 컨텍스트 로 둡니다.moduleContext 의 Function을 null 로 설정합니다.단언 : module .[[Realm]] 은 undefined 가 아닙니다.moduleContext 의 Realm 을 module .[[Realm]] 으로 설정합니다.moduleContext 의 ScriptOrModule을 module 로 설정합니다.moduleContext 의 VariableEnvironment를 module .[[Environment]] 로 설정합니다.moduleContext 의 LexicalEnvironment를 module .[[Environment]] 로 설정합니다.moduleContext 의 PrivateEnvironment를 null 로 설정합니다.module .[[Context]] 를 moduleContext 로 설정합니다.moduleContext 를 실행 컨텍스트 스택 에 푸시합니다. 이제 moduleContext 가 실행 중인 실행 컨텍스트 입니다.code 를 module .[[ECMAScriptCode]] 로 둡니다.variableDecls 를 code 의 VarScopedDeclarations 로 둡니다.declaredVariableNames 를 새로운 빈 List 로 둡니다.variableDecls 의 각 요소 variableDecl 에 대해 다음을 수행합니다.variableDecl 의 BoundNames 의 각 요소 name 에 대해 다음을 수행합니다.declaredVariableNames 에 name 이 포함되어 있지 않으면, 다음을 수행합니다.! envRecord .CreateMutableBinding (name , false )를 수행합니다. ! envRecord .InitializeBinding (name , undefined )를 수행합니다. name 을 declaredVariableNames 에 추가합니다.lexicalDecls 를 code 의 LexicallyScopedDeclarations 로 둡니다.privateEnv 를 null 로 둡니다.lexicalDecls 의 각 요소 lexicalDecl 에 대해 다음을 수행합니다.lexicalDecl 의 BoundNames 의 각 요소 name 에 대해 다음을 수행합니다.lexicalDecl 의 IsConstantDeclaration 이 true 이면, 다음을 수행합니다.! envRecord .CreateImmutableBinding (name , true )를 수행합니다. 그렇지 않으면,! envRecord .CreateMutableBinding (name , false )를 수행합니다. lexicalDecl 이 FunctionDeclaration , GeneratorDeclaration , AsyncFunctionDeclaration 또는 AsyncGeneratorDeclaration 중 하나이면, 다음을 수행합니다.funcObj 를 인수 envRecord 및 privateEnv 를 사용한 lexicalDecl 의 InstantiateFunctionObject 로 둡니다.! envRecord .InitializeBinding (name , funcObj )를 수행합니다. moduleContext 를 실행 컨텍스트 스택 에서 제거합니다.unused 를 반환합니다.
16.2.1.7.3.2 ExecuteModule ( [ capability ] )
a Source Text Module Record module 의 구체 메서드 ExecuteModule . 선택적 인수 capability (PromiseCapability 레코드 ). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
단언 : module 은 연결되었으며 해당 모듈 환경의 선언이 인스턴스화되어 있습니다.moduleContext 를 module .[[Context]] 로 둡니다.module .[[HasTLA]] 가 false 이면, 다음을 수행합니다.단언 : capability 은 존재하지 않습니다.env 를 module .[[Environment]] 로 둡니다.실행 중인 실행 컨텍스트 를 일시 중단합니다.moduleContext 를 실행 컨텍스트 스택 에 푸시합니다. 이제 moduleContext 가 실행 중인 실행 컨텍스트 입니다.result 를 Completion (module .[[ECMAScriptCode]] 의 Evaluation )으로 둡니다.result 를 Completion (DisposeResources (env .[[DisposableResourceStack]] , result ))으로 설정합니다.moduleContext 를 일시 중단하고 실행 컨텍스트 스택 에서 제거합니다.이제 실행 컨텍스트 스택 의 맨 위에 있는 컨텍스트를 실행 중인 실행 컨텍스트 로 재개합니다. result 가 비정상 완료 이면, 다음을 수행합니다.? result 를 반환합니다. 그렇지 않으면,단언 : capability 은 PromiseCapability Record 입니다.AsyncBlockStart (capability , module .[[ECMAScriptCode]] , moduleContext )를 수행합니다. unused 를 반환합니다.
16.2.1.8 Synthetic Module Record
Synthetic Module Record 는 명세에 의해 정의된 모듈에 관한 정보를 나타내는 데 사용됩니다. 내보낸 이름은 생성 시 정적으로 정의되지만 대응 값은 SetSyntheticModuleExport 를 사용하여 시간에 따라 변경될 수 있습니다. import나 종속성은 없습니다.
참고 Synthetic Module Record는 다양한 종류의 모듈, 예를 들어 JSON 모듈이나 CSS 모듈을 정의하는 데 사용할 수 있습니다.
표 39 에 정의된 필드 외에도 Synthetic Module Record에는 표 58 에 나열된 추가 필드가 있습니다.
표 58: Synthetic Module Record 의 추가 필드
16.2.1.8.1 CreateDefaultExportSyntheticModule ( defaultExport )
추상 연산 CreateDefaultExportSyntheticModule. 인수 defaultExport (ECMAScript 언어 값 ). 반환값: Synthetic Module 레코드 . 기본 export가 defaultExport 인 Synthetic Module Record 를 생성합니다. 호출되면 다음 단계를 수행한다.
realm 을 현재 Realm Record 로 둡니다.setDefaultExport 를 매개변수 (module )를 갖고 defaultExport 를 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:SetSyntheticModuleExport (module , "default" , defaultExport )를 수행합니다.NormalCompletion (unused )을 반환합니다.Synthetic Module Record { [[Realm]] : realm , [[Environment]] : empty , [[Namespace]] : empty , [[HostDefined]] : undefined , [[ExportNames]] : « "default" », [[EvaluationSteps]] : setDefaultExport }를 반환합니다.
16.2.1.8.2 ParseJSONModule ( source )
추상 연산 ParseJSONModule. 인수 source (String). 반환값: (정상 완료 (값: Synthetic Module 레코드 ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
parseResult 를 ? ParseJSON (source )로 둡니다.CreateDefaultExportSyntheticModule (parseResult .[[Value]] )을 반환합니다.
16.2.1.8.3 SetSyntheticModuleExport ( module , exportName , exportValue )
추상 연산 SetSyntheticModuleExport. 인수 module (Synthetic Module 레코드 ), exportName (String) 및 exportValue (ECMAScript 언어 값 ). 반환값: unused . Synthetic Module Record 의 기존 export에 대해 내보내는 값을 설정하거나 변경하는 데 사용할 수 있습니다. 호출되면 다음 단계를 수행한다.
단언 : module .[[ExportNames]] 에 exportName 이 포함되어 있습니다.envRecord 를 module .[[Environment]] 로 둡니다.단언 : envRecord 는 empty 가 아닙니다.! envRecord .SetMutableBinding (exportName , exportValue , true )를 수행합니다. unused 를 반환합니다.
16.2.1.8.4 Module Record 추상 메서드의 구현
다음은 표 40 에 정의된 대응 Module Record 추상 메서드를 구현하는 Synthetic Module Record 의 구체 메서드입니다.
16.2.1.8.4.1 LoadRequestedModules ( [ hostDefined ] )
a Synthetic Module Record module 의 구체 메서드 LoadRequestedModules . 선택적 인수 hostDefined (임의의 값). 반환값: Promise. 호출되면 다음 단계를 수행한다.
참고 : 이 LoadRequestedModules 구현은 hostDefined 를 사용하지 않습니다.! PromiseResolve (%Promise% , undefined )를 반환합니다.
참고
16.2.1.8.4.2 GetExportedNames ( [ exportStarSet ] )
a Synthetic Module Record module 의 구체 메서드 GetExportedNames . 선택적 인수 exportStarSet (리스트 (요소: Source Text Module 레코드 )). 반환값: 리스트 (요소: String). 호출되면 다음 단계를 수행한다.
참고 : 이 GetExportedNames 구현은 exportStarSet 을 사용하지 않습니다.module .[[ExportNames]] 를 반환합니다.
16.2.1.8.4.3 ResolveExport ( exportName [ , resolveSet ] )
a Synthetic Module Record module 의 구체 메서드 ResolveExport . 인수 exportName (String) 및 선택적 인수 resolveSet (리스트 (요소: 레코드 (필드: [[Module]] (Module 레코드 ), [[ExportName]] (String)))). 반환값: (ResolvedBinding 레코드 , null 또는 ambiguous ). 호출되면 다음 단계를 수행한다.
참고 : 이 ResolveExport 구현은 resolveSet 을 사용하지 않습니다.module .[[ExportNames]] 에 exportName 이 포함되어 있지 않으면 null 을 반환합니다.ResolvedBinding Record { [[Module]] : module , [[BindingName]] : exportName }을 반환합니다.
16.2.1.8.4.4 Link ( )
a Synthetic Module Record module 의 구체 메서드 Link . 인수 없음. 반환값: 정상 완료 (값: unused ). 호출되면 다음 단계를 수행한다.
realm 을 module .[[Realm]] 으로 둡니다.envRecord 를 NewModuleEnvironment (realm .[[GlobalEnv]] )로 둡니다.module .[[Environment]] 를 envRecord 로 설정합니다.module .[[ExportNames]] 의 각 String exportName 에 대해 다음을 수행합니다.! envRecord .CreateMutableBinding (exportName , false )를 수행합니다. ! envRecord .InitializeBinding (exportName , undefined )를 수행합니다. NormalCompletion (unused )을 반환합니다.
16.2.1.8.4.5 Evaluate ( )
a Synthetic Module Record module 의 구체 메서드 Evaluate . 인수 없음. 반환값: Promise. 호출되면 다음 단계를 수행한다.
moduleContext 를 새로운 ECMAScript 코드 실행 컨텍스트 로 둡니다.moduleContext 의 Function을 null 로 설정합니다.moduleContext 의 Realm 을 module .[[Realm]] 으로 설정합니다.moduleContext 의 ScriptOrModule을 module 로 설정합니다.moduleContext 의 VariableEnvironment를 module .[[Environment]] 로 설정합니다.moduleContext 의 LexicalEnvironment를 module .[[Environment]] 로 설정합니다.실행 중인 실행 컨텍스트 를 일시 중단합니다.moduleContext 를 실행 컨텍스트 스택 에 푸시합니다. 이제 moduleContext 가 실행 중인 실행 컨텍스트 입니다.steps 를 module .[[EvaluationSteps]] 로 둡니다.result 를 Completion (steps (module ))으로 둡니다.moduleContext 를 일시 중단하고 실행 컨텍스트 스택 에서 제거합니다.이제 실행 컨텍스트 스택 의 맨 위에 있는 컨텍스트를 실행 중인 실행 컨텍스트 로 재개합니다. promiseCapability 을 ! NewPromiseCapability (%Promise% )로 둡니다.IfAbruptRejectPromise (result , promiseCapability ).! Call (promiseCapability .[[Resolve]] , undefined , « undefined »)를 수행합니다. promiseCapability .[[Promise]] 를 반환합니다.
16.2.1.9 GetImportedModule ( referrer , request )
추상 연산 GetImportedModule. 인수 referrer (Cyclic Module 레코드 ) 및 request (ModuleRequest 레코드 ). 반환값: Module 레코드 . 호출되면 다음 단계를 수행한다.
records 를 referrer .[[LoadedModules]] 의 각 LoadedModuleRequest Record r 중 ModuleRequestsEqual (r , request )이 true 인 것들로 구성된 List 로 둡니다.단언 : 이 추상 연산 을 호출하기 전에 referrer 에서 LoadRequestedModules 가 성공적으로 완료되었으므로 records 에는 정확히 하나의 요소가 있습니다.record 를 records 의 유일한 요소로 둡니다.record .[[Module]] 을 반환합니다.
16.2.1.10 HostLoadImportedModule ( referrer , moduleRequest , hostDefined , payload )
호스트 정의 추상 연산 HostLoadImportedModule. 인수 referrer ((Script 레코드 , Cyclic Module 레코드 또는 Realm 레코드 )), moduleRequest (ModuleRequest 레코드 ), hostDefined (임의의 값) 및 payload ((GraphLoadingState 레코드 또는 PromiseCapability 레코드 )). 반환값: unused .
참고 1
referrer 가 Realm Record 일 수 있는 예로 웹 브라우저 호스트 를 들 수 있습니다. 여기서 사용자가 다음과 같이 주어진 컨트롤을 클릭하면
<button type ="button" onclick ="import('./foo.mjs')" > Click me</button >
import() 표현식이 실행될 때 활성 스크립트 또는 모듈 이 존재하지 않습니다. 더 일반적으로 이는 호스트 가 null ScriptOrModule 구성 요소를 갖는 실행 컨텍스트 를 실행 컨텍스트 스택 에 푸시하는 모든 상황에서 발생할 수 있습니다.
HostLoadImportedModule 구현은 다음 요구 사항을 준수해야 합니다:
호스트 환경 은 FinishLoadingImportedModule (referrer , moduleRequest , payload , result )을 동기 또는 비동기로 수행해야 하며, 여기서 result 는 로드된 Module Record 를 포함하는 정상 완료 또는 throw 완료 중 하나입니다.
이 연산이 다음 조건을 만족하는 두 (referrer , moduleRequest ) 쌍으로 여러 번 호출되는 경우:
첫 번째 referrer 가 두 번째 referrer 와 동일하고,
ModuleRequestsEqual (첫 번째 moduleRequest , 두 번째 moduleRequest )이 true 이며,
result 가 정상 완료 인 FinishLoadingImportedModule (referrer , moduleRequest , payload , result )을 수행한다면 매번 동일한 result 로 FinishLoadingImportedModule (referrer , moduleRequest , payload , result )을 수행해야 합니다.
moduleRequest .[[Attributes]] 에 entry .[[Key]] 가 "type" 이고 entry .[[Value]] 가 "json" 인 항목 entry 가 있으면, 호스트 환경 이 FinishLoadingImportedModule (referrer , moduleRequest , payload , result )을 수행할 때 result 는 ParseJSONModule 호출이 반환한 Completion Record 또는 throw 완료 중 하나여야 합니다.
이 연산은 payload 를 FinishLoadingImportedModule 에 그대로 전달할 불투명한 값으로 취급해야 합니다.
실제로 수행되는 과정은 호스트 정의 이지만 일반적으로 적절한 Module Record 를 로드하는 데 필요한 I/O 연산을 수행하는 것으로 구성됩니다. 서로 다른 여러 (referrer , moduleRequest .[[Specifier]] , moduleRequest .[[Attributes]] ) 트리플이 동일한 Module Record 인스턴스로 매핑될 수 있습니다. 실제 매핑 의미론은 호스트 정의 이지만 일반적으로 매핑 과정의 일부로 specifier 에 정규화 과정을 적용합니다. 일반적인 정규화 과정에는 상대 경로 및 축약 경로 지정자의 확장과 같은 작업이 포함됩니다.
참고 2
위 텍스트는 type: "json"으로 가져오는 경우(그리고 HostLoadImportedModule이 정상 완료 하는 경우) 호스트 가 JSON 모듈을 지원하도록 요구하지만, type: "json" 없이 가져오는 경우 JSON 모듈을 지원하는 것을 금지하지는 않습니다.
16.2.1.11 FinishLoadingImportedModule ( referrer , moduleRequest , payload , result )
추상 연산 FinishLoadingImportedModule. 인수 referrer ((Script 레코드 , Cyclic Module 레코드 또는 Realm 레코드 )), moduleRequest (ModuleRequest 레코드 ), payload ((GraphLoadingState 레코드 또는 PromiseCapability 레코드 )) 및 result ((정상 완료 (값: Module 레코드 ) 또는 throw 완료 )). 반환값: unused . 호출되면 다음 단계를 수행한다.
result 가 정상 완료 이면, 다음을 수행합니다.referrer .[[LoadedModules]] 에 ModuleRequestsEqual (record , moduleRequest )이 true 인 LoadedModuleRequest Record record 가 포함되어 있으면, 다음을 수행합니다.단언 : record .[[Module]] 과 result .[[Value]] 는 동일한 Module Record 입니다.그렇지 않으면,LoadedModuleRequest Record { [[Specifier]] : moduleRequest .[[Specifier]] , [[Attributes]] : moduleRequest .[[Attributes]] , [[Module]] : result .[[Value]] }를 referrer .[[LoadedModules]] 에 추가합니다. payload 가 GraphLoadingState Record 이면, 다음을 수행합니다.ContinueModuleLoading (payload , result )을 수행합니다.그렇지 않으면,ContinueDynamicImport (payload , result )을 수행합니다. unused 를 반환합니다.
16.2.1.12 AllImportAttributesSupported ( attrs )
추상 연산 AllImportAttributesSupported. 인수 attrs (리스트 (요소: ImportAttribute 레코드 )). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
supported 를 HostGetSupportedImportAttributes ()로 둡니다.attrs 의 각 ImportAttribute Record attr 에 대해 다음을 수행합니다.supported 에 attr .[[Key]] 가 포함되어 있지 않으면 false 를 반환합니다.true 를 반환합니다.
16.2.1.12.1 HostGetSupportedImportAttributes ( )
호스트 정의 추상 연산 HostGetSupportedImportAttributes. 인수 없음. 반환값: 리스트 (요소: String). 호스트 환경 이 어떤 import 속성을 지원하는지 명시할 수 있도록 합니다. 지원되는 키를 갖는 속성만 호스트 에 제공됩니다.
HostGetSupportedImportAttributes 구현은 다음 요구 사항을 준수해야 합니다:
지원되는 속성을 각각 나타내는 String의 List 를 반환해야 합니다.
이 연산을 호출할 때마다 동일한 내용과 동일한 순서의 같은 List 를 반환해야 합니다.
HostGetSupportedImportAttributes의 기본 구현은 새로운 빈 List 를 반환합니다.
참고 모든 속성을
호스트 에 전달한 뒤
호스트 가 처리할 속성을 선택하게 하지 않고
호스트 가 지원하는 import 속성을 명시하도록 요구하는 목적은 지원되지 않는 속성이 서로 다른
호스트 에서 일관된 방식으로 처리되도록 보장하기 위한 것입니다.
16.2.1.13 GetModuleNamespace ( module )
추상 연산 GetModuleNamespace. 인수 module (instance of a concrete subclass of Module 레코드 ). 반환값: a Module Namespace Object. module 의 export를 나타내는 Module Namespace Object를 가져오며, 처음 요청될 때 지연 생성하고 향후 조회를 위해 module .[[Namespace]] 에 저장합니다. 호출되면 다음 단계를 수행한다.
단언 : module 이 Cyclic Module Record 이면 module .[[Status]] 는 new 또는 unlinked 가 아닙니다.namespace 를 module .[[Namespace]] 로 둡니다.namespace 가 empty 이면, 다음을 수행합니다.exportedNames 를 module .GetExportedNames ()로 둡니다.unambiguousNames 를 새로운 빈 List 로 둡니다.exportedNames 의 각 요소 name 에 대해 다음을 수행합니다.resolution 을 module .ResolveExport (name )로 둡니다.resolution 이 ResolvedBinding Record 이면 name 을 unambiguousNames 에 추가합니다.namespace 를 ModuleNamespaceCreate (module , unambiguousNames )로 설정합니다.namespace 를 반환합니다.
참고
GetModuleNamespace는 절대로 예외를 던지지 않습니다. 대신 해석할 수 없는 이름은 이 시점에서 네임스페이스에서 단순히 제외됩니다. 이러한 이름이 어디에서도 명시적으로 요청되지 않은 모호한 star export가 전부인 경우를 제외하면 나중에 실제 연결 오류를 일으킵니다.
16.2.1.14 Runtime Semantics: 평가
Module : [empty]
undefined 를 반환합니다.
ModuleBody : ModuleItemList
result 를 Completion (ModuleItemList 의 Evaluation )으로 둡니다.result 가 정상 완료 이고 result .[[Value]] 가 empty 이면, 다음을 수행합니다.undefined 를 반환합니다.? result 를 반환합니다.
ModuleItemList :
ModuleItemList
ModuleItem
sl 을 ModuleItemList 의 ? Evaluation 으로 둡니다.s 를 Completion (ModuleItem 의 Evaluation )으로 둡니다.? UpdateEmpty (s , sl )을 반환합니다.
참고
ModuleItemList 의 값은 ModuleItemList 에서 값을 생성하는 마지막 항목의 값입니다.
ModuleItem : ImportDeclaration
empty 를 반환합니다.
16.2.2 Import
구문
ImportDeclaration :
import
ImportClause
FromClause
WithClause opt
;
import
ModuleSpecifier
WithClause opt
;
ImportClause :
ImportedDefaultBinding
NameSpaceImport
NamedImports
ImportedDefaultBinding
,
NameSpaceImport
ImportedDefaultBinding
,
NamedImports
ImportedDefaultBinding :
ImportedBinding
NameSpaceImport :
*
as
ImportedBinding
NamedImports :
{
}
{
ImportsList
,opt
}
FromClause :
from
ModuleSpecifier
ImportsList :
ImportSpecifier
ImportsList
,
ImportSpecifier
ImportSpecifier :
ImportedBinding
ModuleExportName
as
ImportedBinding
ModuleSpecifier :
StringLiteral
ImportedBinding :
BindingIdentifier [~Yield, +Await]
WithClause :
with
{
}
with
{
WithEntries
,opt
}
WithEntries :
AttributeKey
:
StringLiteral
AttributeKey
:
StringLiteral
,
WithEntries
AttributeKey :
IdentifierName
StringLiteral
16.2.2.1 Static Semantics: 조기 오류
ModuleItem : ImportDeclaration
WithClause :
with
{
WithEntries
,opt
}
16.2.2.2 Static Semantics: ImportEntries
구문 지향 연산 ImportEntries. 인수 없음. 반환값: 리스트 (요소: ImportEntry 레코드 ). 다음 생성 규칙별로 정의된다.
Module : [empty]
새로운 빈 List 를 반환합니다.
ModuleItemList :
ModuleItemList
ModuleItem
entries1 을 ModuleItemList 의 ImportEntries 로 둡니다.entries2 를 ModuleItem 의 ImportEntries 로 둡니다.entries1 과 entries2 의 목록 연결 을 반환합니다.
ModuleItem :
ExportDeclaration
StatementListItem
새로운 빈 List 를 반환합니다.
ImportDeclaration :
import
ImportClause
FromClause
WithClause opt
;
module 을 ImportDeclaration 의 ModuleRequests 의 유일한 요소로 둡니다.인수 module 을 사용한 ImportClause 의 ImportEntriesForModule 을 반환합니다.
ImportDeclaration :
import
ModuleSpecifier
WithClause opt
;
새로운 빈 List 를 반환합니다.
16.2.2.3 Static Semantics: ImportEntriesForModule
구문 지향 연산 ImportEntriesForModule. 인수 module (ModuleRequest 레코드 ). 반환값: 리스트 (요소: ImportEntry 레코드 ). 다음 생성 규칙별로 정의된다.
ImportClause :
ImportedDefaultBinding
,
NameSpaceImport
entries1 을 인수 module 을 사용한 ImportedDefaultBinding 의 ImportEntriesForModule 로 둡니다.entries2 를 인수 module 을 사용한 NameSpaceImport 의 ImportEntriesForModule 로 둡니다.entries1 과 entries2 의 목록 연결 을 반환합니다.
ImportClause :
ImportedDefaultBinding
,
NamedImports
entries1 을 인수 module 을 사용한 ImportedDefaultBinding 의 ImportEntriesForModule 로 둡니다.entries2 를 인수 module 을 사용한 NamedImports 의 ImportEntriesForModule 로 둡니다.entries1 과 entries2 의 목록 연결 을 반환합니다.
ImportedDefaultBinding : ImportedBinding
localName 을 ImportedBinding 의 BoundNames 의 유일한 요소로 둡니다.defaultEntry 를 ImportEntry Record { [[ModuleRequest]] : module , [[ImportName]] : "default" , [[LocalName]] : localName }로 둡니다.« defaultEntry »을 반환합니다.
NameSpaceImport :
*
as
ImportedBinding
localName 을 ImportedBinding 의 StringValue 로 둡니다.entry 를 ImportEntry Record { [[ModuleRequest]] : module , [[ImportName]] : namespace , [[LocalName]] : localName }로 둡니다.« entry »을 반환합니다.
NamedImports :
{
}
새로운 빈 List 를 반환합니다.
ImportsList :
ImportsList
,
ImportSpecifier
specs1 을 인수 module 을 사용한 ImportsList 의 ImportEntriesForModule 로 둡니다.specs2 를 인수 module 을 사용한 ImportSpecifier 의 ImportEntriesForModule 로 둡니다.specs1 과 specs2 의 목록 연결 을 반환합니다.
ImportSpecifier : ImportedBinding
localName 을 ImportedBinding 의 BoundNames 의 유일한 요소로 둡니다.entry 를 ImportEntry Record { [[ModuleRequest]] : module , [[ImportName]] : localName , [[LocalName]] : localName }로 둡니다.« entry »을 반환합니다.
ImportSpecifier :
ModuleExportName
as
ImportedBinding
importName 을 ModuleExportName 의 StringValue 로 둡니다.localName 을 ImportedBinding 의 StringValue 로 둡니다.entry 를 ImportEntry Record { [[ModuleRequest]] : module , [[ImportName]] : importName , [[LocalName]] : localName }로 둡니다.« entry »을 반환합니다.
16.2.2.4 Static Semantics: WithClauseToAttributes
구문 지향 연산 WithClauseToAttributes. 인수 없음. 반환값: 리스트 (요소: ImportAttribute 레코드 ). 다음 생성 규칙별로 정의된다.
WithClause :
with
{
}
새로운 빈 List 를 반환합니다.
WithClause :
with
{
WithEntries
,opt
}
attrs 를 WithEntries 의 WithClauseToAttributes 로 둡니다.각 [[Key]] 필드 값을 UTF-16 코드 단위 값의 시퀀스로 취급하여 해당 [[Key]] 필드의 사전식 순서에 따라 attrs 를 정렬합니다. 참고 : 호스트 가 속성이 열거되는 순서를 기반으로 동작을 변경하는 것이 금지되어 있다는 점에서만 이 정렬을 관찰할 수 있습니다. attrs 를 반환합니다.
WithEntries :
AttributeKey
:
StringLiteral
key 를 AttributeKey 의 PropName 으로 둡니다.entry 를 ImportAttribute Record { [[Key]] : key , [[Value]] : StringLiteral 의 SV }로 둡니다.« entry »을 반환합니다.
WithEntries :
AttributeKey
:
StringLiteral
,
WithEntries
key 를 AttributeKey 의 PropName 으로 둡니다.entry 를 ImportAttribute Record { [[Key]] : key , [[Value]] : StringLiteral 의 SV }로 둡니다.rest 를 WithEntries 의 WithClauseToAttributes 로 둡니다.« entry »과 rest 의 목록 연결 을 반환합니다.
16.2.3 Export
구문
ExportDeclaration :
export
ExportFromClause
FromClause
WithClause opt
;
export
NamedExports
;
export
VariableStatement [~Yield, +Await]
export
[lookahead ∉ { using , await }]
Declaration [~Yield, +Await]
export
default
HoistableDeclaration [~Yield, +Await, +Default]
export
default
ClassDeclaration [~Yield, +Await, +Default]
export
default
[lookahead ∉ { function , async
[no LineTerminator here]
function , class }]
AssignmentExpression [+In, ~Yield, +Await]
;
ExportFromClause :
*
*
as
ModuleExportName
NamedExports
NamedExports :
{
}
{
ExportsList
,opt
}
ExportsList :
ExportSpecifier
ExportsList
,
ExportSpecifier
ExportSpecifier :
ModuleExportName
ModuleExportName
as
ModuleExportName
16.2.3.1 Static Semantics: 조기 오류
ExportDeclaration :
export
NamedExports
;
참고
16.2.3.2 Static Semantics: ExportedBindings
구문 지향 연산 ExportedBindings. 인수 없음. 반환값: 리스트 (요소: String).
참고
ExportedBindings는 Module 의 ExportedNames 와 명시적으로 연결된 로컬 바인딩 이름입니다.
다음 생성 규칙별로 정의된다.
ModuleItemList :
ModuleItemList
ModuleItem
names1 을 ModuleItemList 의 ExportedBindings 로 둡니다.names2 를 ModuleItem 의 ExportedBindings 로 둡니다.names1 과 names2 의 목록 연결 을 반환합니다.
ModuleItem :
ImportDeclaration
StatementListItem
새로운 빈 List 를 반환합니다.
ExportDeclaration :
export
ExportFromClause
FromClause
WithClause opt
;
새로운 빈 List 를 반환합니다.
ExportDeclaration :
export
NamedExports
;
NamedExports 의 ExportedBindings 를 반환합니다.
ExportDeclaration :
export
VariableStatement
VariableStatement 의 BoundNames 를 반환합니다.
ExportDeclaration :
export
Declaration
Declaration 의 BoundNames 를 반환합니다.
ExportDeclaration :
export
default
HoistableDeclaration
export
default
ClassDeclaration
export
default
AssignmentExpression
;
이 ExportDeclaration 의 BoundNames 를 반환합니다.
NamedExports :
{
}
새로운 빈 List 를 반환합니다.
ExportsList :
ExportsList
,
ExportSpecifier
names1 을 ExportsList 의 ExportedBindings 로 둡니다.names2 를 ExportSpecifier 의 ExportedBindings 로 둡니다.names1 과 names2 의 목록 연결 을 반환합니다.
ExportSpecifier : ModuleExportName
유일한 요소가 ModuleExportName 의 StringValue 인 List 를 반환합니다.
ExportSpecifier :
ModuleExportName
as
ModuleExportName
유일한 요소가 첫 번째 ModuleExportName 의 StringValue 인 List 를 반환합니다.
16.2.3.3 Static Semantics: ExportedNames
구문 지향 연산 ExportedNames. 인수 없음. 반환값: 리스트 (요소: String).
참고
ExportedNames는 Module 이 자신의 로컬 이름 바인딩 중 하나에 명시적으로 매핑하는 외부에서 볼 수 있는 이름입니다.
다음 생성 규칙별로 정의된다.
ModuleItemList :
ModuleItemList
ModuleItem
names1 을 ModuleItemList 의 ExportedNames 로 둡니다.names2 를 ModuleItem 의 ExportedNames 로 둡니다.names1 과 names2 의 목록 연결 을 반환합니다.
ModuleItem : ExportDeclaration
ExportDeclaration 의 ExportedNames 를 반환합니다.
ModuleItem :
ImportDeclaration
StatementListItem
새로운 빈 List 를 반환합니다.
ExportDeclaration :
export
ExportFromClause
FromClause
WithClause opt
;
ExportFromClause 의 ExportedNames 를 반환합니다.
ExportFromClause : *
새로운 빈 List 를 반환합니다.
ExportFromClause :
*
as
ModuleExportName
유일한 요소가 ModuleExportName 의 StringValue 인 List 를 반환합니다.
ExportFromClause : NamedExports
NamedExports 의 ExportedNames 를 반환합니다.
ExportDeclaration :
export
VariableStatement
VariableStatement 의 BoundNames 를 반환합니다.
ExportDeclaration :
export
Declaration
Declaration 의 BoundNames 를 반환합니다.
ExportDeclaration :
export
default
HoistableDeclaration
export
default
ClassDeclaration
export
default
AssignmentExpression
;
« "default" »를 반환합니다.
NamedExports :
{
}
새로운 빈 List 를 반환합니다.
ExportsList :
ExportsList
,
ExportSpecifier
names1 을 ExportsList 의 ExportedNames 로 둡니다.names2 를 ExportSpecifier 의 ExportedNames 로 둡니다.names1 과 names2 의 목록 연결 을 반환합니다.
ExportSpecifier : ModuleExportName
유일한 요소가 ModuleExportName 의 StringValue 인 List 를 반환합니다.
ExportSpecifier :
ModuleExportName
as
ModuleExportName
유일한 요소가 두 번째 ModuleExportName 의 StringValue 인 List 를 반환합니다.
16.2.3.4 Static Semantics: ExportEntries
구문 지향 연산 ExportEntries. 인수 없음. 반환값: 리스트 (요소: ExportEntry 레코드 ). 다음 생성 규칙별로 정의된다.
Module : [empty]
새로운 빈 List 를 반환합니다.
ModuleItemList :
ModuleItemList
ModuleItem
entries1 을 ModuleItemList 의 ExportEntries 로 둡니다.entries2 를 ModuleItem 의 ExportEntries 로 둡니다.entries1 과 entries2 의 목록 연결 을 반환합니다.
ModuleItem :
ImportDeclaration
StatementListItem
새로운 빈 List 를 반환합니다.
ExportDeclaration :
export
ExportFromClause
FromClause
WithClause opt
;
module 을 ExportDeclaration 의 ModuleRequests 의 유일한 요소로 둡니다.인수 module 을 사용한 ExportFromClause 의 ExportEntriesForModule 을 반환합니다.
ExportDeclaration :
export
NamedExports
;
인수 null 을 사용한 NamedExports 의 ExportEntriesForModule 을 반환합니다.
ExportDeclaration :
export
VariableStatement
entries 를 새로운 빈 List 로 둡니다.names 를 VariableStatement 의 BoundNames 로 둡니다.names 의 각 요소 name 에 대해 다음을 수행합니다.ExportEntry Record { [[ModuleRequest]] : null , [[ImportName]] : null , [[LocalName]] : name , [[ExportName]] : name }을 entries 에 추가합니다.entries 를 반환합니다.
ExportDeclaration :
export
Declaration
entries 를 새로운 빈 List 로 둡니다.names 를 Declaration 의 BoundNames 로 둡니다.names 의 각 요소 name 에 대해 다음을 수행합니다.ExportEntry Record { [[ModuleRequest]] : null , [[ImportName]] : null , [[LocalName]] : name , [[ExportName]] : name }을 entries 에 추가합니다.entries 를 반환합니다.
ExportDeclaration :
export
default
HoistableDeclaration
names 를 HoistableDeclaration 의 BoundNames 로 둡니다.localName 을 names 의 유일한 요소로 둡니다.유일한 요소가 새로운 ExportEntry Record { [[ModuleRequest]] : null , [[ImportName]] : null , [[LocalName]] : localName , [[ExportName]] : "default" }인 List 를 반환합니다.
ExportDeclaration :
export
default
ClassDeclaration
names 를 ClassDeclaration 의 BoundNames 로 둡니다.localName 을 names 의 유일한 요소로 둡니다.유일한 요소가 새로운 ExportEntry Record { [[ModuleRequest]] : null , [[ImportName]] : null , [[LocalName]] : localName , [[ExportName]] : "default" }인 List 를 반환합니다.
ExportDeclaration :
export
default
AssignmentExpression
;
entry 를 ExportEntry Record { [[ModuleRequest]] : null , [[ImportName]] : null , [[LocalName]] : "*default*" , [[ExportName]] : "default" }로 둡니다.« entry »을 반환합니다.
참고
"*default*" 는 이 명세 안에서 익명 기본 export 값의 합성 이름으로 사용됩니다. 자세한 내용은 이 참고 를 참조하시기 바랍니다.
16.2.3.5 Static Semantics: ExportEntriesForModule
구문 지향 연산 ExportEntriesForModule. 인수 module ((ModuleRequest 레코드 또는 null )). 반환값: 리스트 (요소: ExportEntry 레코드 ). 다음 생성 규칙별로 정의된다.
ExportFromClause : *
entry 를 ExportEntry Record { [[ModuleRequest]] : module , [[ImportName]] : all-but-default , [[LocalName]] : null , [[ExportName]] : null }로 둡니다.« entry »을 반환합니다.
ExportFromClause :
*
as
ModuleExportName
exportName 을 ModuleExportName 의 StringValue 로 둡니다.entry 를 ExportEntry Record { [[ModuleRequest]] : module , [[ImportName]] : namespace , [[LocalName]] : null , [[ExportName]] : exportName }로 둡니다.« entry »을 반환합니다.
NamedExports :
{
}
새로운 빈 List 를 반환합니다.
ExportsList :
ExportsList
,
ExportSpecifier
specs1 을 인수 module 을 사용한 ExportsList 의 ExportEntriesForModule 로 둡니다.specs2 를 인수 module 을 사용한 ExportSpecifier 의 ExportEntriesForModule 로 둡니다.specs1 과 specs2 의 목록 연결 을 반환합니다.
ExportSpecifier : ModuleExportName
sourceName 을 ModuleExportName 의 StringValue 로 둡니다.module 이 null 이면, 다음을 수행합니다.localName 을 sourceName 으로 둡니다.importName 을 null 로 둡니다.그렇지 않으면,localName 을 null 로 둡니다.importName 을 sourceName 으로 둡니다. 유일한 요소가 새로운 ExportEntry Record { [[ModuleRequest]] : module , [[ImportName]] : importName , [[LocalName]] : localName , [[ExportName]] : sourceName }인 List 를 반환합니다.
ExportSpecifier :
ModuleExportName
as
ModuleExportName
sourceName 을 첫 번째 ModuleExportName 의 StringValue 로 둡니다.exportName 을 두 번째 ModuleExportName 의 StringValue 로 둡니다.module 이 null 이면, 다음을 수행합니다.localName 을 sourceName 으로 둡니다.importName 을 null 로 둡니다.그렇지 않으면,localName 을 null 로 둡니다.importName 을 sourceName 으로 둡니다. 유일한 요소가 새로운 ExportEntry Record { [[ModuleRequest]] : module , [[ImportName]] : importName , [[LocalName]] : localName , [[ExportName]] : exportName }인 List 를 반환합니다.
16.2.3.6 Static Semantics: ReferencedBindings
구문 지향 연산 ReferencedBindings. 인수 없음. 반환값: 리스트 (요소: 구문 분석 노드 ). 다음 생성 규칙별로 정의된다.
NamedExports :
{
}
새로운 빈 List 를 반환합니다.
ExportsList :
ExportsList
,
ExportSpecifier
names1 을 ExportsList 의 ReferencedBindings 로 둡니다.names2 를 ExportSpecifier 의 ReferencedBindings 로 둡니다.names1 과 names2 의 목록 연결 을 반환합니다.
ExportSpecifier :
ModuleExportName
as
ModuleExportName
첫 번째 ModuleExportName 의 ReferencedBindings 를 반환합니다.
ModuleExportName : IdentifierName
유일한 요소가 IdentifierName 인 List 를 반환합니다.
ModuleExportName : StringLiteral
유일한 요소가 StringLiteral 인 List 를 반환합니다.
16.2.3.7 Runtime Semantics: 평가
ExportDeclaration :
export
ExportFromClause
FromClause
WithClause opt
;
export
NamedExports
;
empty 를 반환합니다.
ExportDeclaration :
export
VariableStatement
VariableStatement 의 ? Evaluation 을 반환합니다.
ExportDeclaration :
export
Declaration
Declaration 의 ? Evaluation 을 반환합니다.
ExportDeclaration :
export
default
HoistableDeclaration
HoistableDeclaration 의 ? Evaluation 을 반환합니다.
ExportDeclaration :
export
default
ClassDeclaration
value 를 ClassDeclaration 의 ? BindingClassDeclarationEvaluation 으로 둡니다.className 을 ClassDeclaration 의 BoundNames 의 유일한 요소로 둡니다.className 이 "*default*" 이면, 다음을 수행합니다.envRecord 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.? InitializeBoundName ("*default*" , value , envRecord )를 수행합니다. empty 를 반환합니다.
ExportDeclaration :
export
default
AssignmentExpression
;
IsAnonymousFunctionDefinition (AssignmentExpression )이 true 이면, 다음을 수행합니다.value 를 인수 "default" 를 사용한 AssignmentExpression 의 ? NamedEvaluation 으로 둡니다.그렇지 않으면,rhs 를 AssignmentExpression 의 ? Evaluation 으로 둡니다.value 를 ? GetValue (rhs )로 둡니다. envRecord 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.? InitializeBoundName ("*default*" , value , envRecord )를 수행합니다. empty 를 반환합니다.
17 오류 처리 및 언어 확장
구현체는 관련 ECMAScript 언어 구문이 평가되는 시점에 대부분의 오류를 보고해야 합니다. 조기 오류 는 오류를 포함하는 Script 의 어떤 구문도 평가되기 전에 검출하고 보고할 수 있는 오류입니다. 조기 오류 가 존재하면 해당 구문의 평가가 방지됩니다. 구현체는 ParseScript 에서 해당 Script 를 파싱하는 과정의 일부로 Script 의 조기 오류 를 보고해야 합니다. Module 의 조기 오류 는 Module 이 평가될 시점에 보고되며 해당 Module 은 절대로 초기화되지 않습니다. eval 코드의 조기 오류 는 eval이 호출될 때 보고되며 eval 코드의 평가를 방지합니다. 조기 오류 가 아닌 모든 오류는 런타임 오류입니다.
구현체는 이 명세의 “Static Semantics: 조기 오류 ” 하위 절에 나열된 조건이 발생하면 이를 조기 오류 로 보고해야 합니다.
구현체는 컴파일러가 어떤 구문이 어떠한 상황에서도 오류 없이 실행될 수 없음을 증명할 수 있더라도 다른 종류의 오류를 조기 오류 로 취급해서는 안 됩니다. 이러한 경우 구현체는 조기 경고를 낼 수 있지만 관련 구문이 실제로 실행될 때까지 오류를 보고해서는 안 됩니다.
구현체는 다음의 경우를 제외하고 명시된 대로 모든 오류를 보고해야 합니다:
17.1 에서 제한하는 경우를 제외하고 호스트 또는 구현체는 Script 구문, Module 구문 및 정규 표현식 패턴 또는 플래그 구문을 확장할 수 있습니다. 이를 허용하기 위해 SyntaxError 를 던질 수 있는 모든 연산(예: eval 호출, 정규 표현식 리터럴 사용 또는 Function이나 RegExp 생성자 사용)은 스크립트 구문이나 정규 표현식 패턴 또는 플래그 구문에 대한 호스트 정의 확장을 발견했을 때 SyntaxError 를 던지는 대신 호스트 정의 동작을 나타낼 수 있습니다.
17.1 에서 제한하는 경우를 제외하고 호스트 또는 구현체는 이 명세에 설명된 것 외에 추가 타입, 값, 객체, 프로퍼티 및 함수를 제공할 수 있습니다. 이로 인해 구문(예: 전역 스코프에서 변수를 조회하는 경우)이 오류(예: ReferenceError )를 던지는 대신 호스트 정의 동작을 나타낼 수 있습니다.
17.1 금지된 확장
구현체는 다음과 같은 방식으로 이 명세를 확장해서는 안 됩니다:
엄격 모드 코드 에서 구문적 생성자 를 사용하여 정의된 ECMAScript 함수 객체 에는 "caller" 또는 "arguments" 라는 이름의 자체 프로퍼티를 생성해서는 안 됩니다. 또한 정의가 엄격 모드 코드 안에 포함되어 있는지 여부와 관계없이 ArrowFunction , MethodDefinition , GeneratorDeclaration , GeneratorExpression , AsyncGeneratorDeclaration , AsyncGeneratorExpression , ClassDeclaration , ClassExpression , AsyncFunctionDeclaration , AsyncFunctionExpression 또는 AsyncArrowFunction 을 사용하여 정의된 함수 객체 에도 이러한 자체 프로퍼티를 생성해서는 안 됩니다. 내장 함수, Function 생성자 를 사용하여 생성된 엄격 함수 , Generator 생성자 를 사용하여 생성된 제너레이터 함수, AsyncFunction 생성자 를 사용하여 생성된 비동기 함수 및 bind 메서드를 사용하여 생성된 함수에도 이러한 자체 프로퍼티를 생성해서는 안 됩니다.
구현체가 어떤 함수 객체 에 "caller" 라는 이름의 자체 프로퍼티를 추가하는 경우 [[Get]] 또는 [[GetOwnProperty]] 을 사용하여 관찰되는 해당 프로퍼티의 값은 엄격 함수 객체여서는 안 됩니다. 접근자 프로퍼티 인 경우 해당 프로퍼티의 [[Getter]] 속성 값인 함수는 호출될 때 엄격 함수 를 절대로 반환해서는 안 됩니다.
매핑된 arguments 객체와 매핑되지 않은 arguments 객체 모두 "caller" 라는 이름의 자체 프로퍼티를 갖도록 생성해서는 안 됩니다.
toLocaleString이라는 이름의 메서드처럼 ECMA-402에 명시된 내장 메서드의 동작은 ECMA-402에 명시된 경우를 제외하고 확장해서는 안 됩니다.
22.2.1 및 B.1.2 의 RegExp 패턴 문법은 [UnicodeMode] 문법 매개변수가 존재할 때 소스 문자 A-Z 또는 a-z 중 어떤 것도 IdentityEscape [+UnicodeMode] 로 인식하도록 확장해서는 안 됩니다.
구문 문법은 BindingIdentifier 비단말 기호와 일치하는 소스 텍스트 바로 뒤에 토큰 :가 올 수 있도록 어떤 방식으로도 확장해서는 안 됩니다.
엄격 모드 코드 를 처리할 때 구현체는 12.9.3.1 의 조기 오류 규칙 을 완화해서는 안 됩니다.
TemplateEscapeSequence 는 12.9.4 에 정의된 LegacyOctalEscapeSequence 또는 NonOctalDecimalEscapeSequence 를 포함하도록 확장해서는 안 됩니다.
엄격 모드 코드 를 처리할 때 B.3.1 , B.3.2 , B.3.3 및 B.3.5 에 정의된 확장을 지원해서는 안 됩니다.
Module 목표 기호 를 사용하여 파싱할 때 B.1.1 에 정의된 어휘 문법 확장을 지원해서는 안 됩니다.
ImportCall 은 확장해서는 안 됩니다.
18 ECMAScript 표준 내장 객체
ECMAScript Script 또는 Module 이 실행을 시작할 때마다 사용할 수 있는 특정 내장 객체가 있습니다. 그중 하나인 전역 객체 는 실행 중인 프로그램의 전역 환경의 일부입니다. 그 밖의 객체는 전역 객체 의 초기 프로퍼티로 접근하거나 접근 가능한 내장 객체의 프로퍼티를 통해 간접적으로 접근할 수 있습니다.
달리 명시되지 않는 한 함수로 호출할 수 있는 내장 객체는 10.3 에 설명된 특성을 갖는 내장 함수 객체 입니다. 달리 명시되지 않는 한 내장 객체의 [[Extensible]] 내부 슬롯은 처음에 true 값을 갖습니다. 모든 내장 함수 객체 는 해당 객체가 처음 생성된 realm 의 Realm Record 를 값으로 갖는 [[Realm]] 내부 슬롯을 갖습니다.
많은 내장 객체는 함수이며 인수를 사용하여 호출할 수 있습니다. 그중 일부는 생성자 이기도 하며 new 연산자와 함께 사용하기 위한 함수입니다. 각 내장 함수에 대해 이 명세는 해당 함수에 필요한 인수와 해당 함수 객체 의 프로퍼티를 설명합니다. 각 내장 생성자 에 대해 이 명세는 추가로 해당 생성자 의 프로토타입 객체의 프로퍼티와 해당 생성자 를 호출하는 new 표현식이 반환하는 특정 객체 인스턴스의 프로퍼티를 설명합니다.
특정 함수의 설명에서 달리 명시하지 않는 한 내장 함수 또는 생성자 에 함수가 필요로 하는 것보다 적은 수의 인수가 주어지면, 해당 함수 또는 생성자 는 각 추가 인수가 undefined 값인 충분한 수의 추가 인수를 전달받은 것과 정확히 동일하게 동작해야 합니다. 이러한 누락된 인수는 “존재하지 않는” 것으로 간주되며 명세 알고리즘에서 그러한 방식으로 식별될 수 있습니다. 특정 함수의 설명에서 “this 값” 및 “NewTarget”이라는 용어는 10.3 에 주어진 의미를 갖습니다.
특정 함수의 설명에서 달리 명시하지 않는 한 설명된 내장 함수 또는 생성자 에 함수가 허용하도록 명시된 것보다 많은 인수가 주어지면 추가 인수는 호출에 의해 평가된 다음 함수에서 무시됩니다. 다만 구현체는 단순히 추가 인수가 존재한다는 사실만을 근거로 TypeError 예외를 던지는 동작이 아닌 한 이러한 인수와 관련된 구현체 고유 동작을 정의할 수 있습니다.
참고 1
내장 함수 집합에 추가 기능을 추가하는 구현체는 기존 함수에 새 매개변수를 추가하는 대신 새 함수를 추가하는 방식으로 구현하는 것이 권장됩니다.
달리 명시되지 않는 한 모든 내장 함수와 모든 내장 생성자 는 Function.prototype 표현식의 초기 값인 Function 프로토타입 객체 (20.2.3 )를 [[Prototype]] 내부 슬롯의 값으로 갖습니다.
달리 명시되지 않는 한 Object 프로토타입 객체 자체를 제외한 모든 내장 프로토타입 객체는 Object.prototype 표현식의 초기 값인 Object 프로토타입 객체 (20.1.3 )를 [[Prototype]] 내부 슬롯의 값으로 갖습니다.
이 명세가 알고리즘 단계를 통해 내장 생성자 의 동작을 정의하는 경우 이는 [[Call]] 및 [[Construct]] 모두에 대한 동작입니다. 이러한 알고리즘이 두 경우를 구분해야 한다면 NewTarget이 undefined 인지 검사하며, 이는 [[Call]] 호출임을 나타냅니다.
생성자 로 식별되지 않은 내장 함수 객체 는 특정 함수의 설명에서 달리 명시하지 않는 한 [[Construct]] 내부 메서드를 구현하지 않습니다.
생성자 가 아닌 내장 함수 객체 는 특정 함수의 설명에서 달리 명시하지 않는 한 "prototype" 프로퍼티를 갖지 않습니다.
이 명세에 정의된 각 내장 함수는 CreateBuiltinFunction 추상 연산 (10.3.4 )을 호출하여 생성됩니다. length 및 name 매개변수의 값은 아래에서 설명하는 "length" 및 "name" 프로퍼티의 초기 값입니다. prefix 매개변수의 값도 마찬가지로 아래에서 설명합니다.
생성자 를 포함한 모든 내장 함수 객체 는 값이 음수가 아닌 정수 Number인 "length" 프로퍼티를 갖습니다. 달리 명시되지 않는 한 이 값은 함수 설명의 하위 절 제목에 표시된 필수 매개변수의 수입니다. 선택적 매개변수와 나머지 매개변수는 매개변수 수에 포함되지 않습니다.
참고 2
예를 들어 Array 프로토타입 객체 의 "map" 프로퍼티 초기 값인 함수 객체 는 «Array.prototype.map (callback [ , thisArg])»이라는 하위 절 제목 아래에 설명되어 있으며, callback과 thisArg라는 두 개의 이름 있는 인수가 표시되고 후자는 선택적입니다. 따라서 해당 함수 객체 의 "length" 프로퍼티 값은 1 𝔽 입니다.
달리 명시되지 않는 한 내장 함수 객체 의 "length" 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
생성자 를 포함한 모든 내장 함수 객체 는 값이 String인 "name" 프로퍼티를 갖습니다. 달리 명시되지 않는 한 이 값은 이 명세에서 함수에 주어진 이름입니다. 익명 함수로 식별된 함수는 빈 String을 "name" 프로퍼티의 값으로 사용합니다. 객체의 프로퍼티로 명시된 함수의 경우 name 값은 해당 함수에 접근하는 데 사용하는 프로퍼티 이름 문자열입니다. 내장 프로퍼티의 get 또는 set 접근자 함수로 명시된 함수는 CreateBuiltinFunction 을 호출할 때 각각 "get" 또는 "set" 을 prefix 매개변수에 전달합니다.
프로퍼티 키 가 Symbol 값인 각 내장 함수의 "name" 프로퍼티 값은 명시적으로 지정됩니다. 이렇게 명시적으로 지정된 값이 "get " 또는 "set " 접두사로 시작하고 해당 함수가 내장 프로퍼티의 get 또는 set 접근자 함수이면 접두사를 제거한 값을 name 매개변수에 전달하고 각각 "get" 또는 "set" 값을 CreateBuiltinFunction 호출 시 prefix 매개변수에 전달합니다.
달리 명시되지 않는 한 내장 함수 객체 의 "name" 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
19 부터 28 까지의 절과 부록 B.2 에 설명된 그 밖의 모든 데이터 프로퍼티 는 달리 명시되지 않는 한 { [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
19 부터 28 까지의 절과 부록 B.2 에 설명된 모든 접근자 프로퍼티 는 달리 명시되지 않는 한 { [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다. get 접근자 함수만 설명된 경우 set 접근자 함수는 기본값 undefined 입니다. set 접근자만 설명된 경우 get 접근자는 기본값 undefined 입니다.
19 전역 객체
전역 객체 는:
제어가 어떤 실행 컨텍스트 에 진입하기 전에 생성됩니다.
[[Construct]] 내부 메서드를 갖지 않으므로 new 연산자와 함께 생성자 로 사용할 수 없습니다.
[[Call]] 내부 메서드를 갖지 않으므로 함수로 호출할 수 없습니다.
값이 호스트 정의 인 [[Prototype]] 내부 슬롯을 갖습니다.
이 명세에 정의된 프로퍼티 외에 호스트 정의 프로퍼티를 가질 수 있습니다. 여기에는 값이 전역 객체 자체인 프로퍼티가 포함될 수 있습니다.
19.1 전역 객체의 값 프로퍼티
19.1.1 globalThis
Realm Record realm 에서 전역 객체 의 "globalThis" 프로퍼티 초기 값은 realm .[[GlobalEnv]] .[[GlobalThisValue]] 입니다.
이 프로퍼티는 { [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
19.1.2 Infinity
전역 객체 의 "Infinity" 프로퍼티 초기 값은 +∞ 𝔽 입니다(6.1.6.1 참조).
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
19.1.3 NaN
전역 객체 의 "NaN" 프로퍼티 초기 값은 NaN 입니다(6.1.6.1 참조).
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
19.1.4 undefined
전역 객체 의 "undefined" 프로퍼티 초기 값은 undefined 입니다(6.1.1 참조).
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
19.2 전역 객체의 함수 프로퍼티
19.2.1 eval ( source )
이 함수는 %eval% 내재 객체입니다.
호출되면 다음 단계를 수행합니다:
? PerformEval (source , false , false )를 반환합니다.
19.2.1.1 PerformEval ( source , strictCaller , direct )
추상 연산 PerformEval. 인수 source (ECMAScript 언어 값 ), strictCaller (Boolean) 및 direct (Boolean). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
단언 : direct 가 false 이면 strictCaller 도 false 입니다.source 가 String이 아니면 source 를 반환합니다.evalRealm 을 현재 Realm Record 로 둡니다.참고 : 직접 eval 의 경우 evalRealm 은 eval 호출자와 eval 함수 자체 모두의 realm 입니다.? HostEnsureCanCompileStrings (evalRealm , « », source , direct )를 수행합니다. inFunc 를 false 로 둡니다.inMethod 를 false 로 둡니다.inDerivedCtor 를 false 로 둡니다.inClassFieldInitializer 를 false 로 둡니다.direct 가 true 이면, 다음을 수행합니다.thisEnvRecord 를 GetThisEnvironment ()로 둡니다.thisEnvRecord 가 Function Environment Record 이면, 다음을 수행합니다.func 를 thisEnvRecord .[[FunctionObject]] 로 둡니다.inFunc 를 true 로 설정합니다.inMethod 를 thisEnvRecord .HasSuperBinding ()으로 설정합니다.func .[[ConstructorKind]] 가 derived 이면 inDerivedCtor 를 true 로 설정합니다.classFieldInitializerName 을 func .[[ClassFieldInitializerName]] 으로 둡니다.classFieldInitializerName 이 empty 가 아니면 inClassFieldInitializer 를 true 로 설정합니다.다음 하위 단계를 구현체 정의 순서로 수행하며, 파싱과 오류 검출을 서로 섞어서 수행할 수도 있습니다:script 를 ParseText (source , Script )로 둡니다.script 가 오류의 List 이면 SyntaxError 예외를 던집니다.script Contains ScriptBody 가 false 이면 undefined 를 반환합니다.body 를 script 의 ScriptBody 로 둡니다.inFunc 가 false 이고 body Contains NewTarget 이면 SyntaxError 예외를 던집니다.inMethod 가 false 이고 body Contains SuperProperty 이면 SyntaxError 예외를 던집니다.inDerivedCtor 가 false 이고 body Contains SuperCall 이면 SyntaxError 예외를 던집니다.inClassFieldInitializer 가 true 이고 body 의 ContainsArguments 가 true 이면 SyntaxError 예외를 던집니다. strictCaller 가 true 이면 strictEval 을 true 로 둡니다.그렇지 않으면 strictEval 을 script 의 ScriptIsStrict 로 둡니다. runningContext 를 실행 중인 실행 컨텍스트 로 둡니다.참고 : direct 가 true 이면 runningContext 는 직접 eval 을 수행한 실행 컨텍스트 입니다. direct 가 false 이면 runningContext 는 eval 함수 호출의 실행 컨텍스트 입니다.direct 가 true 이면, 다음을 수행합니다.lexicalEnv 를 NewDeclarativeEnvironment (runningContext 의 LexicalEnvironment)로 둡니다.variableEnv 를 runningContext 의 VariableEnvironment로 둡니다.privateEnv 를 runningContext 의 PrivateEnvironment로 둡니다.그렇지 않으면,lexicalEnv 를 NewDeclarativeEnvironment (evalRealm .[[GlobalEnv]] )로 둡니다.variableEnv 를 evalRealm .[[GlobalEnv]] 로 둡니다.privateEnv 를 null 로 둡니다. strictEval 이 true 이면 variableEnv 를 lexicalEnv 로 설정합니다.runningContext 가 아직 일시 중단되지 않았다면 runningContext 를 일시 중단합니다.evalContext 를 새로운 ECMAScript 코드 실행 컨텍스트 로 둡니다.evalContext 의 Function을 null 로 설정합니다.evalContext 의 Realm 을 evalRealm 으로 설정합니다.evalContext 의 ScriptOrModule을 runningContext 의 ScriptOrModule로 설정합니다.evalContext 의 VariableEnvironment를 variableEnv 로 설정합니다.evalContext 의 LexicalEnvironment를 lexicalEnv 로 설정합니다.evalContext 의 PrivateEnvironment를 privateEnv 로 설정합니다.evalContext 를 실행 컨텍스트 스택 에 푸시합니다. 이제 evalContext 가 실행 중인 실행 컨텍스트 입니다.result 를 Completion (EvalDeclarationInstantiation (body , variableEnv , lexicalEnv , privateEnv , strictEval ))으로 둡니다.result 가 정상 완료 이면, 다음을 수행합니다.result 를 Completion (body 의 Evaluation )으로 설정합니다.result 가 정상 완료 이고 result .[[Value]] 가 empty 이면, 다음을 수행합니다.result 를 NormalCompletion (undefined )으로 설정합니다.evalContext 를 일시 중단하고 실행 컨텍스트 스택 에서 제거합니다.이제 실행 컨텍스트 스택 의 맨 위에 있는 컨텍스트를 실행 중인 실행 컨텍스트 로 재개합니다. ? result 를 반환합니다.
참고
호출 컨텍스트의 코드 또는 eval 코드 중 하나라도 엄격 모드 코드 이면 eval 코드는 eval을 호출한 호출 컨텍스트의 변수 환경에 변수 또는 함수 바인딩을 인스턴스화할 수 없습니다. 대신 이러한 바인딩은 eval 코드에서만 접근할 수 있는 새로운 VariableEnvironment에 인스턴스화됩니다. let, const 또는 class 선언이 도입한 바인딩은 항상 새로운 LexicalEnvironment에 인스턴스화됩니다.
19.2.1.2 HostEnsureCanCompileStrings ( calleeRealm , paramStrings , bodyString , direct )
호스트 정의 추상 연산 HostEnsureCanCompileStrings. 인수 calleeRealm (Realm 레코드 ), paramStrings (리스트 (요소: String)), bodyString (String) 및 direct (Boolean). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 호스트 환경 이 개발자가 문자열을 ECMAScript 코드로 해석하고 평가할 수 있게 하는 특정 ECMAScript 함수를 차단할 수 있도록 합니다.
paramStrings 는 함수 생성자 중 하나를 사용할 때 서로 연결되어 매개변수 목록을 구성하는 문자열을 나타냅니다. bodyString 은 함수 본문 또는 eval 호출에 전달된 문자열을 나타냅니다.
direct 는 평가가 직접 eval 인지 여부를 나타냅니다.
HostEnsureCanCompileStrings의 기본 구현은 NormalCompletion (unused )을 반환합니다.
19.2.1.3 EvalDeclarationInstantiation ( body , variableEnv , lexicalEnv , privateEnv , strict )
추상 연산 EvalDeclarationInstantiation. 인수 body (a ScriptBody Parse Node), variableEnv (Environment 레코드 ), lexicalEnv (Declarative Environment 레코드 ), privateEnv ((PrivateEnvironment 레코드 또는 null )) 및 strict (Boolean). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
variableNames 를 body 의 VarDeclaredNames 로 둡니다.variableDecls 를 body 의 VarScopedDeclarations 로 둡니다.strict 가 false 이면, 다음을 수행합니다.variableEnv 가 Global Environment Record 이면, 다음을 수행합니다.variableNames 의 각 요소 name 에 대해 다음을 수행합니다.HasLexicalDeclaration (variableEnv , name )이 true 이면 SyntaxError 예외를 던집니다.참고 : eval은 전역 렉시컬 선언에 의해 가려지는 전역 var 선언을 생성하지 않습니다.thisEnv 를 lexicalEnv 로 둡니다.단언 : 다음 반복은 종료됩니다.thisEnv 와 variableEnv 가 동일한 Environment Record 가 아닌 동안 다음을 반복합니다.thisEnv 가 Object Environment Record 가 아니면, 다음을 수행합니다.참고 : with 문의 환경에는 렉시컬 선언이 포함될 수 없으므로 var/let 호이스팅 충돌을 검사할 필요가 없습니다.variableNames 의 각 요소 name 에 대해 다음을 수행합니다.! thisEnv .HasBinding (name )이 true 이면, 다음을 수행합니다.Normative Optional
호스트 가 웹 브라우저이거나 그 밖의 방식으로 Catch 블록의 VariableStatement 을 지원하면, 다음을 수행합니다.thisEnv 가 Catch 절의 Environment Record 가 아니면 SyntaxError 예외를 던집니다.그렇지 않으면,SyntaxError 예외를 던집니다. 참고 : 직접 eval 은 같은 이름의 렉시컬 선언을 넘어 var 선언을 호이스팅하지 않습니다.thisEnv 를 thisEnv .[[OuterEnv]] 로 설정합니다.privateIdentifiers 를 새로운 빈 List 로 둡니다.pointer 를 privateEnv 로 둡니다.pointer 가 null 이 아닌 동안 다음을 반복합니다.pointer .[[Names]] 의 각 Private Name binding 에 대해 다음을 수행합니다.privateIdentifiers 에 binding .[[Description]] 이 포함되어 있지 않으면 binding .[[Description]] 을 privateIdentifiers 에 추가합니다.pointer 를 pointer .[[OuterPrivateEnvironment]] 로 설정합니다.인수 privateIdentifiers 를 사용한 body 의 AllPrivateIdentifiersValid 가 false 이면 SyntaxError 예외를 던집니다. funcsToInitialize 를 새로운 빈 List 로 둡니다.declaredFuncNames 를 새로운 빈 List 로 둡니다.variableDecls 의 각 요소 variableDecl 에 대해 List 의 역순으로 다음을 수행합니다.variableDecl 이 VariableDeclaration , ForBinding 또는 BindingIdentifier 중 어느 것도 아니면, 다음을 수행합니다.단언 : variableDecl 은 FunctionDeclaration , GeneratorDeclaration , AsyncFunctionDeclaration 또는 AsyncGeneratorDeclaration 중 하나입니다.참고 : 같은 이름에 여러 함수 선언이 있으면 마지막 선언이 사용됩니다.funcName 을 variableDecl 의 BoundNames 의 유일한 요소로 둡니다.declaredFuncNames 에 funcName 이 포함되어 있지 않으면, 다음을 수행합니다.variableEnv 가 Global Environment Record 이면, 다음을 수행합니다.funcDefinable 을 ? CanDeclareGlobalFunction (variableEnv , funcName )으로 둡니다.funcDefinable 이 false 이면 TypeError 예외를 던집니다.funcName 을 declaredFuncNames 에 추가합니다.variableDecl 을 funcsToInitialize 의 첫 번째 요소로 삽입합니다.declaredVariableNames 를 새로운 빈 List 로 둡니다.variableDecls 의 각 요소 variableDecl 에 대해 다음을 수행합니다.variableDecl 이 VariableDeclaration , ForBinding 또는 BindingIdentifier 중 하나이면, 다음을 수행합니다.variableDecl 의 BoundNames 의 각 String name 에 대해 다음을 수행합니다.declaredFuncNames 에 name 이 포함되어 있지 않으면, 다음을 수행합니다.variableEnv 가 Global Environment Record 이면, 다음을 수행합니다.variableDefinable 을 ? CanDeclareGlobalVar (variableEnv , name )로 둡니다.variableDefinable 이 false 이면 TypeError 예외를 던집니다.declaredVariableNames 에 name 이 포함되어 있지 않으면, 다음을 수행합니다.name 을 declaredVariableNames 에 추가합니다.Normative Optional
strict 가 false 이고 호스트 가 웹 브라우저이거나 그 밖의 방식으로 블록 수준 함수 선언의 웹 레거시 호환성 의미론 을 지원하면, 다음을 수행합니다.declaredFuncOrVariableNames 를 declaredFuncNames 와 declaredVariableNames 의 목록 연결 로 둡니다.body Contains x 가 true 인 어떤 Block , CaseClause 또는 DefaultClause x 의 StatementList 에 직접 포함된 각 FunctionDeclaration funcDecl 에 대해 다음을 수행합니다.funcName 을 funcDecl 의 BindingIdentifier 의 StringValue 로 둡니다.FunctionDeclaration funcDecl 을 funcName 을 BindingIdentifier 로 갖는 VariableStatement 로 바꿔도 body 에 조기 오류 가 발생하지 않으면, 다음을 수행합니다.bindingExists 를 false 로 둡니다.thisEnv 를 lexicalEnv 로 설정합니다.단언 : 다음 반복은 종료됩니다.thisEnv 가 variableEnv 가 아닌 동안 다음을 반복합니다.thisEnv 가 Object Environment Record 가 아니면, 다음을 수행합니다.! thisEnv .HasBinding (funcName )이 true 이면, 다음을 수행합니다.Normative Optional
호스트 가 웹 브라우저이거나 그 밖의 방식으로 Catch 블록의 VariableStatement 을 지원하면, 다음을 수행합니다.thisEnv 가 Catch 절의 Environment Record 가 아니면 bindingExists 를 true 로 설정합니다.그렇지 않으면,bindingExists 를 true 로 설정합니다. thisEnv 를 thisEnv .[[OuterEnv]] 로 설정합니다.bindingExists 가 false 이고 variableEnv 가 Global Environment Record 이면, 다음을 수행합니다.HasLexicalDeclaration (variableEnv , funcName )이 false 이면, 다음을 수행합니다.funcDefinable 을 ? CanDeclareGlobalVar (variableEnv , funcName )로 둡니다.그렇지 않으면,funcDefinable 을 false 로 둡니다. 그렇지 않으면,funcDefinable 을 true 로 둡니다. bindingExists 가 false 이고 funcDefinable 이 true 이면, 다음을 수행합니다.declaredFuncOrVariableNames 에 funcName 이 포함되어 있지 않으면, 다음을 수행합니다.variableEnv 가 Global Environment Record 이면, 다음을 수행합니다.? CreateGlobalVarBinding (variableEnv , funcName , true )를 수행합니다. 그렇지 않으면,bindingExists 를 ! variableEnv .HasBinding (funcName )으로 설정합니다.bindingExists 가 false 이면, 다음을 수행합니다.! variableEnv .CreateMutableBinding (funcName , true )를 수행합니다. ! variableEnv .InitializeBinding (funcName , undefined )를 수행합니다. funcName 을 declaredFuncOrVariableNames 에 추가합니다.FunctionDeclaration funcDecl 이 평가될 때 15.2.6 에 제공된 FunctionDeclaration Evaluation 알고리즘 대신 다음 단계를 수행합니다:globalEnv 를 실행 중인 실행 컨텍스트 의 VariableEnvironment로 둡니다.blockEnv 를 실행 중인 실행 컨텍스트 의 LexicalEnvironment로 둡니다.funcObj 를 ! blockEnv .GetBindingValue (funcName , false )로 둡니다.? globalEnv .SetMutableBinding (funcName , funcObj , false ) 를 수행합니다. unused 를 반환합니다.참고 : variableEnv 가 Global Environment Record 이고 전역 객체 가 Proxy 특수 객체 인 경우를 제외하면 이 알고리즘 단계 이후에는 비정상 종료가 발생하지 않습니다.lexicalDecls 를 body 의 LexicallyScopedDeclarations 로 둡니다.lexicalDecls 의 각 요소 lexicalDecl 에 대해 다음을 수행합니다.참고 : 렉시컬하게 선언된 이름은 여기에서 인스턴스화되기만 하며 초기화되지는 않습니다.lexicalDecl 의 BoundNames 의 각 요소 name 에 대해 다음을 수행합니다.lexicalDecl 의 IsConstantDeclaration 이 true 이면, 다음을 수행합니다.? lexicalEnv .CreateImmutableBinding (name , true )를 수행합니다. 그렇지 않으면,? lexicalEnv .CreateMutableBinding (name , false )를 수행합니다. funcsToInitialize 의 각 Parse Node funcDecl 에 대해 다음을 수행합니다.funcName 을 funcDecl 의 BoundNames 의 유일한 요소로 둡니다.funcObj 를 인수 lexicalEnv 및 privateEnv 를 사용한 funcDecl 의 InstantiateFunctionObject 로 둡니다.variableEnv 가 Global Environment Record 이면, 다음을 수행합니다.? CreateGlobalFunctionBinding (variableEnv , funcName , funcObj , true )를 수행합니다. 그렇지 않으면,bindingExists 를 ! variableEnv .HasBinding (funcName )으로 둡니다.bindingExists 가 false 이면, 다음을 수행합니다.참고 : 다음 호출은 14 단계에 앞선 검증으로 인해 비정상 완료 를 반환할 수 없습니다.! variableEnv .CreateMutableBinding (funcName , true )를 수행합니다. ! variableEnv .InitializeBinding (funcName , funcObj )를 수행합니다. 그렇지 않으면,! variableEnv .SetMutableBinding (funcName , funcObj , false )를 수행합니다. declaredVariableNames 의 각 String variableName 에 대해 다음을 수행합니다.variableEnv 가 Global Environment Record 이면, 다음을 수행합니다.? CreateGlobalVarBinding (variableEnv , variableName , true )를 수행합니다. 그렇지 않으면,bindingExists 를 ! variableEnv .HasBinding (variableName )으로 둡니다.bindingExists 가 false 이면, 다음을 수행합니다.참고 : 다음 호출은 14 단계에 앞선 검증으로 인해 비정상 완료 를 반환할 수 없습니다.! variableEnv .CreateMutableBinding (variableName , true )를 수행합니다. ! variableEnv .InitializeBinding (variableName , undefined )를 수행합니다. unused 를 반환합니다.
19.2.2 isFinite ( value )
이 함수는 %isFinite% 내재 객체입니다.
호출되면 다음 단계를 수행합니다:
number 를 ? ToNumber (value )로 둡니다.number 가 유한 Number 이면 true 를 반환합니다.false 를 반환합니다.
19.2.3 isNaN ( value )
이 함수는 %isNaN% 내재 객체입니다.
호출되면 다음 단계를 수행합니다:
number 를 ? ToNumber (value )로 둡니다.number 가 NaN 이면 true 를 반환합니다.false 를 반환합니다.
참고
ECMAScript 코드에서 값 X가 NaN 인지 안정적으로 검사하는 방법은 X !== X 형식의 표현식을 사용하는 것입니다. X가 NaN 인 경우에만 결과가 true 입니다.
19.2.4 parseFloat ( string )
이 함수는 string 인수의 내용을 십진수 리터럴로 해석하여 결정되는 Number 값 을 생성합니다.
이 함수는 %parseFloat% 내재 객체입니다.
호출되면 다음 단계를 수행합니다:
inputString 을 ? ToString (string )으로 둡니다.trimmedString 을 ! TrimString (inputString , start )으로 둡니다.trimmed 를 StringToCodePoints (trimmedString )로 둡니다.trimmedPrefix 를 StrDecimalLiteral 의 구문을 만족하는 trimmed 의 가장 긴 접두사로 둡니다. 이는 trimmed 자체일 수도 있습니다. 이러한 접두사가 없으면 NaN 을 반환합니다.parsedNumber 를 ParseText (trimmedPrefix , StrDecimalLiteral )로 둡니다.단언 : parsedNumber 는 Parse Node입니다.parsedNumber 의 StringNumericValue 를 반환합니다.
참고
이 함수는 string 의 앞부분만 Number 값 으로 해석할 수 있습니다. 십진수 리터럴 표기의 일부로 해석할 수 없는 코드 단위는 무시하며 이러한 코드 단위가 무시되었다는 어떠한 표시도 제공하지 않습니다.
19.2.5 parseInt ( string , radix )
이 함수는 지정된 radix 에 따라 string 의 내용을 해석하여 결정되는 정수 Number를 생성합니다. string 앞의 공백은 무시됩니다. radix 가 0으로 강제 변환되면(undefined 인 경우 등) 숫자 표현이 "0x" 또는 "0X" 로 시작하는 경우를 제외하고 10으로 간주하며, 해당 경우에는 16으로 간주합니다. radix 가 16이면 숫자 표현은 선택적으로 "0x" 또는 "0X" 로 시작할 수 있습니다.
이 함수는 %parseInt% 내재 객체입니다.
호출되면 다음 단계를 수행합니다:
inputString 을 ? ToString (string )으로 둡니다.radixMV 를 ℝ (? ToInt32 (radix ))로 둡니다.radixMV ≠ 0이고 radixMV 가 2부터 36까지의 폐구간 에 속하지 않으면 NaN 을 반환합니다.trimmedString 을 ! TrimString (inputString , start )으로 둡니다.trimmedString 이 빈 String이면 NaN 을 반환합니다.sign 을 1로 둡니다.trimmedString 의 첫 번째 코드 단위가 코드 단위 0x002D (HYPHEN-MINUS)이면, 다음을 수행합니다.sign 을 -1로 설정합니다.trimmedString 을 trimmedString 의 인덱스 1부터의 부분 문자열 로 설정합니다.그렇지 않고 trimmedString 의 첫 번째 코드 단위가 코드 단위 0x002B (PLUS SIGN)이면, 다음을 수행합니다.trimmedString 을 trimmedString 의 인덱스 1부터의 부분 문자열 로 설정합니다. radixMV = 0 또는 radixMV = 16이면, 다음을 수행합니다.trimmedString 의 길이가 ≥ 2이고 trimmedString 의 인덱스 0부터 2까지의 부분 문자열 이 "0x" 또는 "0X" 중 하나이면, 다음을 수행합니다.trimmedString 을 trimmedString 의 인덱스 2부터의 부분 문자열 로 설정합니다.radixMV 를 16으로 설정합니다.radixMV = 0이면 radixMV 를 10으로 설정합니다.trimmedString 에 기수-radixMV 숫자가 아닌 코드 단위가 포함되어 있으면 end 를 trimmedString 안에서 그러한 첫 번째 코드 단위의 인덱스로 둡니다. 그렇지 않으면 end 를 trimmedString 의 길이로 둡니다.numberString 을 trimmedString 의 인덱스 0부터 end 까지의 부분 문자열 로 둡니다.numberString 이 비어 있으면 NaN 을 반환합니다.mathInt 를 값 10부터 35까지의 숫자에 문자 A 부터 Z 및 a 부터 z 를 사용하여 기수-radixMV 표기법으로 numberString 이 나타내는 정수 값으로 둡니다. (다만 radixMV = 10이고 numberString 에 유효 숫자가 20개보다 많으면 구현체의 선택에 따라 20번째 이후의 모든 유효 숫자를 숫자 0으로 바꿀 수 있습니다. 또한 radixMV 가 2, 4, 8, 10, 16 또는 32 중 하나가 아니면 mathInt 는 기수-radixMV 표기법에서 numberString 이 나타내는 정수 값을 표현하는 구현체 근사 정수 일 수 있습니다.)sign = -1이고 mathInt = 0이면 -0 𝔽 을 반환합니다.𝔽 (sign × mathInt )을 반환합니다.
참고
이 함수는 string 의 앞부분만 정수 값으로 해석할 수 있습니다. 정수 표기의 일부로 해석할 수 없는 코드 단위는 무시하며 이러한 코드 단위가 무시되었다는 어떠한 표시도 제공하지 않습니다.
19.2.6 URI 처리 함수
Uniform Resource Identifier, 즉 URI는 인터넷에서 리소스(예: 웹 페이지 또는 파일)와 이에 접근하기 위한 전송 프로토콜(예: HTTP 또는 FTP)을 식별하는 String입니다. ECMAScript 언어 자체는 이 절에 설명된 URI 인코딩 및 디코딩 함수를 제외하고 URI 사용을 지원하지 않습니다. encodeURI와 decodeURI는 완전한 URI를 처리하기 위한 것입니다. 예약 문자는 특별한 의미(예: 구분자로서)를 갖도록 의도되었다고 가정하므로 인코딩하지 않습니다. encodeURIComponent와 decodeURIComponent는 URI의 개별 구성 요소를 처리하기 위한 것입니다. 예약 문자는 텍스트를 나타낸다고 가정하며 구성 요소가 완전한 URI의 일부가 되었을 때 특별한 의미를 갖지 않도록 인코딩해야 합니다.
참고 1
예약 문자 집합은 RFC 2396을 기반으로 하며 더 최신인 RFC 3986에서 도입된 변경 사항은 반영하지 않습니다.
참고 2
많은 ECMAScript 구현체는 웹 페이지를 조작하는 추가 함수와 메서드를 제공합니다. 이러한 함수는 이 표준의 범위를 벗어납니다.
19.2.6.1 decodeURI ( encodedURI )
이 함수는 encodeURI 함수가 도입할 수 있는 종류의 각 이스케이프 시퀀스 및 UTF-8 인코딩을 해당 코드 포인트의 UTF-16 인코딩으로 바꾼 새로운 URI 버전을 계산합니다. encodeURI가 도입할 수 없었던 이스케이프 시퀀스는 바꾸지 않습니다.
이 함수는 %decodeURI% 내재 객체입니다.
호출되면 다음 단계를 수행합니다:
uriString 을 ? ToString (encodedURI )로 둡니다.preserveEscapeSet 을 ";/?:@&=+$,#" 로 둡니다.? Decode (uriString , preserveEscapeSet )를 반환합니다.
19.2.6.2 decodeURIComponent ( encodedURIComponent )
이 함수는 encodeURIComponent 함수가 도입할 수 있는 종류의 각 이스케이프 시퀀스 및 UTF-8 인코딩을 해당 코드 포인트의 UTF-16 인코딩으로 바꾼 새로운 URI 버전을 계산합니다.
이 함수는 %decodeURIComponent% 내재 객체입니다.
호출되면 다음 단계를 수행합니다:
componentString 을 ? ToString (encodedURIComponent )로 둡니다.preserveEscapeSet 을 빈 String으로 둡니다.? Decode (componentString , preserveEscapeSet )를 반환합니다.
19.2.6.3 encodeURI ( uri )
이 함수는 특정 코드 포인트의 각 인스턴스를 해당 코드 포인트의 UTF-8 인코딩을 나타내는 하나, 둘, 셋 또는 네 개의 이스케이프 시퀀스로 바꾼 UTF-16 인코딩(6.1.4 ) URI의 새로운 버전을 계산합니다.
이 함수는 %encodeURI% 내재 객체입니다.
호출되면 다음 단계를 수행합니다:
uriString 을 ? ToString (uri )로 둡니다.extraUnescaped 를 ";/?:@&=+$,#" 로 둡니다.? Encode (uriString , extraUnescaped )를 반환합니다.
19.2.6.4 encodeURIComponent ( uriComponent )
이 함수는 특정 코드 포인트의 각 인스턴스를 해당 코드 포인트의 UTF-8 인코딩을 나타내는 하나, 둘, 셋 또는 네 개의 이스케이프 시퀀스로 바꾼 UTF-16 인코딩(6.1.4 ) URI의 새로운 버전을 계산합니다.
이 함수는 %encodeURIComponent% 내재 객체입니다.
호출되면 다음 단계를 수행합니다:
componentString 을 ? ToString (uriComponent )로 둡니다.extraUnescaped 를 빈 String으로 둡니다.? Encode (componentString , extraUnescaped )를 반환합니다.
19.2.6.5 Encode ( string , extraUnescaped )
추상 연산 Encode. 인수 string (String) 및 extraUnescaped (String). 반환값: (정상 완료 (값: String) 또는 throw 완료 ). 6.1.4 에 설명된 대로 string 을 UTF-16으로 인코딩된 코드 포인트의 시퀀스로 해석하여 URI 인코딩 및 이스케이프를 수행합니다. 문자가 RFC 2396에서 예약되지 않은 문자로 식별되거나 extraUnescaped 에 나타나면 이스케이프하지 않습니다. 호출되면 다음 단계를 수행한다.
length 를 string 의 길이로 둡니다.result 를 빈 String으로 둡니다.alwaysUnescaped 를 ASCII 단어 문자 와 "-.!~*'()" 의 문자열 연결 로 둡니다.unescapedSet 을 alwaysUnescaped 와 extraUnescaped 의 문자열 연결 로 둡니다.k 를 0으로 둡니다.k < length 인 동안 다음을 반복합니다.codeUnit 을 string 안의 인덱스 k 에 있는 코드 단위로 둡니다.unescapedSet 에 codeUnit 이 포함되어 있으면, 다음을 수행합니다.k 를 k + 1로 설정합니다.result 를 result 와 codeUnit 의 문자열 연결 로 설정합니다.그렇지 않으면,codePoint 를 CodePointAt (string , k )로 둡니다.codePoint .[[IsUnpairedSurrogate]] 가 true 이면 URIError 예외를 던집니다.k 를 k + codePoint .[[CodeUnitCount]] 로 설정합니다.octets 를 codePoint .[[CodePoint]] 에 UTF-8 변환을 적용하여 얻은 옥텟의 List 로 둡니다.octets 의 각 요소 octet 에 대해 다음을 수행합니다.hex 를 octet 을 대문자 16진수로 형식화한 String 표현으로 둡니다.result 를 result , "%" 및 StringPad (hex , 2, "0" , start )의 문자열 연결 로 설정합니다. result 를 반환합니다.
참고
퍼센트 인코딩은 개별 옥텟을 나타내는 데 사용되므로 하나의 코드 포인트는 여러 개의 연속된 이스케이프 시퀀스(각 8비트 UTF-8 코드 단위마다 하나씩)로 표현될 수 있습니다.
19.2.6.6 Decode ( string , preserveEscapeSet )
추상 연산 Decode. 인수 string (String) 및 preserveEscapeSet (String). 반환값: (정상 완료 (값: String) 또는 throw 완료 ). preserveEscapeSet 의 Basic Latin 문자에 대응하는 모든 이스케이프 시퀀스를 유지하면서 URI 이스케이프 해제 및 디코딩을 수행합니다. 호출되면 다음 단계를 수행한다.
length 를 string 의 길이로 둡니다.result 를 빈 String으로 둡니다.k 를 0으로 둡니다.k < length 인 동안 다음을 반복합니다.codeUnit 을 string 안의 인덱스 k 에 있는 코드 단위로 둡니다.segment 를 codeUnit 으로 둡니다.codeUnit 이 코드 단위 0x0025 (PERCENT SIGN)이면, 다음을 수행합니다.k + 3 > length 이면 URIError 예외를 던집니다.escape 를 string 의 인덱스 k 부터 k + 3까지의 부분 문자열 로 둡니다.firstOctet 을 ParseHexOctet (string , k + 1)로 둡니다.firstOctet 이 정수 가 아니면 URIError 예외를 던집니다.k 를 k + 2로 설정합니다.n 을 firstOctet 에서 앞쪽의 1 비트 수로 둡니다.n = 0이면, 다음을 수행합니다.asciiChar 를 숫자 값이 firstOctet 인 코드 단위로 둡니다.preserveEscapeSet 에 asciiChar 가 포함되어 있으면 segment 를 escape 로 설정합니다. 그렇지 않으면 segment 를 asciiChar 로 설정합니다.그렇지 않으면,n = 1 또는 n > 4이면 URIError 예외를 던집니다.octets 를 « firstOctet »으로 둡니다.j 를 1로 둡니다.j < n 인 동안 다음을 반복합니다.k 를 k + 1로 설정합니다.k + 3 > length 이면 URIError 예외를 던집니다.string 안의 인덱스 k 에 있는 코드 단위가 코드 단위 0x0025 (PERCENT SIGN)가 아니면 URIError 예외를 던집니다.continuationByte 를 ParseHexOctet (string , k + 1)로 둡니다.continuationByte 가 정수 가 아니면 URIError 예외를 던집니다.continuationByte 를 octets 에 추가합니다.k 를 k + 2로 설정합니다.j 를 j + 1로 설정합니다.단언 : octets 의 길이는 n 입니다.octets 에 유효한 유니코드 코드 포인트의 UTF-8 인코딩이 포함되어 있지 않으면 URIError 예외를 던집니다.codePoint 를 octets 에 UTF-8 변환을 적용하여, 즉 옥텟의 List 를 21비트 값으로 변환하여 얻은 코드 포인트로 둡니다.segment 를 UTF16EncodeCodePoint (codePoint )로 설정합니다. result 를 result 와 segment 의 문자열 연결 로 설정합니다.k 를 k + 1로 설정합니다.result 를 반환합니다.
참고
RFC 3629는 유효하지 않은 UTF-8 옥텟 시퀀스의 디코딩을 금지합니다. 예를 들어 유효하지 않은 시퀀스 0xC0 0x80은 코드 단위 0x0000으로 디코딩되어서는 안 됩니다. Decode 알고리즘 구현체는 이러한 유효하지 않은 시퀀스를 발견하면 URIError 를 던져야 합니다.
19.2.6.7 ParseHexOctet ( string , position )
추상 연산 ParseHexOctet. 인수 string (String) 및 position (음이 아닌 정수). 반환값: (음이 아닌 정수 또는 a non-empty List of SyntaxError objects). string 의 지정된 position 에 있는 두 개의 16진수 문자 시퀀스를 부호 없는 8비트 정수 로 파싱합니다. 호출되면 다음 단계를 수행한다.
length 를 string 의 길이로 둡니다.단언 : position + 2 ≤ length 입니다.hexDigits 를 string 의 position 부터 position + 2까지의 부분 문자열 로 둡니다.parseResult 를 ParseText (hexDigits , HexDigits [~Sep] )로 둡니다.parseResult 가 Parse Node가 아니면 parseResult 를 반환합니다.n 을 parseResult 의 MV로 둡니다.단언 : n 은 0부터 255까지의 폐구간 에 속합니다.n 을 반환합니다.
19.3 전역 객체의 생성자 프로퍼티
19.3.1 AggregateError ( . . . )
20.5.7.1 를 참조하시기 바랍니다.
19.3.2 Array ( . . . )
23.1.1 를 참조하시기 바랍니다.
19.3.3 ArrayBuffer ( . . . )
25.1.4 를 참조하시기 바랍니다.
19.3.4 AsyncDisposableStack ( . . . )
27.4.1 를 참조하시기 바랍니다.
19.3.5 BigInt ( . . . )
21.2.1 를 참조하시기 바랍니다.
19.3.6 BigInt64Array ( . . . )
23.2.5 를 참조하시기 바랍니다.
19.3.7 BigUint64Array ( . . . )
23.2.5 를 참조하시기 바랍니다.
19.3.8 Boolean ( . . . )
20.3.1 를 참조하시기 바랍니다.
19.3.9 DataView ( . . . )
25.3.2 를 참조하시기 바랍니다.
19.3.10 Date ( . . . )
21.4.2 를 참조하시기 바랍니다.
19.3.11 DisposableStack ( . . . )
27.3.1 를 참조하시기 바랍니다.
19.3.12 Error ( . . . )
20.5.1 를 참조하시기 바랍니다.
19.3.13 EvalError ( . . . )
20.5.5.1 를 참조하시기 바랍니다.
19.3.14 FinalizationRegistry ( . . . )
26.2.1 를 참조하시기 바랍니다.
19.3.15 Float16Array ( . . . )
23.2.5 를 참조하시기 바랍니다.
19.3.16 Float32Array ( . . . )
23.2.5 를 참조하시기 바랍니다.
19.3.17 Float64Array ( . . . )
23.2.5 를 참조하시기 바랍니다.
19.3.18 Function ( . . . )
20.2.1 를 참조하시기 바랍니다.
19.3.19 Int8Array ( . . . )
23.2.5 를 참조하시기 바랍니다.
19.3.20 Int16Array ( . . . )
23.2.5 를 참조하시기 바랍니다.
19.3.21 Int32Array ( . . . )
23.2.5 를 참조하시기 바랍니다.
19.3.22 Iterator ( . . . )
27.1.3.1 를 참조하시기 바랍니다.
19.3.23 Map ( . . . )
24.1.1 를 참조하시기 바랍니다.
19.3.24 Number ( . . . )
21.1.1 를 참조하시기 바랍니다.
19.3.25 Object ( . . . )
20.1.1 를 참조하시기 바랍니다.
19.3.26 Promise ( . . . )
27.5.3 를 참조하시기 바랍니다.
19.3.27 Proxy ( . . . )
28.2.1 를 참조하시기 바랍니다.
19.3.28 RangeError ( . . . )
20.5.5.2 를 참조하시기 바랍니다.
19.3.29 ReferenceError ( . . . )
20.5.5.3 를 참조하시기 바랍니다.
19.3.30 RegExp ( . . . )
22.2.4 를 참조하시기 바랍니다.
19.3.31 Set ( . . . )
24.2.2 를 참조하시기 바랍니다.
19.3.32 SharedArrayBuffer ( . . . )
25.2.3 를 참조하시기 바랍니다.
19.3.33 String ( . . . )
22.1.1 를 참조하시기 바랍니다.
19.3.34 SuppressedError ( . . . )
20.5.8.1 를 참조하시기 바랍니다.
19.3.35 Symbol ( . . . )
20.4.1 를 참조하시기 바랍니다.
19.3.36 SyntaxError ( . . . )
20.5.5.4 를 참조하시기 바랍니다.
19.3.37 TypeError ( . . . )
20.5.5.5 를 참조하시기 바랍니다.
19.3.38 Uint8Array ( . . . )
23.2.5 를 참조하시기 바랍니다.
19.3.39 Uint8ClampedArray ( . . . )
23.2.5 를 참조하시기 바랍니다.
19.3.40 Uint16Array ( . . . )
23.2.5 를 참조하시기 바랍니다.
19.3.41 Uint32Array ( . . . )
23.2.5 를 참조하시기 바랍니다.
19.3.42 URIError ( . . . )
20.5.5.6 를 참조하시기 바랍니다.
19.3.43 WeakMap ( . . . )
24.3.1 를 참조하시기 바랍니다.
19.3.44 WeakRef ( . . . )
26.1.1 를 참조하시기 바랍니다.
19.3.45 WeakSet ( . . . )
24.4 를 참조하시기 바랍니다.
19.4 전역 객체의 기타 프로퍼티
19.4.1 Atomics
25.4 를 참조하시기 바랍니다.
19.4.2 JSON
25.5 를 참조하시기 바랍니다.
19.4.3 Math
21.3 를 참조하시기 바랍니다.
19.4.4 Reflect
28.1 를 참조하시기 바랍니다.
20 기본 객체
20.1 Object 객체
20.1.1 Object 생성자
Object 생성자 는:
%Object% 입니다.
전역 객체 의 "Object" 프로퍼티 초기 값입니다.
생성자 로 호출되면 새로운 일반 객체 를 생성합니다.
생성자 가 아니라 함수로 호출되면 타입 변환을 수행합니다.
클래스 정의의 extends 절 값으로 사용할 수 있습니다.
20.1.1.1 Object ( value )
이 함수는 호출되면 다음 단계를 수행합니다:
NewTarget이 undefined 도 활성 함수 객체 도 아니면, 다음을 수행합니다.? OrdinaryCreateFromConstructor (NewTarget, "%Object.prototype%" )를 반환합니다. value 가 undefined 또는 null 이면 OrdinaryObjectCreate (%Object.prototype% )를 반환합니다.! ToObject (value )를 반환합니다.
20.1.2 Object 생성자의 프로퍼티
Object 생성자 는:
20.1.2.1 Object.assign ( target , ...sources )
이 함수는 하나 이상의 소스 객체에서 열거 가능한 모든 자체 프로퍼티의 값을 target 객체로 복사합니다.
호출되면 다음 단계를 수행합니다:
targetObj 를 ? ToObject (target )로 둡니다.인수가 하나만 전달되었으면 targetObj 를 반환합니다. sources 의 각 요소 nextSource 에 대해 다음을 수행합니다.nextSource 가 undefined 도 null 도 아니면, 다음을 수행합니다.from 을 ! ToObject (nextSource )로 둡니다.keys 를 ? from .[[OwnPropertyKeys]] () 로 둡니다.keys 의 각 요소 nextKey 에 대해 다음을 수행합니다.propertyDesc 를 ? from .[[GetOwnProperty]] (nextKey ) 로 둡니다.propertyDesc 가 undefined 가 아니고 propertyDesc .[[Enumerable]] 이 true 이면, 다음을 수행합니다.propertyValue 를 ? Get (from , nextKey )로 둡니다.? Set (targetObj , nextKey , propertyValue , true )를 수행합니다. targetObj 를 반환합니다.
이 함수의 "length" 프로퍼티는 2 𝔽 입니다.
20.1.2.2 Object.create ( proto , properties )
이 함수는 지정된 프로토타입을 갖는 새로운 객체를 생성합니다.
호출되면 다음 단계를 수행합니다:
proto 가 Object가 아니고 proto 가 null 도 아니면 TypeError 예외를 던집니다.obj 를 OrdinaryObjectCreate (proto )로 둡니다.properties 가 undefined 가 아니면, 다음을 수행합니다.? ObjectDefineProperties (obj , properties )를 반환합니다. obj 를 반환합니다.
20.1.2.3 Object.defineProperties ( obj , properties )
이 함수는 객체에 자체 프로퍼티를 추가하거나 기존 자체 프로퍼티의 속성을 갱신합니다.
호출되면 다음 단계를 수행합니다:
obj 가 Object가 아니면 TypeError 예외를 던집니다.? ObjectDefineProperties (obj , properties )를 반환합니다.
20.1.2.3.1 ObjectDefineProperties ( obj , properties )
추상 연산 ObjectDefineProperties. 인수 obj (Object) 및 properties (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: Object) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
properties 를 ? ToObject (properties )로 설정합니다.keys 를 ? properties .[[OwnPropertyKeys]] () 로 둡니다.propertyDescs 를 새로운 빈 List 로 둡니다.keys 의 각 요소 nextKey 에 대해 다음을 수행합니다.currentPropertyDesc 를 ? properties .[[GetOwnProperty]] (nextKey ) 로 둡니다.currentPropertyDesc 가 undefined 가 아니고 currentPropertyDesc .[[Enumerable]] 이 true 이면, 다음을 수행합니다.propertyDescObj 를 ? Get (properties , nextKey )로 둡니다.propertyDesc 를 ? ToPropertyDescriptor (propertyDescObj )로 둡니다.Record { [[Key]] : nextKey , [[Descriptor]] : propertyDesc }를 propertyDescs 에 추가합니다.propertyDescs 의 각 요소 property 에 대해 다음을 수행합니다.? DefinePropertyOrThrow (obj , property .[[Key]] , property .[[Descriptor]] )를 수행합니다. obj 를 반환합니다.
20.1.2.4 Object.defineProperty ( obj , key , attrs )
이 함수는 객체에 자체 프로퍼티를 추가하거나 기존 자체 프로퍼티의 속성을 갱신합니다.
호출되면 다음 단계를 수행합니다:
obj 가 Object가 아니면 TypeError 예외를 던집니다.propertyKey 를 ? ToPropertyKey (key )로 둡니다.propertyDesc 를 ? ToPropertyDescriptor (attrs )로 둡니다.? DefinePropertyOrThrow (obj , propertyKey , propertyDesc )를 수행합니다. obj 를 반환합니다.
20.1.2.5 Object.entries ( obj )
이 함수는 호출되면 다음 단계를 수행합니다:
coerced 를 ? ToObject (obj )로 둡니다.entryList 를 ? EnumerableOwnProperties (coerced , key+value )로 둡니다.CreateArrayFromList (entryList )를 반환합니다.
20.1.2.6 Object.freeze ( obj )
이 함수는 호출되면 다음 단계를 수행합니다:
obj 가 Object가 아니면 obj 를 반환합니다.status 를 ? SetIntegrityLevel (obj , frozen )으로 둡니다.status 가 false 이면 TypeError 예외를 던집니다.obj 를 반환합니다.
20.1.2.7 Object.fromEntries ( iterable )
이 함수는 호출되면 다음 단계를 수행합니다:
? RequireObjectCoercible (iterable )을 수행합니다. obj 를 OrdinaryObjectCreate (%Object.prototype% )로 둡니다.단언 : obj 는 자체 프로퍼티가 없는 확장 가능한 일반 객체 입니다.closure 를 매개변수 (key , value )를 갖고 obj 를 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:propertyKey 를 ? ToPropertyKey (key )로 둡니다.! CreateDataPropertyOrThrow (obj , propertyKey , value )를 수행합니다. NormalCompletion (undefined )을 반환합니다.adder 를 CreateBuiltinFunction (closure , 2, "" , « »)로 둡니다.? AddEntriesFromIterable (obj , iterable , adder )를 반환합니다.
참고
adder 를 위해 생성된 함수는 ECMAScript 코드에서 절대로 직접 접근할 수 없습니다.
20.1.2.8 Object.getOwnPropertyDescriptor ( obj , key )
이 함수는 호출되면 다음 단계를 수행합니다:
coerced 를 ? ToObject (obj )로 둡니다.propertyKey 를 ? ToPropertyKey (key )로 둡니다.propertyDesc 를 ? coerced .[[GetOwnProperty]] (propertyKey ) 로 둡니다.FromPropertyDescriptor (propertyDesc )를 반환합니다.
20.1.2.9 Object.getOwnPropertyDescriptors ( obj )
이 함수는 호출되면 다음 단계를 수행합니다:
coerced 를 ? ToObject (obj )로 둡니다.ownKeys 를 ? coerced .[[OwnPropertyKeys]] () 로 둡니다.descs 를 OrdinaryObjectCreate (%Object.prototype% )로 둡니다.ownKeys 의 각 요소 key 에 대해 다음을 수행합니다.propertyDesc 를 ? coerced .[[GetOwnProperty]] (key ) 로 둡니다.propertyDescObj 를 FromPropertyDescriptor (propertyDesc )로 둡니다.propertyDescObj 가 undefined 가 아니면 ! CreateDataPropertyOrThrow (descs , key , propertyDescObj )를 수행합니다.descs 를 반환합니다.
20.1.2.10 Object.getOwnPropertyNames ( obj )
이 함수는 호출되면 다음 단계를 수행합니다:
CreateArrayFromList (? GetOwnPropertyKeys (obj , string ))를 반환합니다.
20.1.2.11 Object.getOwnPropertySymbols ( obj )
이 함수는 호출되면 다음 단계를 수행합니다:
CreateArrayFromList (? GetOwnPropertyKeys (obj , symbol ))를 반환합니다.
20.1.2.11.1 GetOwnPropertyKeys ( value , type )
추상 연산 GetOwnPropertyKeys. 인수 value (ECMAScript 언어 값 ) 및 type ((string 또는 symbol )). 반환값: (정상 완료 (값: 리스트 (요소: 프로퍼티 키 )) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
obj 를 ? ToObject (value )로 둡니다.keys 를 ? obj .[[OwnPropertyKeys]] () 로 둡니다.nameList 를 새로운 빈 List 로 둡니다.keys 의 각 요소 nextKey 에 대해 다음을 수행합니다.nextKey 가 Symbol이고 type 이 symbol 이거나, nextKey 가 String이고 type 이 string 이면, 다음을 수행합니다.nextKey 를 nameList 에 추가합니다.nameList 를 반환합니다.
20.1.2.12 Object.getPrototypeOf ( obj )
이 함수는 호출되면 다음 단계를 수행합니다:
coerced 를 ? ToObject (obj )로 둡니다.? coerced .[[GetPrototypeOf]] () 를 반환합니다.
20.1.2.13 Object.groupBy ( items , callback )
참고
callback 은 두 개의 인수를 받는 함수여야 합니다. groupBy는 items 의 각 요소에 대해 오름차순으로 callback 을 한 번씩 호출하고 새로운 객체를 구성합니다. callback 이 반환한 각 값은 프로퍼티 키 로 강제 변환됩니다. 이러한 각 프로퍼티 키 에 대해 결과 객체는 해당 키를 프로퍼티 키 로 하고 callback 반환 값이 해당 키로 강제 변환된 모든 요소를 포함하는 배열을 값으로 하는 프로퍼티를 갖습니다.
callback 은 요소의 값과 요소의 인덱스라는 두 개의 인수로 호출됩니다.
groupBy의 반환 값은 %Object.prototype% 에서 상속하지 않는 객체입니다.
이 함수는 호출되면 다음 단계를 수행합니다:
groups 를 ? GroupBy (items , callback , property )로 둡니다.obj 를 OrdinaryObjectCreate (null )로 둡니다.groups 의 각 Record { [[Key]] , [[Elements]] } group 에 대해 다음을 수행합니다.elements 를 CreateArrayFromList (group .[[Elements]] )로 둡니다.! CreateDataPropertyOrThrow (obj , group .[[Key]] , elements )를 수행합니다. obj 를 반환합니다.
20.1.2.14 Object.hasOwn ( obj , key )
이 함수는 호출되면 다음 단계를 수행합니다:
coerced 를 ? ToObject (obj )로 둡니다.propertyKey 를 ? ToPropertyKey (key )로 둡니다.? HasOwnProperty (coerced , propertyKey )를 반환합니다.
20.1.2.15 Object.is ( value1 , value2 )
이 함수는 호출되면 다음 단계를 수행합니다:
SameValue (value1 , value2 )를 반환합니다.
20.1.2.16 Object.isExtensible ( obj )
이 함수는 호출되면 다음 단계를 수행합니다:
obj 가 Object가 아니면 false 를 반환합니다.? IsExtensible (obj )을 반환합니다.
20.1.2.17 Object.isFrozen ( obj )
이 함수는 호출되면 다음 단계를 수행합니다:
obj 가 Object가 아니면 true 를 반환합니다.? TestIntegrityLevel (obj , frozen )을 반환합니다.
20.1.2.18 Object.isSealed ( obj )
이 함수는 호출되면 다음 단계를 수행합니다:
obj 가 Object가 아니면 true 를 반환합니다.? TestIntegrityLevel (obj , sealed )을 반환합니다.
20.1.2.19 Object.keys ( obj )
이 함수는 호출되면 다음 단계를 수행합니다:
coerced 를 ? ToObject (obj )로 둡니다.keyList 를 ? EnumerableOwnProperties (coerced , key )로 둡니다.CreateArrayFromList (keyList )를 반환합니다.
20.1.2.20 Object.preventExtensions ( obj )
이 함수는 호출되면 다음 단계를 수행합니다:
obj 가 Object가 아니면 obj 를 반환합니다.status 를 ? obj .[[PreventExtensions]] () 로 둡니다.status 가 false 이면 TypeError 예외를 던집니다.obj 를 반환합니다.
20.1.2.21 Object.prototype
Object.prototype의 초기 값은 Object 프로토타입 객체 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
20.1.2.22 Object.seal ( obj )
이 함수는 호출되면 다음 단계를 수행합니다:
obj 가 Object가 아니면 obj 를 반환합니다.status 를 ? SetIntegrityLevel (obj , sealed )로 둡니다.status 가 false 이면 TypeError 예외를 던집니다.obj 를 반환합니다.
20.1.2.23 Object.setPrototypeOf ( obj , proto )
이 함수는 호출되면 다음 단계를 수행합니다:
? RequireObjectCoercible (obj )을 수행합니다. proto 가 Object가 아니고 proto 가 null 도 아니면 TypeError 예외를 던집니다.obj 가 Object가 아니면 obj 를 반환합니다.status 를 ? obj .[[SetPrototypeOf]] (proto ) 로 둡니다.status 가 false 이면 TypeError 예외를 던집니다.obj 를 반환합니다.
20.1.2.24 Object.values ( obj )
이 함수는 호출되면 다음 단계를 수행합니다:
coerced 를 ? ToObject (obj )로 둡니다.valueList 를 ? EnumerableOwnProperties (coerced , value )로 둡니다.CreateArrayFromList (valueList )를 반환합니다.
20.1.3 Object 프로토타입 객체의 프로퍼티
Object 프로토타입 객체 는:
%Object.prototype% 입니다.
값이 true 인 [[Extensible]] 내부 슬롯을 갖습니다.
10.4.7.1 에 정의된 [[SetPrototypeOf]] 메서드를 제외하고 일반 객체 에 정의된 내부 메서드를 갖습니다. (따라서 불변 프로토타입 특수 객체 입니다.)
값이 null 인 [[Prototype]] 내부 슬롯을 갖습니다.
20.1.3.1 Object.prototype.constructor
Object.prototype.constructor의 초기 값은 %Object% 입니다.
20.1.3.2 Object.prototype.hasOwnProperty ( value )
이 메서드는 호출되면 다음 단계를 수행합니다:
propertyKey 를 ? ToPropertyKey (value )로 둡니다.obj 를 ? ToObject (this 값)로 둡니다.? HasOwnProperty (obj , propertyKey )를 반환합니다.
참고
1 및 2 단계의 순서는 this 값이 undefined 또는 null 인 경우에도 이 명세의 이전 판에서 1 단계가 던졌을 예외가 계속 던져지도록 하기 위해 선택되었습니다.
20.1.3.3 Object.prototype.isPrototypeOf ( value )
이 메서드는 호출되면 다음 단계를 수행합니다:
value 가 Object가 아니면 false 를 반환합니다.obj 를 ? ToObject (this 값)로 둡니다.다음을 반복합니다.value 를 ? value .[[GetPrototypeOf]] () 로 설정합니다.value 가 null 이면 false 를 반환합니다.SameValue (obj , value )가 true 이면 true 를 반환합니다.
참고
1 및 2 단계의 순서는 value 가 객체가 아니고 this 값이 undefined 또는 null 인 경우에 대해 이 명세의 이전 판에서 명시한 동작을 보존합니다.
20.1.3.4 Object.prototype.propertyIsEnumerable ( value )
이 메서드는 호출되면 다음 단계를 수행합니다:
propertyKey 를 ? ToPropertyKey (value )로 둡니다.obj 를 ? ToObject (this 값)로 둡니다.propertyDesc 를 ? obj .[[GetOwnProperty]] (propertyKey ) 로 둡니다.propertyDesc 가 undefined 이면 false 를 반환합니다.propertyDesc .[[Enumerable]] 을 반환합니다.
참고 1
이 메서드는 프로토타입 체인의 객체를 고려하지 않습니다.
참고 2
1 및 2 단계의 순서는 this 값이 undefined 또는 null 인 경우에도 이 명세의 이전 판에서 1 단계가 던졌을 예외가 계속 던져지도록 하기 위해 선택되었습니다.
20.1.3.5 Object.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
thisValue 를 this 값으로 둡니다.? Invoke (thisValue , "toString" )을 반환합니다.
이 메서드의 선택적 매개변수는 사용되지 않지만 ECMA-402 toLocaleString 메서드가 사용하는 매개변수 패턴에 대응하도록 의도되었습니다. ECMA-402 지원을 포함하지 않는 구현체는 해당 매개변수 위치를 다른 목적으로 사용해서는 안 됩니다.
참고 1
이 메서드는 로케일에 민감한 toString 동작을 갖지 않는 객체에 대한 일반적인 toLocaleString 구현을 제공합니다. Array, Number, Date 및 %TypedArray% 는 각자의 로케일에 민감한 toLocaleString 메서드를 제공합니다.
참고 2
ECMA-402는 의도적으로 이 기본 구현의 대안을 제공하지 않습니다.
20.1.3.6 Object.prototype.toString ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
this 값이 undefined 이면 "[object Undefined]" 를 반환합니다.this 값이 null 이면 "[object Null]" 을 반환합니다.obj 를 ! ToObject (this 값)로 둡니다.isArray 를 ? IsArray (obj )로 둡니다.isArray 가 true 이면 builtinTag 를 "Array" 로 둡니다.그렇지 않고 obj 가 [[ParameterMap]] 내부 슬롯을 가지면 builtinTag 를 "Arguments" 로 둡니다. 그렇지 않고 obj 가 [[Call]] 내부 메서드를 가지면 builtinTag 를 "Function" 으로 둡니다. 그렇지 않고 obj 가 [[ErrorData]] 내부 슬롯을 가지면 builtinTag 를 "Error" 로 둡니다. 그렇지 않고 obj 가 [[BooleanData]] 내부 슬롯을 가지면 builtinTag 를 "Boolean" 으로 둡니다. 그렇지 않고 obj 가 [[NumberData]] 내부 슬롯을 가지면 builtinTag 를 "Number" 로 둡니다. 그렇지 않고 obj 가 [[StringData]] 내부 슬롯을 가지면 builtinTag 를 "String" 으로 둡니다. 그렇지 않고 obj 가 [[DateValue]] 내부 슬롯을 가지면 builtinTag 를 "Date" 로 둡니다. 그렇지 않고 obj 가 [[RegExpMatcher]] 내부 슬롯을 가지면 builtinTag 를 "RegExp" 로 둡니다. 그렇지 않으면 builtinTag 를 "Object" 로 둡니다. tag 를 ? Get (obj , %Symbol.toStringTag% )로 둡니다.tag 가 String이 아니면 tag 를 builtinTag 로 설정합니다."[object " , tag 및 "]" 의 문자열 연결 을 반환합니다.
참고
역사적으로 이 메서드는 이 명세의 이전 판에서 다양한 내장 객체의 명목상 타입 태그로 사용된 [[Class]] 내부 슬롯의 String 값에 접근하는 데 간혹 사용되었습니다. 위의 toString 정의는 이러한 특정 종류의 내장 객체를 검사하기 위해 toString을 사용하는 레거시 코드와의 호환성을 보존합니다. 다른 종류의 내장 객체 또는 프로그램 정의 객체에 대해서는 신뢰할 수 있는 타입 검사 메커니즘을 제공하지 않습니다. 또한 프로그램은 이러한 레거시 타입 검사의 신뢰성을 무효화하는 방식으로 %Symbol.toStringTag% 를 사용할 수 있습니다.
20.1.3.7 Object.prototype.valueOf ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
? ToObject (this 값)를 반환합니다.
20.1.3.8 Object.prototype.__proto__
Object.prototype.__proto__는 { [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖는 접근자 프로퍼티 입니다. [[Getter]] 및 [[Setter]] 속성은 다음과 같이 정의됩니다:
20.1.3.8.1 get Object.prototype.__proto__
[[Getter]] 속성의 값은 인수를 필요로 하지 않는 내장 함수입니다. 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)로 둡니다.? obj .[[GetPrototypeOf]] () 를 반환합니다.
20.1.3.8.2 set Object.prototype.__proto__
[[Setter]] 속성의 값은 인수 proto 를 받는 내장 함수입니다. 호출되면 다음 단계를 수행합니다:
thisValue 를 this 값으로 둡니다.? RequireObjectCoercible (thisValue )을 수행합니다. proto 가 Object가 아니고 proto 가 null 도 아니면 undefined 를 반환합니다.thisValue 가 Object가 아니면 undefined 를 반환합니다.status 를 ? thisValue .[[SetPrototypeOf]] (proto ) 로 둡니다.status 가 false 이면 TypeError 예외를 던집니다.undefined 를 반환합니다.
20.1.3.9 레거시 Object.prototype 접근자 메서드
20.1.3.9.1 Object.prototype.__defineGetter__ ( key , getter )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)로 둡니다.IsCallable (getter )가 false 이면 TypeError 예외를 던집니다.propertyDesc 를 PropertyDescriptor { [[Getter]] : getter , [[Enumerable]] : true , [[Configurable]] : true }로 둡니다.propertyKey 를 ? ToPropertyKey (key )로 둡니다.? DefinePropertyOrThrow (obj , propertyKey , propertyDesc )를 수행합니다. undefined 를 반환합니다.
20.1.3.9.2 Object.prototype.__defineSetter__ ( key , setter )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)로 둡니다.IsCallable (setter )가 false 이면 TypeError 예외를 던집니다.propertyDesc 를 PropertyDescriptor { [[Setter]] : setter , [[Enumerable]] : true , [[Configurable]] : true }로 둡니다.propertyKey 를 ? ToPropertyKey (key )로 둡니다.? DefinePropertyOrThrow (obj , propertyKey , propertyDesc )를 수행합니다. undefined 를 반환합니다.
20.1.3.9.3 Object.prototype.__lookupGetter__ ( key )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)로 둡니다.propertyKey 를 ? ToPropertyKey (key )로 둡니다.다음을 반복합니다.propertyDesc 를 ? obj .[[GetOwnProperty]] (propertyKey ) 로 둡니다.propertyDesc 가 undefined 가 아니면, 다음을 수행합니다.IsAccessorDescriptor (propertyDesc )가 true 이면 propertyDesc .[[Getter]] 를 반환합니다.undefined 를 반환합니다.obj 를 ? obj .[[GetPrototypeOf]] () 로 설정합니다.obj 가 null 이면 undefined 를 반환합니다.
20.1.3.9.4 Object.prototype.__lookupSetter__ ( key )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)로 둡니다.propertyKey 를 ? ToPropertyKey (key )로 둡니다.다음을 반복합니다.propertyDesc 를 ? obj .[[GetOwnProperty]] (propertyKey ) 로 둡니다.propertyDesc 가 undefined 가 아니면, 다음을 수행합니다.IsAccessorDescriptor (propertyDesc )가 true 이면 propertyDesc .[[Setter]] 를 반환합니다.undefined 를 반환합니다.obj 를 ? obj .[[GetPrototypeOf]] () 로 설정합니다.obj 가 null 이면 undefined 를 반환합니다.
20.1.4 Object 인스턴스의 프로퍼티
Object 인스턴스에는 Object 프로토타입 객체 에서 상속된 프로퍼티 외에 특별한 프로퍼티가 없습니다.
20.2 Function 객체
20.2.1 Function 생성자
Function 생성자 는:
%Function% 입니다.
전역 객체 의 "Function" 프로퍼티 초기 값입니다.
생성자 가 아니라 함수로 호출되면 새로운 함수 객체 를 생성하고 초기화합니다. 따라서 함수 호출 Function(…)은 동일한 인수를 사용한 객체 생성 표현식 new Function(…)과 동등합니다.
클래스 정의의 extends 절 값으로 사용할 수 있습니다. 명시된 Function 동작을 상속하려는 하위 클래스 생성자 는 내장 함수 동작에 필요한 내부 슬롯을 갖는 하위 클래스 인스턴스를 생성하고 초기화하기 위해 Function 생성자 에 대한 super 호출을 포함해야 합니다. 함수 객체 를 정의하는 모든 ECMAScript 구문 형식은 Function의 인스턴스를 생성합니다. 내장 GeneratorFunction, AsyncFunction 및 AsyncGeneratorFunction 하위 클래스를 제외하고 Function 하위 클래스의 인스턴스를 생성하는 구문적 방법은 없습니다.
20.2.1.1 Function ( ...paramArgs , bodyArg )
마지막 인수(있는 경우)는 함수의 본문(실행 가능한 코드)을 지정하며, 그 앞의 모든 인수는 형식 매개변수를 지정합니다.
이 함수는 호출되면 다음 단계를 수행합니다:
ctor 를 활성 함수 객체 로 둡니다.bodyArg 가 존재하지 않으면 bodyArg 를 빈 String으로 설정합니다.? CreateDynamicFunction (ctor , NewTarget, normal , paramArgs , bodyArg )을 반환합니다.
참고
지정할 각 형식 매개변수마다 하나의 인수를 갖는 것은 허용되지만 필수는 아닙니다. 예를 들어 다음 세 표현식은 모두 동일한 결과를 생성합니다:
new Function ("a" , "b" , "c" , "return a+b+c" )
new Function ("a, b, c" , "return a+b+c" )
new Function ("a,b" , "c" , "return a+b+c" )
20.2.1.1.1 CreateDynamicFunction ( ctor , newTarget , kind , paramArgs , bodyArg )
추상 연산 CreateDynamicFunction. 인수 ctor (생성자 ), newTarget ((생성자 또는 undefined )), kind ((normal , generator , async 또는 async-generator )), paramArgs (리스트 (요소: ECMAScript 언어 값 )) 및 bodyArg (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: ECMAScript 함수 객체) 또는 throw 완료 ). ctor 는 이 동작을 수행하는 생성자 함수입니다. newTarget 은 처음 new가 적용된 생성자 입니다. paramArgs 와 bodyArg 는 ctor 에 전달된 인수 값을 반영합니다. 호출되면 다음 단계를 수행한다.
newTarget 이 undefined 이면 newTarget 을 ctor 로 설정합니다.kind 가 normal 이면, 다음을 수행합니다.prefix 를 "function" 으로 둡니다.exprGrammar 를 문법 기호 FunctionExpression 로 둡니다.bodyGrammar 를 문법 기호 FunctionBody [~Yield, ~Await] 로 둡니다.paramGrammar 를 문법 기호 FormalParameters [~Yield, ~Await] 로 둡니다.fallbackProto 를 "%Function.prototype%" 로 둡니다.그렇지 않고 kind 가 generator 이면, 다음을 수행합니다.prefix 를 "function*" 으로 둡니다.exprGrammar 를 문법 기호 GeneratorExpression 로 둡니다.bodyGrammar 를 문법 기호 GeneratorBody 로 둡니다.paramGrammar 를 문법 기호 FormalParameters [+Yield, ~Await] 로 둡니다.fallbackProto 를 "%GeneratorFunction.prototype%" 로 둡니다. 그렇지 않고 kind 가 async 이면, 다음을 수행합니다.prefix 를 "async function" 으로 둡니다.exprGrammar 를 문법 기호 AsyncFunctionExpression 로 둡니다.bodyGrammar 를 문법 기호 AsyncFunctionBody 로 둡니다.paramGrammar 를 문법 기호 FormalParameters [~Yield, +Await] 로 둡니다.fallbackProto 를 "%AsyncFunction.prototype%" 로 둡니다. 그렇지 않으면,단언 : kind 는 async-generator 입니다.prefix 를 "async function*" 으로 둡니다.exprGrammar 를 문법 기호 AsyncGeneratorExpression 로 둡니다.bodyGrammar 를 문법 기호 AsyncGeneratorBody 로 둡니다.paramGrammar 를 문법 기호 FormalParameters [+Yield, +Await] 로 둡니다.fallbackProto 를 "%AsyncGeneratorFunction.prototype%" 로 둡니다. argCount 를 paramArgs 의 요소 수로 둡니다.paramStrings 를 새로운 빈 List 로 둡니다.paramArgs 의 각 요소 arg 에 대해 다음을 수행합니다.? ToString (arg )을 paramStrings 에 추가합니다. bodyString 을 ? ToString (bodyArg )으로 둡니다.currentRealm 을 현재 Realm Record 로 둡니다.? HostEnsureCanCompileStrings (currentRealm , paramStrings , bodyString , false )를 수행합니다. paramString 을 빈 String으로 둡니다.argCount > 0이면, 다음을 수행합니다.paramString 을 paramStrings [0]으로 설정합니다.k 를 1로 둡니다.k < argCount 인 동안 다음을 반복합니다.nextArgString 을 paramStrings [k ]로 둡니다.paramString 을 paramString , "," (쉼표) 및 nextArgString 의 문자열 연결 로 설정합니다.k 를 k + 1로 설정합니다.bodyParseString 을 0x000A (LINE FEED), bodyString 및 0x000A (LINE FEED)의 문자열 연결 로 둡니다.sourceString 을 prefix , " anonymous(" , paramString , 0x000A (LINE FEED), ") {" , bodyParseString 및 "}" 의 문자열 연결 로 둡니다.sourceText 를 StringToCodePoints (sourceString )로 둡니다.params 를 ParseText (paramString , paramGrammar )로 둡니다.params 가 오류의 List 이면 SyntaxError 예외를 던집니다.body 를 ParseText (bodyParseString , bodyGrammar )로 둡니다.body 가 오류의 List 이면 SyntaxError 예외를 던집니다.참고 : 매개변수와 본문은 각각 독립적으로 유효함을 보장하기 위해 별도로 파싱됩니다. 예를 들어 new Function("/*", "*/ ) {")는 함수로 평가되지 않습니다.참고 : 이 단계에 도달하면 sourceText 는 exprGrammar 의 구문을 가져야 합니다(반대 방향의 함의는 성립하지 않음). 다음 두 단계의 목적은 exprGrammar 에 직접 적용되는 모든 조기 오류 규칙 을 적용하는 것입니다.expr 을 ParseText (sourceText , exprGrammar )로 둡니다.expr 이 오류의 List 이면 SyntaxError 예외를 던집니다.funcProto 를 ? GetPrototypeFromConstructor (newTarget , fallbackProto )로 둡니다.envRecord 를 currentRealm .[[GlobalEnv]] 로 둡니다.privateEnv 를 null 로 둡니다.func 를 OrdinaryFunctionCreate (funcProto , sourceText , params , body , non-lexical-this , envRecord , privateEnv )로 둡니다.SetFunctionName (func , "anonymous" )을 수행합니다.kind 가 generator 이면, 다음을 수행합니다.protoProto 를 OrdinaryObjectCreate (%GeneratorPrototype% )로 둡니다.! DefinePropertyOrThrow (func , "prototype" , PropertyDescriptor { [[Value]] : protoProto , [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : false })를 수행합니다. 그렇지 않고 kind 가 async-generator 이면, 다음을 수행합니다.protoProto 를 OrdinaryObjectCreate (%AsyncGeneratorPrototype% )로 둡니다.! DefinePropertyOrThrow (func , "prototype" , PropertyDescriptor { [[Value]] : protoProto , [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : false })를 수행합니다. 그렇지 않고 kind 가 normal 이면, 다음을 수행합니다.MakeConstructor (func )를 수행합니다. 참고 : kind 가 async 인 함수는 생성할 수 없으며 [[Construct]] 내부 메서드 또는 "prototype" 프로퍼티를 갖지 않습니다.func 를 반환합니다.
참고
CreateDynamicFunction은 생성자 로 사용될 가능성을 제공하기 위해 kind 가 async 가 아닌 생성하는 모든 함수에 "prototype" 프로퍼티를 정의합니다.
20.2.2 Function 생성자의 프로퍼티
Function 생성자 는:
20.2.2.1 Function.prototype
Function.prototype의 값은 Function 프로토타입 객체 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
20.2.3 Function 프로토타입 객체의 프로퍼티
Function 프로토타입 객체 는:
%Function.prototype% 입니다.
그 자체가 내장 함수 객체 입니다.
어떤 인수든 허용하며 호출되면 undefined 를 반환합니다.
[[Construct]] 내부 메서드를 갖지 않으므로 new 연산자와 함께 생성자 로 사용할 수 없습니다.
값이 %Object.prototype% 인 [[Prototype]] 내부 슬롯을 갖습니다.
"prototype" 프로퍼티를 갖지 않습니다.
값이 +0 𝔽 인 "length" 프로퍼티를 갖습니다.
값이 빈 String인 "name" 프로퍼티를 갖습니다.
참고
Function 프로토타입 객체는 ECMAScript 2015 명세 이전에 작성된 ECMAScript 코드와의 호환성을 보장하기 위해 함수 객체 로 명시됩니다.
20.2.3.1 Function.prototype.apply ( thisArg , argArray )
이 메서드는 호출되면 다음 단계를 수행합니다:
func 를 this 값으로 둡니다.IsCallable (func )이 false 이면 TypeError 예외를 던집니다.argArray 가 undefined 또는 null 이면, 다음을 수행합니다.PrepareForTailCall ()을 수행합니다.? Call (func , thisArg )를 반환합니다. argList 를 ? CreateListFromArrayLike (argArray )로 둡니다.PrepareForTailCall ()을 수행합니다.? Call (func , thisArg , argList )를 반환합니다.
참고 1
thisArg 값은 수정되지 않은 채 this 값으로 전달됩니다. 이는 undefined 또는 null 인 thisArg 를 전역 객체 로 바꾸고 그 밖의 모든 값에 ToObject 를 적용한 결과를 this 값으로 전달하던 Edition 3에서 변경된 사항입니다. thisArg 가 수정되지 않고 전달되더라도 비엄격 함수 는 함수 진입 시 여전히 이러한 변환을 수행합니다.
참고 2
func 가 화살표 함수 또는 바인드된 함수 특수 객체 중 하나이면 6 단계의 함수 [[Call]] 에서 thisArg 는 무시됩니다.
20.2.3.2 Function.prototype.bind ( thisArg , ...args )
이 메서드는 호출되면 다음 단계를 수행합니다:
target 을 this 값으로 둡니다.IsCallable (target )이 false 이면 TypeError 예외를 던집니다.boundFunc 를 ? BoundFunctionCreate (target , thisArg , args )로 둡니다.length 를 0으로 둡니다.targetHasLength 를 ? HasOwnProperty (target , "length" )로 둡니다.targetHasLength 가 true 이면, 다음을 수행합니다.targetLength 를 ? Get (target , "length" )로 둡니다.targetLength 가 Number이면, 다음을 수행합니다.targetLengthAsInt 를 ! ToIntegerOrInfinity (targetLength )로 둡니다.targetLengthAsInt = +∞이면, 다음을 수행합니다.length 를 +∞로 설정합니다.그렇지 않고 targetLengthAsInt = -∞이면, 다음을 수행합니다.length 를 0으로 설정합니다. 그렇지 않으면,argCount 를 args 의 요소 수로 둡니다.length 를 max (targetLengthAsInt - argCount , 0)으로 설정합니다. SetFunctionLength (boundFunc , length )를 수행합니다.targetName 을 ? Get (target , "name" )로 둡니다.targetName 이 String이 아니면 targetName 을 빈 String으로 설정합니다.SetFunctionName (boundFunc , targetName , "bound" )를 수행합니다.boundFunc 를 반환합니다.
참고 1
Function.prototype.bind를 사용하여 생성된 Function 객체는 특수 객체 입니다. 또한 "prototype" 프로퍼티를 갖지 않습니다.
참고 2
target 이 화살표 함수 또는 바인드된 함수 특수 객체 중 하나이면 이 메서드에 전달된 thisArg 는 이후 func 호출에서 사용되지 않습니다.
20.2.3.3 Function.prototype.call ( thisArg , ...args )
이 메서드는 호출되면 다음 단계를 수행합니다:
func 를 this 값으로 둡니다.IsCallable (func )이 false 이면 TypeError 예외를 던집니다.PrepareForTailCall ()을 수행합니다.? Call (func , thisArg , args )를 반환합니다.
참고 1
thisArg 값은 수정되지 않은 채 this 값으로 전달됩니다. 이는 undefined 또는 null 인 thisArg 를 전역 객체 로 바꾸고 그 밖의 모든 값에 ToObject 를 적용한 결과를 this 값으로 전달하던 Edition 3에서 변경된 사항입니다. thisArg 가 수정되지 않고 전달되더라도 비엄격 함수 는 함수 진입 시 여전히 이러한 변환을 수행합니다.
참고 2
func 가 화살표 함수 또는 바인드된 함수 특수 객체 중 하나이면 4 단계의 함수 [[Call]] 에서 thisArg 는 무시됩니다.
20.2.3.4 Function.prototype.constructor
Function.prototype.constructor의 초기 값은 %Function% 입니다.
20.2.3.5 Function.prototype.toString ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
func 를 this 값으로 둡니다.func 가 Object이고, func 가 [[SourceText]] 내부 슬롯을 가지며, func .[[SourceText]] 가 유니코드 코드 포인트의 시퀀스이고, HostHasSourceTextAvailable (func )이 true 이면, 다음을 수행합니다.CodePointsToString (func .[[SourceText]] )을 반환합니다.func 가 내장 함수 객체 이면 func 의 구현체 정의 String 소스 코드 표현을 반환합니다. 표현은 NativeFunction 의 구문을 가져야 합니다. 또한 func 에 [[InitialName]] 내부 슬롯이 있고 func .[[InitialName]] 이 String이면 반환된 String에서 NativeFunctionAccessor opt PropertyName 과 일치하는 부분은 func .[[InitialName]] 이어야 합니다.func 가 Object이고 IsCallable (func )이 true 이면 func 의 구현체 정의 String 소스 코드 표현을 반환합니다. 표현은 NativeFunction 의 구문을 가져야 합니다.TypeError 예외를 던집니다.
NativeFunction :
function
NativeFunctionAccessor opt
PropertyName [~Yield, ~Await] opt
(
FormalParameters [~Yield, ~Await]
)
{
[
native
code
]
}
NativeFunctionAccessor :
get
set
20.2.3.6 Function.prototype [ %Symbol.hasInstance% ] ( value )
이 메서드는 호출되면 다음 단계를 수행합니다:
thisValue 를 this 값으로 둡니다.? OrdinaryHasInstance (thisValue , value )를 반환합니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
참고
이는 대부분의 함수가 상속하는 %Symbol.hasInstance%의 기본 구현입니다. %Symbol.hasInstance%는 값이 특정 생성자 의 인스턴스인지 결정하기 위해 instanceof 연산자가 호출합니다. 다음과 같은 표현식은
v instanceof F
다음과 같이 평가됩니다.
F[%Symbol .hasInstance %](v)
생성자 함수는 함수에 다른 %Symbol.hasInstance% 메서드를 노출하여 instanceof가 어떤 객체를 자신의 인스턴스로 인식할지 제어할 수 있습니다.
이 프로퍼티는 바인드된 함수의 대상 함수를 전역적으로 노출하는 데 사용될 수 있는 변조를 방지하기 위해 쓰기 불가능하고 구성 불가능합니다.
이 메서드의 "name" 프로퍼티 값은 "[Symbol.hasInstance]" 입니다.
20.2.4 Function 인스턴스
모든 Function 인스턴스는 ECMAScript 함수 객체 이며 표 26 에 나열된 내부 슬롯을 갖습니다. Function.prototype.bind 메서드(20.2.3.2 )를 사용하여 생성된 Function 객체는 표 27 에 나열된 내부 슬롯을 갖습니다.
Function 인스턴스는 다음 프로퍼티를 갖습니다:
20.2.4.1 length
"length" 프로퍼티의 값은 함수가 일반적으로 예상하는 인수 수를 나타내는 정수 Number입니다. 그러나 언어는 다른 수의 인수로 함수를 호출하는 것을 허용합니다. "length" 프로퍼티에 명시된 수와 다른 수의 인수로 함수가 호출되었을 때의 동작은 함수에 따라 달라집니다. 이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
20.2.4.2 name
"name" 프로퍼티의 값은 함수를 설명하는 String입니다. 이름에는 의미론적 중요성이 없지만 일반적으로 ECMAScript 소스 텍스트 에서 함수가 정의된 위치에서 해당 함수를 참조하는 데 사용하는 변수 또는 프로퍼티 이름 입니다. 이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
이 명세에 의해 문맥적 이름이 연결되지 않은 익명 함수 객체 는 빈 String을 "name" 프로퍼티의 값으로 사용합니다.
20.2.4.3 prototype
생성자 로 사용할 수 있는 Function 인스턴스는 "prototype" 프로퍼티를 갖습니다. 이러한 Function 인스턴스가 생성될 때마다 또 다른 일반 객체 도 생성되며 함수의 "prototype" 프로퍼티 초기 값이 됩니다. 달리 명시되지 않는 한 "prototype" 프로퍼티의 값은 해당 함수가 생성자 로 호출될 때 생성되는 객체의 [[Prototype]] 내부 슬롯을 초기화하는 데 사용됩니다.
이 프로퍼티는 { [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
참고
Function.prototype.bind를 사용하여 생성되거나 MethodDefinition (GeneratorMethod 또는 AsyncGeneratorMethod 이 아닌 것) 또는 ArrowFunction 을 평가하여 생성된 Function 객체는 "prototype" 프로퍼티를 갖지 않습니다.
20.2.5 HostHasSourceTextAvailable ( func )
호스트 정의 추상 연산 HostHasSourceTextAvailable. 인수 func (함수 객체 ). 반환값: Boolean. 호스트 환경 이 func 의 소스 텍스트 제공을 막을 수 있도록 합니다.
HostHasSourceTextAvailable 구현은 다음 요구 사항을 준수해야 합니다:
매개변수에 대해 결정적이어야 합니다. 특정 func 를 인수로 호출될 때마다 동일한 결과를 반환해야 합니다.
HostHasSourceTextAvailable의 기본 구현은 true 를 반환합니다.
20.3 Boolean 객체
20.3.1 Boolean 생성자
Boolean 생성자 는:
%Boolean% 입니다.
전역 객체 의 "Boolean" 프로퍼티 초기 값입니다.
생성자 로 호출되면 새로운 Boolean 객체를 생성하고 초기화합니다.
생성자 가 아니라 함수로 호출되면 타입 변환을 수행합니다.
클래스 정의의 extends 절 값으로 사용할 수 있습니다. 명시된 Boolean 동작을 상속하려는 하위 클래스 생성자 는 [[BooleanData]] 내부 슬롯을 갖는 하위 클래스 인스턴스를 생성하고 초기화하기 위해 Boolean 생성자 에 대한 super 호출을 포함해야 합니다.
20.3.1.1 Boolean ( value )
이 함수는 호출되면 다음 단계를 수행합니다:
bool 을 ToBoolean (value )으로 둡니다.NewTarget이 undefined 이면 bool 을 반환합니다. obj 를 ? OrdinaryCreateFromConstructor (NewTarget, "%Boolean.prototype%" , « [[BooleanData]] »)로 둡니다.obj .[[BooleanData]] 를 bool 로 설정합니다.obj 를 반환합니다.
20.3.2 Boolean 생성자의 프로퍼티
Boolean 생성자 는:
20.3.2.1 Boolean.prototype
Boolean.prototype의 초기 값은 Boolean 프로토타입 객체 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
20.3.3 Boolean 프로토타입 객체의 프로퍼티
Boolean 프로토타입 객체 는:
%Boolean.prototype% 입니다.
일반 객체 입니다.
그 자체가 Boolean 객체이며 값이 false 인 [[BooleanData]] 내부 슬롯을 갖습니다.
값이 %Object.prototype% 인 [[Prototype]] 내부 슬롯을 갖습니다.
20.3.3.1 Boolean.prototype.constructor
Boolean.prototype.constructor의 초기 값은 %Boolean% 입니다.
20.3.3.2 Boolean.prototype.toString ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
bool 을 ? ThisBooleanValue (this 값)로 둡니다.bool 이 true 이면 "true" 를 반환합니다."false" 를 반환합니다.
20.3.3.3 Boolean.prototype.valueOf ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
? ThisBooleanValue (this 값)를 반환합니다.
20.3.3.3.1 ThisBooleanValue ( arg )
추상 연산 ThisBooleanValue. 인수 arg (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
arg 가 Boolean이면 arg 를 반환합니다.arg 가 Object이고 arg 에 [[BooleanData]] 내부 슬롯이 있으면, 다음을 수행합니다.bool 을 arg .[[BooleanData]] 로 둡니다.단언 : bool 은 Boolean입니다.bool 을 반환합니다.TypeError 예외를 던집니다.
20.3.4 Boolean 인스턴스의 프로퍼티
Boolean 인스턴스는 Boolean 프로토타입 객체 에서 프로퍼티를 상속하는 일반 객체 입니다. Boolean 인스턴스에는 [[BooleanData]] 내부 슬롯이 있습니다. [[BooleanData]] 내부 슬롯은 이 Boolean 객체가 나타내는 Boolean 값입니다.
20.4 Symbol 객체
20.4.1 Symbol 생성자
Symbol 생성자 는:
%Symbol% 입니다.
전역 객체 의 "Symbol" 프로퍼티 초기 값입니다.
함수로 호출되면 새로운 Symbol 값을 반환합니다.
new 연산자와 함께 사용하도록 의도되지 않았습니다.
하위 클래스를 만들도록 의도되지 않았습니다.
클래스 정의의 extends 절 값으로 사용할 수 있지만 이에 대한 super 호출은 예외를 발생시킵니다.
20.4.1.1 Symbol ( [ description ] )
이 함수는 호출되면 다음 단계를 수행합니다:
NewTarget이 undefined 가 아니면 TypeError 예외를 던집니다. description 이 undefined 이면 descString 을 undefined 로 둡니다.그렇지 않으면 descString 을 ? ToString (description )으로 둡니다. descString 을 [[Description]] 으로 갖는 새로운 Symbol을 반환합니다.
20.4.2 Symbol 생성자의 프로퍼티
Symbol 생성자 는:
20.4.2.1 Symbol.asyncDispose
Symbol.asyncDispose의 초기 값은 잘 알려진 symbol %Symbol.asyncDispose% 입니다(표 1 ).
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
20.4.2.2 Symbol.asyncIterator
Symbol.asyncIterator의 초기 값은 잘 알려진 symbol %Symbol.asyncIterator% 입니다(표 1 ).
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
20.4.2.3 Symbol.dispose
Symbol.dispose의 초기 값은 잘 알려진 symbol %Symbol.dispose% 입니다(표 1 ).
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
20.4.2.4 Symbol.for ( key )
이 함수는 호출되면 다음 단계를 수행합니다:
stringKey 를 ? ToString (key )로 둡니다.agentRecord 를 주변 agent의 Agent Record 로 둡니다.globalSymbolRegistry 를 agentRecord .[[GlobalSymbolRegistry]] 로 둡니다.globalSymbolRegistry 의 각 요소 element 에 대해 다음을 수행합니다.element .[[Key]] 가 stringKey 이면 element .[[Symbol]] 을 반환합니다.단언 : globalSymbolRegistry 에는 현재 stringKey 에 대한 항목이 없습니다.newSymbol 을 [[Description]] 이 stringKey 인 새로운 Symbol로 둡니다.GlobalSymbolRegistry Record { [[Key]] : stringKey , [[Symbol]] : newSymbol }을 globalSymbolRegistry 에 추가합니다.newSymbol 을 반환합니다.
20.4.2.5 Symbol.hasInstance
Symbol.hasInstance의 초기 값은 잘 알려진 symbol %Symbol.hasInstance% 입니다(표 1 ).
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
20.4.2.6 Symbol.isConcatSpreadable
Symbol.isConcatSpreadable의 초기 값은 잘 알려진 symbol %Symbol.isConcatSpreadable% 입니다(표 1 ).
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
20.4.2.7 Symbol.iterator
Symbol.iterator의 초기 값은 잘 알려진 symbol %Symbol.iterator% 입니다(표 1 ).
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
20.4.2.8 Symbol.keyFor ( symbol )
이 함수는 호출되면 다음 단계를 수행합니다:
symbol 이 Symbol이 아니면 TypeError 예외를 던집니다.KeyForSymbol (symbol )을 반환합니다.
20.4.2.9 Symbol.match
Symbol.match의 초기 값은 잘 알려진 symbol %Symbol.match% 입니다(표 1 ).
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
20.4.2.10 Symbol.matchAll
Symbol.matchAll의 초기 값은 잘 알려진 symbol %Symbol.matchAll% 입니다(표 1 ).
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
20.4.2.11 Symbol.prototype
Symbol.prototype의 초기 값은 Symbol 프로토타입 객체 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
20.4.2.12 Symbol.replace
Symbol.replace의 초기 값은 잘 알려진 symbol %Symbol.replace% 입니다(표 1 ).
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
20.4.2.13 Symbol.search
Symbol.search의 초기 값은 잘 알려진 symbol %Symbol.search% 입니다(표 1 ).
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
20.4.2.14 Symbol.species
Symbol.species의 초기 값은 잘 알려진 symbol %Symbol.species% 입니다(표 1 ).
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
20.4.2.15 Symbol.split
Symbol.split의 초기 값은 잘 알려진 symbol %Symbol.split% 입니다(표 1 ).
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
20.4.2.16 Symbol.toPrimitive
Symbol.toPrimitive의 초기 값은 잘 알려진 symbol %Symbol.toPrimitive% 입니다(표 1 ).
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
20.4.2.17 Symbol.toStringTag
Symbol.toStringTag의 초기 값은 잘 알려진 symbol %Symbol.toStringTag% 입니다(표 1 ).
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
20.4.2.18 Symbol.unscopables
Symbol.unscopables의 초기 값은 잘 알려진 symbol %Symbol.unscopables% 입니다(표 1 ).
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
20.4.3 Symbol 프로토타입 객체의 프로퍼티
Symbol 프로토타입 객체 는:
%Symbol.prototype% 입니다.
일반 객체 입니다.
Symbol 인스턴스가 아니며 [[SymbolData]] 내부 슬롯을 갖지 않습니다.
값이 %Object.prototype% 인 [[Prototype]] 내부 슬롯을 갖습니다.
20.4.3.1 Symbol.prototype.constructor
Symbol.prototype.constructor의 초기 값은 %Symbol% 입니다.
20.4.3.2 get Symbol.prototype.description
Symbol.prototype.description은 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
symbol 을 ? ThisSymbolValue (this 값)로 둡니다.symbol .[[Description]] 을 반환합니다.
20.4.3.3 Symbol.prototype.toString ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
symbol 을 ? ThisSymbolValue (this 값)로 둡니다.SymbolDescriptiveString (symbol )을 반환합니다.
20.4.3.3.1 SymbolDescriptiveString ( symbol )
추상 연산 SymbolDescriptiveString. 인수 symbol (Symbol). 반환값: String. 호출되면 다음 단계를 수행한다.
description 을 symbol .[[Description]] 으로 둡니다.description 이 undefined 이면 description 을 빈 String으로 설정합니다.단언 : description 은 String입니다."Symbol(" , description 및 ")" 의 문자열 연결 을 반환합니다.
20.4.3.4 Symbol.prototype.valueOf ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
? ThisSymbolValue (this 값)를 반환합니다.
20.4.3.4.1 ThisSymbolValue ( arg )
추상 연산 ThisSymbolValue. 인수 arg (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: Symbol) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
arg 가 Symbol이면 arg 를 반환합니다.arg 가 Object이고 arg 에 [[SymbolData]] 내부 슬롯이 있으면, 다음을 수행합니다.symbol 을 arg .[[SymbolData]] 로 둡니다.단언 : symbol 은 Symbol입니다.symbol 을 반환합니다.TypeError 예외를 던집니다.
20.4.3.5 Symbol.prototype [ %Symbol.toPrimitive% ] ( hint )
이 메서드는 ECMAScript 언어 연산자가 Symbol 객체를 원시 값으로 변환하기 위해 호출합니다.
호출되면 다음 단계를 수행합니다:
? ThisSymbolValue (this 값)를 반환합니다.
참고
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
이 메서드의 "name" 프로퍼티 값은 "[Symbol.toPrimitive]" 입니다.
20.4.3.6 Symbol.prototype [ %Symbol.toStringTag% ]
%Symbol.toStringTag% 프로퍼티의 초기 값은 String 값 "Symbol" 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
20.4.4 Symbol 인스턴스의 프로퍼티
Symbol 인스턴스는 Symbol 프로토타입 객체 에서 프로퍼티를 상속하는 일반 객체 입니다. Symbol 인스턴스에는 [[SymbolData]] 내부 슬롯이 있습니다. [[SymbolData]] 내부 슬롯은 이 Symbol 객체가 나타내는 Symbol 값입니다.
20.4.5 Symbol을 위한 추상 연산
20.4.5.1 GlobalSymbolRegistry Record
GlobalSymbolRegistry Record 는 Symbol.for 를 통해 등록된 String 키와 Symbol 값을 연결하는 데 사용하는 Record 입니다.
GlobalSymbolRegistry Record에는 표 59 에 나열된 필드가 있습니다.
표 59: GlobalSymbolRegistry Record 필드
필드 이름
값
용도
[[Key]]
a String
Symbol을 전역적으로 식별하는 데 사용하는 문자열 키입니다.
[[Symbol]]
a Symbol
어떤 realm 에서도 가져올 수 있는 symbol입니다.
20.4.5.2 KeyForSymbol ( symbol )
추상 연산 KeyForSymbol. 인수 symbol (Symbol). 반환값: (String 또는 undefined ). symbol 이 주변 agent의 [[GlobalSymbolRegistry]] List 에 있으면 symbol 을 등록하는 데 사용된 String을 반환합니다. 호출되면 다음 단계를 수행한다.
agentRecord 를 주변 agent의 Agent Record 로 둡니다.globalSymbolRegistry 를 agentRecord .[[GlobalSymbolRegistry]] 로 둡니다.globalSymbolRegistry 의 각 요소 element 에 대해 다음을 수행합니다.SameValue (element .[[Symbol]] , symbol )가 true 이면 element .[[Key]] 를 반환합니다.단언 : globalSymbolRegistry 에는 현재 symbol 에 대한 항목이 없습니다.undefined 를 반환합니다.
20.5 Error 객체
런타임 오류가 발생하면 Error 객체의 인스턴스가 예외로 던져집니다. Error 객체는 사용자 정의 예외 클래스의 기본 객체 역할도 할 수 있습니다.
ECMAScript 구현체가 런타임 오류를 검출하면 20.5.5 에 정의된 NativeError 객체 중 하나의 새로운 인스턴스 또는 20.5.7 에 정의된 AggregateError 객체나 20.5.8 에 정의된 SuppressedError 객체 중 하나의 새로운 인스턴스를 던집니다. 이러한 각 객체는 아래에 설명된 구조를 가지며, 생성자 이름으로 NativeError 대신 사용하는 이름, 프로토타입 객체의 "name" 프로퍼티, 프로토타입 객체의 구현체 정의 "message" 프로퍼티, 그리고 %AggregateError% 고유의 "errors" 프로퍼티 또는 %SuppressedError% 고유의 "error" 및 "suppressed" 프로퍼티의 존재 여부만 다릅니다.
20.5.1 Error 생성자
Error 생성자 는:
%Error% 입니다.
전역 객체 의 "Error" 프로퍼티 초기 값입니다.
생성자 가 아니라 함수로 호출되면 새로운 Error 객체를 생성하고 초기화합니다. 따라서 함수 호출 Error(…)는 동일한 인수를 사용한 객체 생성 표현식 new Error(…)와 동등합니다.
클래스 정의의 extends 절 값으로 사용할 수 있습니다. 명시된 Error 동작을 상속하려는 하위 클래스 생성자 는 [[ErrorData]] 내부 슬롯을 갖는 하위 클래스 인스턴스를 생성하고 초기화하기 위해 Error 생성자 에 대한 super 호출을 포함해야 합니다.
20.5.1.1 Error ( message [ , options ] )
이 함수는 호출되면 다음 단계를 수행합니다:
NewTarget이 undefined 이면 newTarget 을 활성 함수 객체 로 둡니다. 그렇지 않으면 newTarget 을 NewTarget으로 둡니다. obj 를 ? OrdinaryCreateFromConstructor (newTarget , "%Error.prototype%" , « [[ErrorData]] »)로 둡니다.message 가 undefined 가 아니면, 다음을 수행합니다.messageString 을 ? ToString (message )으로 둡니다.CreateNonEnumerableDataPropertyOrThrow (obj , "message" , messageString )을 수행합니다.? InstallErrorCause (obj , options )를 수행합니다. obj 를 반환합니다.
20.5.2 Error 생성자의 프로퍼티
Error 생성자 는:
20.5.2.1 Error.isError ( arg )
이 함수는 호출되면 다음 단계를 수행합니다:
arg 가 Object가 아니면 false 를 반환합니다.arg 에 [[ErrorData]] 내부 슬롯이 없으면 false 를 반환합니다.true 를 반환합니다.
20.5.2.2 Error.prototype
Error.prototype의 초기 값은 Error 프로토타입 객체 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
20.5.3 Error 프로토타입 객체의 프로퍼티
Error 프로토타입 객체 는:
%Error.prototype% 입니다.
일반 객체 입니다.
Error 인스턴스가 아니며 [[ErrorData]] 내부 슬롯을 갖지 않습니다.
값이 %Object.prototype% 인 [[Prototype]] 내부 슬롯을 갖습니다.
20.5.3.1 Error.prototype.constructor
Error.prototype.constructor의 초기 값은 %Error% 입니다.
20.5.3.2 Error.prototype.message
Error.prototype.message의 초기 값은 빈 String입니다.
20.5.3.3 Error.prototype.name
Error.prototype.name의 초기 값은 "Error" 입니다.
20.5.3.4 Error.prototype.toString ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.obj 가 Object가 아니면 TypeError 예외를 던집니다.name 을 ? Get (obj , "name" )으로 둡니다.name 이 undefined 이면 name 을 "Error" 로 설정합니다. 그렇지 않으면 name 을 ? ToString (name )으로 설정합니다.message 를 ? Get (obj , "message" )로 둡니다.message 가 undefined 이면 message 를 빈 String으로 설정합니다. 그렇지 않으면 message 를 ? ToString (message )으로 설정합니다.name 이 빈 String이면 message 를 반환합니다.message 가 빈 String이면 name 을 반환합니다.name , 코드 단위 0x003A (COLON), 코드 단위 0x0020 (SPACE) 및 message 의 문자열 연결 을 반환합니다.
20.5.4 Error 인스턴스의 프로퍼티
Error 인스턴스는 Error 프로토타입 객체 에서 프로퍼티를 상속하고 값이 undefined 인 [[ErrorData]] 내부 슬롯을 갖는 일반 객체 입니다. [[ErrorData]] 의 유일한 명시된 용도는 Object.prototype.toString 및 Error.isError 안에서 Error, AggregateError, SuppressedError 및 NativeError 인스턴스를 Error 객체로 식별하는 것입니다.
20.5.5 이 표준에서 사용하는 Native Error 타입
런타임 오류가 검출되면 아래의 NativeError 객체 중 하나 또는 AggregateError 객체나 SuppressedError 객체 중 하나의 새로운 인스턴스가 던져집니다. 모든 NativeError 객체는 20.5.6 에 설명된 동일한 구조를 공유합니다.
20.5.5.1 EvalError
EvalError 생성자 는 %EvalError% 입니다.
이 예외는 현재 이 명세 안에서 사용되지 않습니다. 이 객체는 이 명세의 이전 판과의 호환성을 위해 남아 있습니다.
20.5.5.2 RangeError
RangeError 생성자 는 %RangeError% 입니다.
허용되는 값의 집합 또는 범위에 속하지 않는 값을 나타냅니다.
20.5.5.3 ReferenceError
ReferenceError 생성자 는 %ReferenceError% 입니다.
유효하지 않은 참조가 검출되었음을 나타냅니다.
20.5.5.4 SyntaxError
SyntaxError 생성자 는 %SyntaxError% 입니다.
파싱 오류가 발생했음을 나타냅니다.
20.5.5.5 TypeError
TypeError 생성자 는 %TypeError% 입니다.
TypeError는 다른 NativeError 객체 중 어느 것도 실패 원인을 적절히 나타내지 못할 때 성공하지 못한 연산을 나타내는 데 사용됩니다.
20.5.5.6 URIError
URIError 생성자 는 %URIError% 입니다.
전역 URI 처리 함수 중 하나가 해당 정의와 호환되지 않는 방식으로 사용되었음을 나타냅니다.
20.5.6 NativeError 객체 구조
이러한 각 객체는 아래에 설명된 구조를 가지며, 생성자 이름으로 사용되는 이름과 프로토타입 객체의 "name" 프로퍼티만 다릅니다.
각 오류 객체에 대해 정의 안의 NativeError 참조는 20.5.5 의 적절한 오류 객체 이름으로 바꿔야 합니다.
20.5.6.1 NativeError 생성자
각 NativeError 생성자 는:
생성자 가 아니라 함수로 호출되면 새로운 NativeError 객체를 생성하고 초기화합니다. 객체를 함수로 호출하는 것은 동일한 인수로 생성자 로 호출하는 것과 동등합니다. 따라서 함수 호출 NativeError (…)는 동일한 인수를 사용한 객체 생성 표현식 new NativeError (…)와 동등합니다.
클래스 정의의 extends 절 값으로 사용할 수 있습니다. 명시된 NativeError 동작을 상속하려는 하위 클래스 생성자 는 [[ErrorData]] 내부 슬롯을 갖는 하위 클래스 인스턴스를 생성하고 초기화하기 위해 NativeError 생성자 에 대한 super 호출을 포함해야 합니다.
20.5.6.1.1 NativeError ( message [ , options ] )
각 NativeError 함수는 호출되면 다음 단계를 수행합니다:
NewTarget이 undefined 이면 newTarget 을 활성 함수 객체 로 둡니다. 그렇지 않으면 newTarget 을 NewTarget으로 둡니다. obj 를 ? OrdinaryCreateFromConstructor (newTarget , "%NativeError .prototype%" , « [[ErrorData]] »)로 둡니다.message 가 undefined 가 아니면, 다음을 수행합니다.messageString 을 ? ToString (message )으로 둡니다.CreateNonEnumerableDataPropertyOrThrow (obj , "message" , messageString )을 수행합니다.? InstallErrorCause (obj , options )를 수행합니다. obj 를 반환합니다.
2 단계에서 전달되는 문자열의 실제 값은 정의 중인 NativeError 생성자 에 따라 "%EvalError.prototype%" , "%RangeError.prototype%" , "%ReferenceError.prototype%" , "%SyntaxError.prototype%" , "%TypeError.prototype%" 또는 "%URIError.prototype%" 중 하나입니다.
20.5.6.2 NativeError 생성자의 프로퍼티
각 NativeError 생성자 는:
값이 %Error% 인 [[Prototype]] 내부 슬롯을 갖습니다.
String 값 "NativeError " 을 값으로 갖는 "name" 프로퍼티를 갖습니다.
다음 프로퍼티를 갖습니다:
20.5.6.2.1 NativeError .prototype
NativeError .prototype의 초기 값은 NativeError 프로토타입 객체(20.5.6.3 )입니다. 각 NativeError 생성자 는 서로 다른 프로토타입 객체를 갖습니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
20.5.6.3 NativeError 프로토타입 객체의 프로퍼티
각 NativeError 프로토타입 객체 는:
20.5.6.3.1 NativeError .prototype.constructor
주어진 NativeError 생성자 에 대한 프로토타입의 "constructor" 프로퍼티 초기 값은 해당 생성자 자체입니다.
20.5.6.3.2 NativeError .prototype.message
주어진 NativeError 생성자 에 대한 프로토타입의 "message" 프로퍼티 초기 값은 빈 String입니다.
20.5.6.3.3 NativeError .prototype.name
주어진 NativeError 생성자 에 대한 프로토타입의 "name" 프로퍼티 초기 값은 생성자 의 이름(NativeError 대신 사용되는 이름)으로 구성된 String 값입니다.
20.5.6.4 NativeError 인스턴스의 프로퍼티
NativeError 인스턴스는 해당 NativeError 프로토타입 객체에서 프로퍼티를 상속하고 값이 undefined 인 [[ErrorData]] 내부 슬롯을 갖는 일반 객체 입니다. [[ErrorData]] 의 유일한 명시된 용도는 Object.prototype.toString(20.1.3.6 ) 및 Error.isError(20.5.2.1 )가 Error, AggregateError, SuppressedError 또는 NativeError 인스턴스를 식별하는 것입니다.
20.5.7 AggregateError 객체
20.5.7.1 AggregateError 생성자
AggregateError 생성자 는:
%AggregateError% 입니다.
전역 객체 의 "AggregateError" 프로퍼티 초기 값입니다.
생성자 가 아니라 함수로 호출되면 새로운 AggregateError 객체를 생성하고 초기화합니다. 따라서 함수 호출 AggregateError(…)는 동일한 인수를 사용한 객체 생성 표현식 new AggregateError(…)와 동등합니다.
클래스 정의의 extends 절 값으로 사용할 수 있습니다. 명시된 AggregateError 동작을 상속하려는 하위 클래스 생성자 는 [[ErrorData]] 내부 슬롯을 갖는 하위 클래스 인스턴스를 생성하고 초기화하기 위해 AggregateError 생성자 에 대한 super 호출을 포함해야 합니다.
20.5.7.1.1 AggregateError ( errors , message [ , options ] )
이 함수는 호출되면 다음 단계를 수행합니다:
NewTarget이 undefined 이면 newTarget 을 활성 함수 객체 로 둡니다. 그렇지 않으면 newTarget 을 NewTarget으로 둡니다. obj 를 ? OrdinaryCreateFromConstructor (newTarget , "%AggregateError.prototype%" , « [[ErrorData]] »)로 둡니다.message 가 undefined 가 아니면, 다음을 수행합니다.messageString 을 ? ToString (message )으로 둡니다.CreateNonEnumerableDataPropertyOrThrow (obj , "message" , messageString )을 수행합니다.? InstallErrorCause (obj , options )를 수행합니다. errorsList 를 ? IteratorToList (? GetIterator (errors , sync ))로 둡니다.! DefinePropertyOrThrow (obj , "errors" , PropertyDescriptor { [[Configurable]] : true , [[Enumerable]] : false , [[Writable]] : true , [[Value]] : CreateArrayFromList (errorsList ) })를 수행합니다. obj 를 반환합니다.
20.5.7.2 AggregateError 생성자의 프로퍼티
AggregateError 생성자 는:
값이 %Error% 인 [[Prototype]] 내부 슬롯을 갖습니다.
다음 프로퍼티를 갖습니다:
20.5.7.2.1 AggregateError.prototype
AggregateError.prototype의 초기 값은 %AggregateError.prototype% 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
20.5.7.3 AggregateError 프로토타입 객체의 프로퍼티
AggregateError 프로토타입 객체 는:
%AggregateError.prototype% 입니다.
일반 객체 입니다.
Error 인스턴스도 AggregateError 인스턴스도 아니며 [[ErrorData]] 내부 슬롯을 갖지 않습니다.
값이 %Error.prototype% 인 [[Prototype]] 내부 슬롯을 갖습니다.
20.5.7.3.1 AggregateError.prototype.constructor
AggregateError.prototype.constructor의 초기 값은 %AggregateError% 입니다.
20.5.7.3.2 AggregateError.prototype.message
AggregateError.prototype.message의 초기 값은 빈 String입니다.
20.5.7.3.3 AggregateError.prototype.name
AggregateError.prototype.name의 초기 값은 "AggregateError" 입니다.
20.5.7.4 AggregateError 인스턴스의 프로퍼티
AggregateError 인스턴스는 해당 AggregateError 프로토타입 객체 에서 프로퍼티를 상속하고 값이 undefined 인 [[ErrorData]] 내부 슬롯을 갖는 일반 객체 입니다. [[ErrorData]] 의 유일한 명시된 용도는 Object.prototype.toString(20.1.3.6 ) 및 Error.isError(20.5.2.1 )가 Error, AggregateError, SuppressedError 또는 NativeError 인스턴스를 식별하는 것입니다.
20.5.8 SuppressedError 객체
20.5.8.1 SuppressedError 생성자
SuppressedError 생성자 는:
%SuppressedError% 입니다.
전역 객체 의 "SuppressedError" 프로퍼티 초기 값입니다.
생성자 가 아니라 함수로 호출되면 새로운 SuppressedError 객체를 생성하고 초기화합니다. 따라서 함수 호출 SuppressedError(…)는 동일한 인수를 사용한 객체 생성 표현식 new SuppressedError(…)와 동등합니다.
클래스 정의의 extends 절 값으로 사용할 수 있습니다. 명시된 SuppressedError 동작을 상속하려는 하위 클래스 생성자 는 [[ErrorData]] 내부 슬롯을 갖는 하위 클래스 인스턴스를 생성하고 초기화하기 위해 SuppressedError 생성자 에 대한 super 호출을 포함해야 합니다.
20.5.8.1.1 SuppressedError ( error , suppressed , message )
이 함수는 호출되면 다음 단계를 수행합니다:
NewTarget이 undefined 이면 newTarget 을 활성 함수 객체 로 둡니다. 그렇지 않으면 newTarget 을 NewTarget으로 둡니다. obj 를 ? OrdinaryCreateFromConstructor (newTarget , "%SuppressedError.prototype%" , « [[ErrorData]] »)로 둡니다.message 가 undefined 가 아니면, 다음을 수행합니다.messageString 을 ? ToString (message )으로 둡니다.CreateNonEnumerableDataPropertyOrThrow (obj , "message" , messageString )을 수행합니다.CreateNonEnumerableDataPropertyOrThrow (obj , "error" , error )를 수행합니다.CreateNonEnumerableDataPropertyOrThrow (obj , "suppressed" , suppressed )를 수행합니다.obj 를 반환합니다.
20.5.8.2 SuppressedError 생성자의 프로퍼티
SuppressedError 생성자 는:
값이 %Error% 인 [[Prototype]] 내부 슬롯을 갖습니다.
다음 프로퍼티를 갖습니다:
20.5.8.2.1 SuppressedError.prototype
SuppressedError.prototype의 초기 값은 SuppressedError 프로토타입 객체 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
20.5.8.3 SuppressedError 프로토타입 객체의 프로퍼티
SuppressedError 프로토타입 객체 는:
%SuppressedError.prototype% 입니다.
일반 객체 입니다.
Error 인스턴스도 SuppressedError 인스턴스도 아니며 [[ErrorData]] 내부 슬롯을 갖지 않습니다.
값이 %Error.prototype% 인 [[Prototype]] 내부 슬롯을 갖습니다.
20.5.8.3.1 SuppressedError.prototype.constructor
SuppressedError.prototype.constructor의 초기 값은 %SuppressedError% 입니다.
20.5.8.3.2 SuppressedError.prototype.message
SuppressedError.prototype.message의 초기 값은 빈 String입니다.
20.5.8.3.3 SuppressedError.prototype.name
SuppressedError.prototype.name의 초기 값은 "SuppressedError" 입니다.
20.5.8.4 SuppressedError 인스턴스의 프로퍼티
SuppressedError 인스턴스는 해당 SuppressedError 프로토타입 객체 에서 프로퍼티를 상속하고 값이 undefined 인 [[ErrorData]] 내부 슬롯을 갖는 일반 객체 입니다. [[ErrorData]] 의 유일한 명시된 용도는 Object.prototype.toString 및 Error.isError 안에서 Error, AggregateError, SuppressedError 및 NativeError 인스턴스를 Error 객체로 식별하는 것입니다.
20.5.9 Error 객체를 위한 추상 연산
20.5.9.1 InstallErrorCause ( obj , options )
추상 연산 InstallErrorCause. 인수 obj (Object) 및 options (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). options 에 "cause" 프로퍼티가 존재할 때 obj 에 "cause" 프로퍼티를 생성하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
options 가 Object이고 ? HasProperty (options , "cause" )가 true 이면, 다음을 수행합니다.cause 를 ? Get (options , "cause" )로 둡니다.CreateNonEnumerableDataPropertyOrThrow (obj , "cause" , cause )를 수행합니다.unused 를 반환합니다.
21 숫자와 날짜
21.1 Number 객체
21.1.1 Number 생성자
Number 생성자 는:
%Number% 입니다.
전역 객체 의 "Number" 프로퍼티 초기 값입니다.
생성자 로 호출되면 새로운 Number 객체를 생성하고 초기화합니다.
생성자 가 아니라 함수로 호출되면 타입 변환을 수행합니다.
클래스 정의의 extends 절 값으로 사용할 수 있습니다. 명시된 Number 동작을 상속하려는 하위 클래스 생성자 는 [[NumberData]] 내부 슬롯을 갖는 하위 클래스 인스턴스를 생성하고 초기화하기 위해 Number 생성자 에 대한 super 호출을 포함해야 합니다.
21.1.1.1 Number ( value )
이 함수는 호출되면 다음 단계를 수행합니다:
value 가 존재하면, 다음을 수행합니다.primitive 를 ? ToNumeric (value )으로 둡니다.primitive 가 BigInt이면 n 을 𝔽 (ℝ (primitive ))로 둡니다.그렇지 않으면 n 을 primitive 로 둡니다. 그렇지 않으면,n 을 +0 𝔽 으로 둡니다. NewTarget이 undefined 이면 n 을 반환합니다. obj 를 ? OrdinaryCreateFromConstructor (NewTarget, "%Number.prototype%" , « [[NumberData]] »)로 둡니다.obj .[[NumberData]] 를 n 으로 설정합니다.obj 를 반환합니다.
21.1.2 Number 생성자의 프로퍼티
Number 생성자 는:
21.1.2.1 Number.EPSILON
Number.EPSILON의 값은 1과 Number 값 으로 표현할 수 있는 1보다 큰 가장 작은 값의 차이의 크기에 해당하는 Number 값 이며, 약 2.2204460492503130808472633361816 × 10-16 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
21.1.2.2 Number.isFinite ( number )
이 함수는 호출될 때 다음 단계를 수행합니다:
number 가 유한 Number 이면 true 를 반환합니다.false 를 반환합니다.
21.1.2.3 Number.isInteger ( number )
이 함수는 호출될 때 다음 단계를 수행합니다:
number 가 정수 Number이면 true 를 반환합니다.false 를 반환합니다.
21.1.2.4 Number.isNaN ( number )
이 함수는 호출될 때 다음 단계를 수행합니다:
number 가 Number가 아니면 false 를 반환합니다.number 가 NaN 이면 true 를 반환합니다.false 를 반환합니다.
참고
이 함수는 인수가 NaN 인지 판별하기 전에 인수를 Number로 변환하지 않는다는 점에서 전역 isNaN 함수(19.2.3 )와 다릅니다.
21.1.2.5 Number.isSafeInteger ( number )
참고
정수 n 에 대한 Number 값 이 다른 어떤 정수 에 대한 Number 값 도 아닌 경우에만 정수 n 을 “안전한 정수 ”라고 합니다.
이 함수는 호출될 때 다음 단계를 수행합니다:
number 가 정수 Number이면 다음을 수행합니다.abs (ℝ (number )) ≤ 253 - 1이면 true 를 반환합니다.false 를 반환합니다.
21.1.2.6 Number.MAX_SAFE_INTEGER
참고
IEEE 754-2019 의 정밀도 제한으로 인해 필요한 반올림 동작 때문에 Number.MAX_SAFE_INTEGER보다 큰 모든 정수 에 대한 Number 값 은 적어도 하나의 다른 정수 와 공유됩니다. 따라서 이러한 큰 크기의 정수 는 안전하지 않으며, Number 값 으로 정확히 표현될 수 있거나 서로 구별될 수 있다고 보장되지 않습니다. 예를 들어 9007199254740992와 9007199254740993은 모두 Number 값 9007199254740992 𝔽 로 평가됩니다.
Number.MAX_SAFE_INTEGER의 값은 9007199254740991 𝔽 (𝔽 (253 - 1))입니다.
이 속성에는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 특성이 있습니다.
21.1.2.7 Number.MAX_VALUE
Number.MAX_VALUE의 값은 가장 큰 양의 유한 Number 이며, 대략 1.7976931348623157 × 10308 입니다.
이 속성에는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 특성이 있습니다.
21.1.2.8 Number.MIN_SAFE_INTEGER
참고
IEEE 754-2019 의 정밀도 제한으로 인해 필요한 반올림 동작 때문에 Number.MIN_SAFE_INTEGER보다 작은 모든 정수 에 대한 Number 값 은 적어도 하나의 다른 정수 와 공유됩니다. 따라서 이러한 큰 크기의 정수 는 안전하지 않으며, Number 값 으로 정확히 표현될 수 있거나 서로 구별될 수 있다고 보장되지 않습니다. 예를 들어 -9007199254740992와 -9007199254740993은 모두 Number 값 -9007199254740992 𝔽 로 평가됩니다.
Number.MIN_SAFE_INTEGER의 값은 -9007199254740991 𝔽 (𝔽 (-(253 - 1)))입니다.
이 속성에는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 특성이 있습니다.
21.1.2.9 Number.MIN_VALUE
Number.MIN_VALUE의 값은 Number 타입 의 가장 작은 양의 값이며, 대략 5 × 10-324 입니다.
IEEE 754-2019 배정밀도 이진 표현에서 가능한 가장 작은 값은 비정규화된 수입니다. 구현이 비정규화된 값을 지원하지 않는 경우 Number.MIN_VALUE의 값은 구현에서 실제로 표현할 수 있는 가장 작은 0이 아닌 양의 값이어야 합니다.
이 속성에는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 특성이 있습니다.
21.1.2.10 Number.NaN
Number.NaN의 값은 NaN 입니다.
이 속성에는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 특성이 있습니다.
21.1.2.11 Number.NEGATIVE_INFINITY
Number.NEGATIVE_INFINITY의 값은 -∞ 𝔽 입니다.
이 속성에는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 특성이 있습니다.
21.1.2.12 Number.parseFloat ( string )
"parseFloat" 속성의 초기값은 %parseFloat% 입니다.
21.1.2.13 Number.parseInt ( string , radix )
"parseInt" 속성의 초기값은 %parseInt% 입니다.
21.1.2.14 Number.POSITIVE_INFINITY
Number.POSITIVE_INFINITY의 값은 +∞ 𝔽 입니다.
이 속성에는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 특성이 있습니다.
21.1.2.15 Number.prototype
Number.prototype의 초기값은 Number 프로토타입 객체 입니다.
이 속성에는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 특성이 있습니다.
21.1.3 Number 프로토타입 객체의 속성
Number 프로토타입 객체 는 다음과 같습니다:
%Number.prototype% 입니다.
일반 객체 입니다.
그 자체가 Number 객체이며, 값이 +0 𝔽 인 [[NumberData]] 내부 슬롯을 가집니다.
값이 %Object.prototype% 인 [[Prototype]] 내부 슬롯을 가집니다.
명시적으로 달리 언급되지 않는 한, 아래에 정의된 Number 프로토타입 객체의 메서드는 제네릭이 아니며, 해당 메서드에 전달되는 this 값은 Number 값 또는 Number 값 으로 초기화된 [[NumberData]] 내부 슬롯을 가진 객체여야 합니다.
메서드 명세에서 “이 Number 값 ”이라는 구문은 메서드 호출의 this 값을 인수로 전달하여 추상 연산 ThisNumberValue 를 호출했을 때 반환되는 결과를 가리킵니다.
21.1.3.1 Number.prototype.constructor
Number.prototype.constructor의 초기값은 %Number% 입니다.
21.1.3.2 Number.prototype.toExponential ( fractionDigits )
이 메서드는 이 Number 값 을 유효숫자의 소수점 앞에 한 자리, 유효숫자의 소수점 뒤에 fractionDigits 자리 숫자가 있는 십진 지수 표기법으로 나타낸 String을 반환합니다. fractionDigits 가 undefined 이면 Number를 고유하게 지정하는 데 필요한 만큼의 유효숫자를 포함합니다(ToString 과 같지만 이 경우 Number는 항상 지수 표기법으로 출력됩니다).
호출될 때 다음 단계를 수행합니다:
number 를 ? ThisNumberValue (this 값)으로 둡니다.fractionCount 를 ? ToIntegerOrInfinity (fractionDigits )로 둡니다.단언 : fractionDigits 가 undefined 이면 fractionCount 는 0입니다.number 가 유한 Number 가 아니면 Number::toString (number , 10)을 반환합니다.fractionCount 가 정수 가 아니면 RangeError 예외를 던집니다.fractionCount < 0 또는 fractionCount > 100이면 RangeError 예외를 던집니다.number 를 ℝ (number )로 설정합니다.sign 을 빈 String으로 둡니다.number < 0이면 다음을 수행합니다.sign 을 "-" 로 설정합니다.number 를 -number 로 설정합니다.number = 0이면 다음을 수행합니다.significand 를 코드 단위 0x0030 (DIGIT ZERO)이 fractionCount + 1회 나타나는 String 값으로 둡니다.exponent 를 0으로 둡니다.그렇지 않으면,fractionDigits 가 undefined 가 아니면 다음을 수행합니다.exponent 와 intSignificand 를 10fractionCount ≤ intSignificand < 10fractionCount + 1 이고 intSignificand × 10exponent - fractionCount - number 가 가능한 한 0에 가까워지는 정수 로 둡니다. 이러한 exponent 와 intSignificand 의 쌍이 두 개 있으면 intSignificand × 10exponent - fractionCount 가 더 큰 exponent 와 intSignificand 를 선택합니다.그렇지 않으면,exponent , intSignificand , ff 를 ff ≥ 0, 10ff ≤ intSignificand < 10ff + 1 , 𝔽 (intSignificand × 10exponent - ff )가 𝔽 (number )이고 ff 가 가능한 한 작은 정수 로 둡니다. intSignificand 의 십진 표현은 ff + 1자리 숫자를 가지며, intSignificand 는 10으로 나누어떨어지지 않고, intSignificand 의 최하위 숫자가 이러한 기준에 의해 반드시 고유하게 결정되는 것은 아니라는 점에 유의하십시오.fractionCount 를 ff 로 설정합니다. significand 를 intSignificand 의 십진 표현 숫자들로 구성된 String 값으로 둡니다(순서대로, 선행 0 없이). fractionCount ≠ 0이면 다음을 수행합니다.intPart 를 significand 의 첫 번째 코드 단위로 둡니다.fractionalPart 를 significand 의 나머지 fractionCount 개 코드 단위로 둡니다.significand 를 intPart , "." , fractionalPart 의 문자열 연결 로 설정합니다.exponent = 0이면 다음을 수행합니다.exponentSign 을 "+" 로 둡니다.exponentDigits 를 "0" 으로 둡니다.그렇지 않으면,exponent > 0이면 다음을 수행합니다.exponentSign 을 "+" 로 둡니다.그렇지 않으면,단언 : exponent < 0입니다.exponentSign 을 "-" 로 둡니다.exponent 를 -exponent 로 설정합니다. exponentDigits 를 exponent 의 십진 표현 숫자들로 구성된 String 값으로 둡니다(순서대로, 선행 0 없이). significand 를 significand , "e" , exponentSign , exponentDigits 의 문자열 연결 로 설정합니다.sign 과 significand 의 문자열 연결 을 반환합니다.
참고
위 규칙에서 요구하는 것보다 더 정확한 변환을 제공하는 구현의 경우, 11.b.i 단계의 다음 대체 버전을 지침으로 사용하는 것이 권장됩니다:
exponent , intSignificand , ff 를 ff ≥ 0, 10ff ≤ intSignificand < 10ff + 1 , 𝔽 (intSignificand × 10exponent - ff )가 𝔽 (number )이고 ff 가 가능한 한 작은 정수 로 둡니다. intSignificand 에 여러 가능성이 있으면 𝔽 (intSignificand × 10exponent - ff )가 𝔽 (number )에 가장 가까워지는 intSignificand 를 선택합니다. 이러한 가능한 intSignificand 값이 두 개 있으면 짝수인 값을 선택합니다.
21.1.3.3 Number.prototype.toFixed ( fractionDigits )
참고 1
이 메서드는 이 Number 값 을 소수점 뒤에 fractionDigits 자리 숫자가 있는 십진 고정 소수점 표기법으로 나타낸 String을 반환합니다. fractionDigits 가 undefined 이면 0으로 간주합니다.
호출될 때 다음 단계를 수행합니다:
number 를 ? ThisNumberValue (this 값)으로 둡니다.fractionCount 를 ? ToIntegerOrInfinity (fractionDigits )로 둡니다.단언 : fractionDigits 가 undefined 이면 fractionCount 는 0입니다.fractionCount 가 정수 가 아니면 RangeError 예외를 던집니다.fractionCount < 0 또는 fractionCount > 100이면 RangeError 예외를 던집니다.number 가 유한 Number 가 아니면 Number::toString (number , 10)을 반환합니다.number 를 ℝ (number )로 설정합니다.sign 을 빈 String으로 둡니다.number < 0이면 다음을 수행합니다.sign 을 "-" 로 설정합니다.number 를 -number 로 설정합니다.number ≥ 1021 이면 다음을 수행합니다.digitString 을 ! ToString (𝔽 (number ))으로 둡니다.그렇지 않으면,intValue 를 intValue / 10fractionCount - number 가 가능한 한 0에 가까워지는 정수 로 둡니다. 이러한 intValue 가 두 개 있으면 더 큰 intValue 를 선택합니다.intValue = 0이면 digitString 을 "0" 으로 둡니다. 그렇지 않으면 digitString 을 intValue 의 십진 표현 숫자들로 구성된 String 값으로 둡니다(순서대로, 선행 0 없이).fractionCount ≠ 0이면 다음을 수행합니다.digitCount 를 digitString 의 길이로 둡니다.digitCount ≤ fractionCount 이면 다음을 수행합니다.zeroPad 를 코드 단위 0x0030 (DIGIT ZERO)이 fractionCount + 1 - digitCount 회 나타나는 String 값으로 둡니다.digitString 을 zeroPad 와 digitString 의 문자열 연결 로 설정합니다.digitCount 를 fractionCount + 1로 설정합니다.intPart 를 digitString 의 처음 digitCount - fractionCount 개 코드 단위로 둡니다.fractionalPart 를 digitString 의 나머지 fractionCount 개 코드 단위로 둡니다.digitString 을 intPart , "." , fractionalPart 의 문자열 연결 로 설정합니다. sign 과 digitString 의 문자열 연결 을 반환합니다.
참고 2
toString은 숫자를 인접한 Number 값 과 구별하는 데 충분한 유효숫자만 출력하므로 일부 값에서는 toFixed의 출력이 toString보다 더 정밀할 수 있습니다. 예를 들어,
(1000000000000000128).toString()은 "1000000000000000100" 을 반환하지만,
(1000000000000000128).toFixed(0)은 "1000000000000000128" 을 반환합니다.
21.1.3.4 Number.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )
ECMA-402 국제화 API를 포함하는 ECMAScript 구현은 ECMA-402에 명시된 대로 이 메서드를 구현해야 합니다. 그렇지 않으면 다음과 같은 이 메서드의 명세를 사용합니다:
이 메서드는 호스트 환경 의 현재 로캘 규칙에 따라 형식화된 이 Number 값 을 나타내는 String 값을 생성합니다. 이 메서드는 구현 정의이며, 권장되지는 않지만 toString과 동일한 값을 반환하는 것도 허용됩니다.
이 메서드의 선택적 매개변수의 의미는 ECMA-402에 정의되어 있습니다. ECMA-402 지원을 포함하지 않는 구현은 해당 매개변수 위치를 다른 용도로 사용해서는 안 됩니다.
21.1.3.5 Number.prototype.toPrecision ( precision )
이 메서드는 이 Number 값 을 유효숫자의 소수점 앞에 한 자리, 유효숫자의 소수점 뒤에 precision - 1 자리 숫자가 있는 십진 지수 표기법 또는 precision 개의 유효숫자가 있는 십진 고정 표기법으로 나타낸 String을 반환합니다. precision 이 undefined 이면 대신 ToString 을 호출합니다.
호출될 때 다음 단계를 수행합니다:
number 를 ? ThisNumberValue (this 값)으로 둡니다.precision 이 undefined 이면 ! ToString (number )을 반환합니다.precisionCount 를 ? ToIntegerOrInfinity (precision )로 둡니다.number 가 유한 Number 가 아니면 Number::toString (number , 10)을 반환합니다.precisionCount 가 정수 가 아니면 RangeError 예외를 던집니다.precisionCount < 1 또는 precisionCount > 100이면 RangeError 예외를 던집니다.number 를 ℝ (number )로 설정합니다.sign 을 빈 String으로 둡니다.number < 0이면 다음을 수행합니다.sign 을 코드 단위 0x002D (HYPHEN-MINUS)로 설정합니다.number 를 -number 로 설정합니다.number = 0이면 다음을 수행합니다.significand 를 코드 단위 0x0030 (DIGIT ZERO)이 precisionCount 회 나타나는 String 값으로 둡니다.exponent 를 0으로 둡니다.그렇지 않으면,exponent 와 intSignificand 를 10precisionCount - 1 ≤ intSignificand < 10precisionCount 이고 intSignificand × 10exponent - precisionCount + 1 - number 가 가능한 한 0에 가까워지는 정수 로 둡니다. 이러한 exponent 와 intSignificand 의 쌍이 두 개 있으면 intSignificand × 10exponent - precisionCount + 1 이 더 큰 exponent 와 intSignificand 를 선택합니다.significand 를 intSignificand 의 십진 표현 숫자들로 구성된 String 값으로 둡니다(순서대로, 선행 0 없이).exponent < -6 또는 exponent ≥ precisionCount 이면 다음을 수행합니다.단언 : exponent ≠ 0입니다.precisionCount ≠ 1이면 다음을 수행합니다.intPart 를 significand 의 첫 번째 코드 단위로 둡니다.fractionalPart 를 significand 의 나머지 precisionCount - 1개 코드 단위로 둡니다.significand 를 intPart , "." , fractionalPart 의 문자열 연결 로 설정합니다.exponent > 0이면 다음을 수행합니다.exponentSign 을 코드 단위 0x002B (PLUS SIGN)로 둡니다.그렇지 않으면,단언 : exponent < 0입니다.exponentSign 을 코드 단위 0x002D (HYPHEN-MINUS)로 둡니다.exponent 를 -exponent 로 설정합니다. exponentDigits 를 exponent 의 십진 표현 숫자들로 구성된 String 값으로 둡니다(순서대로, 선행 0 없이).sign , significand , 코드 단위 0x0065 (LATIN SMALL LETTER E), exponentSign , exponentDigits 의 문자열 연결 을 반환합니다. exponent = precisionCount - 1이면 sign 과 significand 의 문자열 연결 을 반환합니다.exponent ≥ 0이면 다음을 수행합니다.significand 를 significand 의 처음 exponent + 1개 코드 단위, 코드 단위 0x002E (FULL STOP), 나머지 precisionCount - (exponent + 1)개 코드 단위의 문자열 연결 로 설정합니다.그렇지 않으면,significand 를 코드 단위 0x0030 (DIGIT ZERO), 코드 단위 0x002E (FULL STOP), 코드 단위 0x0030 (DIGIT ZERO)의 -(exponent + 1)회 반복, String significand 의 문자열 연결 로 설정합니다. sign 과 significand 의 문자열 연결 을 반환합니다.
21.1.3.6 Number.prototype.toString ( [ radix ] )
참고
선택적 radix 는 2 𝔽 부터 36 𝔽 까지의 양 끝을 포함하는 구간 에 있는 정수 Number 값 이어야 합니다. radix 가 undefined 이면 10 𝔽 을 radix 의 값으로 사용합니다.
이 메서드는 호출될 때 다음 단계를 수행합니다:
x 를 ? ThisNumberValue (this 값)으로 둡니다.radix 가 undefined 이면 radixMV 를 10으로 둡니다.그렇지 않으면 radixMV 를 ? SnapToInteger (radix , truncate , 2, 36)로 둡니다. Number::toString (x , radixMV )을 반환합니다.
이 메서드는 제네릭이 아닙니다. this 값이 Number 또는 Number 객체가 아니면 TypeError 예외를 던집니다. 따라서 메서드로 사용하기 위해 다른 종류의 객체로 전송할 수 없습니다.
이 메서드의 "length" 속성은 1 𝔽 입니다.
21.1.3.7 Number.prototype.valueOf ( )
? ThisNumberValue (this 값)을 반환합니다.
21.1.3.7.1 ThisNumberValue ( arg )
추상 연산 ThisNumberValue. 인수 arg (ECMAScript 언어 값 ). 반환값: Number를 포함하는 정상 완료 또는 throw 완료 . 호출되면 다음 단계를 수행한다.
arg 가 Number이면 arg 를 반환합니다.arg 가 Object이고 arg 에 [[NumberData]] 내부 슬롯이 있으면 다음을 수행합니다.number 를 arg .[[NumberData]] 로 둡니다.단언 : number 는 Number입니다.number 를 반환합니다.TypeError 예외를 던집니다.
21.1.4 Number 인스턴스의 속성
Number 인스턴스는 Number 프로토타입 객체 에서 속성을 상속하는 일반 객체 입니다. Number 인스턴스에는 [[NumberData]] 내부 슬롯도 있습니다. [[NumberData]] 내부 슬롯은 이 Number 객체가 나타내는 Number 값 입니다.
21.2 BigInt 객체
21.2.1 BigInt 생성자
BigInt 생성자 는 다음과 같습니다:
%BigInt% 입니다.
전역 객체 의 "BigInt" 속성의 초기값입니다.
생성자 가 아니라 함수로 호출될 때 타입 변환을 수행합니다.
new 연산자와 함께 사용하거나 서브클래싱하는 용도로 의도되지 않았습니다. 클래스 정의의 extends 절의 값으로 사용할 수 있지만 BigInt 생성자 에 대한 super 호출은 예외를 발생시킵니다.
21.2.1.1 BigInt ( value )
이 함수는 호출될 때 다음 단계를 수행합니다:
NewTarget이 undefined 가 아니면 TypeError 예외를 던집니다. primitive 를 ? ToPrimitive (value , number )로 둡니다.primitive 가 Number이면 ? NumberToBigInt (primitive )를 반환합니다.? ToBigInt (primitive )를 반환합니다.
21.2.1.1.1 NumberToBigInt ( number )
추상 연산 NumberToBigInt. 인수 number (Number). 반환값: BigInt를 포함하는 정상 완료 또는 throw 완료 . 호출되면 다음 단계를 수행한다.
number 가 정수 Number가 아니면 RangeError 예외를 던집니다.ℤ (ℝ (number ))를 반환합니다.
21.2.2 BigInt 생성자의 속성
BigInt 생성자 는 다음과 같습니다:
21.2.2.1 BigInt.asIntN ( bits , bigint )
이 함수는 호출될 때 다음 단계를 수행합니다:
bits 를 ? ToIndex (bits )로 설정합니다.bigint 를 ? ToBigInt (bigint )로 설정합니다.remainder 를 ℝ (bigint ) modulo 2bits 로 둡니다.remainder ≥ 2bits - 1 이면 ℤ (remainder - 2bits )를 반환합니다.ℤ (remainder )를 반환합니다.
21.2.2.2 BigInt.asUintN ( bits , bigint )
이 함수는 호출될 때 다음 단계를 수행합니다:
bits 를 ? ToIndex (bits )로 설정합니다.bigint 를 ? ToBigInt (bigint )로 설정합니다.ℤ (ℝ (bigint ) modulo 2bits )를 반환합니다.
21.2.2.3 BigInt.prototype
BigInt.prototype의 초기값은 BigInt 프로토타입 객체 입니다.
이 속성에는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 특성이 있습니다.
21.2.3 BigInt 프로토타입 객체의 속성
BigInt 프로토타입 객체 는 다음과 같습니다:
%BigInt.prototype% 입니다.
일반 객체 입니다.
BigInt 객체가 아니며 [[BigIntData]] 내부 슬롯을 가지지 않습니다.
값이 %Object.prototype% 인 [[Prototype]] 내부 슬롯을 가집니다.
메서드 명세에서 “이 BigInt 값 ”이라는 구문은 메서드 호출의 this 값을 인수로 전달하여 추상 연산 ThisBigIntValue 를 호출했을 때 반환되는 결과를 가리킵니다.
21.2.3.1 BigInt.prototype.constructor
BigInt.prototype.constructor의 초기값은 %BigInt% 입니다.
21.2.3.2 BigInt.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )
ECMA-402 국제화 API를 포함하는 ECMAScript 구현은 ECMA-402에 명시된 대로 이 메서드를 구현해야 합니다. 그렇지 않으면 다음과 같은 이 메서드의 명세를 사용합니다:
이 메서드는 호스트 환경 의 현재 로캘 규칙에 따라 형식화된 이 BigInt 값 을 나타내는 String 값을 생성합니다. 이 메서드는 구현 정의이며, 권장되지는 않지만 toString과 동일한 값을 반환하는 것도 허용됩니다.
이 메서드의 선택적 매개변수의 의미는 ECMA-402에 정의되어 있습니다. ECMA-402 지원을 포함하지 않는 구현은 해당 매개변수 위치를 다른 용도로 사용해서는 안 됩니다.
21.2.3.3 BigInt.prototype.toString ( [ radix ] )
참고
선택적 radix 는 2 𝔽 부터 36 𝔽 까지의 양 끝을 포함하는 구간 에 있는 정수 Number 값 이어야 합니다. radix 가 undefined 이면 10 𝔽 을 radix 의 값으로 사용합니다.
이 메서드는 호출될 때 다음 단계를 수행합니다:
x 를 ? ThisBigIntValue (this 값)으로 둡니다.radix 가 undefined 이면 radixMV 를 10으로 둡니다.그렇지 않으면 radixMV 를 ? SnapToInteger (radix , truncate , 2, 36)로 둡니다. BigInt::toString (x , radixMV )을 반환합니다.
이 메서드는 제네릭이 아닙니다. this 값이 BigInt 또는 BigInt 객체가 아니면 TypeError 예외를 던집니다. 따라서 메서드로 사용하기 위해 다른 종류의 객체로 전송할 수 없습니다.
21.2.3.4 BigInt.prototype.valueOf ( )
? ThisBigIntValue (this 값)을 반환합니다.
21.2.3.4.1 ThisBigIntValue ( arg )
추상 연산 ThisBigIntValue. 인수 arg (ECMAScript 언어 값 ). 반환값: BigInt를 포함하는 정상 완료 또는 throw 완료 . 호출되면 다음 단계를 수행한다.
arg 가 BigInt이면 arg 를 반환합니다.arg 가 Object이고 arg 에 [[BigIntData]] 내부 슬롯이 있으면 다음을 수행합니다.단언 : arg .[[BigIntData]] 는 BigInt입니다.arg .[[BigIntData]] 를 반환합니다.TypeError 예외를 던집니다.
21.2.3.5 BigInt.prototype [ %Symbol.toStringTag% ]
%Symbol.toStringTag% 속성의 초기값은 String 값 "BigInt" 입니다.
이 속성에는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 특성이 있습니다.
21.2.4 BigInt 인스턴스의 속성
BigInt 인스턴스는 BigInt 프로토타입 객체 에서 속성을 상속하는 일반 객체 입니다. BigInt 인스턴스에는 [[BigIntData]] 내부 슬롯도 있습니다. [[BigIntData]] 내부 슬롯은 이 BigInt 객체가 나타내는 BigInt 값 입니다.
21.3 Math 객체
Math 객체는 다음과 같습니다:
%Math% 입니다.
전역 객체 의 "Math" 속성의 초기값입니다.
일반 객체 입니다.
값이 %Object.prototype% 인 [[Prototype]] 내부 슬롯을 가집니다.
함수 객체 가 아닙니다.
[[Construct]] 내부 메서드를 가지지 않으므로 new 연산자와 함께 생성자 로 사용할 수 없습니다.
[[Call]] 내부 메서드를 가지지 않으므로 함수로 호출할 수 없습니다.
참고
이 명세에서 “x 에 대한 Number 값 ”이라는 구문은 6.1.6.1 에 정의된 기술적 의미를 가집니다.
21.3.1 Math 객체의 값 속성
21.3.1.1 Math.E
자연로그의 밑인 e 에 대한 Number 값 이며, 대략 2.7182818284590452354입니다.
이 속성에는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 특성이 있습니다.
21.3.1.2 Math.LN10
10의 자연로그에 대한 Number 값 이며, 대략 2.302585092994046입니다.
이 속성에는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 특성이 있습니다.
21.3.1.3 Math.LN2
2의 자연로그에 대한 Number 값 이며, 대략 0.6931471805599453입니다.
이 속성에는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 특성이 있습니다.
21.3.1.4 Math.LOG10E
자연로그의 밑인 e 의 밑이 10인 로그에 대한 Number 값 이며, 이 값은 대략 0.4342944819032518입니다.
이 속성에는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 특성이 있습니다.
참고
Math.LOG10E의 값은 Math.LN10 값의 역수와 대략 같습니다.
21.3.1.5 Math.LOG2E
자연로그의 밑인 e 의 밑이 2인 로그에 대한 Number 값 이며, 이 값은 대략 1.4426950408889634입니다.
이 속성에는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 특성이 있습니다.
참고
Math.LOG2E의 값은 Math.LN2 값의 역수와 대략 같습니다.
21.3.1.6 Math.PI
원의 지름에 대한 둘레의 비율인 π에 대한 Number 값 이며, 대략 3.1415926535897932입니다.
이 속성에는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 특성이 있습니다.
21.3.1.7 Math.SQRT1_2
½의 제곱근에 대한 Number 값 이며, 대략 0.7071067811865476입니다.
이 속성에는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 특성이 있습니다.
참고
Math.SQRT1_2의 값은 Math.SQRT2 값의 역수와 대략 같습니다.
21.3.1.8 Math.SQRT2
2의 제곱근에 대한 Number 값 이며, 대략 1.4142135623730951입니다.
이 속성에는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 특성이 있습니다.
21.3.1.9 Math [ %Symbol.toStringTag% ]
%Symbol.toStringTag% 속성의 초기값은 String 값 "Math" 입니다.
이 속성에는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 특성이 있습니다.
21.3.2 Math 객체의 함수 속성
참고
acos, acosh, asin, asinh, atan, atanh, atan2, cbrt, cos, cosh, exp, expm1, hypot, log, log1p, log2, log10, pow, random, sin, sinh, tan, tanh 함수의 동작은 관심 있는 경계 사례를 나타내는 특정 인수 값에 대해 특정 결과를 요구하는 것을 제외하고는 여기에서 정확히 명시되지 않습니다. 다른 인수 값에 대해 이러한 함수는 익숙한 수학 함수의 결과에 대한 근삿값을 계산하도록 의도되지만, 근사 알고리즘의 선택에는 어느 정도의 재량이 허용됩니다. 일반적인 의도는 구현자가 특정 하드웨어 플랫폼에서 ECMAScript에 대해 해당 플랫폼의 C 프로그래머가 사용할 수 있는 것과 동일한 수학 라이브러리를 사용할 수 있도록 하는 것입니다.
알고리즘의 선택은 구현에 맡겨져 있지만, 구현에서는 Sun Microsystems의 자유롭게 배포 가능한 수학 라이브러리인 fdlibm에 포함된 IEEE 754-2019 산술용 근사 알고리즘을 사용하는 것이 권장됩니다(다만 이 표준에서 명시하는 것은 아닙니다)(http://www.netlib.org/fdlibm ).
21.3.2.1 Math.abs ( x )
이 함수는 x 의 절댓값을 반환합니다. 결과는 x 와 크기가 같지만 양의 부호를 가집니다.
호출될 때 다음 단계를 수행합니다:
n 을 ? ToNumber (x )로 둡니다.n 이 NaN 이면 NaN 을 반환합니다.n 이 -0 𝔽 이면 +0 𝔽 을 반환합니다.n 이 -∞ 𝔽 이면 +∞ 𝔽 을 반환합니다.n < -0 𝔽 이면 -n 을 반환합니다.n 을 반환합니다.
21.3.2.2 Math.acos ( x )
이 함수는 x 의 아크코사인을 반환합니다. 결과는 라디안으로 표현되며 +0 𝔽 부터 𝔽 (π)까지의 양 끝을 포함하는 구간 에 있습니다.
호출될 때 다음 단계를 수행합니다:
n 을 ? ToNumber (x )로 둡니다.n 이 NaN 이거나, n > 1 𝔽 이거나, n < -1 𝔽 이면 NaN 을 반환합니다.n 이 1 𝔽 이면 +0 𝔽 을 반환합니다.ℝ (n )의 아크코사인을 나타내는 구현에서 근사한 Number 값 을 반환합니다.
21.3.2.3 Math.acosh ( x )
이 함수는 x 의 역쌍곡코사인을 반환합니다.
호출될 때 다음 단계를 수행합니다:
n 을 ? ToNumber (x )로 둡니다.n 이 NaN 또는 +∞ 𝔽 중 하나이면 n 을 반환합니다.n 이 1 𝔽 이면 +0 𝔽 을 반환합니다.n < 1 𝔽 이면 NaN 을 반환합니다.ℝ (n )의 역쌍곡코사인을 나타내는 구현에서 근사한 Number 값 을 반환합니다.
21.3.2.4 Math.asin ( x )
이 함수는 x 의 아크사인을 반환합니다. 결과는 라디안으로 표현되며 𝔽 (-π / 2)부터 𝔽 (π / 2)까지의 양 끝을 포함하는 구간 에 있습니다.
호출될 때 다음 단계를 수행합니다:
n 을 ? ToNumber (x )로 둡니다.n 이 NaN , +0 𝔽 , -0 𝔽 중 하나이면 n 을 반환합니다.n > 1 𝔽 또는 n < -1 𝔽 이면 NaN 을 반환합니다.ℝ (n )의 아크사인을 나타내는 구현에서 근사한 Number 값 을 반환합니다.
21.3.2.5 Math.asinh ( x )
이 함수는 x 의 역쌍곡사인을 반환합니다.
호출될 때 다음 단계를 수행합니다:
n 을 ? ToNumber (x )로 둡니다.n 이 유한 Number 가 아니거나 n 이 +0 𝔽 또는 -0 𝔽 중 하나이면 n 을 반환합니다.ℝ (n )의 역쌍곡사인을 나타내는 구현에서 근사한 Number 값 을 반환합니다.
21.3.2.6 Math.atan ( x )
이 함수는 x 의 아크탄젠트를 반환합니다. 결과는 라디안으로 표현되며 𝔽 (-π / 2)부터 𝔽 (π / 2)까지의 양 끝을 포함하는 구간 에 있습니다.
호출될 때 다음 단계를 수행합니다:
n 을 ? ToNumber (x )로 둡니다.n 이 NaN , +0 𝔽 , -0 𝔽 중 하나이면 n 을 반환합니다.n 이 +∞ 𝔽 이면 π / 2를 나타내는 구현에서 근사한 Number 값 을 반환합니다.n 이 -∞ 𝔽 이면 -π / 2를 나타내는 구현에서 근사한 Number 값 을 반환합니다.ℝ (n )의 아크탄젠트를 나타내는 구현에서 근사한 Number 값 을 반환합니다.
21.3.2.7 Math.atanh ( x )
이 함수는 x 의 역쌍곡탄젠트를 반환합니다.
호출될 때 다음 단계를 수행합니다:
n 을 ? ToNumber (x )로 둡니다.n 이 NaN , +0 𝔽 , -0 𝔽 중 하나이면 n 을 반환합니다.n > 1 𝔽 또는 n < -1 𝔽 이면 NaN 을 반환합니다.n 이 1 𝔽 이면 +∞ 𝔽 을 반환합니다.n 이 -1 𝔽 이면 -∞ 𝔽 을 반환합니다.ℝ (n )의 역쌍곡탄젠트를 나타내는 구현에서 근사한 Number 값 을 반환합니다.
21.3.2.8 Math.atan2 ( y , x )
이 함수는 인수 y 와 x 의 몫 y / x 의 아크탄젠트를 반환하며, 여기서 y 와 x 의 부호를 사용하여 결과의 사분면을 결정합니다. 두 인수를 받는 아크탄젠트 함수에서 y 라는 이름의 인수가 첫 번째이고 x 라는 이름의 인수가 두 번째인 것은 의도적이며 전통적인 방식이라는 점에 유의하십시오. 결과는 라디안으로 표현되며 -π부터 +π까지의 양 끝을 포함하는 구간 에 있습니다.
호출될 때 다음 단계를 수행합니다:
ny 를 ? ToNumber (y )로 둡니다.nx 를 ? ToNumber (x )로 둡니다.ny 가 NaN 이거나 nx 가 NaN 이면 NaN 을 반환합니다.ny 가 +∞ 𝔽 이면 다음을 수행합니다.nx 가 +∞ 𝔽 이면 π / 4를 나타내는 구현에서 근사한 Number 값 을 반환합니다.nx 가 -∞ 𝔽 이면 3π / 4를 나타내는 구현에서 근사한 Number 값 을 반환합니다.π / 2를 나타내는 구현에서 근사한 Number 값 을 반환합니다. ny 가 -∞ 𝔽 이면 다음을 수행합니다.nx 가 +∞ 𝔽 이면 -π / 4를 나타내는 구현에서 근사한 Number 값 을 반환합니다.nx 가 -∞ 𝔽 이면 -3π / 4를 나타내는 구현에서 근사한 Number 값 을 반환합니다.-π / 2를 나타내는 구현에서 근사한 Number 값 을 반환합니다. ny 가 +0 𝔽 이면 다음을 수행합니다.nx > +0 𝔽 이거나 nx 가 +0 𝔽 이면 +0 𝔽 을 반환합니다.π를 나타내는 구현에서 근사한 Number 값 을 반환합니다. ny 가 -0 𝔽 이면 다음을 수행합니다.nx > +0 𝔽 이거나 nx 가 +0 𝔽 이면 -0 𝔽 을 반환합니다.-π를 나타내는 구현에서 근사한 Number 값 을 반환합니다. 단언 : ny 는 유한 Number 이며 +0 𝔽 도 -0 𝔽 도 아닙니다.ny > +0 𝔽 이면 다음을 수행합니다.nx 가 +∞ 𝔽 이면 +0 𝔽 을 반환합니다.nx 가 -∞ 𝔽 이면 π를 나타내는 구현에서 근사한 Number 값 을 반환합니다.nx 가 +0 𝔽 또는 -0 𝔽 중 하나이면 π / 2를 나타내는 구현에서 근사한 Number 값 을 반환합니다.ny < -0 𝔽 이면 다음을 수행합니다.nx 가 +∞ 𝔽 이면 -0 𝔽 을 반환합니다.nx 가 -∞ 𝔽 이면 -π를 나타내는 구현에서 근사한 Number 값 을 반환합니다.nx 가 +0 𝔽 또는 -0 𝔽 중 하나이면 -π / 2를 나타내는 구현에서 근사한 Number 값 을 반환합니다.단언 : nx 는 유한 Number 이며 +0 𝔽 도 -0 𝔽 도 아닙니다.result 를 abs (ℝ (ny ) / ℝ (nx ))의 아크탄젠트로 둡니다.nx < -0 𝔽 이면 다음을 수행합니다.ny > +0 𝔽 이면 result 를 π - result 로 설정합니다.그렇지 않으면 result 를 -π + result 로 설정합니다. 그렇지 않으면,ny < -0 𝔽 이면 result 를 -result 로 설정합니다. result 를 나타내는 구현에서 근사한 Number 값 을 반환합니다.
21.3.2.9 Math.cbrt ( x )
이 함수는 x 의 세제곱근을 반환합니다.
호출될 때 다음 단계를 수행합니다:
n 을 ? ToNumber (x )로 둡니다.n 이 유한 Number 가 아니거나 n 이 +0 𝔽 또는 -0 𝔽 중 하나이면 n 을 반환합니다.ℝ (n )의 세제곱근을 나타내는 구현에서 근사한 Number 값 을 반환합니다.
21.3.2.10 Math.ceil ( x )
이 함수는 x 보다 작지 않은 가장 작은(-∞에 가장 가까운) 정수 Number 값 을 반환합니다. x 가 이미 정수 Number이면 결과는 x 입니다.
호출될 때 다음 단계를 수행합니다:
n 을 ? ToNumber (x )로 둡니다.n 이 유한 Number 가 아니거나 n 이 +0 𝔽 또는 -0 𝔽 중 하나이면 n 을 반환합니다.n < -0 𝔽 이고 n > -1 𝔽 이면 -0 𝔽 을 반환합니다.n 이 정수 Number이면 n 을 반환합니다.n 보다 작지 않은 가장 작은(-∞에 가장 가까운) 정수 Number 값 을 반환합니다.
참고
Math.ceil(x)의 값은 -Math.floor(-x)의 값과 같습니다.
21.3.2.11 Math.clz32 ( x )
이 함수는 호출될 때 다음 단계를 수행합니다:
n 을 ? ToUint32 (x )로 둡니다.p 를 n 의 부호 없는 32비트 이진 표현에서 선행 0 비트의 수로 둡니다.𝔽 (p )를 반환합니다.
참고
n 이 +0 𝔽 또는 -0 𝔽 중 하나이면 이 메서드는 32 𝔽 를 반환합니다. n 의 32비트 이진 인코딩에서 최상위 비트가 1이면 이 메서드는 +0 𝔽 을 반환합니다.
21.3.2.12 Math.cos ( x )
이 함수는 x 의 코사인을 반환합니다. 인수는 라디안으로 표현됩니다.
호출될 때 다음 단계를 수행합니다:
n 을 ? ToNumber (x )로 둡니다.n 이 유한 Number 가 아니면 NaN 을 반환합니다.n 이 +0 𝔽 또는 -0 𝔽 중 하나이면 1 𝔽 을 반환합니다.ℝ (n )의 코사인을 나타내는 구현에서 근사한 Number 값 을 반환합니다.
21.3.2.13 Math.cosh ( x )
이 함수는 x 의 쌍곡코사인을 반환합니다.
호출될 때 다음 단계를 수행합니다:
n 을 ? ToNumber (x )로 둡니다.n 이 NaN 이면 NaN 을 반환합니다.n 이 +∞ 𝔽 또는 -∞ 𝔽 중 하나이면 +∞ 𝔽 을 반환합니다.n 이 +0 𝔽 또는 -0 𝔽 중 하나이면 1 𝔽 을 반환합니다.ℝ (n )의 쌍곡코사인을 나타내는 구현에서 근사한 Number 값 을 반환합니다.
참고
Math.cosh(x)의 값은 (Math.exp(x) + Math.exp(-x)) / 2의 값과 같습니다.
21.3.2.14 Math.exp ( x )
이 함수는 x 의 지수 함수(자연로그의 밑인 e 를 x 제곱한 값)를 반환합니다.
호출될 때 다음 단계를 수행합니다:
n 을 ? ToNumber (x )로 둡니다.n 이 NaN 또는 +∞ 𝔽 중 하나이면 n 을 반환합니다.n 이 +0 𝔽 또는 -0 𝔽 중 하나이면 1 𝔽 을 반환합니다.n 이 -∞ 𝔽 이면 +0 𝔽 을 반환합니다.ℝ (n )의 지수 함수를 나타내는 구현에서 근사한 Number 값 을 반환합니다.
21.3.2.15 Math.expm1 ( x )
이 함수는 x 의 지수 함수(자연로그의 밑인 e 를 x 제곱한 값)에서 1을 뺀 결과를 반환합니다. 결과는 x 의 값이 0에 가까운 경우에도 정확하도록 계산됩니다.
호출될 때 다음 단계를 수행합니다:
n 을 ? ToNumber (x )로 둡니다.n 이 NaN , +0 𝔽 , -0 𝔽 , +∞ 𝔽 중 하나이면 n 을 반환합니다.n 이 -∞ 𝔽 이면 -1 𝔽 을 반환합니다.exp 를 ℝ (n )의 지수 함수로 둡니다.exp - 1을 나타내는 구현에서 근사한 Number 값 을 반환합니다.
21.3.2.16 Math.floor ( x )
이 함수는 x 보다 크지 않은 가장 큰(+∞에 가장 가까운) 정수 Number 값 을 반환합니다. x 가 이미 정수 Number이면 결과는 x 입니다.
호출될 때 다음 단계를 수행합니다:
n 을 ? ToNumber (x )로 둡니다.n 이 유한 Number 가 아니거나 n 이 +0 𝔽 또는 -0 𝔽 중 하나이면 n 을 반환합니다.n < 1 𝔽 이고 n > +0 𝔽 이면 +0 𝔽 을 반환합니다.n 이 정수 Number이면 n 을 반환합니다.n 보다 크지 않은 가장 큰(+∞에 가장 가까운) 정수 Number 값 을 반환합니다.
참고
Math.floor(x)의 값은 -Math.ceil(-x)의 값과 같습니다.
21.3.2.17 Math.fround ( x )
이 함수는 호출될 때 다음 단계를 수행합니다:
n 을 ? ToNumber (x )로 둡니다.n 이 NaN 이면 NaN 을 반환합니다.n 이 +0 𝔽 , -0 𝔽 , +∞ 𝔽 , -∞ 𝔽 중 하나이면 n 을 반환합니다.n32 를 roundTiesToEven 모드를 사용하여 n 을 IEEE 754-2019 binary32 형식으로 변환한 결과로 둡니다.n64 를 n32 를 IEEE 754-2019 binary64 형식으로 변환한 결과로 둡니다.n64 에 대응하는 ECMAScript Number 값 을 반환합니다.
21.3.2.18 Math.f16round ( x )
이 함수는 호출될 때 다음 단계를 수행합니다:
n 을 ? ToNumber (x )로 둡니다.n 이 NaN 이면 NaN 을 반환합니다.n 이 +0 𝔽 , -0 𝔽 , +∞ 𝔽 , -∞ 𝔽 중 하나이면 n 을 반환합니다.n16 을 roundTiesToEven 모드를 사용하여 n 을 IEEE 754-2019 binary16 형식으로 변환한 결과로 둡니다.n64 를 n16 을 IEEE 754-2019 binary64 형식으로 변환한 결과로 둡니다.n64 에 대응하는 ECMAScript Number 값 을 반환합니다.
참고
이 연산은 이중 반올림 가능성 때문에 binary32로 캐스팅한 다음 binary16으로 캐스팅하는 것과 같지 않습니다. 예를 들어 k = 1.00048828125000022204 𝔽 인 수를 고려하면 Math.f16round(k )는 1.0009765625 𝔽 이지만 Math.f16round(Math.fround(k ))는 1 𝔽 입니다.
모든 플랫폼이 binary64에서 binary16으로의 캐스팅을 기본적으로 지원하는 것은 아닙니다. MIT 라이선스의 half 라이브러리를 포함하여 이를 제공할 수 있는 다양한 라이브러리가 있습니다. 또는 먼저 roundTiesToEven에서 binary64를 binary32로 캐스팅한 다음 결과가 잘못된 이중 반올림을 초래할 수 있는지 확인할 수 있습니다. 이러한 경우에는 binary32 값의 가수를 조정하여 초기 캐스팅을 roundTiesToOdd에서 수행했을 때 생성되는 값이 되도록 명시적으로 처리할 수 있습니다. 그런 다음 조정된 값을 roundTiesToEven에서 binary16으로 캐스팅하면 올바른 값이 생성됩니다.
21.3.2.19 Math.hypot ( ...args )
0개 이상의 인수가 주어지면 이 함수는 각 인수의 제곱합의 제곱근을 반환합니다.
호출될 때 다음 단계를 수행합니다:
coerced 를 새로운 빈 List 로 둡니다.args 의 각 요소 arg 에 대해 다음을 수행합니다.n 을 ? ToNumber (arg )로 둡니다.n 을 coerced 에 추가합니다.coerced 의 각 요소 number 에 대해 다음을 수행합니다.number 가 +∞ 𝔽 또는 -∞ 𝔽 중 하나이면 +∞ 𝔽 을 반환합니다.onlyZero 를 true 로 둡니다.coerced 의 각 요소 number 에 대해 다음을 수행합니다.number 가 NaN 이면 NaN 을 반환합니다.number 가 +0 𝔽 도 -0 𝔽 도 아니면 onlyZero 를 false 로 설정합니다.onlyZero 가 true 이면 +0 𝔽 을 반환합니다.coerced 요소들의 수학적 값 의 제곱합의 제곱근을 나타내는 구현에서 근사한 Number 값 을 반환합니다.
이 함수의 "length" 속성은 2 𝔽 입니다.
참고
구현은 이 함수가 두 개 이상의 인수로 호출될 때 단순한 구현에서 발생하기 쉬운 오버플로와 언더플로로 인한 정밀도 손실을 방지하도록 주의해야 합니다.
21.3.2.20 Math.imul ( x , y )
이 함수는 호출될 때 다음 단계를 수행합니다:
a 를 ℝ (? ToUint32 (x ))로 둡니다.b 를 ℝ (? ToUint32 (y ))로 둡니다.product 를 (a × b ) modulo 232 로 둡니다.product ≥ 231 이면 𝔽 (product - 232 )를 반환합니다.𝔽 (product )를 반환합니다.
21.3.2.21 Math.log ( x )
이 함수는 x 의 자연로그를 반환합니다.
호출될 때 다음 단계를 수행합니다:
n 을 ? ToNumber (x )로 둡니다.n 이 NaN 또는 +∞ 𝔽 중 하나이면 n 을 반환합니다.n 이 1 𝔽 이면 +0 𝔽 을 반환합니다.n 이 +0 𝔽 또는 -0 𝔽 중 하나이면 -∞ 𝔽 을 반환합니다.n < -0 𝔽 이면 NaN 을 반환합니다.ln (ℝ (n ))을 나타내는 구현에서 근사한 Number 값 을 반환합니다.
21.3.2.22 Math.log1p ( x )
이 함수는 1 + x 의 자연로그를 반환합니다. 결과는 x의 값이 0에 가까운 경우에도 정확하도록 계산됩니다.
호출될 때 다음 단계를 수행합니다:
n 을 ? ToNumber (x )로 둡니다.n 이 NaN , +0 𝔽 , -0 𝔽 , +∞ 𝔽 중 하나이면 n 을 반환합니다.n 이 -1 𝔽 이면 -∞ 𝔽 을 반환합니다.n < -1 𝔽 이면 NaN 을 반환합니다.ln (1 + ℝ (n ))을 나타내는 구현에서 근사한 Number 값 을 반환합니다.
21.3.2.23 Math.log10 ( x )
이 함수는 x 의 밑이 10인 로그를 반환합니다.
호출될 때 다음 단계를 수행합니다:
n 을 ? ToNumber (x )로 둡니다.n 이 NaN 또는 +∞ 𝔽 중 하나이면 n 을 반환합니다.n 이 1 𝔽 이면 +0 𝔽 을 반환합니다.n 이 +0 𝔽 또는 -0 𝔽 중 하나이면 -∞ 𝔽 을 반환합니다.n < -0 𝔽 이면 NaN 을 반환합니다.log10 (ℝ (n ))을 나타내는 구현에서 근사한 Number 값 을 반환합니다.
21.3.2.24 Math.log2 ( x )
이 함수는 x 의 밑이 2인 로그를 반환합니다.
호출될 때 다음 단계를 수행합니다:
n 을 ? ToNumber (x )로 둡니다.n 이 NaN 또는 +∞ 𝔽 중 하나이면 n 을 반환합니다.n 이 1 𝔽 이면 +0 𝔽 을 반환합니다.n 이 +0 𝔽 또는 -0 𝔽 중 하나이면 -∞ 𝔽 을 반환합니다.n < -0 𝔽 이면 NaN 을 반환합니다.log2 (ℝ (n ))을 나타내는 구현에서 근사한 Number 값 을 반환합니다.
21.3.2.25 Math.max ( ...args )
0개 이상의 인수가 주어지면 이 함수는 각 인수에 대해 ToNumber 를 호출하고 결과 값 중 가장 큰 값을 반환합니다.
호출될 때 다음 단계를 수행합니다:
coerced 를 새로운 빈 List 로 둡니다.args 의 각 요소 arg 에 대해 다음을 수행합니다.n 을 ? ToNumber (arg )로 둡니다.n 을 coerced 에 추가합니다.highest 를 -∞ 𝔽 로 둡니다.coerced 의 각 요소 number 에 대해 다음을 수행합니다.number 가 NaN 이면 NaN 을 반환합니다.number 가 +0 𝔽 이고 highest 가 -0 𝔽 이면 highest 를 +0 𝔽 으로 설정합니다.number > highest 이면 highest 를 number 로 설정합니다.highest 를 반환합니다.
참고
가장 큰 값을 결정하기 위한 값의 비교는 +0 𝔽 을 -0 𝔽 보다 큰 것으로 간주한다는 점을 제외하면 IsLessThan 알고리즘을 사용하여 수행됩니다.
이 함수의 "length" 속성은 2 𝔽 입니다.
21.3.2.26 Math.min ( ...args )
0개 이상의 인수가 주어지면 이 함수는 각 인수에 대해 ToNumber 를 호출하고 결과 값 중 가장 작은 값을 반환합니다.
호출될 때 다음 단계를 수행합니다:
coerced 를 새로운 빈 List 로 둡니다.args 의 각 요소 arg 에 대해 다음을 수행합니다.n 을 ? ToNumber (arg )로 둡니다.n 을 coerced 에 추가합니다.lowest 를 +∞ 𝔽 로 둡니다.coerced 의 각 요소 number 에 대해 다음을 수행합니다.number 가 NaN 이면 NaN 을 반환합니다.number 가 -0 𝔽 이고 lowest 가 +0 𝔽 이면 lowest 를 -0 𝔽 으로 설정합니다.number < lowest 이면 lowest 를 number 로 설정합니다.lowest 를 반환합니다.
참고
가장 작은 값을 결정하기 위한 값의 비교는 +0 𝔽 을 -0 𝔽 보다 큰 것으로 간주한다는 점을 제외하면 IsLessThan 알고리즘을 사용하여 수행됩니다.
이 함수의 "length" 속성은 2 𝔽 입니다.
21.3.2.27 Math.pow ( base , exponent )
이 함수는 호출될 때 다음 단계를 수행합니다:
base 를 ? ToNumber (base )로 설정합니다.exponent 를 ? ToNumber (exponent )로 설정합니다.Number::exponentiate (base , exponent )를 반환합니다.
21.3.2.28 Math.random ( )
이 함수는 양의 부호를 가지며 +0 𝔽 이상이지만 1 𝔽 보다 엄격히 작은 Number 값 을 반환합니다. 이 값은 구현 정의 알고리즘 또는 전략을 사용하여 해당 범위에 걸쳐 대략 균등한 분포로 무작위 또는 의사 무작위로 선택됩니다.
서로 다른 realm 에 대해 생성된 각 Math.random 함수는 연속 호출에서 서로 다른 값의 시퀀스를 생성해야 합니다.
21.3.2.29 Math.round ( x )
이 함수는 x 에 가장 가깝고 정수인 Number 값을 반환합니다. 두 정수 Number가 x 에 동일하게 가까우면 결과는 +∞에 더 가까운 Number 값 입니다. x 가 이미 정수 이면 결과는 x 입니다.
호출될 때 다음 단계를 수행합니다:
n 을 ? ToNumber (x )로 둡니다.n 이 유한 Number 가 아니거나 n 이 정수 Number이면 n 을 반환합니다.n < 0.5 𝔽 이고 n > +0 𝔽 이면 +0 𝔽 을 반환합니다.n < -0 𝔽 이고 n ≥ -0.5 𝔽 이면 -0 𝔽 을 반환합니다.n 에 가장 가까운 정수 Number를 반환하며, 동률인 경우 +∞에 더 가까운 Number를 우선합니다.
참고 1
Math.round(3.5)는 4를 반환하지만 Math.round(-3.5)는 -3을 반환합니다.
참고 2
Math.round(x)의 값이 항상 Math.floor(x + 0.5)의 값과 같은 것은 아닙니다. x가 -0 𝔽 이거나 x가 -0 𝔽 보다 작지만 -0.5 𝔽 이상인 경우 Math.round(x)는 -0 𝔽 을 반환하지만 Math.floor(x + 0.5)는 +0 𝔽 을 반환합니다. Math.round(x)는 x + 0.5를 계산할 때 발생하는 내부 반올림 때문에 Math.floor(x + 0.5)의 값과 다를 수도 있습니다.
21.3.2.30 Math.sign ( x )
이 함수는 x 의 부호를 반환하여 x 가 양수인지, 음수인지 또는 0인지 나타냅니다.
호출될 때 다음 단계를 수행합니다:
n 을 ? ToNumber (x )로 둡니다.n 이 NaN , +0 𝔽 , -0 𝔽 중 하나이면 n 을 반환합니다.n < -0 𝔽 이면 -1 𝔽 을 반환합니다.1 𝔽 을 반환합니다.
21.3.2.31 Math.sin ( x )
이 함수는 x 의 사인을 반환합니다. 인수는 라디안으로 표현됩니다.
호출될 때 다음 단계를 수행합니다:
n 을 ? ToNumber (x )로 둡니다.n 이 NaN , +0 𝔽 , -0 𝔽 중 하나이면 n 을 반환합니다.n 이 +∞ 𝔽 또는 -∞ 𝔽 중 하나이면 NaN 을 반환합니다.ℝ (n )의 사인을 나타내는 구현에서 근사한 Number 값 을 반환합니다.
21.3.2.32 Math.sinh ( x )
이 함수는 x 의 쌍곡사인을 반환합니다.
호출될 때 다음 단계를 수행합니다:
n 을 ? ToNumber (x )로 둡니다.n 이 유한 Number 가 아니거나 n 이 +0 𝔽 또는 -0 𝔽 중 하나이면 n 을 반환합니다.ℝ (n )의 쌍곡사인을 나타내는 구현에서 근사한 Number 값 을 반환합니다.
참고
Math.sinh(x)의 값은 (Math.exp(x) - Math.exp(-x)) / 2의 값과 같습니다.
21.3.2.33 Math.sqrt ( x )
이 함수는 x 의 제곱근을 반환합니다.
호출될 때 다음 단계를 수행합니다:
n 을 ? ToNumber (x )로 둡니다.n 이 NaN , +0 𝔽 , -0 𝔽 , +∞ 𝔽 중 하나이면 n 을 반환합니다.n < -0 𝔽 이면 NaN 을 반환합니다.𝔽 (ℝ (n )의 제곱근)을 반환합니다.
21.3.2.34 Math.sumPrecise ( items )
Numbers의 iterable 이 주어지면 이 함수는 iterable 의 각 값을 합산하고 그 합을 반환합니다. 어떤 값이라도 Number가 아니면 TypeError 예외를 던집니다.
호출될 때 다음 단계를 수행합니다:
? RequireObjectCoercible (items )를 수행합니다. iteratorRecord 를 ? GetIterator (items , sync )로 둡니다.state 를 minus-zero 로 둡니다.sum 을 0으로 둡니다.count 를 0으로 둡니다.next 를 not-started 로 둡니다.next 가 done 이 아닌 동안 다음을 반복합니다.next 를 ? IteratorStepValue (iteratorRecord )로 설정합니다.next 가 done 이 아니면 다음을 수행합니다.count ≥ 253 - 1이면 다음을 수행합니다.참고 : 이 단계는 실제로 도달할 것으로 예상되지 않으며, 구현이 이 명세를 위반하지 않고 입력이 “합리적인 크기”라고 가정할 수 있도록 하기 위해서만 포함되어 있습니다.error 를 ThrowCompletion (새로 생성된 RangeError 객체)로 둡니다.? IteratorClose (iteratorRecord , error )를 반환합니다. next 가 Number가 아니면 다음을 수행합니다.error 를 ThrowCompletion (새로 생성된 TypeError 객체)로 둡니다.? IteratorClose (iteratorRecord , error )를 반환합니다. n 을 next 로 둡니다.state 가 not-a-number 가 아니면 다음을 수행합니다.n 이 NaN 이면 다음을 수행합니다.state 를 not-a-number 로 설정합니다.그렇지 않고 n 이 +∞ 𝔽 이면 다음을 수행합니다.state 가 minus-infinity 이면 state 를 not-a-number 로 설정합니다.그렇지 않으면 state 를 plus-infinity 로 설정합니다. 그렇지 않고 n 이 -∞ 𝔽 이면 다음을 수행합니다.state 가 plus-infinity 이면 state 를 not-a-number 로 설정합니다.그렇지 않으면 state 를 minus-infinity 로 설정합니다. 그렇지 않고 n 이 -0 𝔽 이 아니며 state 가 minus-zero 또는 finite 중 하나이면 다음을 수행합니다.state 를 finite 로 설정합니다.sum 을 sum + ℝ (n )으로 설정합니다. count 를 count + 1로 설정합니다.state 가 not-a-number 이면 NaN 을 반환합니다.state 가 plus-infinity 이면 +∞ 𝔽 을 반환합니다.state 가 minus-infinity 이면 -∞ 𝔽 을 반환합니다.state 가 minus-zero 이면 -0 𝔽 을 반환합니다.𝔽 (sum )을 반환합니다.
참고
sum 의 값은 다양한 알고리즘을 사용하여 임의 정밀도 산술 없이 계산할 수 있습니다. 그중 하나는 Jonathan Richard Shewchuk의 Adaptive Precision Floating-Point Arithmetic and Fast Robust Geometric Predicates 에 제시된 “Grow-Expansion” 알고리즘입니다. 더 최근의 알고리즘은 “Fast exact summation using small and large superaccumulators ”에 제시되어 있으며, 해당 코드는 https://gitlab.com/radfordneal/xsum 에서 사용할 수 있습니다.
21.3.2.35 Math.tan ( x )
이 함수는 x 의 탄젠트를 반환합니다. 인수는 라디안으로 표현됩니다.
호출될 때 다음 단계를 수행합니다:
n 을 ? ToNumber (x )로 둡니다.n 이 NaN , +0 𝔽 , -0 𝔽 중 하나이면 n 을 반환합니다.n 이 +∞ 𝔽 또는 -∞ 𝔽 중 하나이면 NaN 을 반환합니다.ℝ (n )의 탄젠트를 나타내는 구현에서 근사한 Number 값 을 반환합니다.
21.3.2.36 Math.tanh ( x )
이 함수는 x 의 쌍곡탄젠트를 반환합니다.
호출될 때 다음 단계를 수행합니다:
n 을 ? ToNumber (x )로 둡니다.n 이 NaN , +0 𝔽 , -0 𝔽 중 하나이면 n 을 반환합니다.n 이 +∞ 𝔽 이면 1 𝔽 을 반환합니다.n 이 -∞ 𝔽 이면 -1 𝔽 을 반환합니다.ℝ (n )의 쌍곡탄젠트를 나타내는 구현에서 근사한 Number 값 을 반환합니다.
참고
Math.tanh(x)의 값은 (Math.exp(x) - Math.exp(-x)) / (Math.exp(x) + Math.exp(-x))의 값과 같습니다.
21.3.2.37 Math.trunc ( x )
이 함수는 소수 부분을 제거하여 수 x 의 정수 부분을 반환합니다. x 가 이미 정수 이면 결과는 x 입니다.
호출될 때 다음 단계를 수행합니다:
n 을 ? ToNumber (x )로 둡니다.n 이 유한 Number 가 아니거나 n 이 +0 𝔽 또는 -0 𝔽 중 하나이면 n 을 반환합니다.n < 1 𝔽 이고 n > +0 𝔽 이면 +0 𝔽 을 반환합니다.n < -0 𝔽 이고 n > -1 𝔽 이면 -0 𝔽 을 반환합니다.+0 𝔽 방향으로 n 에 가장 가까운 정수 Number를 반환합니다.
21.4 Date 객체
21.4.1 Date 객체 개요 및 추상 연산 정의
다음 추상 연산 은 시간 값 (21.4.1.1 에 정의됨)을 대상으로 동작합니다. 모든 경우에 이러한 함수 중 하나의 인수가 NaN 이면 결과도 NaN 이 된다는 점에 유의하시기 바랍니다.
21.4.1.1 시간 값과 시간 범위
ECMAScript의 시간 측정은 POSIX의 시간 측정과 유사하며, 특히 역산 그레고리력, 1970년 1월 1일 UTC 시작 시점의 자정인 epoch , 그리고 모든 날이 정확히 86,400초(각각 1000밀리초)로 구성된다는 정의를 공유합니다.
ECMAScript 시간 값 은 Number이며, 밀리초 정밀도로 시간상의 한 시점을 나타내는 정수 Number(유한 시간 값 이라고 함)이거나 특정 시점을 나타내지 않는 NaN 입니다. MillisecondsPerDay 의 정수 배인 유한 시간 값(즉, 어떤 정수 d 에 대해 MillisecondsPerDay × d 인 값)은 에포크로부터 d 개의 온전한 UTC 일이 지난 뒤 시작되는 UTC 일의 시작 시점을 나타냅니다(음수 d 의 경우 에포크보다 앞선 시점). 그 밖의 모든 유한 시간 값 tv 는 그러한 배수이면서 그보다 앞선 가장 큰 유한 시간 값 s 를 기준으로 정의되며, s 와 동일한 UTC 일 내에서 s 보다 (tv - s )밀리초 뒤에 발생하는 시점을 나타냅니다.
시간 값은 UTC 윤초를 고려하지 않습니다. 양의 윤초 안의 순간을 나타내는 시간 값은 없으며, 음의 윤초로 UTC 시간선에서 제거된 순간을 나타내는 시간 값은 존재합니다. 그러나 시간 값의 정의는 여전히 UTC와 구간 별 정렬을 이루며, 불연속은 윤초 경계에서만 발생하고 윤초 이외에서는 차이가 0입니다.
Number는 -9,007,199,254,740,992부터 9,007,199,254,740,992까지의 모든 정수 를 정확하게 나타낼 수 있습니다(21.1.2.8 및 21.1.2.6 ). 시간 값은 이보다 약간 작은 -8,640,000,000,000,000부터 8,640,000,000,000,000밀리초까지의 범위를 지원합니다. 이는 1970년 1월 1일 UTC 시작 시점의 자정을 기준으로 정확히 -100,000,000일부터 100,000,000일까지의 시간 값 범위를 제공합니다.
1970년 1월 1일 UTC 시작 시점의 자정 정확한 순간은 시간 값 +0 𝔽 으로 나타냅니다.
참고
역산 그레고리력에서 윤년은 정확히 4로 나누어떨어지고 동시에 400으로 나누어떨어지거나 100으로 나누어떨어지지 않는 해입니다.
역산 그레고리력의 400년 주기에는 97개의 윤년이 포함됩니다. 따라서 연평균은 365.2425일이며 이는 31,556,952,000밀리초입니다. 따라서 Number가 밀리초 정밀도로 정확하게 나타낼 수 있는 최대 범위는 1970년을 기준으로 약 -285,426년부터 285,426년까지입니다. 이 절에 명시된 시간 값이 지원하는 더 작은 범위는 1970년을 기준으로 약 -273,790년부터 273,790년까지입니다.
21.4.1.2 시간 관련 상수
이러한 상수는 다음 절의 알고리즘에서 참조됩니다.
HoursPerDay = 24
MinutesPerHour = 60
SecondsPerMinute = 60
MillisecondsPerSecond = 1000
NanosecondsPerMillisecond = 106
NanosecondsPerMicrosecond = 103
21.4.1.3 Day ( tv )
추상 연산 Day. 인수 tv (a finite time value). 반환값: 정수 . tv 가 속하는 날짜의 날짜 번호를 반환합니다. 호출되면 다음 단계를 수행한다.
floor (ℝ (tv ) / MillisecondsPerDay )를 반환합니다.
21.4.1.4 TimeWithinDay ( tv )
추상 연산 TimeWithinDay. 인수 tv (a finite time value). 반환값: an integer in the interval from 0 (inclusive) to MillisecondsPerDay (exclusive). tv 가 속하는 날의 시작 이후 경과한 밀리초 수를 반환합니다. 호출되면 다음 단계를 수행한다.
ℝ (tv ) modulo MillisecondsPerDay 를 반환합니다.
21.4.1.5 DayFromYear ( y )
추상 연산 DayFromYear. 인수 y (정수 ). 반환값: 정수 . 연도 y 의 첫날에 해당하는 날짜 번호를 반환합니다. 호출되면 다음 단계를 수행한다.
참고 : 다음 단계에서 numberYears1 , numberYears4 , numberYears100 및 numberYears400 은 각각 epoch 와 연도 y 의 시작 사이에 나타나는 1, 4, 100 및 400으로 나누어떨어지는 연도의 수를 나타냅니다. y 가 epoch 보다 이전이면 이 수는 음수입니다.numberYears1 을 (y - 1970)으로 둡니다.numberYears4 를 floor ((y - 1969) / 4)로 둡니다.numberYears100 을 floor ((y - 1901) / 100)으로 둡니다.numberYears400 을 floor ((y - 1601) / 400)으로 둡니다.365 × numberYears1 + numberYears4 - numberYears100 + numberYears400 을 반환합니다.
21.4.1.6 TimeFromYear ( y )
추상 연산 TimeFromYear. 인수 y (정수 ). 반환값: a time value. 연도 y 의 시작에 해당하는 시간 값 을 반환합니다. 호출되면 다음 단계를 수행한다.
𝔽 (MillisecondsPerDay × DayFromYear (y ))를 반환합니다.
21.4.1.7 YearFromTime ( tv )
추상 연산 YearFromTime. 인수 tv (a finite time value). 반환값: 정수 . tv 가 속하는 연도를 반환합니다. 호출되면 다음 단계를 수행한다.
TimeFromYear (y ) ≤ tv 를 만족하는 가장 큰(+∞에 가장 가까운) 정수 y 를 반환합니다.
21.4.1.8 DayWithinYear ( tv )
추상 연산 DayWithinYear. 인수 tv (a finite time value). 반환값: an integer in the inclusive interval from 0 to 365. 호출되면 다음 단계를 수행한다.
Day (tv ) - DayFromYear (YearFromTime (tv ))를 반환합니다.
21.4.1.9 InLeapYear ( tv )
추상 연산 InLeapYear. 인수 tv (a finite time value). 반환값: (0 또는 1). tv 가 윤년에 속하면 1을 반환하고 그렇지 않으면 0을 반환합니다. 호출되면 다음 단계를 수행한다.
y 를 YearFromTime (tv )로 둡니다.(y modulo 400) = 0이면 1을 반환합니다. (y modulo 100) = 0이면 0을 반환합니다. (y modulo 4) = 0이면 1을 반환합니다. 0을 반환합니다.
21.4.1.10 MonthFromTime ( tv )
추상 연산 MonthFromTime. 인수 tv (a finite time value). 반환값: an integer in the inclusive interval from 0 to 11. tv 가 속하는 월을 식별하는 정수 를 반환합니다. 월 값 0은 1월, 1은 2월, 2는 3월, 3은 4월, 4는 5월, 5는 6월, 6은 7월, 7은 8월, 8은 9월, 9는 10월, 10은 11월, 11은 12월을 지정합니다. MonthFromTime(+0 𝔽 ) = 0 이며 이는 1970년 1월 1일 목요일에 대응한다는 점에 유의하시기 바랍니다. 호출되면 다음 단계를 수행한다.
inLeapYear 를 InLeapYear (tv )로 둡니다.dayWithinYear 를 DayWithinYear (tv )로 둡니다.dayWithinYear < 31이면 0을 반환합니다.dayWithinYear < 59 + inLeapYear 이면 1을 반환합니다.dayWithinYear < 90 + inLeapYear 이면 2를 반환합니다.dayWithinYear < 120 + inLeapYear 이면 3을 반환합니다.dayWithinYear < 151 + inLeapYear 이면 4를 반환합니다.dayWithinYear < 181 + inLeapYear 이면 5를 반환합니다.dayWithinYear < 212 + inLeapYear 이면 6을 반환합니다.dayWithinYear < 243 + inLeapYear 이면 7을 반환합니다.dayWithinYear < 273 + inLeapYear 이면 8을 반환합니다.dayWithinYear < 304 + inLeapYear 이면 9를 반환합니다.dayWithinYear < 334 + inLeapYear 이면 10을 반환합니다.단언 : dayWithinYear < 365 + inLeapYear 입니다.11을 반환합니다.
21.4.1.11 DateFromTime ( tv )
추상 연산 DateFromTime. 인수 tv (a finite time value). 반환값: an integer in the inclusive interval from 1 to 31. tv 가 속하는 월의 날짜를 반환합니다. 호출되면 다음 단계를 수행한다.
inLeapYear 를 InLeapYear (tv )로 둡니다.dayWithinYear 를 DayWithinYear (tv )로 둡니다.month 를 MonthFromTime (tv )로 둡니다.month = 0이면 dayWithinYear + 1을 반환합니다.month = 1이면 dayWithinYear - 30을 반환합니다.month = 2이면 dayWithinYear - 58 - inLeapYear 를 반환합니다.month = 3이면 dayWithinYear - 89 - inLeapYear 를 반환합니다.month = 4이면 dayWithinYear - 119 - inLeapYear 를 반환합니다.month = 5이면 dayWithinYear - 150 - inLeapYear 를 반환합니다.month = 6이면 dayWithinYear - 180 - inLeapYear 를 반환합니다.month = 7이면 dayWithinYear - 211 - inLeapYear 를 반환합니다.month = 8이면 dayWithinYear - 242 - inLeapYear 를 반환합니다.month = 9이면 dayWithinYear - 272 - inLeapYear 를 반환합니다.month = 10이면 dayWithinYear - 303 - inLeapYear 를 반환합니다.단언 : month = 11입니다.dayWithinYear - 333 - inLeapYear 를 반환합니다.
21.4.1.12 WeekDay ( tv )
추상 연산 WeekDay. 인수 tv (a finite time value). 반환값: an integer in the inclusive interval from 0 to 6. tv 가 속하는 요일을 식별하는 정수 를 반환합니다. 요일 값 0은 일요일, 1은 월요일, 2는 화요일, 3은 수요일, 4는 목요일, 5는 금요일, 6은 토요일을 지정합니다. WeekDay(+0 𝔽 ) = 4 이며 이는 1970년 1월 1일 목요일에 대응한다는 점에 유의하시기 바랍니다. 호출되면 다음 단계를 수행한다.
(Day (tv ) + 4) modulo 7을 반환합니다.
21.4.1.13 HourFromTime ( tv )
추상 연산 HourFromTime. 인수 tv (a finite time value). 반환값: an integer in the inclusive interval from 0 to 23. tv 가 속하는 날의 시를 반환합니다. 호출되면 다음 단계를 수행한다.
floor (ℝ (tv ) / MillisecondsPerHour ) modulo HoursPerDay 를 반환합니다.
21.4.1.14 MinuteFromTime ( tv )
추상 연산 MinuteFromTime. 인수 tv (a finite time value). 반환값: an integer in the inclusive interval from 0 to 59. tv 가 속하는 시의 분을 반환합니다. 호출되면 다음 단계를 수행한다.
floor (ℝ (tv ) / MillisecondsPerMinute ) modulo MinutesPerHour 를 반환합니다.
21.4.1.15 SecondFromTime ( tv )
추상 연산 SecondFromTime. 인수 tv (a finite time value). 반환값: an integer in the inclusive interval from 0 to 59. tv 가 속하는 분의 초를 반환합니다. 호출되면 다음 단계를 수행한다.
floor (ℝ (tv ) / MillisecondsPerSecond ) modulo SecondsPerMinute 를 반환합니다.
21.4.1.16 MillisecondFromTime ( tv )
추상 연산 MillisecondFromTime. 인수 tv (a finite time value). 반환값: an integer in the inclusive interval from 0 to 999. tv 가 속하는 초의 밀리초를 반환합니다. 호출되면 다음 단계를 수행한다.
ℝ (tv ) modulo MillisecondsPerSecond 를 반환합니다.
21.4.1.17 Epoch 나노초와 범위
epoch 나노초 수 는 나노초 정밀도로 시간의 한 순간을 나타내는 정수 입니다. 시간 값 과 동일한 범위를 지원하지만 나노초로 표현되며, MinEpochNanoseconds 부터 MaxEpochNanoseconds 까지입니다. 시간 값 NaN 에 대응하는 나노초 값은 없으며, 특정 순간이 없음을 나타내는 표현도 없습니다.
1970년 1월 1일 UTC 시작 시점의 자정 정확한 순간은 값 0으로 나타냅니다. 최대 값은 MaxEpochNanoseconds 이고 최소 값은 MinEpochNanoseconds 입니다.
21.4.1.18 GetUTCEpochNanoseconds ( year , month , day , hour , minute , second , millisecond , microsecond , nanosecond )
추상 연산 GetUTCEpochNanoseconds. 인수 year (정수 ), month (an integer in the inclusive interval from 1 to 12), day (an integer in the inclusive interval from 1 to 31), hour (an integer in the inclusive interval from 0 to 23), minute (an integer in the inclusive interval from 0 to 59), second (an integer in the inclusive interval from 0 to 59), millisecond (an integer in the inclusive interval from 0 to 999), microsecond (an integer in the inclusive interval from 0 to 999) 및 nanosecond (an integer in the inclusive interval from 0 to 999). 반환값: an epoch nanoseconds count. 반환 값은 주어진 ISO 8601 달력 날짜와 UTC의 시계 시간에 대응하는 epoch 나노초 수 입니다. 호출되면 다음 단계를 수행한다.
date 를 MakeDay (𝔽 (year ), 𝔽 (month - 1), 𝔽 (day ))로 둡니다.time 을 MakeTime (𝔽 (hour ), 𝔽 (minute ), 𝔽 (second ), 𝔽 (millisecond ))로 둡니다.epochMilliseconds 를 MakeDate (date , time )로 둡니다.단언 : epochMilliseconds 는 정수 Number입니다.ℝ (epochMilliseconds ) × NanosecondsPerMillisecond + microsecond × NanosecondsPerMicrosecond + nanosecond 를 반환합니다.
21.4.1.19 시간대 식별자
ECMAScript의 시간대는 시간대 식별자 로 나타내며, 이는 0x0000부터 0x007F까지의 폐구간 에 속하는 코드 단위만으로 구성된 String입니다.
ECMAScript 구현체가 지원하는 시간대는 AvailableNamedTimeZoneIdentifiers 가 반환하는 Time Zone Identifier Record 의 [[Identifier]] 필드로 나타내는 사용 가능한 이름 있는 시간대 이거나, IsTimeZoneOffsetString 이 true 를 반환하는 String으로 나타내는 오프셋 시간대 일 수 있습니다.
주 시간대 식별자 는 사용 가능한 이름 있는 시간대의 기본 식별자입니다.
비주 시간대 식별자 는 주 시간대 식별자가 아닌 사용 가능한 이름 있는 시간대의 식별자입니다.
사용 가능한 이름 있는 시간대 식별자 는 주 시간대 식별자 또는 비주 시간대 식별자 중 하나입니다.
각 사용 가능한 이름 있는 시간대 식별자는 정확히 하나의 사용 가능한 이름 있는 시간대와 연결됩니다.
각 사용 가능한 이름 있는 시간대는 정확히 하나의 주 시간대 식별자 및 0개 이상의 비주 시간대 식별자와 연결됩니다.
ECMAScript 구현체는 식별자가 "UTC" 인 사용 가능한 이름 있는 시간대를 지원해야 하며, 이는 UTC 시간대의 주 시간대 식별자여야 합니다.
또한 구현체는 임의의 수의 다른 사용 가능한 이름 있는 시간대를 지원할 수 있습니다.
ECMA-402 국제화 API 명세에 설명된 시간대 요구 사항을 따르는 구현체를 시간대 인식 구현체라고 합니다.
시간대 인식 구현체는 IANA Time Zone Database 의 “Zone” 및 “Link ” 이름에 대응하는 사용 가능한 이름 있는 시간대를 지원해야 하며, 그러한 이름만 지원해야 합니다.
시간대 인식 구현체에서 주 시간대 식별자는 IANA Time Zone Database의 “Zone” 이름이고, 비주 시간대 식별자는 각각 “Link ” 이름입니다. 다만 ECMA-402에 명시된 AvailableNamedTimeZoneIdentifiers 에 의해 특별히 재정의된 경우는 제외합니다.
전체 IANA Time Zone Database를 지원하지 않는 구현체에도 시간대를 나타내는 식별자로 IANA Time Zone Database 이름을 사용하는 것이 권장됩니다.
21.4.1.20 GetNamedTimeZoneEpochNanoseconds ( timeZoneIdentifier , year , month , day , hour , minute , second , millisecond , microsecond , nanosecond )
구현 정의 추상 연산 GetNamedTimeZoneEpochNanoseconds. 인수 timeZoneIdentifier (String), year (정수 ), month (an integer in the inclusive interval from 1 to 12), day (an integer in the inclusive interval from 1 to 31), hour (an integer in the inclusive interval from 0 to 23), minute (an integer in the inclusive interval from 0 to 59), second (an integer in the inclusive interval from 0 to 59), millisecond (an integer in the inclusive interval from 0 to 999), microsecond (an integer in the inclusive interval from 0 to 999) 및 nanosecond (an integer in the inclusive interval from 0 to 999). 반환값: 리스트 (요소: epoch nanoseconds counts ).
반환된 List 의 각 값은 timeZoneIdentifier 가 식별하는 이름 있는 시간대에서 주어진 ISO 8601 달력 날짜 및 시계 시간에 대응하는 epoch 나노초 수 를 나타냅니다.
입력이 음의 시간대 전이 때문에 두 번 이상 발생하는 로컬 시간을 나타내면(예: 일광 절약 시간이 끝나거나 시간대 규칙 변경으로 시간대 오프셋이 감소하는 경우) 반환된 List 에는 둘 이상의 요소가 있으며 숫자 값의 오름차순으로 정렬됩니다.
입력이 양의 시간대 전이 때문에 건너뛴 로컬 시간을 나타내면(예: 일광 절약 시간이 시작되거나 시간대 규칙 변경으로 시간대 오프셋이 증가하는 경우) 반환된 List 는 비어 있습니다.
그 밖의 경우 반환된 List 에는 하나의 요소가 있습니다.
어떤 시간대에도 로컬 정치적 규칙을 포함하지 않는 ECMAScript 구현체에서 사용하는 GetNamedTimeZoneEpochNanoseconds의 기본 구현은 호출되면 다음 단계를 수행합니다:
단언 : timeZoneIdentifier 는 "UTC" 입니다.epochNanoseconds 를 GetUTCEpochNanoseconds (year , month , day , hour , minute , second , millisecond , microsecond , nanosecond )로 둡니다.« epochNanoseconds »을 반환합니다.
참고
시간대 인식 구현체는 IANA Time Zone Database 의 시간대 정보를 사용해야 하며, 다른 모든 구현체에도 이를 사용하는 것이 권장됩니다.
America/New_York에서 2017년 11월 5일 오전 1:30은 두 번 반복되므로 GetNamedTimeZoneEpochNanoseconds("America/New_York" , 2017, 11, 5, 1, 30, 0, 0, 0, 0)은 길이가 2인 List 를 반환하며, 첫 번째 요소는 05:30 UTC (UTC 오프셋 -04:00인 미국 동부 일광 절약 시간의 01:30에 대응)를 나타내고 두 번째 요소는 06:30 UTC (UTC 오프셋 -05:00인 미국 동부 표준시의 01:30에 대응)를 나타냅니다.
America/New_York에서 2017년 3월 12일 오전 2:30은 존재하지 않으므로 GetNamedTimeZoneEpochNanoseconds("America/New_York" , 2017, 3, 12, 2, 30, 0, 0, 0, 0)은 빈 List 를 반환합니다.
21.4.1.21 GetNamedTimeZoneOffsetNanoseconds ( timeZoneIdentifier , epochNanoseconds )
구현 정의 추상 연산 GetNamedTimeZoneOffsetNanoseconds. 인수 timeZoneIdentifier (String) 및 epochNanoseconds (an epoch nanoseconds count). 반환값: 정수 .
반환된 정수 는 epoch 나노초 수 epochNanoseconds 에 대응하는 순간에 timeZoneIdentifier 가 식별하는 이름 있는 시간대의 UTC로부터의 오프셋을 나노초 단위로 나타냅니다.
어떤 시간대에도 로컬 정치적 규칙을 포함하지 않는 ECMAScript 구현체에서 사용하는 GetNamedTimeZoneOffsetNanoseconds의 기본 구현은 호출되면 다음 단계를 수행합니다:
단언 : timeZoneIdentifier 는 "UTC" 입니다.0을 반환합니다.
참고
시간대 오프셋 값은 양수 또는 음수일 수 있습니다.
21.4.1.22 Time Zone Identifier Record
Time Zone Identifier Record 는 사용 가능한 이름 있는 시간대 식별자 및 이에 대응하는 주 시간대 식별자 를 설명하는 데 사용하는 Record 입니다.
Time Zone Identifier Record에는 표 60 에 나열된 필드가 있습니다.
표 60: Time Zone Identifier Record 필드
참고
[[Identifier]] 가 주 시간대 식별자 이면 [[Identifier]] 는 [[PrimaryIdentifier]] 입니다.
21.4.1.23 AvailableNamedTimeZoneIdentifiers ( )
구현 정의 추상 연산 AvailableNamedTimeZoneIdentifiers. 인수 없음. 반환값: 리스트 (요소: Time Zone Identifier 레코드 ).
결과는 이 구현체에서 사용할 수 있는 모든 이름 있는 시간대 식별자 와 각 사용 가능한 이름 있는 시간대 식별자 에 대응하는 주 시간대 식별자 를 설명합니다.
List 는 각 Time Zone Identifier Record 의 [[Identifier]] 필드에 따라 정렬됩니다.
ECMA-402 국제화 API를 구현하는 모든 구현체를 포함한 시간대 인식 구현체는 ECMA-402에 명시된 대로 AvailableNamedTimeZoneIdentifiers 추상 연산 을 구현해야 합니다.
그렇지 않으면 AvailableNamedTimeZoneIdentifiers는 호출되면 다음 단계를 수행합니다:
구현체가 어떤 시간대에도 로컬 정치적 규칙을 포함하지 않으면, 다음을 수행합니다.« Time Zone Identifier Record { [[Identifier]] : "UTC" , [[PrimaryIdentifier]] : "UTC" } »를 반환합니다. identifiers 를 고유한 사용 가능한 이름 있는 시간대 식별자 의 List 로 두고, 사전식 코드 단위 순서 에 따라 정렬합니다.result 를 새로운 빈 List 로 둡니다.identifiers 의 각 요소 identifier 에 대해 다음을 수행합니다.primary 를 identifier 로 둡니다.identifier 가 이 구현체의 비주 시간대 식별자 이고 identifier 가 "UTC" 가 아니면, 다음을 수행합니다.primary 를 identifier 와 연결된 주 시간대 식별자 로 설정합니다.참고 : 구현체는 주 시간대 식별자 를 얻기 위해 identifier 를 반복적으로 해석해야 할 수 있습니다.record 를 Time Zone Identifier Record { [[Identifier]] : identifier , [[PrimaryIdentifier]] : primary }로 둡니다.record 를 result 에 추가합니다.단언 : result 에는 record .[[Identifier]] 가 "UTC" 이고 record .[[PrimaryIdentifier]] 가 "UTC" 인 Time Zone Identifier Record record 가 포함되어 있습니다.result 를 반환합니다.
21.4.1.24 SystemTimeZoneIdentifier ( )
구현 정의 추상 연산 SystemTimeZoneIdentifier. 인수 없음. 반환값: String.
호스트 환경 의 현재 시간대를 나타내는 String을 반환하며, 이는 IsTimeZoneOffsetString 이 true 를 반환하는 UTC 오프셋을 나타내는 String 또는 주 시간대 식별자 중 하나입니다.
호출되면 다음 단계를 수행한다.
구현체가 UTC 시간대만 지원하면 "UTC" 를 반환합니다. systemTimeZoneString 을 호스트 환경 의 현재 시간대를 나타내는 String으로 두며, 주 시간대 식별자 또는 오프셋 시간대 식별자 중 하나입니다.systemTimeZoneString 을 반환합니다.
참고
구현체가 Date 객체의 메서드에서 일반적으로 제공하는 기능 수준을 보장하기 위해, 그러한 것이 존재한다면 SystemTimeZoneIdentifier가 호스트 환경 의 시간대 설정에 대응하는 IANA 시간대 이름을 반환하는 것이 권장됩니다.
GetNamedTimeZoneEpochNanoseconds 및 GetNamedTimeZoneOffsetNanoseconds 는 해당 시간대에 표준시 및 일광 절약 시간에 대한 로컬 정치적 규칙이 존재하는 경우 이를 반영해야 합니다.
예를 들어 호스트 환경 이 사용자가 미국 동부 시간을 자신의 시간대로 선택한 시스템의 브라우저이면 SystemTimeZoneIdentifier는 "America/New_York" 를 반환합니다.
21.4.1.25 LocalTime ( tv )
추상 연산 LocalTime. 인수 tv (a finite time value). 반환값: 정수인 Number .
tv 를 UTC에서 로컬 시간으로 변환합니다.
tv 에 적용되는 표준시 및 일광 절약 시간에 대한 로컬 정치적 규칙을 사용하여 이 절에 명시된 방식으로 결과를 결정해야 합니다.
호출되면 다음 단계를 수행한다.
systemTimeZoneIdentifier 를 SystemTimeZoneIdentifier ()로 둡니다.IsTimeZoneOffsetString (systemTimeZoneIdentifier )이 true 이면, 다음을 수행합니다.offsetNanoseconds 를 ParseTimeZoneOffsetString (systemTimeZoneIdentifier )으로 둡니다.그렇지 않으면,offsetNanoseconds 를 GetNamedTimeZoneOffsetNanoseconds (systemTimeZoneIdentifier , ℝ (tv ) × NanosecondsPerMillisecond )로 둡니다. offsetMilliseconds 를 truncate (offsetNanoseconds / NanosecondsPerMillisecond )로 둡니다.tv + 𝔽 (offsetMilliseconds )를 반환합니다.
참고 1
로컬 시간 tv 에 대한 정치적 규칙을 구현체 안에서 사용할 수 없으면 SystemTimeZoneIdentifier 가 "UTC" 를 반환하고 GetNamedTimeZoneOffsetNanoseconds 가 0을 반환하므로 결과는 tv 입니다.
참고 2
시간대 인식 구현체는 IANA Time Zone Database https://www.iana.org/time-zones/ 의 시간대 정보를 사용해야 하며, 다른 모든 구현체에도 이를 사용하는 것이 권장됩니다.
참고 3
반복되는 시간이 있는 음의 시간대 전이 시점(예: 일광 절약 시간이 끝나거나 시간대 조정이 감소하는 경우)에 서로 다른 두 입력 시간 값 tv UTC 가 동일한 로컬 시간 tlocal 로 변환됩니다.
LocalTime(UTC (tv local )) 은 반드시 항상 tv local 과 같지는 않습니다. 마찬가지로 UTC (LocalTime(tv UTC )) 도 반드시 항상 tv UTC 과 같지는 않습니다.
21.4.1.26 UTC ( t )
추상 연산 UTC. 인수 t (Number). 반환값: a time value.
t 를 로컬 시간에서 UTC 시간 값 으로 변환합니다.
t 에 적용되는 표준시 및 일광 절약 시간에 대한 로컬 정치적 규칙을 사용하여 이 절에 명시된 방식으로 결과를 결정해야 합니다.
호출되면 다음 단계를 수행한다.
t 가 유한 Number 가 아니면 NaN 을 반환합니다.systemTimeZoneIdentifier 를 SystemTimeZoneIdentifier ()로 둡니다.IsTimeZoneOffsetString (systemTimeZoneIdentifier )이 true 이면, 다음을 수행합니다.offsetNanoseconds 를 ParseTimeZoneOffsetString (systemTimeZoneIdentifier )으로 둡니다.그렇지 않으면,possibleInstants 를 GetNamedTimeZoneEpochNanoseconds (systemTimeZoneIdentifier , YearFromTime (t ), MonthFromTime (t ) + 1, DateFromTime (t ), HourFromTime (t ), MinuteFromTime (t ), SecondFromTime (t ), MillisecondFromTime (t ), 0, 0)으로 둡니다.참고 : 다음 단계는 t 가 음의 시간대 전이에서 여러 번 반복되는 로컬 시간(예: 일광 절약 시간이 끝나거나 시간대 규칙 변경으로 시간대 오프셋이 감소하는 경우) 또는 양의 시간대 전이에서 건너뛴 로컬 시간(예: 일광 절약 시간이 시작되거나 시간대 규칙 변경으로 시간대 오프셋이 증가하는 경우)을 나타낼 때 t 가 전이 이전의 시간대 오프셋을 사용하여 해석되도록 보장합니다.possibleInstants 가 비어 있지 않으면, 다음을 수행합니다.disambiguatedInstant 를 possibleInstants [0]으로 둡니다.그렇지 않으면,참고 : t 는 양의 시간대 전이에서 건너뛴 로컬 시간을 나타냅니다(예: 일광 절약 시간이 시작되거나 시간대 규칙 변경으로 UTC 오프셋이 증가하는 경우).possibleInstantsBefore 를 GetNamedTimeZoneEpochNanoseconds (systemTimeZoneIdentifier , YearFromTime (tBefore ), MonthFromTime (tBefore ) + 1, DateFromTime (tBefore ), HourFromTime (tBefore ), MinuteFromTime (tBefore ), SecondFromTime (tBefore ), MillisecondFromTime (tBefore ), 0, 0)으로 둡니다. 여기서 tBefore 는 possibleInstantsBefore 가 비어 있지 않은(즉, tBefore 가 전이 이전의 마지막 로컬 시간을 나타내는) 가장 큰 정수 Number < t 입니다.disambiguatedInstant 를 possibleInstantsBefore 의 마지막 요소로 둡니다. offsetNanoseconds 를 GetNamedTimeZoneOffsetNanoseconds (systemTimeZoneIdentifier , disambiguatedInstant )로 둡니다. offsetMilliseconds 를 truncate (offsetNanoseconds / NanosecondsPerMillisecond )로 둡니다.t - 𝔽 (offsetMilliseconds )를 반환합니다.
입력 t 는 명목상 시간 값 이지만 어떤 Number 값 이든 될 수 있습니다.
로컬 UTC 오프셋과 관계없이 시간 값 범위의 경계에 대응하는 입력을 지원할 수 있도록 알고리즘은 t 를 시간 값 범위로 제한해서는 안 됩니다.
예를 들어 최대 시간 값 은 8.64 × 1015 이며 "+275760-09-13T00:00:00Z" 에 대응합니다.
해당 순간에 로컬 시간대 오프셋이 UTC보다 1시간 앞선 환경에서는 8.64 × 1015 + 3.6 × 106 이라는 더 큰 입력으로 나타내며, 이는 "+275760-09-13T01:00:00+01:00" 에 대응합니다.
로컬 시간 t 에 대한 정치적 규칙을 구현체 안에서 사용할 수 없으면 SystemTimeZoneIdentifier 가 "UTC" 를 반환하고 GetNamedTimeZoneOffsetNanoseconds 가 0을 반환하므로 결과는 t 입니다.
참고 1
시간대 인식 구현체는 IANA Time Zone Database 의 시간대 정보를 사용해야 하며, 다른 모든 구현체에도 이를 사용하는 것이 권장됩니다.
America/New_York에서 2017년 11월 5일 오전 1:30은 두 번 반복되지만(시계를 뒤로 돌림), 오전 1:30 UTC-05가 아니라 오전 1:30 UTC-04로 해석해야 합니다.
UTC(TimeClip (MakeDate (MakeDay (2017, 10, 5), MakeTime (1, 30, 0, 0))))에서 offsetMilliseconds 의 값은 -4 × MillisecondsPerHour 입니다.
America/New_York에서 2017년 3월 12일 오전 2:30은 존재하지 않지만 오전 2:30 UTC-05(오전 3:30 UTC-04와 동등)로 해석해야 합니다.
UTC(TimeClip (MakeDate (MakeDay (2017, 2, 12), MakeTime (2, 30, 0, 0))))에서 offsetMilliseconds 의 값은 -5 × MillisecondsPerHour 입니다.
참고 2
UTC(LocalTime (t UTC )) 은 반드시 항상 t UTC 과 같지는 않습니다. 마찬가지로 LocalTime (UTC(t local )) 도 반드시 항상 t local 과 같지는 않습니다.
21.4.1.27 MakeTime ( hour , minute , second , millisecond )
추상 연산 MakeTime. 인수 hour (Number), minute (Number), second (Number) 및 millisecond (Number). 반환값: Number. 밀리초 수를 계산합니다. 호출되면 다음 단계를 수행한다.
hour 가 유한 Number 가 아니거나, minute 이 유한 Number 가 아니거나, second 가 유한 Number 가 아니거나, millisecond 가 유한 Number 가 아니면 NaN 을 반환합니다.hourMV 를 ! ToIntegerOrInfinity (hour )로 둡니다.minuteMV 를 ! ToIntegerOrInfinity (minute )로 둡니다.secondMV 를 ! ToIntegerOrInfinity (second )로 둡니다.millisecondMV 를 ! ToIntegerOrInfinity (millisecond )로 둡니다.((𝔽 (hourMV ) × 𝔽 (MillisecondsPerHour ) + 𝔽 (minuteMV ) × 𝔽 (MillisecondsPerMinute )) + 𝔽 (secondMV ) × 𝔽 (MillisecondsPerSecond )) + 𝔽 (millisecondMV )를 반환합니다.
참고
MakeTime의 산술은 결합법칙이 성립하지 않는 부동 소수점 산술이므로 연산을 올바른 순서로 수행해야 합니다.
21.4.1.28 MakeDay ( year , month , day )
추상 연산 MakeDay. 인수 year (Number), month (Number) 및 day (Number). 반환값: (a finite Number 또는 NaN ). 날짜 수를 계산합니다. 호출되면 다음 단계를 수행한다.
year 가 유한 Number 가 아니거나, month 가 유한 Number 가 아니거나, day 가 유한 Number 가 아니면 NaN 을 반환합니다.yearMV 를 ! ToIntegerOrInfinity (year )로 둡니다.monthMV 를 ! ToIntegerOrInfinity (month )로 둡니다.dayMV 를 ! ToIntegerOrInfinity (day )로 둡니다.balancedYear 를 𝔽 (yearMV ) + 𝔽 (floor (monthMV / 12))로 둡니다.balancedYear 가 유한 Number 가 아니면 NaN 을 반환합니다.balancedMonthMV 를 monthMV modulo 12로 둡니다.YearFromTime (tv ) = ℝ (balancedYear ), MonthFromTime (tv ) = balancedMonthMV , DateFromTime (tv ) = 1을 만족하는 유한 시간 값 tv 를 찾습니다. 단, 이것이 가능하지 않으면(일부 인수가 범위를 벗어나기 때문에) NaN 을 반환합니다.𝔽 (Day (tv )) + 𝔽 (dayMV ) - 1 𝔽 을 반환합니다.
21.4.1.29 MakeDate ( day , time )
추상 연산 MakeDate. 인수 day (Number) 및 time (Number). 반환값: (a finite Number 또는 NaN ). 밀리초 수를 계산합니다. 호출되면 다음 단계를 수행한다.
day 가 유한 Number 가 아니거나 time 이 유한 Number 가 아니면 NaN 을 반환합니다.tv 를 day × 𝔽 (MillisecondsPerDay ) + time 으로 둡니다.tv 가 유한 Number 가 아니면 NaN 을 반환합니다.tv 를 반환합니다.
21.4.1.30 MakeFullYear ( year )
추상 연산 MakeFullYear. 인수 year (Number). 반환값: (정수인 Number 또는 NaN ). year 의 정수 부분과 연결된 전체 연도를 반환하며, 0부터 99까지의 폐구간 에 속하는 값은 1900년 시작 이후 경과한 연도 수로 해석합니다. 역산 그레고리력과 맞추기 위해 “전체 연도”는 연도 0(기원전 1년)의 시작 이후 완료된 연도의 부호 있는 수로 정의됩니다. 호출되면 다음 단계를 수행한다.
year 가 NaN , +∞ 𝔽 또는 -∞ 𝔽 중 하나이면 NaN 을 반환합니다.truncated 를 ! ToIntegerOrInfinity (year )로 둡니다.truncated 가 0부터 99까지의 폐구간 에 속하면 1900 𝔽 + 𝔽 (truncated )를 반환합니다.𝔽 (truncated )를 반환합니다.
21.4.1.31 TimeClip ( time )
추상 연산 TimeClip. 인수 time (Number). 반환값: a time value. 밀리초 수를 계산합니다. 호출되면 다음 단계를 수행한다.
time 가 유한 Number 가 아니면 NaN 을 반환합니다.abs (ℝ (time )) > 8.64 × 1015 이면 NaN 을 반환합니다.𝔽 (! ToIntegerOrInfinity (time ))를 반환합니다.
21.4.1.32 날짜 시간 문자열 형식
ECMAScript는 ISO 8601 달력 날짜 확장 형식에서 변형된 날짜-시간 문자열 교환 형식을 정의합니다. 형식은 다음과 같습니다: YYYY-MM-DDTHH:mm:ss.sssZ
각 요소는 다음과 같습니다:
YYYY
역산 그레고리력의 연도를 0000부터 9999까지의 네 자리 십진수로 나타내거나, "+" 또는 "-" 뒤에 여섯 자리 십진수가 이어지는 확장 연도 로 나타냅니다.
-
"-" (하이픈)은 문자열에 문자 그대로 두 번 나타납니다.
MM
01(1월)부터 12(12월)까지 두 자리 십진수로 나타내는 연중 월입니다.
DD
01부터 31까지 두 자리 십진수로 나타내는 월중 날짜입니다.
T
시간 요소의 시작을 나타내기 위해 "T" 가 문자열에 문자 그대로 나타납니다.
HH
자정 이후 지나간 완전한 시간 수를 00부터 24까지 두 자리 십진수로 나타냅니다.
:
":" (콜론)이 문자열에 문자 그대로 두 번 나타납니다.
mm
시가 시작된 이후 지나간 완전한 분의 수를 00부터 59까지 두 자리 십진수로 나타냅니다.
ss
분이 시작된 이후 지나간 완전한 초의 수를 00부터 59까지 두 자리 십진수로 나타냅니다.
.
"." (점)이 문자열에 문자 그대로 나타납니다.
sss
초가 시작된 이후 지나간 완전한 밀리초 수를 세 자리 십진수로 나타냅니다.
Z
"Z" (오프셋이 없는 UTC) 또는 "+" 나 "-" 뒤에 시간 표현 HH:mm이 이어지는 형식으로 지정되는 UTC 오프셋 표현입니다(각각 UTC보다 앞서거나 뒤처진 로컬 시간을 나타내기 위한 시간대 오프셋 문자열 형식 의 부분 집합).
이 형식에는 날짜 전용 형식도 포함됩니다:
YYYY
YYYY-MM
YYYY-MM-DD
또한 위 날짜 전용 형식 중 하나 바로 뒤에 다음 시간 형식 중 하나가 이어지고 선택적으로 UTC 오프셋 표현이 추가되는 “날짜-시간” 형식도 포함됩니다:
THH:mm
THH:mm:ss
THH:mm:ss.sss
범위를 벗어나거나 형식에 맞지 않는 요소를 포함하는 문자열은 이 형식의 유효한 인스턴스가 아닙니다.
참고 1
모든 날은 자정에 시작하고 자정에 끝나므로 하나의 날짜와 연결될 수 있는 두 자정을 구별하기 위해 00:00과 24:00이라는 두 표기법을 사용할 수 있습니다. 따라서 1995-02-04T24:00과 1995-02-05T00:00이라는 다음 두 표기법은 정확히 동일한 시점을 가리킵니다.
참고 2
이 형식은 RFC 9557에 정의된 시간대 이름 주석을 지원하지 않으며, 시간대 오프셋의 숫자 표현만 지원합니다.
21.4.1.32.1 확장 연도
1970년 1월 1일을 기준으로 앞뒤 약 273,790년의 전체 시간 값 범위(21.4.1.1 )를 다루려면 0 이전 또는 9999 이후의 연도를 나타내야 합니다. ISO 8601은 연도 표현의 확장을 허용하지만 정보 교환 당사자 간의 상호 합의가 있는 경우에만 허용합니다. 단순화된 ECMAScript 형식에서 이러한 확장 연도 표현은 6자리 숫자를 가져야 하며 항상 + 또는 - 부호가 앞에 붙습니다. 연도 0은 양수로 간주되며 + 부호가 앞에 붙어야 합니다. 연도 0을 -000000으로 나타내는 것은 유효하지 않습니다. 확장 연도를 사용하여 시간 값 범위 밖의 순간을 나타내며 날짜 시간 문자열 형식 과 일치하는 문자열은 Date.parse 에서 인식할 수 없는 것으로 취급되며, 이 함수는 구현체 고유 동작이나 휴리스틱으로 대체하지 않고 NaN 을 반환합니다.
참고
확장 연도를 사용하는 날짜-시간 값 의 예:
-271821-04-20T00:00:00Z
기원전 271822년
-000001-01-01T00:00:00Z
기원전 2년
+000000-01-01T00:00:00Z
기원전 1년
+000001-01-01T00:00:00Z
서기 1년
+001970-01-01T00:00:00Z
서기 1970년
+002009-12-15T00:00:00Z
서기 2009년
+275760-09-13T00:00:00Z
서기 275760년
21.4.1.33 시간대 오프셋 문자열 형식
ECMAScript는 ISO 8601에서 파생된 UTC 오프셋용 문자열 교환 형식을 정의합니다.
형식은 다음 문법으로 설명됩니다.
구문
UTCOffset :::
ASCIISign
Hour
ASCIISign
Hour
HourSubcomponents [+Extended]
ASCIISign
Hour
HourSubcomponents [~Extended]
ASCIISign ::: one of + -
Hour :::
0
DecimalDigit
1
DecimalDigit
20
21
22
23
HourSubcomponents [Extended] :::
TimeSeparator [?Extended]
MinuteSecond
TimeSeparator [?Extended]
MinuteSecond
TimeSeparator [?Extended]
MinuteSecond
TemporalDecimalFraction opt
TimeSeparator [Extended] ::: [+Extended]
:
[~Extended]
[empty]
MinuteSecond :::
0
DecimalDigit
1
DecimalDigit
2
DecimalDigit
3
DecimalDigit
4
DecimalDigit
5
DecimalDigit
TemporalDecimalFraction :::
TemporalDecimalSeparator
DecimalDigit
TemporalDecimalSeparator
DecimalDigit
DecimalDigit
TemporalDecimalSeparator
DecimalDigit
DecimalDigit
DecimalDigit
TemporalDecimalSeparator
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
TemporalDecimalSeparator
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
TemporalDecimalSeparator
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
TemporalDecimalSeparator
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
TemporalDecimalSeparator
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
TemporalDecimalSeparator
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
TemporalDecimalSeparator ::: one of . ,
21.4.1.33.1 IsTimeZoneOffsetString ( offsetString )
추상 연산 IsTimeZoneOffsetString. 인수 offsetString (String). 반환값: Boolean. 반환 값은 offsetString 이 UTCOffset 이 제시하는 문법을 준수하는지 나타냅니다. 호출되면 다음 단계를 수행한다.
parseResult 를 ParseText (offsetString , UTCOffset )로 둡니다.parseResult 가 오류의 List 이면 false 를 반환합니다.true 를 반환합니다.
21.4.1.33.2 ParseTimeZoneOffsetString ( offsetString )
추상 연산 ParseTimeZoneOffsetString. 인수 offsetString (String). 반환값: 정수 . 반환 값은 String offsetString 에 대응하는 UTC 오프셋을 나노초 수로 나타낸 것입니다. 호출되면 다음 단계를 수행한다.
parseResult 를 ParseText (offsetString , UTCOffset )로 둡니다.단언 : parseResult 는 오류의 List 가 아닙니다.단언 : parseResult 에는 ASCIISign Parse Node가 포함되어 있습니다.parsedSign 을 parseResult 안에 포함된 ASCIISign Parse Node와 일치하는 소스 텍스트 로 둡니다.parsedSign 이 단일 코드 포인트 U+002D (HYPHEN-MINUS)이면, 다음을 수행합니다.sign 을 -1로 둡니다.그렇지 않으면,sign 을 1로 둡니다. 참고 : 아래의 StringToNumber 적용은 파싱된 각 값이 충분히 짧은 십진수 문자열임이 보장되므로 정밀도를 잃지 않습니다.단언 : parseResult 에는 Hour Parse Node가 포함되어 있습니다.parsedHours 를 parseResult 안에 포함된 Hour Parse Node와 일치하는 소스 텍스트 로 둡니다.hours 를 ℝ (StringToNumber (CodePointsToString (parsedHours )))로 둡니다.parseResult 에 MinuteSecond Parse Node가 포함되어 있지 않으면, 다음을 수행합니다.minutes 를 0으로 둡니다.그렇지 않으면,parsedMinutes 를 parseResult 안에 포함된 첫 번째 MinuteSecond Parse Node와 일치하는 소스 텍스트 로 둡니다.minutes 를 ℝ (StringToNumber (CodePointsToString (parsedMinutes )))로 둡니다. parseResult 에 두 개의 MinuteSecond Parse Node가 포함되어 있지 않으면, 다음을 수행합니다.seconds 를 0으로 둡니다.그렇지 않으면,parsedSeconds 를 parseResult 안에 포함된 두 번째 MinuteSecond Parse Node와 일치하는 소스 텍스트 로 둡니다.seconds 를 ℝ (StringToNumber (CodePointsToString (parsedSeconds )))로 둡니다. parseResult 에 TemporalDecimalFraction Parse Node가 포함되어 있지 않으면, 다음을 수행합니다.nanoseconds 를 0으로 둡니다.그렇지 않으면,parsedFraction 을 parseResult 안에 포함된 TemporalDecimalFraction Parse Node와 일치하는 소스 텍스트 로 둡니다.fraction 을 CodePointsToString (parsedFraction )과 "000000000" 의 문자열 연결 로 둡니다.nanosecondsString 을 fraction 의 인덱스 1부터 10까지의 부분 문자열 로 둡니다.nanoseconds 를 ℝ (StringToNumber (nanosecondsString ))로 둡니다. sign × (((hours × MinutesPerHour + minutes ) × SecondsPerMinute + seconds ) × NanosecondsPerSecond + nanoseconds )를 반환합니다.
21.4.2 Date 생성자
Date 생성자 는:
%Date% 입니다.
전역 객체 의 "Date" 프로퍼티 초기 값입니다.
생성자 로 호출되면 새로운 Date를 생성하고 초기화합니다.
생성자 가 아니라 함수로 호출되면 현재 시간(UTC)을 나타내는 String을 반환합니다.
인수의 수와 타입에 따라 동작이 달라지는 함수입니다.
클래스 정의의 extends 절 값으로 사용할 수 있습니다. 명시된 Date 동작을 상속하려는 하위 클래스 생성자 는 [[DateValue]] 내부 슬롯을 갖는 하위 클래스 인스턴스를 생성하고 초기화하기 위해 Date 생성자 에 대한 super 호출을 포함해야 합니다.
21.4.2.1 Date ( ...values )
이 함수는 호출되면 다음 단계를 수행합니다:
NewTarget이 undefined 이면, 다음을 수행합니다.now 를 현재 시간을 식별하는 시간 값 (UTC)으로 둡니다.ToDateString (now )을 반환합니다. numberOfArgs 를 values 의 요소 수로 둡니다.numberOfArgs = 0이면, 다음을 수행합니다.dv 를 현재 시간을 식별하는 시간 값 (UTC)으로 둡니다.그렇지 않고 numberOfArgs = 1이면, 다음을 수행합니다.value 를 values [0]으로 둡니다.value 가 Object이고 value 에 [[DateValue]] 내부 슬롯이 있으면, 다음을 수행합니다.tv 를 value .[[DateValue]] 로 둡니다.그렇지 않으면,primitive 를 ? ToPrimitive (value )로 둡니다.primitive 가 String이면, 다음을 수행합니다.단언 : primitive 가 String이므로 다음 단계는 절대로 비정상 완료 를 반환하지 않습니다.tv 를 parse 메서드(21.4.3.2 )와 정확히 동일한 방식으로 primitive 를 날짜로 파싱한 결과로 둡니다.그렇지 않으면,tv 를 ? ToNumber (primitive )로 둡니다. dv 를 TimeClip (tv )로 둡니다. 그렇지 않으면,단언 : numberOfArgs ≥ 2입니다.yearNumber 를 ? ToNumber (values [0])으로 둡니다.monthNumber 를 ? ToNumber (values [1])로 둡니다.numberOfArgs > 2이면 dayNumber 를 ? ToNumber (values [2])로 둡니다. 그렇지 않으면 dayNumber 를 1 𝔽 로 둡니다.numberOfArgs > 3이면 hourNumber 를 ? ToNumber (values [3])로 둡니다. 그렇지 않으면 hourNumber 를 +0 𝔽 으로 둡니다.numberOfArgs > 4이면 minuteNumber 를 ? ToNumber (values [4])로 둡니다. 그렇지 않으면 minuteNumber 를 +0 𝔽 으로 둡니다.numberOfArgs > 5이면 secondNumber 를 ? ToNumber (values [5])로 둡니다. 그렇지 않으면 secondNumber 를 +0 𝔽 으로 둡니다.numberOfArgs > 6이면 millisecondNumber 를 ? ToNumber (values [6])로 둡니다. 그렇지 않으면 millisecondNumber 를 +0 𝔽 으로 둡니다.yearNumber 를 MakeFullYear (yearNumber )로 설정합니다.finalDate 를 MakeDate (MakeDay (yearNumber , monthNumber , dayNumber ), MakeTime (hourNumber , minuteNumber , secondNumber , millisecondNumber ))로 둡니다.dv 를 TimeClip (UTC (finalDate ))로 둡니다. obj 를 ? OrdinaryCreateFromConstructor (NewTarget, "%Date.prototype%" , « [[DateValue]] »)로 둡니다.obj .[[DateValue]] 를 dv 로 설정합니다.obj 를 반환합니다.
21.4.3 Date 생성자의 프로퍼티
Date 생성자 는:
21.4.3.1 Date.now ( )
이 함수는 호출이 발생한 UTC 날짜와 시간을 지정하는 시간 값 을 반환합니다.
21.4.3.2 Date.parse ( string )
이 함수는 인수에 ToString 연산자를 적용합니다. ToString 이 비정상 완료 를 생성하면 해당 Completion Record 를 즉시 반환합니다. 그렇지 않으면 이 함수는 결과 String을 날짜와 시간으로 해석하고, 해당 날짜와 시간에 대응하는 UTC 시간 값 인 Number를 반환합니다. String의 내용에 따라 String은 로컬 시간, UTC 시간 또는 다른 시간대의 시간으로 해석될 수 있습니다. 함수는 먼저 확장 연도 를 포함하여 날짜 시간 문자열 형식(21.4.1.32 )에 설명된 형식에 따라 String을 파싱하려고 합니다. String이 해당 형식을 준수하지 않으면 함수는 구현체 고유 휴리스틱 또는 구현체 고유 날짜 형식으로 대체할 수 있습니다. 인식할 수 없거나 범위를 벗어난 형식 요소 값을 포함하는 String은 이 함수가 NaN 을 반환하게 해야 합니다.
String이 날짜 시간 문자열 형식 을 준수하면 존재하지 않는 형식 요소 대신 대체 값이 사용됩니다. MM 또는 DD 요소가 없으면 "01" 을 사용합니다. HH, mm 또는 ss 요소가 없으면 "00" 을 사용합니다. sss 요소가 없으면 "000" 을 사용합니다. UTC 오프셋 표현이 없으면 날짜 전용 형식은 UTC 시간으로 해석하고 날짜-시간 형식은 로컬 시간으로 해석합니다.
x가 특정 ECMAScript 구현체에서 밀리초 값이 0인 임의의 Date이고 참조되는 모든 프로퍼티가 초기 값을 갖는다면 다음 표현식은 모두 해당 구현체에서 동일한 숫자 값을 생성해야 합니다:
x.valueOf ()
Date .parse (x.toString ())
Date .parse (x.toUTCString ())
Date .parse (x.toISOString ())
그러나 다음 표현식은
Date .parse (x.toLocaleString ())
앞의 세 표현식과 동일한 Number 값 을 생성해야 할 필요가 없으며, 일반적으로 날짜 시간 문자열 형식 을 준수하지 않고 해당 구현체의 toString 또는 toUTCString 메서드가 생성할 수도 없는 임의의 String 값이 주어지면 이 함수가 생성하는 값은 구현체 정의 입니다.
21.4.3.3 Date.prototype
Date.prototype의 초기 값은 Date 프로토타입 객체 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
21.4.3.4 Date.UTC ( year [ , month [ , day [ , hour [ , minute [ , second [ , millisecond ] ] ] ] ] ] )
이 함수는 호출되면 다음 단계를 수행합니다:
yearNumber 를 ? ToNumber (year )로 둡니다.month 가 존재하면 monthNumber 를 ? ToNumber (month )로 둡니다. 그렇지 않으면 monthNumber 를 +0 𝔽 으로 둡니다.day 가 존재하면 dayNumber 를 ? ToNumber (day )로 둡니다. 그렇지 않으면 dayNumber 를 1 𝔽 로 둡니다.hour 가 존재하면 hourNumber 를 ? ToNumber (hour )로 둡니다. 그렇지 않으면 hourNumber 를 +0 𝔽 으로 둡니다.minute 이 존재하면 minuteNumber 를 ? ToNumber (minute )로 둡니다. 그렇지 않으면 minuteNumber 를 +0 𝔽 으로 둡니다.second 가 존재하면 secondNumber 를 ? ToNumber (second )로 둡니다. 그렇지 않으면 secondNumber 를 +0 𝔽 으로 둡니다.millisecond 가 존재하면 millisecondNumber 를 ? ToNumber (millisecond )로 둡니다. 그렇지 않으면 millisecondNumber 를 +0 𝔽 으로 둡니다.yearNumber 를 MakeFullYear (yearNumber )로 설정합니다.TimeClip (MakeDate (MakeDay (yearNumber , monthNumber , dayNumber ), MakeTime (hourNumber , minuteNumber , secondNumber , millisecondNumber )))을 반환합니다.
이 함수의 "length" 프로퍼티는 7 𝔽 입니다.
참고
이 함수는 두 가지 점에서 Date 생성자 와 다릅니다. Date를 생성하는 대신 시간 값 을 Number로 반환하며, 인수를 로컬 시간이 아니라 UTC로 해석합니다.
21.4.4 Date 프로토타입 객체의 프로퍼티
Date 프로토타입 객체 는:
%Date.prototype% 입니다.
그 자체가 일반 객체 입니다.
Date 인스턴스가 아니며 [[DateValue]] 내부 슬롯을 갖지 않습니다.
값이 %Object.prototype% 인 [[Prototype]] 내부 슬롯을 갖습니다.
명시적으로 달리 정의되지 않는 한 아래에 정의된 Date 프로토타입 객체의 메서드는 일반적이지 않으며, 메서드에 전달되는 this 값은 시간 값 으로 초기화된 [[DateValue]] 내부 슬롯을 갖는 객체여야 합니다.
21.4.4.1 Date.prototype.constructor
Date.prototype.constructor의 초기 값은 %Date% 입니다.
21.4.4.2 Date.prototype.getDate ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.tv 가 NaN 이면 NaN 을 반환합니다.𝔽 (DateFromTime (LocalTime (tv )))을 반환합니다.
21.4.4.3 Date.prototype.getDay ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.tv 가 NaN 이면 NaN 을 반환합니다.𝔽 (WeekDay (LocalTime (tv )))를 반환합니다.
21.4.4.4 Date.prototype.getFullYear ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.tv 가 NaN 이면 NaN 을 반환합니다.𝔽 (YearFromTime (LocalTime (tv )))를 반환합니다.
21.4.4.5 Date.prototype.getHours ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.tv 가 NaN 이면 NaN 을 반환합니다.𝔽 (HourFromTime (LocalTime (tv )))을 반환합니다.
21.4.4.6 Date.prototype.getMilliseconds ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.tv 가 NaN 이면 NaN 을 반환합니다.𝔽 (MillisecondFromTime (LocalTime (tv )))을 반환합니다.
21.4.4.7 Date.prototype.getMinutes ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.tv 가 NaN 이면 NaN 을 반환합니다.𝔽 (MinuteFromTime (LocalTime (tv )))를 반환합니다.
21.4.4.8 Date.prototype.getMonth ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.tv 가 NaN 이면 NaN 을 반환합니다.𝔽 (MonthFromTime (LocalTime (tv )))를 반환합니다.
21.4.4.9 Date.prototype.getSeconds ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.tv 가 NaN 이면 NaN 을 반환합니다.𝔽 (SecondFromTime (LocalTime (tv )))를 반환합니다.
21.4.4.10 Date.prototype.getTime ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. dateObj .[[DateValue]] 를 반환합니다.
21.4.4.11 Date.prototype.getTimezoneOffset ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.tv 가 NaN 이면 NaN 을 반환합니다.(tv - LocalTime (tv )) / 𝔽 (MillisecondsPerMinute )를 반환합니다.
21.4.4.12 Date.prototype.getUTCDate ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.tv 가 NaN 이면 NaN 을 반환합니다.𝔽 (DateFromTime (tv ))를 반환합니다.
21.4.4.13 Date.prototype.getUTCDay ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.tv 가 NaN 이면 NaN 을 반환합니다.𝔽 (WeekDay (tv ))를 반환합니다.
21.4.4.14 Date.prototype.getUTCFullYear ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.tv 가 NaN 이면 NaN 을 반환합니다.𝔽 (YearFromTime (tv ))를 반환합니다.
21.4.4.15 Date.prototype.getUTCHours ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.tv 가 NaN 이면 NaN 을 반환합니다.𝔽 (HourFromTime (tv ))를 반환합니다.
21.4.4.16 Date.prototype.getUTCMilliseconds ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.tv 가 NaN 이면 NaN 을 반환합니다.𝔽 (MillisecondFromTime (tv ))를 반환합니다.
21.4.4.17 Date.prototype.getUTCMinutes ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.tv 가 NaN 이면 NaN 을 반환합니다.𝔽 (MinuteFromTime (tv ))를 반환합니다.
21.4.4.18 Date.prototype.getUTCMonth ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.tv 가 NaN 이면 NaN 을 반환합니다.𝔽 (MonthFromTime (tv ))를 반환합니다.
21.4.4.19 Date.prototype.getUTCSeconds ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.tv 가 NaN 이면 NaN 을 반환합니다.𝔽 (SecondFromTime (tv ))를 반환합니다.
21.4.4.20 Date.prototype.setDate ( day )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.dayNumber 를 ? ToNumber (day )로 둡니다.tv 가 NaN 이면 NaN 을 반환합니다.tv 를 LocalTime (tv )로 설정합니다.newDate 를 MakeDate (MakeDay (𝔽 (YearFromTime (tv )), 𝔽 (MonthFromTime (tv )), dayNumber ), 𝔽 (TimeWithinDay (tv )))로 둡니다.u 를 TimeClip (UTC (newDate ))로 둡니다.dateObj .[[DateValue]] 를 u 로 설정합니다.u 를 반환합니다.
21.4.4.21 Date.prototype.setFullYear ( year [ , month [ , day ] ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.yearNumber 를 ? ToNumber (year )로 둡니다.tv 가 NaN 이면 tv 를 +0 𝔽 으로 설정합니다. 그렇지 않으면 tv 를 LocalTime (tv )로 설정합니다.month 가 존재하면 monthNumber 를 ? ToNumber (month )로 둡니다. 그렇지 않으면 monthNumber 를 𝔽 (MonthFromTime (tv ))로 둡니다.day 가 존재하면 dayNumber 를 ? ToNumber (day )로 둡니다. 그렇지 않으면 dayNumber 를 𝔽 (DateFromTime (tv ))로 둡니다.newDate 를 MakeDate (MakeDay (yearNumber , monthNumber , dayNumber ), 𝔽 (TimeWithinDay (tv )))로 둡니다.u 를 TimeClip (UTC (newDate ))로 둡니다.dateObj .[[DateValue]] 를 u 로 설정합니다.u 를 반환합니다.
이 메서드의 "length" 프로퍼티는 3 𝔽 입니다.
참고
month 가 존재하지 않으면 이 메서드는 month 가 getMonth() 값으로 존재했던 것처럼 동작합니다. day 가 존재하지 않으면 day 가 getDate() 값으로 존재했던 것처럼 동작합니다.
21.4.4.22 Date.prototype.setHours ( hour [ , minute [ , second [ , millisecond ] ] ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.hourNumber 를 ? ToNumber (hour )로 둡니다.minute 이 존재하면 minuteNumber 를 ? ToNumber (minute )로 둡니다.second 가 존재하면 secondNumber 를 ? ToNumber (second )로 둡니다.millisecond 가 존재하면 millisecondNumber 를 ? ToNumber (millisecond )로 둡니다.tv 가 NaN 이면 NaN 을 반환합니다.tv 를 LocalTime (tv )로 설정합니다.minute 이 존재하지 않으면 minuteNumber 를 𝔽 (MinuteFromTime (tv ))로 둡니다.second 가 존재하지 않으면 secondNumber 를 𝔽 (SecondFromTime (tv ))로 둡니다.millisecond 가 존재하지 않으면 millisecondNumber 를 𝔽 (MillisecondFromTime (tv ))로 둡니다.date 를 MakeDate (𝔽 (Day (tv )), MakeTime (hourNumber , minuteNumber , secondNumber , millisecondNumber ))로 둡니다.u 를 TimeClip (UTC (date ))로 둡니다.dateObj .[[DateValue]] 를 u 로 설정합니다.u 를 반환합니다.
이 메서드의 "length" 프로퍼티는 4 𝔽 입니다.
참고
minute 이 존재하지 않으면 이 메서드는 minute 이 getMinutes() 값으로 존재했던 것처럼 동작합니다. second 가 존재하지 않으면 second 가 getSeconds() 값으로 존재했던 것처럼 동작합니다. millisecond 가 존재하지 않으면 millisecond 가 getMilliseconds() 값으로 존재했던 것처럼 동작합니다.
21.4.4.23 Date.prototype.setMilliseconds ( millisecond )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.millisecondNumber 를 ? ToNumber (millisecond )로 둡니다.tv 가 NaN 이면 NaN 을 반환합니다.tv 를 LocalTime (tv )로 설정합니다.time 을 MakeTime (𝔽 (HourFromTime (tv )), 𝔽 (MinuteFromTime (tv )), 𝔽 (SecondFromTime (tv )), millisecondNumber )로 둡니다.u 를 TimeClip (UTC (MakeDate (𝔽 (Day (tv )), time )))로 둡니다.dateObj .[[DateValue]] 를 u 로 설정합니다.u 를 반환합니다.
21.4.4.24 Date.prototype.setMinutes ( minute [ , second [ , millisecond ] ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.minuteNumber 를 ? ToNumber (minute )로 둡니다.second 가 존재하면 secondNumber 를 ? ToNumber (second )로 둡니다.millisecond 가 존재하면 millisecondNumber 를 ? ToNumber (millisecond )로 둡니다.tv 가 NaN 이면 NaN 을 반환합니다.tv 를 LocalTime (tv )로 설정합니다.second 가 존재하지 않으면 secondNumber 를 𝔽 (SecondFromTime (tv ))로 둡니다.millisecond 가 존재하지 않으면 millisecondNumber 를 𝔽 (MillisecondFromTime (tv ))로 둡니다.date 를 MakeDate (𝔽 (Day (tv )), MakeTime (𝔽 (HourFromTime (tv )), minuteNumber , secondNumber , millisecondNumber ))로 둡니다.u 를 TimeClip (UTC (date ))로 둡니다.dateObj .[[DateValue]] 를 u 로 설정합니다.u 를 반환합니다.
이 메서드의 "length" 프로퍼티는 3 𝔽 입니다.
참고
second 가 존재하지 않으면 이 메서드는 second 가 getSeconds() 값으로 존재했던 것처럼 동작합니다. millisecond 가 존재하지 않으면 millisecond 가 getMilliseconds() 값으로 존재했던 것처럼 동작합니다.
21.4.4.25 Date.prototype.setMonth ( month [ , day ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.monthNumber 를 ? ToNumber (month )로 둡니다.day 가 존재하면 dayNumber 를 ? ToNumber (day )로 둡니다.tv 가 NaN 이면 NaN 을 반환합니다.tv 를 LocalTime (tv )로 설정합니다.day 가 존재하지 않으면 dayNumber 를 𝔽 (DateFromTime (tv ))로 둡니다.newDate 를 MakeDate (MakeDay (𝔽 (YearFromTime (tv )), monthNumber , dayNumber ), 𝔽 (TimeWithinDay (tv )))로 둡니다.u 를 TimeClip (UTC (newDate ))로 둡니다.dateObj .[[DateValue]] 를 u 로 설정합니다.u 를 반환합니다.
이 메서드의 "length" 프로퍼티는 2 𝔽 입니다.
참고
day 가 존재하지 않으면 이 메서드는 day 가 getDate() 값으로 존재했던 것처럼 동작합니다.
21.4.4.26 Date.prototype.setSeconds ( second [ , millisecond ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.secondNumber 를 ? ToNumber (second )로 둡니다.millisecond 가 존재하면 millisecondNumber 를 ? ToNumber (millisecond )로 둡니다.tv 가 NaN 이면 NaN 을 반환합니다.tv 를 LocalTime (tv )로 설정합니다.millisecond 가 존재하지 않으면 millisecondNumber 를 𝔽 (MillisecondFromTime (tv ))로 둡니다.date 를 MakeDate (𝔽 (Day (tv )), MakeTime (𝔽 (HourFromTime (tv )), 𝔽 (MinuteFromTime (tv )), secondNumber , millisecondNumber ))로 둡니다.u 를 TimeClip (UTC (date ))로 둡니다.dateObj .[[DateValue]] 를 u 로 설정합니다.u 를 반환합니다.
이 메서드의 "length" 프로퍼티는 2 𝔽 입니다.
참고
millisecond 가 존재하지 않으면 이 메서드는 millisecond 가 getMilliseconds() 값으로 존재했던 것처럼 동작합니다.
21.4.4.27 Date.prototype.setTime ( time )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. t 를 ? ToNumber (time )로 둡니다.v 를 TimeClip (t )로 둡니다.dateObj .[[DateValue]] 를 v 로 설정합니다.v 를 반환합니다.
21.4.4.28 Date.prototype.setUTCDate ( day )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.dayNumber 를 ? ToNumber (day )로 둡니다.tv 가 NaN 이면 NaN 을 반환합니다.newDate 를 MakeDate (MakeDay (𝔽 (YearFromTime (tv )), 𝔽 (MonthFromTime (tv )), dayNumber ), 𝔽 (TimeWithinDay (tv )))로 둡니다.v 를 TimeClip (newDate )로 둡니다.dateObj .[[DateValue]] 를 v 로 설정합니다.v 를 반환합니다.
21.4.4.29 Date.prototype.setUTCFullYear ( year [ , month [ , day ] ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.tv 가 NaN 이면 tv 를 +0 𝔽 으로 설정합니다.yearNumber 를 ? ToNumber (year )로 둡니다.month 가 존재하면 monthNumber 를 ? ToNumber (month )로 둡니다. 그렇지 않으면 monthNumber 를 𝔽 (MonthFromTime (tv ))로 둡니다.day 가 존재하면 dayNumber 를 ? ToNumber (day )로 둡니다. 그렇지 않으면 dayNumber 를 𝔽 (DateFromTime (tv ))로 둡니다.newDate 를 MakeDate (MakeDay (yearNumber , monthNumber , dayNumber ), 𝔽 (TimeWithinDay (tv )))로 둡니다.v 를 TimeClip (newDate )로 둡니다.dateObj .[[DateValue]] 를 v 로 설정합니다.v 를 반환합니다.
이 메서드의 "length" 프로퍼티는 3 𝔽 입니다.
참고
month 가 존재하지 않으면 이 메서드는 month 가 getUTCMonth() 값으로 존재했던 것처럼 동작합니다. day 가 존재하지 않으면 day 가 getUTCDate() 값으로 존재했던 것처럼 동작합니다.
21.4.4.30 Date.prototype.setUTCHours ( hour [ , minute [ , second [ , millisecond ] ] ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.hourNumber 를 ? ToNumber (hour )로 둡니다.minute 이 존재하면 minuteNumber 를 ? ToNumber (minute )로 둡니다.second 가 존재하면 secondNumber 를 ? ToNumber (second )로 둡니다.millisecond 가 존재하면 millisecondNumber 를 ? ToNumber (millisecond )로 둡니다.tv 가 NaN 이면 NaN 을 반환합니다.minute 이 존재하지 않으면 minuteNumber 를 𝔽 (MinuteFromTime (tv ))로 둡니다.second 가 존재하지 않으면 secondNumber 를 𝔽 (SecondFromTime (tv ))로 둡니다.millisecond 가 존재하지 않으면 millisecondNumber 를 𝔽 (MillisecondFromTime (tv ))로 둡니다.date 를 MakeDate (𝔽 (Day (tv )), MakeTime (hourNumber , minuteNumber , secondNumber , millisecondNumber ))로 둡니다.v 를 TimeClip (date )로 둡니다.dateObj .[[DateValue]] 를 v 로 설정합니다.v 를 반환합니다.
이 메서드의 "length" 프로퍼티는 4 𝔽 입니다.
참고
minute 이 존재하지 않으면 이 메서드는 minute 이 getUTCMinutes() 값으로 존재했던 것처럼 동작합니다. second 가 존재하지 않으면 second 가 getUTCSeconds() 값으로 존재했던 것처럼 동작합니다. millisecond 가 존재하지 않으면 millisecond 가 getUTCMilliseconds() 값으로 존재했던 것처럼 동작합니다.
21.4.4.31 Date.prototype.setUTCMilliseconds ( millisecond )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.millisecondNumber 를 ? ToNumber (millisecond )로 둡니다.tv 가 NaN 이면 NaN 을 반환합니다.time 을 MakeTime (𝔽 (HourFromTime (tv )), 𝔽 (MinuteFromTime (tv )), 𝔽 (SecondFromTime (tv )), millisecondNumber )로 둡니다.v 를 TimeClip (MakeDate (𝔽 (Day (tv )), time ))로 둡니다.dateObj .[[DateValue]] 를 v 로 설정합니다.v 를 반환합니다.
21.4.4.32 Date.prototype.setUTCMinutes ( minute [ , second [ , millisecond ] ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.minuteNumber 를 ? ToNumber (minute )로 둡니다.second 가 존재하면 secondNumber 를 ? ToNumber (second )로 둡니다.millisecond 가 존재하면 millisecondNumber 를 ? ToNumber (millisecond )로 둡니다.tv 가 NaN 이면 NaN 을 반환합니다.second 가 존재하지 않으면 secondNumber 를 𝔽 (SecondFromTime (tv ))로 둡니다.millisecond 가 존재하지 않으면 millisecondNumber 를 𝔽 (MillisecondFromTime (tv ))로 둡니다.date 를 MakeDate (𝔽 (Day (tv )), MakeTime (𝔽 (HourFromTime (tv )), minuteNumber , secondNumber , millisecondNumber ))로 둡니다.v 를 TimeClip (date )로 둡니다.dateObj .[[DateValue]] 를 v 로 설정합니다.v 를 반환합니다.
이 메서드의 "length" 프로퍼티는 3 𝔽 입니다.
참고
second 가 존재하지 않으면 이 메서드는 second 가 getUTCSeconds() 값으로 존재했던 것처럼 동작합니다. millisecond 가 존재하지 않으면 이 메서드는 millisecond 가 getUTCMilliseconds()가 반환하는 값으로 존재했던 것처럼 동작합니다.
21.4.4.33 Date.prototype.setUTCMonth ( month [ , day ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.monthNumber 를 ? ToNumber (month )로 둡니다.day 가 존재하면 dayNumber 를 ? ToNumber (day )로 둡니다.tv 가 NaN 이면 NaN 을 반환합니다.day 가 존재하지 않으면 dayNumber 를 𝔽 (DateFromTime (tv ))로 둡니다.newDate 를 MakeDate (MakeDay (𝔽 (YearFromTime (tv )), monthNumber , dayNumber ), 𝔽 (TimeWithinDay (tv )))로 둡니다.v 를 TimeClip (newDate )로 둡니다.dateObj .[[DateValue]] 를 v 로 설정합니다.v 를 반환합니다.
이 메서드의 "length" 프로퍼티는 2 𝔽 입니다.
참고
day 가 존재하지 않으면 이 메서드는 day 가 getUTCDate() 값으로 존재했던 것처럼 동작합니다.
21.4.4.34 Date.prototype.setUTCSeconds ( second [ , millisecond ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.secondNumber 를 ? ToNumber (second )로 둡니다.millisecond 가 존재하면 millisecondNumber 를 ? ToNumber (millisecond )로 둡니다.tv 가 NaN 이면 NaN 을 반환합니다.millisecond 가 존재하지 않으면 millisecondNumber 를 𝔽 (MillisecondFromTime (tv ))로 둡니다.date 를 MakeDate (𝔽 (Day (tv )), MakeTime (𝔽 (HourFromTime (tv )), 𝔽 (MinuteFromTime (tv )), secondNumber , millisecondNumber ))로 둡니다.v 를 TimeClip (date )로 둡니다.dateObj .[[DateValue]] 를 v 로 설정합니다.v 를 반환합니다.
이 메서드의 "length" 프로퍼티는 2 𝔽 입니다.
참고
millisecond 가 존재하지 않으면 이 메서드는 millisecond 가 getUTCMilliseconds() 값으로 존재했던 것처럼 동작합니다.
21.4.4.35 Date.prototype.toDateString ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.tv 가 NaN 이면 "Invalid Date" 를 반환합니다.t 를 LocalTime (tv )로 둡니다.DateString (t )을 반환합니다.
21.4.4.36 Date.prototype.toISOString ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.tv 가 NaN 이면 RangeError 예외를 던집니다.단언 : tv 는 정수 Number입니다.tv 가 날짜 시간 문자열 형식 으로 나타낼 수 없는 연도에 대응하면 RangeError 예외를 던집니다.모든 형식 요소와 UTC 오프셋 표현 "Z" 를 포함하여 UTC 시간 척도에서 날짜 시간 문자열 형식 으로 tv 를 나타내는 String을 반환합니다.
21.4.4.37 Date.prototype.toJSON ( key )
이 메서드는 JSON.stringify(25.5.4 )에서 사용하기 위한 Date의 String 표현을 제공합니다.
호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.tv 를 ? ToPrimitive (obj , number )로 둡니다.tv 가 Number이고 tv 가 유한 Number 가 아니면 null 을 반환합니다.? Invoke (obj , "toISOString" )를 반환합니다.
참고 1
참고 2
이 메서드는 의도적으로 일반적이며 this 값이 Date일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다. 다만 그러한 객체에는 toISOString 메서드가 있어야 합니다.
21.4.4.38 Date.prototype.toLocaleDateString ( [ reserved1 [ , reserved2 ] ] )
ECMA-402 국제화 API를 포함하는 ECMAScript 구현체는 ECMA-402에 명시된 대로 이 메서드를 구현해야 합니다. 그렇지 않으면 다음과 같은 이 메서드 명세가 사용됩니다:
이 메서드는 String 값을 반환합니다. String의 내용은 구현체 정의 이지만 호스트 환경 의 현재 로케일 관례에 대응하는 편리하고 사람이 읽을 수 있는 형식으로 현재 시간대에서 Date의 “날짜” 부분을 나타내도록 의도됩니다.
이 메서드의 선택적 매개변수의 의미는 ECMA-402에 정의되어 있습니다. ECMA-402 지원을 포함하지 않는 구현체는 해당 매개변수 위치를 다른 용도로 사용해서는 안 됩니다.
21.4.4.39 Date.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )
ECMA-402 국제화 API를 포함하는 ECMAScript 구현체는 ECMA-402에 명시된 대로 이 메서드를 구현해야 합니다. 그렇지 않으면 다음과 같은 이 메서드 명세가 사용됩니다:
이 메서드는 String 값을 반환합니다. String의 내용은 구현체 정의 이지만 호스트 환경 의 현재 로케일 관례에 대응하는 편리하고 사람이 읽을 수 있는 형식으로 현재 시간대의 Date를 나타내도록 의도됩니다.
이 메서드의 선택적 매개변수의 의미는 ECMA-402에 정의되어 있습니다. ECMA-402 지원을 포함하지 않는 구현체는 해당 매개변수 위치를 다른 용도로 사용해서는 안 됩니다.
21.4.4.40 Date.prototype.toLocaleTimeString ( [ reserved1 [ , reserved2 ] ] )
ECMA-402 국제화 API를 포함하는 ECMAScript 구현체는 ECMA-402에 명시된 대로 이 메서드를 구현해야 합니다. 그렇지 않으면 다음과 같은 이 메서드 명세가 사용됩니다:
이 메서드는 String 값을 반환합니다. String의 내용은 구현체 정의 이지만 호스트 환경 의 현재 로케일 관례에 대응하는 편리하고 사람이 읽을 수 있는 형식으로 현재 시간대에서 Date의 “시간” 부분을 나타내도록 의도됩니다.
이 메서드의 선택적 매개변수의 의미는 ECMA-402에 정의되어 있습니다. ECMA-402 지원을 포함하지 않는 구현체는 해당 매개변수 위치를 다른 용도로 사용해서는 안 됩니다.
21.4.4.41 Date.prototype.toString ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.ToDateString (tv )을 반환합니다.
참고 1
d.[[DateValue]] 가 1000으로 나누어떨어지는 임의의 Date d에 대해 Date.parse(d.toString()) = d.valueOf()입니다. 21.4.3.2 를 참조하시기 바랍니다.
참고 2
이 메서드는 일반적이지 않습니다. this 값이 Date가 아니면 TypeError 예외를 던집니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 없습니다.
21.4.4.41.1 TimeString ( tv )
추상 연산 TimeString. 인수 tv (a Number, but not NaN ). 반환값: String. 호출되면 다음 단계를 수행한다.
hour 를 ToZeroPaddedDecimalString (HourFromTime (tv ), 2)로 둡니다.minute 을 ToZeroPaddedDecimalString (MinuteFromTime (tv ), 2)로 둡니다.second 를 ToZeroPaddedDecimalString (SecondFromTime (tv ), 2)로 둡니다.hour , ":" , minute , ":" , second , 코드 단위 0x0020 (SPACE) 및 "GMT" 의 문자열 연결 을 반환합니다.
21.4.4.41.2 DateString ( tv )
추상 연산 DateString. 인수 tv (a Number, but not NaN ). 반환값: String. 호출되면 다음 단계를 수행한다.
weekday 를 WeekDay Index = WeekDay (tv )인 표 61 항목의 Name으로 둡니다.month 를 Month Index = MonthFromTime (tv )인 표 62 항목의 Name으로 둡니다.day 를 ToZeroPaddedDecimalString (DateFromTime (tv ), 2)로 둡니다.yv 를 YearFromTime (tv )로 둡니다.yv ≥ 0이면 yearSign 을 빈 String으로 둡니다. 그렇지 않으면 yearSign 을 "-" 로 둡니다.paddedYear 를 ToZeroPaddedDecimalString (abs (yv ), 4)로 둡니다.weekday , 코드 단위 0x0020 (SPACE), month , 코드 단위 0x0020 (SPACE), day , 코드 단위 0x0020 (SPACE), yearSign 및 paddedYear 의 문자열 연결 을 반환합니다.
표 61: 요일 이름
WeekDay 인덱스
이름
0
"Sun"
1
"Mon"
2
"Tue"
3
"Wed"
4
"Thu"
5
"Fri"
6
"Sat"
표 62: 연중 월 이름
Month 인덱스
이름
0
"Jan"
1
"Feb"
2
"Mar"
3
"Apr"
4
"May"
5
"Jun"
6
"Jul"
7
"Aug"
8
"Sep"
9
"Oct"
10
"Nov"
11
"Dec"
21.4.4.41.3 TimeZoneString ( tv )
추상 연산 TimeZoneString. 인수 tv (정수인 Number ). 반환값: String. 호출되면 다음 단계를 수행한다.
systemTimeZoneIdentifier 를 SystemTimeZoneIdentifier ()로 둡니다.IsTimeZoneOffsetString (systemTimeZoneIdentifier )이 true 이면, 다음을 수행합니다.offsetNanoseconds 를 ParseTimeZoneOffsetString (systemTimeZoneIdentifier )으로 둡니다.그렇지 않으면,offsetNanoseconds 를 GetNamedTimeZoneOffsetNanoseconds (systemTimeZoneIdentifier , ℝ (tv ) × NanosecondsPerMillisecond )로 둡니다. offsetMilliseconds 를 truncate (offsetNanoseconds / NanosecondsPerMillisecond )로 둡니다.offsetMilliseconds ≥ 0이면, 다음을 수행합니다.offsetSign 을 "+" 로 둡니다.absOffsetMilliseconds 를 offsetMilliseconds 로 둡니다.그렇지 않으면,offsetSign 을 "-" 로 둡니다.absOffsetMilliseconds 를 -offsetMilliseconds 로 둡니다. offsetMinute 을 ToZeroPaddedDecimalString (MinuteFromTime (𝔽 (absOffsetMilliseconds )), 2)로 둡니다.offsetHour 를 ToZeroPaddedDecimalString (HourFromTime (𝔽 (absOffsetMilliseconds )), 2)로 둡니다.timeZoneName 을 빈 String 또는 코드 단위 0x0020 (SPACE), 코드 단위 0x0028 (LEFT PARENTHESIS), 구현체 정의 시간대 이름 및 코드 단위 0x0029 (RIGHT PARENTHESIS)의 문자열 연결 중 하나인 구현체 정의 문자열로 둡니다.offsetSign , offsetHour , offsetMinute 및 timeZoneName 의 문자열 연결 을 반환합니다.
21.4.4.41.4 ToDateString ( tv )
추상 연산 ToDateString. 인수 tv ((정수인 Number 또는 NaN )). 반환값: String. 호출되면 다음 단계를 수행한다.
tv 가 NaN 이면 "Invalid Date" 를 반환합니다.localTime 을 LocalTime (tv )로 둡니다.DateString (localTime ), 코드 단위 0x0020 (SPACE), TimeString (localTime ) 및 TimeZoneString (tv )의 문자열 연결 을 반환합니다.
21.4.4.42 Date.prototype.toTimeString ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.tv 가 NaN 이면 "Invalid Date" 를 반환합니다.localTime 을 LocalTime (tv )로 둡니다.TimeString (localTime )과 TimeZoneString (tv )의 문자열 연결 을 반환합니다.
21.4.4.43 Date.prototype.toUTCString ( )
이 메서드는 this 값에 대응하는 시간의 순간을 나타내는 String 값을 반환합니다. String 형식은 RFC 7231의 HTTP-date를 기반으로 하며 ECMAScript Date가 지원하는 전체 시간 범위를 지원하도록 일반화되어 있습니다.
호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.tv 가 NaN 이면 "Invalid Date" 를 반환합니다.weekday 를 WeekDay Index = WeekDay (tv )인 표 61 항목의 Name으로 둡니다.month 를 Month Index = MonthFromTime (tv )인 표 62 항목의 Name으로 둡니다.day 를 ToZeroPaddedDecimalString (DateFromTime (tv ), 2)로 둡니다.yv 를 YearFromTime (tv )로 둡니다.yv ≥ 0이면 yearSign 을 빈 String으로 둡니다. 그렇지 않으면 yearSign 을 "-" 로 둡니다.paddedYear 를 ToZeroPaddedDecimalString (abs (yv ), 4)로 둡니다.weekday , "," , 코드 단위 0x0020 (SPACE), day , 코드 단위 0x0020 (SPACE), month , 코드 단위 0x0020 (SPACE), yearSign , paddedYear , 코드 단위 0x0020 (SPACE) 및 TimeString (tv )의 문자열 연결 을 반환합니다.
21.4.4.44 Date.prototype.valueOf ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. dateObj .[[DateValue]] 를 반환합니다.
21.4.4.45 Date.prototype [ %Symbol.toPrimitive% ] ( hint )
이 메서드는 ECMAScript 언어 연산자가 Date를 원시 값으로 변환하기 위해 호출합니다. hint 에 허용되는 값은 "default" , "number" 및 "string" 입니다. Date는 "default" 를 "string" 과 동등하게 취급한다는 점에서 내장 ECMAScript 객체 중 유일합니다. 다른 모든 내장 ECMAScript 객체는 "default" 를 "number" 와 동등하게 취급합니다.
호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.obj 가 Object가 아니면 TypeError 예외를 던집니다.hint 가 "string" 또는 "default" 중 하나이면, 다음을 수행합니다.tryFirst 를 string 으로 둡니다.그렇지 않고 hint 가 "number" 이면, 다음을 수행합니다.tryFirst 를 number 로 둡니다. 그렇지 않으면,TypeError 예외를 던집니다. ? OrdinaryToPrimitive (obj , tryFirst )를 반환합니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
이 메서드의 "name" 프로퍼티 값은 "[Symbol.toPrimitive]" 입니다.
21.4.5 Date 인스턴스의 프로퍼티
Date 인스턴스는 Date 프로토타입 객체 에서 프로퍼티를 상속하는 일반 객체 입니다. Date 인스턴스에는 [[DateValue]] 내부 슬롯도 있습니다. [[DateValue]] 내부 슬롯은 이 Date가 나타내는 시간 값 입니다.
22 텍스트 처리
22.1 String 객체
22.1.1 String 생성자
String 생성자 는:
%String% 입니다.
전역 객체 의 "String" 프로퍼티 초기 값입니다.
생성자 로 호출되면 새로운 String 객체를 생성하고 초기화합니다.
생성자 가 아니라 함수로 호출되면 타입 변환을 수행합니다.
클래스 정의의 extends 절 값으로 사용할 수 있습니다. 명시된 String 동작을 상속하려는 하위 클래스 생성자 는 [[StringData]] 내부 슬롯을 갖는 하위 클래스 인스턴스를 생성하고 초기화하기 위해 String 생성자 에 대한 super 호출을 포함해야 합니다.
22.1.1.1 String ( value )
이 함수는 호출되면 다음 단계를 수행합니다:
value 가 존재하지 않으면, 다음을 수행합니다.string 을 빈 String으로 둡니다.그렇지 않으면,NewTarget이 undefined 이고 value 가 Symbol이면 SymbolDescriptiveString (value )을 반환합니다. string 을 ? ToString (value )으로 둡니다. NewTarget이 undefined 이면 string 을 반환합니다. StringCreate (string , ? GetPrototypeFromConstructor (NewTarget, "%String.prototype%" ))를 반환합니다.
22.1.2 String 생성자의 프로퍼티
String 생성자 는:
22.1.2.1 String.fromCharCode ( ...codeUnits )
이 함수는 나머지 매개변수 codeUnits 를 구성하는 임의의 수의 인수로 호출할 수 있습니다.
호출되면 다음 단계를 수행합니다:
result 를 빈 String으로 둡니다.codeUnits 의 각 요소 next 에 대해 다음을 수행합니다.nextCU 를 숫자 값이 ℝ (? ToUint16 (next ))인 코드 단위로 둡니다.result 를 result 와 nextCU 의 문자열 연결 로 설정합니다.result 를 반환합니다.
이 함수의 "length" 프로퍼티는 1 𝔽 입니다.
22.1.2.2 String.fromCodePoint ( ...codePoints )
이 함수는 나머지 매개변수 codePoints 를 구성하는 임의의 수의 인수로 호출할 수 있습니다.
호출되면 다음 단계를 수행합니다:
result 를 빈 String으로 둡니다.codePoints 의 각 요소 next 에 대해 다음을 수행합니다.nextCP 를 ? ToNumber (next )로 둡니다.nextCP 가 정수 Number가 아니면 RangeError 예외를 던집니다.ℝ (nextCP ) < 0 또는 ℝ (nextCP ) > 0x10FFFF이면 RangeError 예외를 던집니다.result 를 result 와 UTF16EncodeCodePoint (ℝ (nextCP ))의 문자열 연결 로 설정합니다.단언 : codePoints 가 비어 있으면 result 는 빈 String입니다.result 를 반환합니다.
이 함수의 "length" 프로퍼티는 1 𝔽 입니다.
22.1.2.3 String.prototype
String.prototype의 초기 값은 String 프로토타입 객체 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
22.1.2.4 String.raw ( template , ...substitutions )
이 함수는 가변 개수의 인수로 호출할 수 있습니다. 첫 번째 인수는 template 이며 나머지 인수는 List substitutions 를 구성합니다.
호출되면 다음 단계를 수행합니다:
substitutionCount 를 substitutions 의 요소 수로 둡니다.cooked 를 ? ToObject (template )로 둡니다.literals 를 ? ToObject (? Get (cooked , "raw" ))로 둡니다.literalCount 를 ? LengthOfArrayLike (literals )로 둡니다.literalCount ≤ 0이면 빈 String을 반환합니다.result 를 빈 String으로 둡니다.nextIndex 를 0으로 둡니다.다음을 반복합니다.nextLiteralValue 를 ? Get (literals , ! ToString (𝔽 (nextIndex )))로 둡니다.nextLiteral 을 ? ToString (nextLiteralValue )으로 둡니다.result 를 result 와 nextLiteral 의 문자열 연결 로 설정합니다.nextIndex + 1 = literalCount 이면 result 를 반환합니다.nextIndex < substitutionCount 이면, 다음을 수행합니다.nextSubValue 를 substitutions [nextIndex ]로 둡니다.nextSub 를 ? ToString (nextSubValue )로 둡니다.result 를 result 와 nextSub 의 문자열 연결 로 설정합니다.nextIndex 를 nextIndex + 1로 설정합니다.
참고
이 함수는 Tagged Template(13.3.11 )의 태그 함수로 사용하도록 의도되었습니다. 이러한 방식으로 호출되면 첫 번째 인수는 올바른 형식의 템플릿 객체이며 나머지 매개변수에는 치환 값이 포함됩니다.
22.1.3 String 프로토타입 객체의 프로퍼티
String 프로토타입 객체 는:
%String.prototype% 입니다.
String 특수 객체 이며 이러한 객체에 지정된 내부 메서드를 갖습니다.
값이 빈 String인 [[StringData]] 내부 슬롯을 갖습니다.
초기 값이 +0 𝔽 이고 속성이 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false }인 "length" 프로퍼티를 갖습니다.
값이 %Object.prototype% 인 [[Prototype]] 내부 슬롯을 갖습니다.
명시적으로 달리 언급하지 않는 한 아래에 정의된 String 프로토타입 객체의 메서드는 일반적이지 않으며, 전달되는 this 값은 String 값 또는 String 값으로 초기화된 [[StringData]] 내부 슬롯을 갖는 객체여야 합니다.
22.1.3.1 String.prototype.at ( index )
thisValue 를 this 값으로 둡니다.? RequireObjectCoercible (thisValue )를 수행합니다. string 을 ? ToString (thisValue )으로 둡니다.length 를 string 의 길이로 둡니다.k 를 ? ToAbsoluteIndex (index , length )로 둡니다.k < 0 또는 k ≥ length 이면 undefined 를 반환합니다.string 의 k 부터 k + 1까지의 부분 문자열 을 반환합니다.
22.1.3.2 String.prototype.charAt ( position )
참고 1
이 메서드는 이 객체를 String으로 변환하여 얻은 String 값의 인덱스 position 에 있는 코드 단위를 포함하는 단일 요소 String을 반환합니다. 해당 인덱스에 요소가 없으면 결과는 빈 String입니다. 결과는 String 객체가 아니라 String 값입니다.
pos가 정수 Number이면 x.charAt(pos)의 결과는 x.substring(pos, pos + 1)의 결과와 동등합니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
thisValue 를 this 값으로 둡니다.? RequireObjectCoercible (thisValue )를 수행합니다. string 을 ? ToString (thisValue )으로 둡니다.position 을 ? ToIntegerOrInfinity (position )으로 설정합니다.size 를 string 의 길이로 둡니다.position < 0 또는 position ≥ size 이면 빈 String을 반환합니다.string 의 position 부터 position + 1까지의 부분 문자열 을 반환합니다.
참고 2
이 메서드는 의도적으로 일반적이며 this 값이 String 객체일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
22.1.3.3 String.prototype.charCodeAt ( position )
참고 1
이 메서드는 이 객체를 String으로 변환하여 얻은 String의 인덱스 position 에 있는 코드 단위의 숫자 값인 Number(216 보다 작은 음이 아닌 정수 Number)를 반환합니다. 해당 인덱스에 요소가 없으면 결과는 NaN 입니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
thisValue 를 this 값으로 둡니다.? RequireObjectCoercible (thisValue )를 수행합니다. string 을 ? ToString (thisValue )으로 둡니다.position 을 ? ToIntegerOrInfinity (position )으로 설정합니다.size 를 string 의 길이로 둡니다.position < 0 또는 position ≥ size 이면 NaN 을 반환합니다.String string 안의 인덱스 position 에 있는 코드 단위의 숫자 값에 해당하는 Number 값 을 반환합니다.
참고 2
이 메서드는 의도적으로 일반적이며 this 값이 String 객체일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
22.1.3.4 String.prototype.codePointAt ( position )
참고 1
이 메서드는 이 객체를 String으로 변환하여 얻은 String의 인덱스 position 에 있는 문자열 요소에서 시작하는 UTF-16 인코딩 코드 포인트(6.1.4 )의 숫자 값인 0x10FFFF 𝔽 이하의 음이 아닌 정수 Number를 반환합니다. 해당 인덱스에 요소가 없으면 결과는 undefined 입니다. 유효한 UTF-16 서로게이트 쌍 이 position 에서 시작하지 않으면 결과는 position 의 코드 단위입니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
thisValue 를 this 값으로 둡니다.? RequireObjectCoercible (thisValue )를 수행합니다. string 을 ? ToString (thisValue )으로 둡니다.position 을 ? ToIntegerOrInfinity (position )으로 설정합니다.size 를 string 의 길이로 둡니다.position < 0 또는 position ≥ size 이면 undefined 를 반환합니다.codePoint 를 CodePointAt (string , position )로 둡니다.𝔽 (codePoint .[[CodePoint]] )를 반환합니다.
참고 2
이 메서드는 의도적으로 일반적이며 this 값이 String 객체일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
22.1.3.5 String.prototype.concat ( ...args )
참고 1
이 메서드가 호출되면 this 값의 코드 단위(this 값을 String으로 변환한 것) 뒤에 각 인수를 String으로 변환한 코드 단위가 이어지는 String 값을 반환합니다. 결과는 String 객체가 아니라 String 값입니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
thisValue 를 this 값으로 둡니다.? RequireObjectCoercible (thisValue )를 수행합니다. string 을 ? ToString (thisValue )으로 둡니다.result 를 string 으로 둡니다.args 의 각 요소 next 에 대해 다음을 수행합니다.nextString 을 ? ToString (next )으로 둡니다.result 를 result 와 nextString 의 문자열 연결 로 설정합니다.result 를 반환합니다.
이 메서드의 "length" 프로퍼티는 1 𝔽 입니다.
참고 2
이 메서드는 의도적으로 일반적이며 this 값이 String 객체일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
22.1.3.6 String.prototype.constructor
String.prototype.constructor의 초기 값은 %String% 입니다.
22.1.3.7 String.prototype.endsWith ( searchString [ , endPosition ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
thisValue 를 this 값으로 둡니다.? RequireObjectCoercible (thisValue )를 수행합니다. string 을 ? ToString (thisValue )으로 둡니다.isRegexp 를 ? IsRegExp (searchString )로 둡니다.isRegexp 가 true 이면 TypeError 예외를 던집니다.searchString 을 ? ToString (searchString )으로 설정합니다.length 를 string 의 길이로 둡니다.endPosition 이 undefined 이면 end 를 length 로 둡니다. 그렇지 않으면 end 를 ? ToIntegerOrInfinity (endPosition )을 0과 length 사이로 제한한 결과로 둡니다.searchLength 를 searchString 의 길이로 둡니다.searchLength = 0이면 true 를 반환합니다.start 를 end - searchLength 로 둡니다.start < 0이면 false 를 반환합니다.substring 을 string 의 start 부터 end 까지의 부분 문자열 로 둡니다.substring 이 searchString 이면 true 를 반환합니다.false 를 반환합니다.
참고 1
첫 번째 인수가 RegExp이면 예외를 던지도록 명시한 것은 향후 판에서 이러한 인수 값을 허용하는 확장을 정의할 수 있도록 하기 위함입니다.
참고 2
이 메서드는 의도적으로 일반적이며 this 값이 String 객체일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
22.1.3.8 String.prototype.includes ( searchString [ , position ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
thisValue 를 this 값으로 둡니다.? RequireObjectCoercible (thisValue )를 수행합니다. string 을 ? ToString (thisValue )으로 둡니다.isRegexp 를 ? IsRegExp (searchString )로 둡니다.isRegexp 가 true 이면 TypeError 예외를 던집니다.searchString 을 ? ToString (searchString )으로 설정합니다.length 를 string 의 길이로 둡니다.start 를 ? ToIntegerOrInfinity (position )을 0과 length 사이로 제한한 결과로 둡니다.단언 : position 이 undefined 이면 start 는 0입니다.index 를 StringIndexOf (string , searchString , start )로 둡니다.index 가 not-found 이면 false 를 반환합니다.true 를 반환합니다.
참고 1
searchString 이 이 객체를 String으로 변환한 결과의 부분 문자열 로서 position 이상인 하나 이상의 인덱스에 나타나면 이 함수는 true 를 반환하고, 그렇지 않으면 false 를 반환합니다. position 이 undefined 이면 전체 String을 검색하도록 0으로 간주합니다.
참고 2
첫 번째 인수가 RegExp이면 예외를 던지도록 명시한 것은 향후 판에서 이러한 인수 값을 허용하는 확장을 정의할 수 있도록 하기 위함입니다.
참고 3
이 메서드는 의도적으로 일반적이며 this 값이 String 객체일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
22.1.3.9 String.prototype.indexOf ( searchString [ , position ] )
참고 1
searchString 이 이 객체를 String으로 변환한 결과의 부분 문자열 로서 position 이상인 하나 이상의 인덱스에 나타나면 그러한 인덱스 중 가장 작은 값을 반환하고, 그렇지 않으면 -1 𝔽 을 반환합니다. position 이 undefined 이면 전체 String을 검색하도록 +0 𝔽 으로 간주합니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
thisValue 를 this 값으로 둡니다.? RequireObjectCoercible (thisValue )를 수행합니다. string 을 ? ToString (thisValue )으로 둡니다.searchString 을 ? ToString (searchString )으로 설정합니다.length 를 string 의 길이로 둡니다.start 를 ? ToIntegerOrInfinity (position )을 0과 length 사이로 제한한 결과로 둡니다.단언 : position 이 undefined 이면 start 는 0입니다.result 를 StringIndexOf (string , searchString , start )로 둡니다.result 가 not-found 이면 -1 𝔽 을 반환합니다.𝔽 (result )를 반환합니다.
참고 2
이 메서드는 의도적으로 일반적이며 this 값이 String 객체일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
22.1.3.10 String.prototype.isWellFormed ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
thisValue 를 this 값으로 둡니다.? RequireObjectCoercible (thisValue )를 수행합니다. string 을 ? ToString (thisValue )으로 둡니다.IsStringWellFormedUnicode (string )를 반환합니다.
22.1.3.11 String.prototype.lastIndexOf ( searchString [ , position ] )
참고 1
searchString 이 이 객체를 String으로 변환한 결과의 부분 문자열 로서 position 이하인 하나 이상의 인덱스에 나타나면 그러한 인덱스 중 가장 큰 값을 반환하고, 그렇지 않으면 -1 𝔽 을 반환합니다. position 이 undefined 이면 전체 String을 검색하도록 String 값의 길이로 간주합니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
thisValue 를 this 값으로 둡니다.? RequireObjectCoercible (thisValue )를 수행합니다. string 을 ? ToString (thisValue )으로 둡니다.searchString 을 ? ToString (searchString )으로 설정합니다.numberPosition 을 ? ToNumber (position )으로 둡니다.length 를 string 의 길이로 둡니다.searchLength 를 searchString 의 길이로 둡니다.maxStart 를 length - searchLength 로 둡니다.maxStart < 0이면 -1 𝔽 을 반환합니다.numberPosition 이 NaN 이면 start 를 maxStart 로 둡니다. 그렇지 않으면 start 를 ! ToIntegerOrInfinity (numberPosition )을 0과 maxStart 사이로 제한한 결과로 둡니다.단언 : position 이 undefined 이면 start 는 maxStart 입니다.result 를 StringLastIndexOf (string , searchString , start )로 둡니다.result 가 not-found 이면 -1 𝔽 을 반환합니다.𝔽 (result )를 반환합니다.
참고 2
이 메서드는 의도적으로 일반적이며 this 값이 String 객체일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
22.1.3.12 String.prototype.localeCompare ( that [ , reserved1 [ , reserved2 ] ] )
ECMA-402 국제화 API를 포함하는 ECMAScript 구현체는 ECMA-402에 명시된 대로 이 메서드를 구현해야 합니다. 그렇지 않으면 다음과 같은 이 메서드 명세가 사용됩니다:
이 메서드는 this 값(String string 으로 변환됨)과 that (String thatValue 로 변환됨)을 구현체 정의 로케일 민감 String 비교한 결과를 나타내는 NaN 이 아닌 Number를 반환합니다. 결과는 호스트 환경 의 현재 로케일 관례에 따른 String 값의 정렬 순서 에 대응하도록 의도되며, string 이 thatValue 보다 앞에 정렬되면 음수, string 이 thatValue 보다 뒤에 정렬되면 양수, 그 밖의 모든 경우에는 0(string 과 thatValue 사이에 상대적 순서가 없음을 나타냄)이 됩니다.
비교를 수행하기 전에 이 메서드는 String을 준비하기 위해 다음 단계를 수행합니다:
thisValue 를 this 값으로 둡니다.? RequireObjectCoercible (thisValue )를 수행합니다. string 을 ? ToString (thisValue )으로 둡니다.thatValue 를 ? ToString (that )으로 둡니다.
이 메서드의 선택적 두 번째 및 세 번째 매개변수의 의미는 ECMA-402에 정의되어 있습니다. ECMA-402 지원을 포함하지 않는 구현체는 해당 매개변수 위치에 다른 해석을 부여해서는 안 됩니다.
추가 정보를 인코딩할 수 있도록 실제 반환 값은 구현체 정의 이지만, 이 메서드를 두 인수의 메서드로 간주할 때 모든 String 집합에 대한 전순서를 정의하는 일관된 비교기 여야 합니다. 또한 이 메서드는 유니코드 표준에 따른 정규 동등성을 인식하고 준수해야 하며, 구별 가능한 String이 정규적으로 동등한 경우 비교 시 +0 𝔽 을 반환하는 것도 포함됩니다.
참고 1
이 메서드 자체는 Array.prototype.sort의 인수로 직접 사용하기에는 적합하지 않습니다. 후자는 두 인수를 받는 함수를 필요로 하기 때문입니다.
참고 2
이 메서드는 호스트 환경 이 ECMAScript 환경에 제공하는 언어 및/또는 로케일 민감 비교 기능을 사용할 수 있으며, 호스트 환경 의 현재 로케일 관례에 따라 비교하도록 의도됩니다. 그러나 비교 기능과 관계없이 이 메서드는 유니코드 표준에 따른 정규 동등성을 인식하고 준수해야 합니다. 예를 들어 다음 비교는 모두 +0 𝔽 을 반환해야 합니다:
"\u212B" .localeCompare ("A\u030A" )
"\u2126" .localeCompare ("\u03A9" )
"\u1E69" .localeCompare ("s\u0307\u0323" )
"\u1E0B\u0323" .localeCompare ("\u1E0D\u0307" )
"\u1100\u1161" .localeCompare ("\uAC00" )
정규 동등성의 정의와 논의는 유니코드 표준 제2장 및 제3장과 Unicode Standard Annex #15, Unicode Normalization Forms 및 Unicode Technical Note #5, Canonical Equivalence in Applications 를 참조하시기 바랍니다. 또한 Unicode Technical Standard #10, Unicode Collation Algorithm 도 참조하시기 바랍니다.
이 메서드는 유니코드 표준 제3장 3.7절에 정의된 유니코드 호환 동등 또는 호환 분해를 준수하지 않는 것이 권장됩니다.
참고 3
이 메서드는 의도적으로 일반적이며 this 값이 String 객체일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
22.1.3.13 String.prototype.match ( regexpOrPattern )
이 메서드는 호출되면 다음 단계를 수행합니다:
thisValue 를 this 값으로 둡니다.? RequireObjectCoercible (thisValue )를 수행합니다. regexpOrPattern 이 Object이면, 다음을 수행합니다.matcher 를 ? GetMethod (regexpOrPattern , %Symbol.match% )로 둡니다.matcher 가 undefined 가 아니면, 다음을 수행합니다.? Call (matcher , regexpOrPattern , « thisValue »)를 반환합니다. string 을 ? ToString (thisValue )으로 둡니다.regexp 를 ? RegExpCreate (regexpOrPattern , undefined )로 둡니다.? Invoke (regexp , %Symbol.match% , « string »)를 반환합니다.
참고
이 메서드는 의도적으로 일반적이며 this 값이 String 객체일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
22.1.3.14 String.prototype.matchAll ( regexpOrPattern )
이 메서드는 this 값을 나타내는 String과 regexpOrPattern 사이에서 정규 표현식 일치를 수행하고 일치 결과를 생성하는 반복자를 반환합니다. 각 일치 결과는 String에서 일치한 부분을 첫 번째 요소로 포함하고, 그 뒤에 캡처링 그룹이 일치한 부분이 이어지는 Array입니다. 정규 표현식이 한 번도 일치하지 않으면 반환된 반복자는 어떤 일치 결과도 생성하지 않습니다.
호출되면 다음 단계를 수행합니다:
thisValue 를 this 값으로 둡니다.? RequireObjectCoercible (thisValue )를 수행합니다. regexpOrPattern 이 Object이면, 다음을 수행합니다.isRegexp 를 ? IsRegExp (regexpOrPattern )로 둡니다.isRegexp 가 true 이면, 다음을 수행합니다.flags 를 ? Get (regexpOrPattern , "flags" )로 둡니다.? RequireObjectCoercible (flags )를 수행합니다. ? ToString (flags )에 "g" 가 포함되어 있지 않으면 TypeError 예외를 던집니다. matcher 를 ? GetMethod (regexpOrPattern , %Symbol.matchAll% )로 둡니다.matcher 가 undefined 가 아니면, 다음을 수행합니다.? Call (matcher , regexpOrPattern , « thisValue »)를 반환합니다. string 을 ? ToString (thisValue )으로 둡니다.regexp 를 ? RegExpCreate (regexpOrPattern , "g" )로 둡니다.? Invoke (regexp , %Symbol.matchAll% , « string »)를 반환합니다.
참고 1 이 메서드는 의도적으로 일반적이며 this 값이 String 객체일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
참고 2 String.prototype.split과 마찬가지로 String.prototype.matchAll은 일반적으로 입력을 변경하지 않고 동작하도록 설계되었습니다.
22.1.3.15 String.prototype.normalize ( [ form ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
thisValue 를 this 값으로 둡니다.? RequireObjectCoercible (thisValue )를 수행합니다. string 을 ? ToString (thisValue )으로 둡니다.form 이 undefined 이면 form 을 "NFC" 로 설정합니다.그렇지 않으면 form 을 ? ToString (form )으로 설정합니다. form 이 "NFC" , "NFD" , "NFKC" 또는 "NFKD" 중 하나가 아니면 RangeError 예외를 던집니다.normal 을 최신 유니코드 표준의 정규화 형식 에 명시된 대로 form 이 이름을 지정하는 정규화 형식으로 string 을 정규화한 결과인 String 값으로 둡니다.normal 을 반환합니다.
참고
이 메서드는 의도적으로 일반적이며 this 값이 String 객체일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
22.1.3.16 String.prototype.padEnd ( maxLength [ , fillString ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
thisValue 를 this 값으로 둡니다.? RequireObjectCoercible (thisValue )를 수행합니다. ? StringPaddingBuiltinsImpl (thisValue , maxLength , fillString , end )를 반환합니다.
22.1.3.17 String.prototype.padStart ( maxLength [ , fillString ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
thisValue 를 this 값으로 둡니다.? RequireObjectCoercible (thisValue )를 수행합니다. ? StringPaddingBuiltinsImpl (thisValue , maxLength , fillString , start )를 반환합니다.
22.1.3.17.1 StringPaddingBuiltinsImpl ( thisValue , maxLength , fillString , placement )
추상 연산 StringPaddingBuiltinsImpl. 인수 thisValue (ECMAScript 언어 값 ), maxLength (ECMAScript 언어 값 ), fillString (ECMAScript 언어 값 ) 및 placement ((start 또는 end )). 반환값: (정상 완료 (값: String) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
string 을 ? ToString (thisValue )으로 둡니다.intMaxLength 를 ℝ (? ToLength (maxLength ))로 둡니다.stringLength 를 string 의 길이로 둡니다.intMaxLength ≤ stringLength 이면 string 을 반환합니다.fillString 이 undefined 이면 fillString 을 코드 단위 0x0020 (SPACE)만으로 구성된 String 값으로 설정합니다.그렇지 않으면 fillString 을 ? ToString (fillString )으로 설정합니다. StringPad (string , intMaxLength , fillString , placement )를 반환합니다.
22.1.3.17.2 StringPad ( string , maxLength , fillString , placement )
추상 연산 StringPad. 인수 string (String), maxLength (음이 아닌 정수), fillString (String) 및 placement ((start 또는 end )). 반환값: String. 호출되면 다음 단계를 수행한다.
stringLength 를 string 의 길이로 둡니다.maxLength ≤ stringLength 이면 string 을 반환합니다.fillString 이 빈 String이면 string 을 반환합니다.fillLength 를 maxLength - stringLength 로 둡니다.truncatedStringFiller 를 fillString 의 반복된 연결을 길이 fillLength 로 잘라 구성한 String 값으로 둡니다.placement 가 start 이면 truncatedStringFiller 와 string 의 문자열 연결 을 반환합니다.string 과 truncatedStringFiller 의 문자열 연결 을 반환합니다.
참고 1
인수 maxLength 는 string 의 길이보다 작아질 수 없도록 제한됩니다.
참고 2
인수 fillString 의 기본값은 " " (코드 단위 0x0020 SPACE로 구성된 String 값)입니다.
22.1.3.17.3 ToZeroPaddedDecimalString ( n , minLength )
추상 연산 ToZeroPaddedDecimalString. 인수 n (음이 아닌 정수) 및 minLength (음이 아닌 정수). 반환값: String. 호출되면 다음 단계를 수행한다.
string 을 십진수로 형식화한 n 의 String 표현으로 둡니다.StringPad (string , minLength , "0" , start )를 반환합니다.
22.1.3.18 String.prototype.repeat ( count )
이 메서드는 호출되면 다음 단계를 수행합니다:
thisValue 를 this 값으로 둡니다.? RequireObjectCoercible (thisValue )를 수행합니다. string 을 ? ToString (thisValue )으로 둡니다.n 을 ? ToIntegerOrInfinity (count )로 둡니다.n < 0 또는 n = +∞이면 RangeError 예외를 던집니다.n = 0이면 빈 String을 반환합니다.string 의 복사본 n 개를 서로 이어 붙여 만든 String 값을 반환합니다.
참고 1
이 메서드는 this 값(String으로 변환됨)의 코드 단위를 count 번 반복한 String 값을 생성합니다.
참고 2
이 메서드는 의도적으로 일반적이며 this 값이 String 객체일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
22.1.3.19 String.prototype.replace ( searchValue , replaceValue )
이 메서드는 호출되면 다음 단계를 수행합니다:
thisValue 를 this 값으로 둡니다.? RequireObjectCoercible (thisValue )를 수행합니다. searchValue 가 Object이면, 다음을 수행합니다.replacer 를 ? GetMethod (searchValue , %Symbol.replace% )로 둡니다.replacer 가 undefined 가 아니면, 다음을 수행합니다.? Call (replacer , searchValue , « thisValue , replaceValue »)를 반환합니다. string 을 ? ToString (thisValue )으로 둡니다.searchString 을 ? ToString (searchValue )으로 둡니다.functionalReplace 를 IsCallable (replaceValue )로 둡니다.functionalReplace 가 false 이면, 다음을 수행합니다.replaceValue 를 ? ToString (replaceValue )으로 설정합니다.searchLength 를 searchString 의 길이로 둡니다.position 을 StringIndexOf (string , searchString , 0)으로 둡니다.position 이 not-found 이면 string 을 반환합니다.preceding 을 string 의 0부터 position 까지의 부분 문자열 로 둡니다.following 을 string 의 position + searchLength 부터의 부분 문자열 로 둡니다.functionalReplace 가 true 이면, 다음을 수행합니다.replacement 를 ? ToString (? Call (replaceValue , undefined , « searchString , 𝔽 (position ), string »))으로 둡니다.그렇지 않으면,단언 : replaceValue 는 String입니다.captures 를 새로운 빈 List 로 둡니다.replacement 를 ! GetSubstitution (searchString , string , position , captures , undefined , replaceValue )로 둡니다. preceding , replacement 및 following 의 문자열 연결 을 반환합니다.
참고
이 메서드는 의도적으로 일반적이며 this 값이 String 객체일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
22.1.3.19.1 GetSubstitution ( matched , string , position , captures , namedCaptures , replacementTemplate )
추상 연산 GetSubstitution. 인수 matched (String), string (String), position (음이 아닌 정수), captures (리스트 (요소: (String 또는 undefined ))), namedCaptures ((Object 또는 undefined )) 및 replacementTemplate (String). 반환값: (정상 완료 (값: String) 또는 throw 완료 ). 이 추상 연산 의 목적상 십진 숫자 는 0x0030 (DIGIT ZERO)부터 0x0039 (DIGIT NINE)까지의 폐구간 에 속하는 코드 단위입니다. 호출되면 다음 단계를 수행한다.
stringLength 를 string 의 길이로 둡니다.단언 : position ≤ stringLength 입니다.result 를 빈 String으로 둡니다.templateRemainder 를 replacementTemplate 로 둡니다.templateRemainder 가 빈 String이 아닌 동안 다음을 반복합니다.참고 : 다음 단계는 ref (templateRemainder 의 접두사)를 분리하고, refReplacement (그 치환 값)를 결정한 다음 해당 치환 값을 result 에 추가합니다.templateRemainder 가 "$$" 로 시작하면, 다음을 수행합니다.ref 를 "$$" 로 둡니다.refReplacement 를 "$" 로 둡니다.그렇지 않고 templateRemainder 가 "$`" 로 시작하면, 다음을 수행합니다.ref 를 "$`" 로 둡니다.refReplacement 를 string 의 0부터 position 까지의 부분 문자열 로 둡니다. 그렇지 않고 templateRemainder 가 "$&" 로 시작하면, 다음을 수행합니다.ref 를 "$&" 로 둡니다.refReplacement 를 matched 로 둡니다. 그렇지 않고 templateRemainder 가 "$'" (0x0024 (DOLLAR SIGN) 뒤에 0x0027 (APOSTROPHE)이 이어짐)로 시작하면, 다음을 수행합니다.ref 를 "$'" 로 둡니다.matchLength 를 matched 의 길이로 둡니다.tailPosition 을 position + matchLength 로 둡니다.refReplacement 를 string 의 min (tailPosition , stringLength )부터의 부분 문자열 로 둡니다.참고 : tailPosition 이 stringLength 를 초과할 수 있는 경우는 이 추상 연산 이 "exec" 프로퍼티가 내재 %RegExp.prototype.exec%가 아닌 객체에 대해 %RegExp.prototype% 의 내재 %Symbol.replace% 메서드를 호출하여 실행된 경우뿐입니다. 그렇지 않고 templateRemainder 가 "$" 뒤에 하나 이상의 십진 숫자가 이어지는 형태로 시작하면, 다음을 수행합니다.templateRemainder 가 "$" 뒤에 둘 이상의 십진 숫자가 이어지는 형태로 시작하면 digitCount 를 2로 둡니다. 그렇지 않으면 digitCount 를 1로 둡니다.digits 를 templateRemainder 의 1부터 1 + digitCount 까지의 부분 문자열 로 둡니다.index 를 ℝ (StringToNumber (digits ))로 둡니다.단언 : 0 ≤ index ≤ 99입니다.captureLength 를 captures 의 요소 수로 둡니다.index > captureLength 이고 digitCount = 2이면, 다음을 수행합니다.참고 : 두 자리 치환 패턴이 캡처링 그룹 수를 초과하는 인덱스를 지정하면 한 자리 치환 패턴 뒤에 리터럴 숫자가 이어진 것으로 처리합니다.digitCount 를 1로 설정합니다.digits 를 digits 의 0부터 1까지의 부분 문자열 로 설정합니다.index 를 ℝ (StringToNumber (digits ))로 설정합니다.ref 를 templateRemainder 의 0부터 1 + digitCount 까지의 부분 문자열 로 둡니다.1 ≤ index ≤ captureLength 이면, 다음을 수행합니다.capture 를 captures [index - 1]로 둡니다.capture 가 undefined 이면, 다음을 수행합니다.refReplacement 를 빈 String으로 둡니다.그렇지 않으면,refReplacement 를 capture 로 둡니다. 그렇지 않으면,refReplacement 를 ref 로 둡니다. 그렇지 않고 templateRemainder 가 "$<" 로 시작하면, 다음을 수행합니다.gtPosition 을 StringIndexOf (templateRemainder , ">" , 0)으로 둡니다.gtPosition 이 not-found 이거나 namedCaptures 가 undefined 이면, 다음을 수행합니다.ref 를 "$<" 로 둡니다.refReplacement 를 ref 로 둡니다.그렇지 않으면,ref 를 templateRemainder 의 0부터 gtPosition + 1까지의 부분 문자열 로 둡니다.groupName 을 templateRemainder 의 2부터 gtPosition 까지의 부분 문자열 로 둡니다.단언 : namedCaptures 는 Object입니다.capture 를 ? Get (namedCaptures , groupName )로 둡니다.capture 가 undefined 이면, 다음을 수행합니다.refReplacement 를 빈 String으로 둡니다.그렇지 않으면,refReplacement 를 ? ToString (capture )으로 둡니다. 그렇지 않으면,ref 를 templateRemainder 의 0부터 1까지의 부분 문자열 로 둡니다.refReplacement 를 ref 로 둡니다. refLength 를 ref 의 길이로 둡니다.templateRemainder 를 templateRemainder 의 refLength 부터의 부분 문자열 로 설정합니다.result 를 result 와 refReplacement 의 문자열 연결 로 설정합니다.result 를 반환합니다.
22.1.3.20 String.prototype.replaceAll ( searchValue , replaceValue )
이 메서드는 호출되면 다음 단계를 수행합니다:
thisValue 를 this 값으로 둡니다.? RequireObjectCoercible (thisValue )를 수행합니다. searchValue 가 Object이면, 다음을 수행합니다.isRegexp 를 ? IsRegExp (searchValue )로 둡니다.isRegexp 가 true 이면, 다음을 수행합니다.flags 를 ? Get (searchValue , "flags" )로 둡니다.? RequireObjectCoercible (flags )를 수행합니다. ? ToString (flags )에 "g" 가 포함되어 있지 않으면 TypeError 예외를 던집니다. replacer 를 ? GetMethod (searchValue , %Symbol.replace% )로 둡니다.replacer 가 undefined 가 아니면, 다음을 수행합니다.? Call (replacer , searchValue , « thisValue , replaceValue »)를 반환합니다. string 을 ? ToString (thisValue )으로 둡니다.searchString 을 ? ToString (searchValue )으로 둡니다.functionalReplace 를 IsCallable (replaceValue )로 둡니다.functionalReplace 가 false 이면, 다음을 수행합니다.replaceValue 를 ? ToString (replaceValue )으로 설정합니다.searchLength 를 searchString 의 길이로 둡니다.advanceBy 를 max (1, searchLength )로 둡니다.matchPositions 를 새로운 빈 List 로 둡니다.position 을 StringIndexOf (string , searchString , 0)으로 둡니다.position 이 not-found 가 아닌 동안 다음을 반복합니다.position 을 matchPositions 에 추가합니다.position 을 StringIndexOf (string , searchString , position + advanceBy )로 설정합니다.endOfLastMatch 를 0으로 둡니다.result 를 빈 String으로 둡니다.matchPositions 의 각 요소 matchPosition 에 대해 다음을 수행합니다.preserved 를 string 의 endOfLastMatch 부터 matchPosition 까지의 부분 문자열 로 둡니다.functionalReplace 가 true 이면, 다음을 수행합니다.replacement 를 ? ToString (? Call (replaceValue , undefined , « searchString , 𝔽 (matchPosition ), string »))으로 둡니다.그렇지 않으면,단언 : replaceValue 는 String입니다.captures 를 새로운 빈 List 로 둡니다.replacement 를 ! GetSubstitution (searchString , string , matchPosition , captures , undefined , replaceValue )로 둡니다. result 를 result , preserved 및 replacement 의 문자열 연결 로 설정합니다.endOfLastMatch 를 matchPosition + searchLength 로 설정합니다.endOfLastMatch < string 의 길이이면, 다음을 수행합니다.result 를 result 와 string 의 endOfLastMatch 부터의 부분 문자열 의 문자열 연결 로 설정합니다.result 를 반환합니다.
22.1.3.21 String.prototype.search ( regexpOrPattern )
이 메서드는 호출되면 다음 단계를 수행합니다:
thisValue 를 this 값으로 둡니다.? RequireObjectCoercible (thisValue )를 수행합니다. regexpOrPattern 이 Object이면, 다음을 수행합니다.searcher 를 ? GetMethod (regexpOrPattern , %Symbol.search% )로 둡니다.searcher 가 undefined 가 아니면, 다음을 수행합니다.? Call (searcher , regexpOrPattern , « thisValue »)를 반환합니다. string 을 ? ToString (thisValue )으로 둡니다.regexp 를 ? RegExpCreate (regexpOrPattern , undefined )로 둡니다.? Invoke (regexp , %Symbol.search% , « string »)를 반환합니다.
참고
이 메서드는 의도적으로 일반적이며 this 값이 String 객체일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
22.1.3.22 String.prototype.slice ( start , end )
이 메서드는 이 객체를 String으로 변환한 결과의 인덱스 start 에서 시작하여 인덱스 end 직전까지 이어지는 부분 문자열 (end 가 undefined 이면 String의 끝까지)을 반환합니다. start 가 음수이면 String의 길이인 sourceLength 에 대해 sourceLength + start 로 처리합니다. end 가 음수이면 sourceLength + end 로 처리합니다. 결과는 String 객체가 아니라 String 값입니다.
호출되면 다음 단계를 수행합니다:
thisValue 를 this 값으로 둡니다.? RequireObjectCoercible (thisValue )를 수행합니다. string 을 ? ToString (thisValue )으로 둡니다.length 를 string 의 길이로 둡니다.from 을 ? ToClampedIndex (start , length )로 둡니다.end 가 undefined 이면 to 를 length 로 둡니다. 그렇지 않으면 to 를 ? ToClampedIndex (end , length )로 둡니다.from ≥ to 이면 빈 String을 반환합니다.string 의 from 부터 to 까지의 부분 문자열 을 반환합니다.
참고
이 메서드는 의도적으로 일반적이며 this 값이 String 객체일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
22.1.3.23 String.prototype.split ( separator , limit )
이 메서드는 이 객체를 String으로 변환한 결과의 부분 문자열 을 저장한 Array를 반환합니다. 부분 문자열 은 왼쪽에서 오른쪽으로 separator 의 출현을 검색하여 결정합니다. 이러한 출현은 반환되는 배열 안의 어떤 String에도 포함되지 않고 String 값을 나누는 역할을 합니다. separator 값은 임의 길이의 String일 수도 있고 %Symbol.split% 메서드를 갖는 RegExp와 같은 객체일 수도 있습니다.
호출되면 다음 단계를 수행합니다:
thisValue 를 this 값으로 둡니다.? RequireObjectCoercible (thisValue )를 수행합니다. separator 가 Object이면, 다음을 수행합니다.splitter 를 ? GetMethod (separator , %Symbol.split% )로 둡니다.splitter 가 undefined 가 아니면, 다음을 수행합니다.? Call (splitter , separator , « thisValue , limit »)를 반환합니다. string 을 ? ToString (thisValue )으로 둡니다.limit 가 undefined 이면 lim 을 232 - 1로 둡니다. 그렇지 않으면 lim 을 ℝ (? ToUint32 (limit ))로 둡니다.separatorString 을 ? ToString (separator )로 둡니다.lim = 0이면, 다음을 수행합니다.CreateArrayFromList (« »)를 반환합니다.separator 가 undefined 이면, 다음을 수행합니다.CreateArrayFromList (« string »)를 반환합니다.separatorLength 를 separatorString 의 길이로 둡니다.separatorLength = 0이면, 다음을 수행합니다.stringLength 를 string 의 길이로 둡니다.outLength 를 lim 을 0과 stringLength 사이로 제한한 결과로 둡니다.head 를 string 의 0부터 outLength 까지의 부분 문자열 로 둡니다.codeUnits 를 head 의 요소인 코드 단위 시퀀스로 구성된 List 로 둡니다.CreateArrayFromList (codeUnits )를 반환합니다.string 이 빈 String이면 CreateArrayFromList (« string »)를 반환합니다.substrings 를 새로운 빈 List 로 둡니다.searchStart 를 0으로 둡니다.matchIndex 를 StringIndexOf (string , separatorString , 0)으로 둡니다.matchIndex 가 not-found 가 아닌 동안 다음을 반복합니다.substring 을 string 의 searchStart 부터 matchIndex 까지의 부분 문자열 로 둡니다.substring 을 substrings 에 추가합니다.substrings 의 요소 수가 lim 이면 CreateArrayFromList (substrings )를 반환합니다.searchStart 를 matchIndex + separatorLength 로 설정합니다.matchIndex 를 StringIndexOf (string , separatorString , searchStart )로 설정합니다.substring 을 string 의 searchStart 부터의 부분 문자열 로 둡니다.substring 을 substrings 에 추가합니다.CreateArrayFromList (substrings )를 반환합니다.
참고 1
separator 값은 빈 String일 수 있습니다. 이 경우 separator 는 입력 String의 시작이나 끝에 있는 빈 부분 문자열 과 일치하지 않으며, 이전 구분자 일치의 끝에 있는 빈 부분 문자열 과도 일치하지 않습니다. separator 가 빈 String이면 String은 개별 코드 단위 요소로 분할됩니다. 결과 배열의 길이는 String의 길이와 같고 각 부분 문자열 에는 하나의 코드 단위가 포함됩니다.
this 값이 빈 String이거나 빈 String으로 변환되는 경우 결과는 separator 가 빈 String과 일치할 수 있는지에 따라 달라집니다. 일치할 수 있으면 결과 배열에는 요소가 없습니다. 그렇지 않으면 결과 배열에는 빈 String인 하나의 요소가 있습니다.
separator 가 undefined 이면 결과 배열에는 this 값(String으로 변환됨)인 하나의 String만 포함됩니다. limit 가 undefined 가 아니면 출력 배열은 limit 개보다 많은 요소를 포함하지 않도록 잘립니다.
참고 2
이 메서드는 의도적으로 일반적이며 this 값이 String 객체일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
22.1.3.24 String.prototype.startsWith ( searchString [ , position ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
thisValue 를 this 값으로 둡니다.? RequireObjectCoercible (thisValue )를 수행합니다. string 을 ? ToString (thisValue )으로 둡니다.isRegexp 를 ? IsRegExp (searchString )로 둡니다.isRegexp 가 true 이면 TypeError 예외를 던집니다.searchString 을 ? ToString (searchString )으로 설정합니다.length 를 string 의 길이로 둡니다.start 를 ? ToIntegerOrInfinity (position )을 0과 length 사이로 제한한 결과로 둡니다.단언 : position 이 undefined 이면 start 는 0입니다.searchLength 를 searchString 의 길이로 둡니다.searchLength = 0이면 true 를 반환합니다.end 를 start + searchLength 로 둡니다.end > length 이면 false 를 반환합니다.substring 을 string 의 start 부터 end 까지의 부분 문자열 로 둡니다.substring 이 searchString 이면 true 를 반환합니다.false 를 반환합니다.
참고 1
첫 번째 인수가 RegExp이면 예외를 던지도록 명시한 것은 향후 판에서 이러한 인수 값을 허용하는 확장을 정의할 수 있도록 하기 위함입니다.
참고 2
이 메서드는 의도적으로 일반적이며 this 값이 String 객체일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
22.1.3.25 String.prototype.substring ( start , end )
이 메서드는 이 객체를 String으로 변환한 결과의 인덱스 start 에서 시작하여 String의 인덱스 end 직전까지 이어지는 부분 문자열 (end 가 undefined 이면 String의 끝까지)을 반환합니다. 결과는 String 객체가 아니라 String 값입니다.
어느 인수든 NaN 이거나 음수이면 0으로 대체되고, 어느 인수든 String의 길이보다 엄격하게 크면 String의 길이로 대체됩니다.
start 가 end 보다 엄격하게 크면 서로 교환됩니다.
호출되면 다음 단계를 수행합니다:
thisValue 를 this 값으로 둡니다.? RequireObjectCoercible (thisValue )를 수행합니다. string 을 ? ToString (thisValue )으로 둡니다.length 를 string 의 길이로 둡니다.finalStart 를 ? ToIntegerOrInfinity (start )을 0과 length 사이로 제한한 결과로 둡니다.단언 : start 가 undefined 이면 finalStart 는 0입니다.end 가 undefined 이면 finalEnd 를 length 로 둡니다. 그렇지 않으면 finalEnd 를 ? ToIntegerOrInfinity (end )을 0과 length 사이로 제한한 결과로 둡니다.from 을 min (finalStart , finalEnd )으로 둡니다.to 를 max (finalStart , finalEnd )로 둡니다.string 의 from 부터 to 까지의 부분 문자열 을 반환합니다.
참고
이 메서드는 의도적으로 일반적이며 this 값이 String 객체일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
22.1.3.26 String.prototype.toLocaleLowerCase ( [ reserved1 [ , reserved2 ] ] )
ECMA-402 국제화 API를 포함하는 ECMAScript 구현체는 ECMA-402에 명시된 대로 이 메서드를 구현해야 합니다. 그렇지 않으면 다음과 같은 이 메서드 명세가 사용됩니다:
이 메서드는 6.1.4 에 설명된 대로 String 값을 UTF-16 인코딩 코드 포인트의 시퀀스로 해석합니다.
호스트 환경 의 현재 로케일 관례에 대응하는 로케일 민감 결과를 생성하도록 의도된다는 점을 제외하면 toLowerCase와 정확히 동일하게 동작합니다. 해당 언어의 규칙이 일반적인 유니코드 대소문자 매핑과 충돌하는 소수의 경우(예: 터키어)에만 차이가 있습니다.
이 메서드의 선택적 매개변수의 의미는 ECMA-402에 정의되어 있습니다. ECMA-402 지원을 포함하지 않는 구현체는 해당 매개변수 위치를 다른 용도로 사용해서는 안 됩니다.
참고
이 메서드는 의도적으로 일반적이며 this 값이 String 객체일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
22.1.3.27 String.prototype.toLocaleUpperCase ( [ reserved1 [ , reserved2 ] ] )
ECMA-402 국제화 API를 포함하는 ECMAScript 구현체는 ECMA-402에 명시된 대로 이 메서드를 구현해야 합니다. 그렇지 않으면 다음과 같은 이 메서드 명세가 사용됩니다:
이 메서드는 6.1.4 에 설명된 대로 String 값을 UTF-16 인코딩 코드 포인트의 시퀀스로 해석합니다.
호스트 환경 의 현재 로케일 관례에 대응하는 로케일 민감 결과를 생성하도록 의도된다는 점을 제외하면 toUpperCase와 정확히 동일하게 동작합니다. 해당 언어의 규칙이 일반적인 유니코드 대소문자 매핑과 충돌하는 소수의 경우(예: 터키어)에만 차이가 있습니다.
이 메서드의 선택적 매개변수의 의미는 ECMA-402에 정의되어 있습니다. ECMA-402 지원을 포함하지 않는 구현체는 해당 매개변수 위치를 다른 용도로 사용해서는 안 됩니다.
참고
이 메서드는 의도적으로 일반적이며 this 값이 String 객체일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
22.1.3.28 String.prototype.toLowerCase ( )
이 메서드는 6.1.4 에 설명된 대로 String 값을 UTF-16 인코딩 코드 포인트의 시퀀스로 해석합니다.
호출되면 다음 단계를 수행합니다:
thisValue 를 this 값으로 둡니다.? RequireObjectCoercible (thisValue )를 수행합니다. string 을 ? ToString (thisValue )으로 둡니다.sText 를 StringToCodePoints (string )로 둡니다.lowerText 를 Unicode Default Case Conversion 알고리즘에 따라 toLowercase(sText )로 둡니다.lowercaseString 을 CodePointsToString (lowerText )로 둡니다.lowercaseString 을 반환합니다.
결과는 Unicode Character Database의 로케일 비민감 대소문자 매핑에 따라 파생되어야 합니다(이는 UnicodeData.txt 파일뿐만 아니라 함께 제공되는 SpecialCasing.txt 파일의 모든 로케일 비민감 매핑도 명시적으로 포함합니다).
참고 1
일부 코드 포인트의 대소문자 매핑은 여러 코드 포인트를 생성할 수 있습니다. 이 경우 결과 String의 길이는 소스 String과 같지 않을 수 있습니다. toUpperCase와 toLowerCase 모두 문맥 민감 동작을 하므로 두 메서드는 대칭적이지 않습니다. 즉, s.toUpperCase().toLowerCase()는 반드시 s.toLowerCase()와 같지는 않습니다.
참고 2
이 메서드는 의도적으로 일반적이며 this 값이 String 객체일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
22.1.3.29 String.prototype.toString ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
? ThisStringValue (this 값)를 반환합니다.
참고
String 객체의 경우 이 메서드는 우연히 valueOf 메서드와 동일한 것을 반환합니다.
22.1.3.30 String.prototype.toUpperCase ( )
이 메서드는 6.1.4 에 설명된 대로 String 값을 UTF-16 인코딩 코드 포인트의 시퀀스로 해석합니다.
String이 Unicode Default Case Conversion의 toUppercase 알고리즘을 사용하여 매핑된다는 점을 제외하면 String.prototype.toLowerCase와 정확히 동일하게 동작합니다.
참고
이 메서드는 의도적으로 일반적이며 this 값이 String 객체일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
22.1.3.31 String.prototype.toWellFormed ( )
이 메서드는 서로게이트 쌍 의 일부가 아닌 모든 선행 서로게이트 와 후행 서로게이트 를 U+FFFD (REPLACEMENT CHARACTER)로 대체한 이 객체의 String 표현을 반환합니다.
호출되면 다음 단계를 수행합니다:
thisValue 를 this 값으로 둡니다.? RequireObjectCoercible (thisValue )를 수행합니다. string 을 ? ToString (thisValue )으로 둡니다.stringLength 를 string 의 길이로 둡니다.k 를 0으로 둡니다.result 를 빈 String으로 둡니다.k < stringLength 인 동안 다음을 반복합니다.codePoint 를 CodePointAt (string , k )로 둡니다.codePoint .[[IsUnpairedSurrogate]] 가 true 이면, 다음을 수행합니다.result 를 result 와 0xFFFD (REPLACEMENT CHARACTER)의 문자열 연결 로 설정합니다.그렇지 않으면,result 를 result 와 UTF16EncodeCodePoint (codePoint .[[CodePoint]] )의 문자열 연결 로 설정합니다. k 를 k + codePoint .[[CodeUnitCount]] 로 설정합니다.result 를 반환합니다.
22.1.3.32 String.prototype.trim ( )
이 메서드는 6.1.4 에 설명된 대로 String 값을 UTF-16 인코딩 코드 포인트의 시퀀스로 해석합니다.
호출되면 다음 단계를 수행합니다:
thisValue 를 this 값으로 둡니다.? TrimString (thisValue , start+end )를 반환합니다.
참고
이 메서드는 의도적으로 일반적이며 this 값이 String 객체일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
22.1.3.32.1 TrimString ( arg , where )
추상 연산 TrimString. 인수 arg (ECMAScript 언어 값 ) 및 where ((start , end 또는 start+end )). 반환값: (정상 완료 (값: String) 또는 throw 완료 ). 6.1.4 에 설명된 대로 arg 를 UTF-16 인코딩 코드 포인트의 시퀀스로 해석합니다. 호출되면 다음 단계를 수행한다.
? RequireObjectCoercible (arg )를 수행합니다. string 을 ? ToString (arg )으로 둡니다.where 가 start 이면, 다음을 수행합니다.trimmedString 을 string 의 앞쪽 공백을 제거한 복사본인 String 값으로 둡니다.그렇지 않고 where 가 end 이면, 다음을 수행합니다.trimmedString 을 string 의 뒤쪽 공백을 제거한 복사본인 String 값으로 둡니다. 그렇지 않으면,단언 : where 는 start+end 입니다.trimmedString 을 string 의 앞쪽과 뒤쪽 공백을 모두 제거한 복사본인 String 값으로 둡니다. trimmedString 을 반환합니다.
공백의 정의는 WhiteSpace 와 LineTerminator 의 합집합입니다. 유니코드 코드 포인트가 유니코드 일반 범주 “Space_Separator” (“Zs”)에 속하는지 결정할 때 코드 단위 시퀀스는 6.1.4 에 명시된 대로 UTF-16 인코딩 코드 포인트 시퀀스로 해석됩니다.
22.1.3.33 String.prototype.trimEnd ( )
이 메서드는 6.1.4 에 설명된 대로 String 값을 UTF-16 인코딩 코드 포인트의 시퀀스로 해석합니다.
호출되면 다음 단계를 수행합니다:
string 을 this 값으로 둡니다.? TrimString (string , end )를 반환합니다.
참고
이 메서드는 의도적으로 일반적이며 this 값이 String 객체일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
22.1.3.34 String.prototype.trimStart ( )
이 메서드는 6.1.4 에 설명된 대로 String 값을 UTF-16 인코딩 코드 포인트의 시퀀스로 해석합니다.
호출되면 다음 단계를 수행합니다:
string 을 this 값으로 둡니다.? TrimString (string , start )를 반환합니다.
참고
이 메서드는 의도적으로 일반적이며 this 값이 String 객체일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
22.1.3.35 String.prototype.valueOf ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
? ThisStringValue (this 값)를 반환합니다.
22.1.3.35.1 ThisStringValue ( arg )
추상 연산 ThisStringValue. 인수 arg (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: String) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
arg 가 String이면 arg 를 반환합니다.arg 가 Object이고 arg 에 [[StringData]] 내부 슬롯이 있으면, 다음을 수행합니다.string 을 arg .[[StringData]] 로 둡니다.단언 : string 은 String입니다.string 을 반환합니다.TypeError 예외를 던집니다.
22.1.3.36 String.prototype [ %Symbol.iterator% ] ( )
이 메서드는 String 값의 코드 포인트를 순회하면서 각 코드 포인트를 String 값으로 반환하는 반복자 객체를 반환합니다.
호출되면 다음 단계를 수행합니다:
string 을 this 값으로 둡니다.? RequireObjectCoercible (string )를 수행합니다. string 을 ? ToString (string )으로 설정합니다.closure 를 매개변수가 없고 string 을 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:length 를 string 의 길이로 둡니다.position 을 0으로 둡니다.position < length 인 동안 다음을 반복합니다.codePoint 를 CodePointAt (string , position )로 둡니다.nextIndex 를 position + codePoint .[[CodeUnitCount]] 로 둡니다.resultString 을 string 의 position 부터 nextIndex 까지의 부분 문자열 로 둡니다.position 을 nextIndex 로 설정합니다.? GeneratorYield (CreateIteratorResultObject (resultString , false ))를 수행합니다. NormalCompletion (unused )을 반환합니다.CreateIteratorFromClosure (closure , "%StringIteratorPrototype%" , %StringIteratorPrototype% )를 반환합니다.
이 메서드의 "name" 프로퍼티 값은 "[Symbol.iterator]" 입니다.
22.1.4 String 인스턴스의 프로퍼티
String 인스턴스는 String 특수 객체 이며 이러한 객체에 지정된 내부 메서드를 갖습니다. String 인스턴스는 String 프로토타입 객체 에서 프로퍼티를 상속합니다. String 인스턴스에는 [[StringData]] 내부 슬롯도 있습니다. [[StringData]] 내부 슬롯은 이 String 객체가 나타내는 String 값입니다.
String 인스턴스는 "length" 프로퍼티와 정수 인덱스 이름을 갖는 열거 가능한 프로퍼티 집합을 갖습니다.
22.1.4.1 length
이 String 객체가 나타내는 String 값의 요소 수입니다.
String 객체가 초기화되면 이 프로퍼티는 변경되지 않습니다. 이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
22.1.5 String Iterator 객체
String Iterator 는 특정 String 인스턴스 객체에 대한 특정 순회를 나타내는 객체입니다. String Iterator 객체에는 이름 있는 생성자 가 없습니다. 대신 String Iterator 객체는 String 인스턴스 객체의 특정 메서드를 호출하여 생성됩니다.
22.1.5.1 %StringIteratorPrototype% 객체
%StringIteratorPrototype% 객체는:
22.1.5.1.1 %StringIteratorPrototype%.next ( )
? GeneratorResume (this 값, empty , "%StringIteratorPrototype%" )를 반환합니다.
22.1.5.1.2 %StringIteratorPrototype% [ %Symbol.toStringTag% ]
%Symbol.toStringTag% 프로퍼티의 초기 값은 String 값 "String Iterator" 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
22.2 RegExp(정규 표현식) 객체
RegExp 객체는 정규 표현식과 관련 플래그를 포함합니다.
참고
정규 표현식의 형식과 기능은 Perl 5 프로그래밍 언어의 정규 표현식 기능을 모델로 합니다.
22.2.1 패턴
RegExp 생성자 는 입력 패턴 String에 다음 문법을 적용합니다. 문법이 String을 Pattern 의 전개로 해석할 수 없으면 오류가 발생합니다.
구문
Pattern [UnicodeMode, UnicodeSetsMode, NamedCaptureGroups] ::
Disjunction [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
Disjunction [UnicodeMode, UnicodeSetsMode, NamedCaptureGroups] ::
Alternative [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
Alternative [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
|
Disjunction [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
Alternative [UnicodeMode, UnicodeSetsMode, NamedCaptureGroups] ::
[empty]
Alternative [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
Term [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
Term [UnicodeMode, UnicodeSetsMode, NamedCaptureGroups] ::
Assertion [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
Atom [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
Atom [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
Quantifier
Assertion [UnicodeMode, UnicodeSetsMode, NamedCaptureGroups] ::
^
$
\b
\B
(?=
Disjunction [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
)
(?!
Disjunction [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
)
(?<=
Disjunction [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
)
(?<!
Disjunction [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
)
Quantifier ::
QuantifierPrefix
QuantifierPrefix
?
QuantifierPrefix ::
*
+
?
{
DecimalDigits [~Sep]
}
{
DecimalDigits [~Sep]
,}
{
DecimalDigits [~Sep]
,
DecimalDigits [~Sep]
}
Atom [UnicodeMode, UnicodeSetsMode, NamedCaptureGroups] ::
PatternCharacter
.
\
AtomEscape [?UnicodeMode, ?NamedCaptureGroups]
CharacterClass [?UnicodeMode, ?UnicodeSetsMode]
(
GroupSpecifier [?UnicodeMode] opt
Disjunction [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
)
(?
RegularExpressionModifiers
:
Disjunction [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
)
(?
RegularExpressionModifiers
-
RegularExpressionModifiers
:
Disjunction [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
)
RegularExpressionModifiers ::
[empty]
RegularExpressionModifiers
RegularExpressionModifier
RegularExpressionModifier :: one of i m s
SyntaxCharacter :: one of ^ $ \ . * + ? ( ) [ ] { } |
PatternCharacter ::
SourceCharacter but not SyntaxCharacter
AtomEscape [UnicodeMode, NamedCaptureGroups] ::
DecimalEscape
CharacterClassEscape [?UnicodeMode]
CharacterEscape [?UnicodeMode]
[+NamedCaptureGroups]
k
GroupName [?UnicodeMode]
CharacterEscape [UnicodeMode] ::
ControlEscape
c
AsciiLetter
0
[lookahead ∉ DecimalDigit ]
HexEscapeSequence
RegExpUnicodeEscapeSequence [?UnicodeMode]
IdentityEscape [?UnicodeMode]
ControlEscape :: one of f n r t v
GroupSpecifier [UnicodeMode] ::
?
GroupName [?UnicodeMode]
GroupName [UnicodeMode] ::
<
RegExpIdentifierName [?UnicodeMode]
>
RegExpIdentifierName [UnicodeMode] ::
RegExpIdentifierStart [?UnicodeMode]
RegExpIdentifierName [?UnicodeMode]
RegExpIdentifierPart [?UnicodeMode]
RegExpIdentifierStart [UnicodeMode] ::
IdentifierStartChar
\
RegExpUnicodeEscapeSequence [+UnicodeMode]
[~UnicodeMode]
UnicodeLeadSurrogate
UnicodeTrailSurrogate
RegExpIdentifierPart [UnicodeMode] ::
IdentifierPartChar
\
RegExpUnicodeEscapeSequence [+UnicodeMode]
[~UnicodeMode]
UnicodeLeadSurrogate
UnicodeTrailSurrogate
RegExpUnicodeEscapeSequence [UnicodeMode] :: [+UnicodeMode]
u
HexLeadSurrogate
\u
HexTrailSurrogate
[+UnicodeMode]
u
HexLeadSurrogate
[+UnicodeMode]
u
HexTrailSurrogate
[+UnicodeMode]
u
HexNonSurrogate
[~UnicodeMode]
u
Hex4Digits
[+UnicodeMode]
u{
CodePoint
}
UnicodeLeadSurrogate ::
any Unicode code point in the inclusive interval from U+D800 to U+DBFF
UnicodeTrailSurrogate ::
any Unicode code point in the inclusive interval from U+DC00 to U+DFFF
연결할 u HexLeadSurrogate 의 선택이 모호한 각 \u HexTrailSurrogate 는 그렇지 않으면 대응하는 \u HexTrailSurrogate 가 없는 가장 가까운 가능한 u HexLeadSurrogate 와 연결되어야 합니다.
HexLeadSurrogate ::
Hex4Digits
but only if the MV of Hex4Digits is in the inclusive interval from 0xD800 to 0xDBFF
HexNonSurrogate ::
Hex4Digits
but only if the MV of Hex4Digits is not in the inclusive interval from 0xD800 to 0xDFFF
IdentityEscape [UnicodeMode] :: [+UnicodeMode]
SyntaxCharacter
[+UnicodeMode]
/
[~UnicodeMode]
SourceCharacter but not UnicodeIDContinue
DecimalEscape ::
NonZeroDigit
DecimalDigits [~Sep] opt
[lookahead ∉ DecimalDigit ]
CharacterClassEscape [UnicodeMode] ::
d
D
s
S
w
W
[+UnicodeMode]
p{
UnicodePropertyValueExpression
}
[+UnicodeMode]
P{
UnicodePropertyValueExpression
}
UnicodePropertyValueExpression ::
UnicodePropertyName
=
UnicodePropertyValue
LoneUnicodePropertyNameOrValue
UnicodePropertyName ::
UnicodePropertyNameCharacters
UnicodePropertyNameCharacters ::
UnicodePropertyNameCharacter
UnicodePropertyNameCharacters opt
UnicodePropertyValue ::
UnicodePropertyValueCharacters
LoneUnicodePropertyNameOrValue ::
UnicodePropertyValueCharacters
UnicodePropertyValueCharacters ::
UnicodePropertyValueCharacter
UnicodePropertyValueCharacters opt
UnicodePropertyValueCharacter ::
UnicodePropertyNameCharacter
DecimalDigit
UnicodePropertyNameCharacter ::
AsciiLetter
_
CharacterClass [UnicodeMode, UnicodeSetsMode] ::
[
[lookahead ≠ ^ ]
ClassContents [?UnicodeMode, ?UnicodeSetsMode]
]
[^
ClassContents [?UnicodeMode, ?UnicodeSetsMode]
]
ClassContents [UnicodeMode, UnicodeSetsMode] ::
[empty]
[~UnicodeSetsMode]
NonemptyClassRanges [?UnicodeMode]
[+UnicodeSetsMode]
ClassSetExpression
NonemptyClassRanges [UnicodeMode] ::
ClassAtom [?UnicodeMode]
ClassAtom [?UnicodeMode]
NonemptyClassRangesNoDash [?UnicodeMode]
ClassAtom [?UnicodeMode]
-
ClassAtom [?UnicodeMode]
ClassContents [?UnicodeMode, ~UnicodeSetsMode]
NonemptyClassRangesNoDash [UnicodeMode] ::
ClassAtom [?UnicodeMode]
ClassAtomNoDash [?UnicodeMode]
NonemptyClassRangesNoDash [?UnicodeMode]
ClassAtomNoDash [?UnicodeMode]
-
ClassAtom [?UnicodeMode]
ClassContents [?UnicodeMode, ~UnicodeSetsMode]
ClassAtom [UnicodeMode] ::
-
ClassAtomNoDash [?UnicodeMode]
ClassAtomNoDash [UnicodeMode] ::
SourceCharacter but not one of \ or ] or -
\
ClassEscape [?UnicodeMode]
ClassEscape [UnicodeMode] ::
b
[+UnicodeMode]
-
CharacterClassEscape [?UnicodeMode]
CharacterEscape [?UnicodeMode]
ClassSetExpression ::
ClassUnion
ClassIntersection
ClassSubtraction
ClassUnion ::
ClassSetRange
ClassUnion opt
ClassSetOperand
ClassUnion opt
ClassIntersection ::
ClassSetOperand
&&
[lookahead ≠ & ]
ClassSetOperand
ClassIntersection
&&
[lookahead ≠ & ]
ClassSetOperand
ClassSubtraction ::
ClassSetOperand
--
ClassSetOperand
ClassSubtraction
--
ClassSetOperand
ClassSetRange ::
ClassSetCharacter
-
ClassSetCharacter
ClassSetOperand ::
NestedClass
ClassStringDisjunction
ClassSetCharacter
NestedClass ::
[
[lookahead ≠ ^ ]
ClassContents [+UnicodeMode, +UnicodeSetsMode]
]
[^
ClassContents [+UnicodeMode, +UnicodeSetsMode]
]
\
CharacterClassEscape [+UnicodeMode]
참고 1
여기서 처음 두 줄은 CharacterClass와 동등합니다.
ClassStringDisjunction ::
\q{
ClassStringDisjunctionContents
}
ClassStringDisjunctionContents ::
ClassString
ClassString
|
ClassStringDisjunctionContents
ClassString ::
[empty]
NonEmptyClassString
NonEmptyClassString ::
ClassSetCharacter
NonEmptyClassString opt
ClassSetCharacter ::
[lookahead ∉ ClassSetReservedDoublePunctuator ]
SourceCharacter but not ClassSetSyntaxCharacter
\
CharacterEscape [+UnicodeMode]
\
ClassSetReservedPunctuator
\b
ClassSetReservedDoublePunctuator :: one of && !! ## $$ %% ** ++ ,, .. :: ;; << == >> ?? @@ ^^ `` ~~
ClassSetSyntaxCharacter :: one of ( ) [ ] { } / - \ |
ClassSetReservedPunctuator :: one of & - ! # % , : ; < = > @ ` ~
참고 2
이 절의 여러 생성식에는 B.1.2 절에서 대체 정의가 제공됩니다.
22.2.1.1 Static Semantics: 조기 오류
참고
Pattern :: Disjunction
QuantifierPrefix ::
{
DecimalDigits
,
DecimalDigits
}
Atom ::
(?
RegularExpressionModifiers
:
Disjunction
)
Atom ::
(?
RegularExpressionModifiers
-
RegularExpressionModifiers
:
Disjunction
)
AtomEscape ::
k
GroupName
AtomEscape :: DecimalEscape
NonemptyClassRanges ::
ClassAtom
-
ClassAtom
ClassContents
NonemptyClassRangesNoDash ::
ClassAtomNoDash
-
ClassAtom
ClassContents
RegExpIdentifierStart ::
\
RegExpUnicodeEscapeSequence
RegExpIdentifierStart ::
UnicodeLeadSurrogate
UnicodeTrailSurrogate
RegExpIdentifierPart ::
\
RegExpUnicodeEscapeSequence
RegExpIdentifierPart ::
UnicodeLeadSurrogate
UnicodeTrailSurrogate
UnicodePropertyValueExpression ::
UnicodePropertyName
=
UnicodePropertyValue
UnicodePropertyValueExpression :: LoneUnicodePropertyNameOrValue
CharacterClassEscape ::
P{
UnicodePropertyValueExpression
}
CharacterClass ::
[^
ClassContents
]
NestedClass ::
[^
ClassContents
]
ClassSetRange ::
ClassSetCharacter
-
ClassSetCharacter
22.2.1.2 Static Semantics: CountLeftCapturingParensWithin ( parseNode )
추상 연산 CountLeftCapturingParensWithin. 인수 parseNode (구문 분석 노드). 반환값: 음이 아닌 정수. parseNode 안의 왼쪽 캡처링 괄호 수를 반환합니다. 왼쪽 캡처링 괄호 는
Atom ::
(
GroupSpecifier opt
Disjunction
)
생성식의 ( 터미널과 일치하는 모든 ( 패턴 문자입니다.
참고
호출되면 다음 단계를 수행한다.
단언 : parseNode 는 RegExp Pattern 문법 에 있는 생성식의 인스턴스입니다.parseNode 안에 포함된
Atom ::
(
GroupSpecifier opt
Disjunction
)
Parse Node의 수를 반환합니다.
22.2.1.3 Static Semantics: CountLeftCapturingParensBefore ( parseNode )
추상 연산 CountLeftCapturingParensBefore. 인수 parseNode (구문 분석 노드). 반환값: 음이 아닌 정수. 둘러싸는 패턴 안에서 parseNode 의 왼쪽에 나타나는 왼쪽 캡처링 괄호 의 수를 반환합니다.
참고
호출되면 다음 단계를 수행한다.
단언 : parseNode 는 RegExp Pattern 문법 에 있는 생성식의 인스턴스입니다.pattern 을 parseNode 를 포함하는 Pattern 으로 둡니다.pattern 안에 포함되고 parseNode 보다 앞에 나타나거나 parseNode 를 포함하는
Atom ::
(
GroupSpecifier opt
Disjunction
)
Parse Node의 수를 반환합니다.
22.2.1.4 Static Semantics: MightBothParticipate ( x , y )
추상 연산 MightBothParticipate. 인수 x (구문 분석 노드) 및 y (구문 분석 노드). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
단언 : x 와 y 는 동일한 둘러싸는 Pattern 을 갖습니다.둘러싸는 Pattern 에
Disjunction ::
Alternative
|
Disjunction
Parse Node가 포함되어 있고 x 가 Alternative 안에 포함되며 y 가 파생된 Disjunction 안에 포함되거나, x 가 파생된 Disjunction 안에 포함되며 y 가 Alternative 안에 포함되면 false 를 반환합니다. true 를 반환합니다.
22.2.1.5 Static Semantics: CapturingGroupNumber
구문 지향 연산 CapturingGroupNumber. 인수 없음. 반환값: 양의 정수.
참고
다음 생성 규칙별로 정의된다.
DecimalEscape :: NonZeroDigit
NonZeroDigit 의 MV를 반환합니다.
DecimalEscape ::
NonZeroDigit
DecimalDigits
n 을 DecimalDigits 의 코드 포인트 수로 둡니다.(NonZeroDigit 의 MV × 10n 에 DecimalDigits 의 MV를 더한 값)를 반환합니다.
“NonZeroDigit 의 MV”와 “DecimalDigits 의 MV” 정의는 12.9.3 에 있습니다.
22.2.1.6 Static Semantics: IsCharacterClass
구문 지향 연산 IsCharacterClass. 인수 없음. 반환값: Boolean.
참고
다음 생성 규칙별로 정의된다.
ClassAtom ::
-
ClassAtomNoDash ::
SourceCharacter but not one of \ or ] or -
ClassEscape ::
b
-
CharacterEscape
false 를 반환합니다.
ClassEscape :: CharacterClassEscape
true 를 반환합니다.
22.2.1.7 Static Semantics: CharacterValue
구문 지향 연산 CharacterValue. 인수 없음. 반환값: 음이 아닌 정수.
참고 1
다음 생성 규칙별로 정의된다.
ClassAtom :: -
U+002D (HYPHEN-MINUS)의 숫자 값을 반환합니다.
ClassAtomNoDash :: SourceCharacter but not one of \ or ] or -
codePoint 를 SourceCharacter 와 일치하는 코드 포인트로 둡니다.codePoint 의 숫자 값을 반환합니다.
ClassEscape :: b
U+0008 (BACKSPACE)의 숫자 값을 반환합니다.
ClassEscape ::
U+002D (HYPHEN-MINUS)의 숫자 값을 반환합니다.
CharacterEscape :: ControlEscape
표 63 에 따른 숫자 값을 반환합니다.
표 63: ControlEscape 코드 포인트 값
ControlEscape
숫자 값
코드 포인트
유니코드 이름
기호
t
9
U+0009
CHARACTER TABULATION
<HT>
n
10
U+000A
LINE FEED (LF)
<LF>
v
11
U+000B
LINE TABULATION
<VT>
f
12
U+000C
FORM FEED (FF)
<FF>
r
13
U+000D
CARRIAGE RETURN (CR)
<CR>
CharacterEscape ::
c
AsciiLetter
codePoint 를 AsciiLetter 와 일치하는 코드 포인트로 둡니다.i 를 codePoint 의 숫자 값으로 둡니다.i 를 32로 나눈 나머지를 반환합니다.
CharacterEscape ::
0
[lookahead ∉ DecimalDigit ]
U+0000 (NULL)의 숫자 값을 반환합니다.
참고 2
\0은 <NUL> 문자를 나타내며 뒤에 십진 숫자가 올 수 없습니다.
CharacterEscape :: HexEscapeSequence
HexEscapeSequence 의 MV를 반환합니다.
RegExpUnicodeEscapeSequence ::
u
HexLeadSurrogate
\u
HexTrailSurrogate
lead 를 HexLeadSurrogate 의 CharacterValue 로 둡니다.trail 을 HexTrailSurrogate 의 CharacterValue 로 둡니다.codePoint 를 UTF16SurrogatePairToCodePoint (lead , trail )로 둡니다.codePoint 의 숫자 값을 반환합니다.
RegExpUnicodeEscapeSequence ::
u
Hex4Digits
Hex4Digits 의 MV를 반환합니다.
RegExpUnicodeEscapeSequence ::
u{
CodePoint
}
CodePoint 의 MV를 반환합니다.
HexLeadSurrogate :: Hex4Digits
HexTrailSurrogate :: Hex4Digits
HexNonSurrogate :: Hex4Digits
Hex4Digits 의 MV를 반환합니다.
CharacterEscape :: IdentityEscape
codePoint 를 IdentityEscape 와 일치하는 코드 포인트로 둡니다.codePoint 의 숫자 값을 반환합니다.
ClassSetCharacter :: SourceCharacter but not ClassSetSyntaxCharacter
codePoint 를 SourceCharacter 와 일치하는 코드 포인트로 둡니다.codePoint 의 숫자 값을 반환합니다.
ClassSetCharacter ::
\
ClassSetReservedPunctuator
codePoint 를 ClassSetReservedPunctuator 와 일치하는 코드 포인트로 둡니다.codePoint 의 숫자 값을 반환합니다.
ClassSetCharacter :: \b
U+0008 (BACKSPACE)의 숫자 값을 반환합니다.
22.2.1.8 Static Semantics: MayContainStrings
구문 지향 연산 MayContainStrings. 인수 없음. 반환값: Boolean. 다음 생성 규칙별로 정의된다.
CharacterClassEscape ::
d
D
s
S
w
W
P{
UnicodePropertyValueExpression
}
UnicodePropertyValueExpression ::
UnicodePropertyName
=
UnicodePropertyValue
NestedClass ::
[^
ClassContents
]
ClassContents ::
[empty]
NonemptyClassRanges
ClassSetOperand ::
ClassSetCharacter
false 를 반환합니다.
UnicodePropertyValueExpression :: LoneUnicodePropertyNameOrValue
LoneUnicodePropertyNameOrValue 과 일치하는 소스 텍스트 가 표 67 의 “Property name ” 열에 나열된 문자열의 이진 프로퍼티이면 true 를 반환합니다.false 를 반환합니다.
ClassUnion ::
ClassSetRange
ClassUnion opt
ClassUnion 이 존재하면 ClassUnion 의 MayContainStrings 를 반환합니다.false 를 반환합니다.
ClassUnion ::
ClassSetOperand
ClassUnion opt
ClassSetOperand 의 MayContainStrings 가 true 이면 true 를 반환합니다.ClassUnion 이 존재하면 ClassUnion 의 MayContainStrings 를 반환합니다.false 를 반환합니다.
ClassIntersection ::
ClassSetOperand
&&
ClassSetOperand
첫 번째 ClassSetOperand 의 MayContainStrings 가 false 이면 false 를 반환합니다. 두 번째 ClassSetOperand 의 MayContainStrings 가 false 이면 false 를 반환합니다. true 를 반환합니다.
ClassIntersection ::
ClassIntersection
&&
ClassSetOperand
ClassIntersection 의 MayContainStrings 가 false 이면 false 를 반환합니다.ClassSetOperand 의 MayContainStrings 가 false 이면 false 를 반환합니다.true 를 반환합니다.
ClassSubtraction ::
ClassSetOperand
--
ClassSetOperand
첫 번째 ClassSetOperand 의 MayContainStrings 를 반환합니다.
ClassSubtraction ::
ClassSubtraction
--
ClassSetOperand
ClassSubtraction 의 MayContainStrings 를 반환합니다.
ClassStringDisjunctionContents ::
ClassString
|
ClassStringDisjunctionContents
ClassString 의 MayContainStrings 가 true 이면 true 를 반환합니다.ClassStringDisjunctionContents 의 MayContainStrings 를 반환합니다.
ClassString :: [empty]
true 를 반환합니다.
ClassString :: NonEmptyClassString
NonEmptyClassString 의 MayContainStrings 를 반환합니다.
NonEmptyClassString ::
ClassSetCharacter
NonEmptyClassString opt
NonEmptyClassString 이 존재하면 true 를 반환합니다.false 를 반환합니다.
22.2.1.9 Static Semantics: GroupSpecifiersThatMatch ( thisGroupName )
추상 연산 GroupSpecifiersThatMatch. 인수 thisGroupName (a GroupName Parse Node). 반환값: 리스트 (요소: GroupSpecifier Parse Nodes ). 호출되면 다음 단계를 수행한다.
name 을 thisGroupName 의 CapturingGroupName 으로 둡니다.pattern 을 thisGroupName 을 포함하는 Pattern 으로 둡니다.result 를 새로운 빈 List 로 둡니다.pattern 이 포함하는 각 GroupSpecifier groupSpecifier 에 대해 다음을 수행합니다.groupSpecifier 의 CapturingGroupName 이 name 이면, 다음을 수행합니다.groupSpecifier 를 result 에 추가합니다.result 를 반환합니다.
22.2.1.10 Static Semantics: CapturingGroupName
구문 지향 연산 CapturingGroupName. 인수 없음. 반환값: String. 다음 생성 규칙별로 정의된다.
GroupName ::
<
RegExpIdentifierName
>
nameUnescaped 를 RegExpIdentifierName 의 RegExpIdentifierCodePoints 로 둡니다.CodePointsToString (nameUnescaped )을 반환합니다.
22.2.1.11 Static Semantics: RegExpIdentifierCodePoints
구문 지향 연산 RegExpIdentifierCodePoints. 인수 없음. 반환값: 리스트 (요소: 코드 포인트). 다음 생성 규칙별로 정의된다.
RegExpIdentifierName :: RegExpIdentifierStart
codePoint 를 RegExpIdentifierStart 의 RegExpIdentifierCodePoint 로 둡니다.« codePoint »을 반환합니다.
RegExpIdentifierName ::
RegExpIdentifierName
RegExpIdentifierPart
codePoints 를 파생된 RegExpIdentifierName 의 RegExpIdentifierCodePoints 로 둡니다.codePoint 를 RegExpIdentifierPart 의 RegExpIdentifierCodePoint 로 둡니다.codePoints 와 « codePoint »의 목록 연결 을 반환합니다.
22.2.1.12 Static Semantics: RegExpIdentifierCodePoint
구문 지향 연산 RegExpIdentifierCodePoint. 인수 없음. 반환값: 코드 포인트. 다음 생성 규칙별로 정의된다.
RegExpIdentifierStart :: IdentifierStartChar
IdentifierStartChar 와 일치하는 코드 포인트를 반환합니다.
RegExpIdentifierPart :: IdentifierPartChar
IdentifierPartChar 와 일치하는 코드 포인트를 반환합니다.
RegExpIdentifierStart ::
\
RegExpUnicodeEscapeSequence
RegExpIdentifierPart ::
\
RegExpUnicodeEscapeSequence
숫자 값이 RegExpUnicodeEscapeSequence 의 CharacterValue 인 코드 포인트를 반환합니다.
RegExpIdentifierStart ::
UnicodeLeadSurrogate
UnicodeTrailSurrogate
RegExpIdentifierPart ::
UnicodeLeadSurrogate
UnicodeTrailSurrogate
lead 를 숫자 값이 UnicodeLeadSurrogate 와 일치하는 코드 포인트의 숫자 값인 코드 단위로 둡니다.trail 을 숫자 값이 UnicodeTrailSurrogate 와 일치하는 코드 포인트의 숫자 값인 코드 단위로 둡니다.UTF16SurrogatePairToCodePoint (lead , trail )를 반환합니다.
22.2.2 패턴 의미론
정규 표현식 패턴은 아래에 설명된 과정을 사용하여 Abstract Closure 로 변환됩니다. 결과가 동일하다면 구현체는 아래에 나열된 알고리즘보다 더 효율적인 알고리즘을 사용하는 것이 권장됩니다. Abstract Closure 는 RegExp 객체의 [[RegExpMatcher]] 내부 슬롯 값으로 사용됩니다.
Pattern 의 관련 플래그에 u도 v도 포함되어 있지 않으면 해당 Pattern 은 BMP 패턴입니다. 그렇지 않으면 유니코드 패턴입니다. BMP 패턴은 Basic Multilingual Plane 범위의 유니코드 코드 포인트인 16비트 값의 시퀀스로 구성된 것으로 해석되는 String과 일치합니다. 유니코드 패턴은 UTF-16으로 인코딩된 유니코드 코드 포인트로 구성된 것으로 해석되는 String과 일치합니다. BMP 패턴의 동작을 설명하는 문맥에서 “문자”는 단일 16비트 유니코드 BMP 코드 포인트를 의미합니다. 유니코드 패턴의 동작을 설명하는 문맥에서 “문자”는 UTF-16 인코딩 코드 포인트(6.1.4 )를 의미합니다. 어느 문맥에서든 “문자 값”은 대응하는 인코딩되지 않은 코드 포인트의 숫자 값을 의미합니다.
Pattern 의 구문과 의미론은 Pattern 의 소스 텍스트가 각 SourceCharacter 가 하나의 유니코드 코드 포인트에 대응하는 SourceCharacter 값의 List 인 것처럼 정의됩니다. BMP 패턴에 비-BMP SourceCharacter 가 포함되어 있으면 전체 패턴을 UTF-16으로 인코딩하고 해당 인코딩의 개별 코드 단위를 List 의 요소로 사용합니다.
참고
예를 들어 소스 텍스트에서 단일 비-BMP 문자 U+1D11E (MUSICAL SYMBOL G CLEF)로 표현된 패턴을 생각해 보시기 바랍니다. 유니코드 패턴으로 해석하면 단일 코드 포인트 U+1D11E로 구성된 단일 요소(문자) List 가 됩니다. 그러나 BMP 패턴으로 해석하면 먼저 UTF-16으로 인코딩되어 코드 단위 0xD834와 0xDD1E로 구성된 두 요소 List 가 생성됩니다.
패턴은 비-BMP 문자가 UTF-16으로 인코딩된 ECMAScript String 값으로 RegExp 생성자 에 전달됩니다. 예를 들어 단일 문자 MUSICAL SYMBOL G CLEF 패턴을 String 값으로 표현하면 요소가 코드 단위 0xD834와 0xDD1E인 길이 2의 String입니다. 따라서 두 패턴 문자로 구성된 BMP 패턴으로 처리하기 위해 문자열을 추가로 변환할 필요는 없습니다. 그러나 유니코드 패턴으로 처리하려면 유일한 요소가 단일 패턴 문자, 즉 코드 포인트 U+1D11E인 List 를 생성할 때 UTF16SurrogatePairToCodePoint 를 사용해야 합니다.
구현체는 실제로 UTF-16으로 또는 UTF-16에서 이러한 변환을 수행하지 않을 수 있지만, 이 명세의 의미론은 패턴 일치 결과가 그러한 변환이 수행된 것과 같아야 함을 요구합니다.
22.2.2.1 표기법
아래 설명에서는 다음 내부 데이터 구조를 사용합니다:
CharSetElement 는 다음 두 엔티티 중 하나입니다:
regexpRecord .[[UnicodeSets]] 가 false 이면 CharSetElement는 위의 패턴 의미론에서 말하는 문자입니다.
regexpRecord .[[UnicodeSets]] 가 true 이면 CharSetElement는 요소가 위의 패턴 의미론에서 말하는 문자인 시퀀스입니다. 여기에는 빈 시퀀스, 한 문자의 시퀀스 및 둘 이상의 문자의 시퀀스가 포함됩니다. 편의를 위해 이러한 종류의 CharSetElement를 다룰 때 개별 문자는 한 문자의 시퀀스와 상호 교환 가능하게 취급합니다.
CharSet 은 CharSetElement의 수학적 집합입니다.
CaptureRange 는 캡처에 포함된 문자 범위를 나타내는 Record { [[StartIndex]] , [[EndIndex]] }입니다. 여기서 [[StartIndex]] 는 input 안에서 범위의 시작 인덱스(포함)를 나타내는 정수 이고 [[EndIndex]] 는 input 안에서 범위의 끝 인덱스(제외)를 나타내는 정수 입니다. 모든 CaptureRange 에서 이러한 인덱스는 [[StartIndex]] ≤ [[EndIndex]] 라는 불변 조건을 만족해야 합니다.
MatchState 는 Record { [[Input]] , [[EndIndex]] , [[Captures]] }입니다. 여기서 [[Input]] 은 일치 대상 String을 나타내는 문자 List 이고, [[EndIndex]] 는 정수 이며, [[Captures]] 는 패턴의 각 왼쪽 캡처링 괄호 마다 하나의 값을 갖는 List 입니다. MatchState 는 정규 표현식 일치 알고리즘에서 부분 일치 상태를 나타내는 데 사용됩니다. [[EndIndex]] 는 지금까지 패턴이 일치한 마지막 입력 문자의 인덱스에 1을 더한 값이며, [[Captures]] 는 캡처링 괄호의 결과를 보관합니다. [[Captures]] 의 n th 요소는 n th 캡처링 괄호 집합이 캡처한 문자 범위를 나타내는 CaptureRange 이거나, n th 캡처링 괄호 집합에 아직 도달하지 않은 경우 undefined 입니다. 백트래킹 때문에 일치 과정 중 언제든 여러 MatchState 가 사용 중일 수 있습니다.
MatcherContinuation 은 하나의 MatchState 인수를 받고 MatchState 또는 failure 를 반환하는 Abstract Closure 입니다. MatcherContinuation 은 MatchState 인수가 지정한 중간 상태에서 시작하여 input 에 대해 패턴의 남은 부분(클로저가 캡처한 값으로 지정됨)을 일치시키려고 시도합니다. 일치가 성공하면 MatcherContinuation 은 도달한 최종 MatchState 를 반환하고, 일치가 실패하면 failure 를 반환합니다.
Matcher 는 두 인수, 즉 MatchState 와 MatcherContinuation 을 받고 MatchState 또는 failure 를 반환하는 Abstract Closure 입니다. Matcher 는 MatchState 인수가 지정한 중간 상태에서 시작하여 MatchState 의 [[Input]] 에 대해 패턴의 중간 하위 패턴(클로저가 캡처한 값으로 지정됨)을 일치시키려고 시도합니다. MatcherContinuation 인수는 패턴의 나머지를 일치시키는 클로저여야 합니다. 패턴의 하위 패턴을 일치시켜 새로운 MatchState 를 얻은 뒤 Matcher 는 새 MatchState 에 대해 MatcherContinuation 을 호출하여 패턴의 나머지도 일치할 수 있는지 검사합니다. 가능하면 Matcher 는 MatcherContinuation 이 반환한 MatchState 를 반환하고, 그렇지 않으면 선택 지점에서 다른 선택을 시도하면서 성공하거나 모든 가능성이 소진될 때까지 MatcherContinuation 을 반복 호출할 수 있습니다.
22.2.2.1.1 RegExp Record
RegExp Record 는 컴파일 중 및 필요한 경우 일치 중에 필요한 RegExp 정보를 저장하는 데 사용하는 Record 입니다.
다음 필드를 갖습니다:
표 64: RegExp Record 필드
필드 이름
값
의미
[[IgnoreCase]]
a Boolean
RegExp의 플래그에 "i" 가 나타나는지 나타냅니다.
[[Multiline]]
a Boolean
RegExp의 플래그에 "m" 이 나타나는지 나타냅니다.
[[DotAll]]
a Boolean
RegExp의 플래그에 "s" 가 나타나는지 나타냅니다.
[[Unicode]]
a Boolean
RegExp의 플래그에 "u" 가 나타나는지 나타냅니다.
[[UnicodeSets]]
a Boolean
RegExp의 플래그에 "v" 가 나타나는지 나타냅니다.
[[CapturingGroupsCount]]
a non-negative integer
RegExp 패턴의 왼쪽 캡처링 괄호 수입니다.
22.2.2.2 Runtime Semantics: CompilePattern
구문 지향 연산 CompilePattern. 인수 regexpRecord (RegExp 레코드 ). 반환값: an Abstract Closure that takes a List of characters and a non-negative integer and returns either a MatchState or failure . 다음 생성 규칙별로 정의된다.
Pattern :: Disjunction
m 을 인수 regexpRecord 및 forward 를 사용한 Disjunction 의 CompileSubpattern 으로 둡니다.regexpRecord 와 m 을 캡처하고 호출될 때 다음 단계를 수행하는 매개변수 (input , index )를 갖는 새로운 Abstract Closure 를 반환합니다:단언 : input 은 문자의 List 입니다.단언 : 0 ≤ index ≤ input 의 요소 수입니다.c 를 아무것도 캡처하지 않고 호출될 때 다음 단계를 수행하는 매개변수 (y )를 갖는 새로운 MatcherContinuation 으로 둡니다:단언 : y 는 MatchState 입니다.y 를 반환합니다.capability 를 1부터 regexpRecord .[[CapturingGroupsCount]] 까지 인덱싱된 regexpRecord .[[CapturingGroupsCount]] 개의 undefined 값으로 구성된 List 로 둡니다.x 를 MatchState { [[Input]] : input , [[EndIndex]] : index , [[Captures]] : capability }로 둡니다.m (x , c )를 반환합니다.
참고
Pattern은 Abstract Closure 값으로 컴파일됩니다. 그런 다음 RegExpBuiltinExec 는 이 프로시저를 문자 List 와 해당 List 안의 오프셋에 적용하여 패턴이 List 안의 정확히 해당 오프셋에서 시작하여 일치하는지, 그리고 일치하는 경우 캡처링 괄호의 값이 무엇인지 결정할 수 있습니다. 22.2.2 의 알고리즘은 패턴 컴파일이 SyntaxError 예외를 던질 수 있도록 설계되어 있습니다. 반면 패턴이 성공적으로 컴파일된 후에는 결과 Abstract Closure 를 적용하여 문자 List 안에서 일치를 찾는 과정은 예외를 던질 수 없습니다(메모리 부족처럼 어디서든 발생할 수 있는 구현체 정의 예외는 제외).
22.2.2.3 Runtime Semantics: CompileSubpattern
구문 지향 연산 CompileSubpattern. 인수 regexpRecord (RegExp 레코드 ) 및 direction ((forward 또는 backward )). 반환값: Matcher .
참고 1
다음 생성 규칙별로 정의된다.
Disjunction ::
Alternative
|
Disjunction
m1 을 인수 regexpRecord 및 direction 을 사용한 Alternative 의 CompileSubpattern 으로 둡니다.m2 를 인수 regexpRecord 및 direction 을 사용한 Disjunction 의 CompileSubpattern 으로 둡니다.MatchTwoAlternatives (m1 , m2 )를 반환합니다.
참고 2
| 정규 표현식 연산자는 두 대안을 구분합니다. 패턴은 먼저 왼쪽 Alternative (정규 표현식의 후속 부분이 이어짐)를 일치시키려고 시도하고, 실패하면 오른쪽 Disjunction (정규 표현식의 후속 부분이 이어짐)을 일치시키려고 시도합니다. 왼쪽 Alternative , 오른쪽 Disjunction 및 후속 부분에 모두 선택 지점이 있으면 왼쪽 Alternative 의 다음 선택으로 이동하기 전에 후속 부분의 모든 선택을 시도합니다. 왼쪽 Alternative 의 선택이 소진되면 왼쪽 Alternative 대신 오른쪽 Disjunction 을 시도합니다. |에 의해 건너뛴 패턴 부분 안의 캡처링 괄호는 String 대신 undefined 값을 생성합니다. 따라서 예를 들어,
/a|ab/.exec ("abc" )
는 "ab" 가 아니라 "a" 결과를 반환합니다. 또한,
/((a)|(ab))((c)|(bc))/.exec ("abc" )
는 다음 배열을 반환하고
["abc" , "a" , "a" , undefined , "bc" , undefined , "bc" ]
다음 배열은 반환하지 않습니다.
["abc" , "ab" , undefined , "ab" , "c" , "c" , undefined ]
두 대안을 시도하는 순서는 direction 값과 무관합니다.
Alternative :: [empty]
EmptyMatcher ()를 반환합니다.
Alternative ::
Alternative
Term
m1 을 인수 regexpRecord 및 direction 을 사용한 Alternative 의 CompileSubpattern 으로 둡니다.m2 를 인수 regexpRecord 및 direction 을 사용한 Term 의 CompileSubpattern 으로 둡니다.MatchSequence (m1 , m2 , direction )를 반환합니다.
참고 3
연속된 Term 은 input 의 연속된 부분을 동시에 일치시키려고 시도합니다. direction 이 forward 이고 왼쪽 Alternative , 오른쪽 Term 및 정규 표현식의 후속 부분에 모두 선택 지점이 있으면 오른쪽 Term 의 다음 선택으로 이동하기 전에 후속 부분의 모든 선택을 시도하며, 왼쪽 Alternative 의 다음 선택으로 이동하기 전에 오른쪽 Term 의 모든 선택을 시도합니다. direction 이 backward 이면 Alternative 와 Term 의 평가 순서가 반대가 됩니다.
Term :: Assertion
인수 regexpRecord 를 사용한 Assertion 의 CompileAssertion 을 반환합니다.
참고 4
결과 Matcher 는 direction 과 무관합니다.
Term :: Atom
인수 regexpRecord 및 direction 을 사용한 Atom 의 CompileAtom 을 반환합니다.
Term ::
Atom
Quantifier
m 을 인수 regexpRecord 및 direction 을 사용한 Atom 의 CompileAtom 으로 둡니다.q 를 Quantifier 의 CompileQuantifier 로 둡니다.단언 : q .[[Min]] ≤ q .[[Max]] 입니다.parenIndex 를 CountLeftCapturingParensBefore (Term )로 둡니다.parenCount 를 CountLeftCapturingParensWithin (Atom )로 둡니다.m , q , parenIndex 및 parenCount 를 캡처하고 호출될 때 다음 단계를 수행하는 매개변수 (x , c )를 갖는 새로운 Matcher 를 반환합니다:단언 : x 는 MatchState 입니다.단언 : c 는 MatcherContinuation 입니다.RepeatMatcher (m , q .[[Min]] , q .[[Max]] , q .[[Greedy]] , x , c , parenIndex , parenCount )를 반환합니다.
22.2.2.3.1 RepeatMatcher ( m , min , max , greedy , matchState , continue , parenIndex , parenCount )
추상 연산 RepeatMatcher. 인수 m (Matcher ), min (음이 아닌 정수), max ((음이 아닌 정수 또는 +∞)), greedy (Boolean), matchState (MatchState ), continue (MatcherContinuation ), parenIndex (음이 아닌 정수) 및 parenCount (음이 아닌 정수). 반환값: (MatchState 또는 failure ). 호출되면 다음 단계를 수행한다.
max = 0이면 continue (matchState )를 반환합니다.d 를 m , min , max , greedy , matchState , continue , parenIndex 및 parenCount 를 캡처하고 호출될 때 다음 단계를 수행하는 매개변수 (y )를 갖는 새로운 MatcherContinuation 으로 둡니다:단언 : y 는 MatchState 입니다.min = 0이고 y .[[EndIndex]] = matchState .[[EndIndex]] 이면 failure 를 반환합니다.min = 0이면 min2 를 0으로 둡니다. 그렇지 않으면 min2 를 min - 1로 둡니다.max = +∞이면 max2 를 +∞로 둡니다. 그렇지 않으면 max2 를 max - 1로 둡니다.RepeatMatcher (m , min2 , max2 , greedy , y , continue , parenIndex , parenCount )를 반환합니다.capability 를 matchState .[[Captures]] 의 복사본으로 둡니다.parenIndex + 1부터 parenIndex + parenCount 까지의 폐구간 에 속하는 각 정수 k 에 대해 capability [k ]를 undefined 로 설정합니다.input 을 matchState .[[Input]] 으로 둡니다.e 를 matchState .[[EndIndex]] 로 둡니다.xr 를 MatchState { [[Input]] : input , [[EndIndex]] : e , [[Captures]] : capability }로 둡니다.min ≠ 0이면 m (xr , d )를 반환합니다.greedy 가 false 이면, 다음을 수행합니다.z 를 continue (matchState )로 둡니다.z 가 failure 가 아니면 z 를 반환합니다.m (xr , d )를 반환합니다.z 를 m (xr , d )로 둡니다.z 가 failure 가 아니면 z 를 반환합니다.continue (matchState )를 반환합니다.
참고 1
Quantifier 가 뒤따르는 Atom 은 Quantifier 가 지정한 횟수만큼 반복됩니다. Quantifier 는 비탐욕적일 수 있으며, 이 경우 Atom 패턴은 후속 부분과 여전히 일치하는 범위에서 가능한 한 적게 반복됩니다. 또는 탐욕적일 수 있으며, 이 경우 Atom 패턴은 후속 부분과 여전히 일치하는 범위에서 가능한 한 많이 반복됩니다. 일치하는 입력 문자 시퀀스가 아니라 Atom 패턴 자체가 반복되므로 Atom 의 서로 다른 반복은 서로 다른 입력 부분 문자열 과 일치할 수 있습니다.
참고 2
Atom 과 정규 표현식의 후속 부분에 모두 선택 지점이 있으면 Atom 은 먼저 가능한 한 많이(비탐욕적이면 가능한 한 적게) 일치합니다. 후속 부분의 모든 선택은 Atom 의 마지막 반복에서 다음 선택으로 이동하기 전에 시도됩니다. Atom 의 마지막(nth ) 반복의 모든 선택은 마지막에서 두 번째(n - 1)st 반복의 다음 선택으로 이동하기 전에 시도됩니다. 이 시점에서 Atom 을 더 많이 또는 더 적게 반복할 수 있음이 밝혀질 수 있으며, 이러한 가능성은 (다시 가능한 한 적게 또는 많이 시작하여) 소진된 뒤 (n - 1)st 반복의 다음 선택으로 이동하는 식으로 계속됩니다.
다음을 비교해 보시기 바랍니다.
/a[a-z]{2 ,4 }/.exec ("abcdefghi" )
이는 "abcde" 를 반환하며, 다음은
/a[a-z]{2 ,4 }?/.exec ("abcdefghi" )
"abc" 를 반환합니다.
또한 다음도 생각해 보시기 바랍니다.
/(aa|aabaac|ba|b|c)*/.exec ("aabaac" )
위의 선택 지점 순서에 따라 다음 배열을 반환하고
["aaba" , "ba" ]
다음 중 어느 것도 반환하지 않습니다:
["aabaac" , "aabaac" ]
["aabaac" , "c" ]
위의 선택 지점 순서를 이용하면 두 숫자(단항 표기법으로 표현됨)의 최대공약수를 계산하는 정규 표현식을 작성할 수 있습니다. 다음 예는 10과 15의 최대공약수를 계산합니다:
"aaaaaaaaaa,aaaaaaaaaaaaaaa" .replace (/^(a+)\1*,\1+$/ , "$1" )
이는 단항 표기법으로 된 최대공약수 "aaaaa" 를 반환합니다.
참고 3
RepeatMatcher의 4 단계는 Atom 이 반복될 때마다 Atom 의 캡처를 지웁니다. 다음 정규 표현식에서 그 동작을 확인할 수 있습니다.
/(z)((a+)?(b+)?(c))*/.exec ("zaacbbbcac" )
이는 다음 배열을 반환하고
["zaacbbbcac" , "z" , "ac" , "a" , undefined , "c" ]
다음은 반환하지 않습니다.
["zaacbbbcac" , "z" , "ac" , "a" , "bbb" , "c" ]
가장 바깥쪽 *의 각 반복이 수량화된 Atom 안에 포함된 모든 캡처 String을 지우기 때문이며, 이 경우 번호 2, 3, 4 및 5의 캡처 String이 포함됩니다.
참고 4
RepeatMatcher의 2.b 단계는 최소 반복 횟수가 충족된 후 빈 문자 시퀀스와 일치하는 Atom 의 추가 확장은 이후 반복에서 고려하지 않는다고 명시합니다. 이는 다음과 같은 패턴에서 정규 표현식 엔진이 무한 루프에 빠지는 것을 방지합니다:
/(a*)*/.exec ("b" )
또는 조금 더 복잡한 다음 패턴:
/(a*)b\1 +/.exec ("baaaac" )
이는 다음 배열을 반환합니다.
["b" , "" ]
22.2.2.3.2 EmptyMatcher ( )
추상 연산 EmptyMatcher. 인수 없음. 반환값: Matcher . 호출되면 다음 단계를 수행한다.
아무것도 캡처하지 않고 호출될 때 다음 단계를 수행하는 매개변수 (matchState , continue )를 갖는 새로운 Matcher 를 반환합니다:단언 : matchState 는 MatchState 입니다.단언 : continue 는 MatcherContinuation 입니다.continue (matchState )를 반환합니다.
22.2.2.3.3 MatchTwoAlternatives ( m1 , m2 )
추상 연산 MatchTwoAlternatives. 인수 m1 (Matcher ) 및 m2 (Matcher ). 반환값: Matcher . 호출되면 다음 단계를 수행한다.
m1 과 m2 를 캡처하고 호출될 때 다음 단계를 수행하는 매개변수 (matchState , continue )를 갖는 새로운 Matcher 를 반환합니다:단언 : matchState 는 MatchState 입니다.단언 : continue 는 MatcherContinuation 입니다.result 를 m1 (matchState , continue )로 둡니다.result 가 failure 가 아니면 result 를 반환합니다.m2 (matchState , continue )를 반환합니다.
22.2.2.3.4 MatchSequence ( m1 , m2 , direction )
추상 연산 MatchSequence. 인수 m1 (Matcher ), m2 (Matcher ) 및 direction ((forward 또는 backward )). 반환값: Matcher . 호출되면 다음 단계를 수행한다.
direction 이 forward 이면, 다음을 수행합니다.m1 과 m2 를 캡처하고 호출될 때 다음 단계를 수행하는 매개변수 (matchState , continue )를 갖는 새로운 Matcher 를 반환합니다:단언 : matchState 는 MatchState 입니다.단언 : continue 는 MatcherContinuation 입니다.d 를 continue 와 m2 를 캡처하고 호출될 때 다음 단계를 수행하는 매개변수 (y )를 갖는 새로운 MatcherContinuation 으로 둡니다:단언 : y 는 MatchState 입니다.m2 (y , continue )를 반환합니다.m1 (matchState , d )를 반환합니다.단언 : direction 은 backward 입니다.m1 과 m2 를 캡처하고 호출될 때 다음 단계를 수행하는 매개변수 (matchState , continue )를 갖는 새로운 Matcher 를 반환합니다:단언 : matchState 는 MatchState 입니다.단언 : continue 는 MatcherContinuation 입니다.d 를 continue 와 m1 을 캡처하고 호출될 때 다음 단계를 수행하는 매개변수 (y )를 갖는 새로운 MatcherContinuation 으로 둡니다:단언 : y 는 MatchState 입니다.m1 (y , continue )를 반환합니다.m2 (matchState , d )를 반환합니다.
22.2.2.4 Runtime Semantics: CompileAssertion
구문 지향 연산 CompileAssertion. 인수 regexpRecord (RegExp 레코드 ). 반환값: Matcher .
참고 1
다음 생성 규칙별로 정의된다.
Assertion :: ^
regexpRecord 를 캡처하고 호출될 때 다음 단계를 수행하는 매개변수 (matchState , continue )를 갖는 새로운 Matcher 를 반환합니다:단언 : matchState 는 MatchState 입니다.단언 : continue 는 MatcherContinuation 입니다.input 을 matchState .[[Input]] 으로 둡니다.e 를 matchState .[[EndIndex]] 로 둡니다.e = 0이거나, regexpRecord .[[Multiline]] 이 true 이고 문자 input [e - 1]이 LineTerminator 와 일치하면, 다음을 수행합니다.continue (matchState )를 반환합니다.failure 를 반환합니다.
참고 2
패턴에 y 플래그를 사용하는 경우에도 ^는 항상 input 의 시작 또는 (regexpRecord .[[Multiline]] 이 true 인 경우) 줄의 시작에서만 일치합니다.
Assertion :: $
regexpRecord 를 캡처하고 호출될 때 다음 단계를 수행하는 매개변수 (matchState , continue )를 갖는 새로운 Matcher 를 반환합니다:단언 : matchState 는 MatchState 입니다.단언 : continue 는 MatcherContinuation 입니다.input 을 matchState .[[Input]] 으로 둡니다.e 를 matchState .[[EndIndex]] 로 둡니다.inputLength 를 input 의 요소 수로 둡니다.e = inputLength 이거나, regexpRecord .[[Multiline]] 이 true 이고 문자 input [e ]가 LineTerminator 와 일치하면, 다음을 수행합니다.continue (matchState )를 반환합니다.failure 를 반환합니다.
Assertion :: \b
regexpRecord 를 캡처하고 호출될 때 다음 단계를 수행하는 매개변수 (matchState , continue )를 갖는 새로운 Matcher 를 반환합니다:단언 : matchState 는 MatchState 입니다.단언 : continue 는 MatcherContinuation 입니다.input 을 matchState .[[Input]] 으로 둡니다.e 를 matchState .[[EndIndex]] 로 둡니다.a 를 IsWordChar (regexpRecord , input , e - 1)로 둡니다.b 를 IsWordChar (regexpRecord , input , e )로 둡니다.a 가 true 이고 b 가 false 이거나, a 가 false 이고 b 가 true 이면 continue (matchState )를 반환합니다.failure 를 반환합니다.
Assertion :: \B
regexpRecord 를 캡처하고 호출될 때 다음 단계를 수행하는 매개변수 (matchState , continue )를 갖는 새로운 Matcher 를 반환합니다:단언 : matchState 는 MatchState 입니다.단언 : continue 는 MatcherContinuation 입니다.input 을 matchState .[[Input]] 으로 둡니다.e 를 matchState .[[EndIndex]] 로 둡니다.a 를 IsWordChar (regexpRecord , input , e - 1)로 둡니다.b 를 IsWordChar (regexpRecord , input , e )로 둡니다.a 가 true 이고 b 가 true 이거나, a 가 false 이고 b 가 false 이면 continue (matchState )를 반환합니다.failure 를 반환합니다.
Assertion ::
(?=
Disjunction
)
m 을 인수 regexpRecord 및 forward 를 사용한 Disjunction 의 CompileSubpattern 으로 둡니다.m 을 캡처하고 호출될 때 다음 단계를 수행하는 매개변수 (matchState , continue )를 갖는 새로운 Matcher 를 반환합니다:단언 : matchState 는 MatchState 입니다.단언 : continue 는 MatcherContinuation 입니다.d 를 아무것도 캡처하지 않고 호출될 때 다음 단계를 수행하는 매개변수 (y )를 갖는 새로운 MatcherContinuation 으로 둡니다:단언 : y 는 MatchState 입니다.y 를 반환합니다.result 를 m (matchState , d )로 둡니다.result 가 failure 이면 failure 를 반환합니다.단언 : result 는 MatchState 입니다.capability 를 result .[[Captures]] 로 둡니다.input 을 matchState .[[Input]] 으로 둡니다.xe 를 matchState .[[EndIndex]] 로 둡니다.z 를 MatchState { [[Input]] : input , [[EndIndex]] : xe , [[Captures]] : capability }로 둡니다.continue (z )를 반환합니다.
참고 3
(?= Disjunction ) 형식은 너비가 0인 긍정형 전방 탐색을 지정합니다. 성공하려면 Disjunction 안의 패턴이 현재 위치에서 일치해야 하지만, 후속 부분을 일치시키기 전에 현재 위치는 전진하지 않습니다. Disjunction 이 현재 위치에서 여러 방식으로 일치할 수 있으면 첫 번째 방식만 시도합니다. 다른 정규 표현식 연산자와 달리 (?= 형식 안으로 백트래킹하지 않습니다(이 비정상적인 동작은 Perl에서 상속됨). 이는 Disjunction 에 캡처링 괄호가 포함되고 패턴의 후속 부분에 해당 캡처에 대한 역참조가 포함된 경우에만 중요합니다.
예를 들어,
/(?=(a+))/.exec ("baaabac" )
는 첫 번째 b 바로 뒤의 빈 String과 일치하므로 다음 배열을 반환합니다:
["" , "aaa" ]
전방 탐색 안으로 백트래킹하지 않는다는 점을 보여 주기 위해 다음을 생각해 보시기 바랍니다:
/(?=(a+))a*b\1 /.exec ("baaabac" )
이 표현식은 다음을 반환하며
["aba" , "a" ]
다음은 반환하지 않습니다:
["aaaba" , "a" ]
Assertion ::
(?!
Disjunction
)
m 을 인수 regexpRecord 및 forward 를 사용한 Disjunction 의 CompileSubpattern 으로 둡니다.m 을 캡처하고 호출될 때 다음 단계를 수행하는 매개변수 (matchState , continue )를 갖는 새로운 Matcher 를 반환합니다:단언 : matchState 는 MatchState 입니다.단언 : continue 는 MatcherContinuation 입니다.d 를 아무것도 캡처하지 않고 호출될 때 다음 단계를 수행하는 매개변수 (y )를 갖는 새로운 MatcherContinuation 으로 둡니다:단언 : y 는 MatchState 입니다.y 를 반환합니다.result 를 m (matchState , d )로 둡니다.result 가 failure 가 아니면 failure 를 반환합니다.continue (matchState )를 반환합니다.
참고 4
(?! Disjunction ) 형식은 너비가 0인 부정형 전방 탐색을 지정합니다. 성공하려면 Disjunction 안의 패턴이 현재 위치에서 일치하지 않아야 합니다. 후속 부분을 일치시키기 전에 현재 위치는 전진하지 않습니다. Disjunction 은 캡처링 괄호를 포함할 수 있지만 이에 대한 역참조는 Disjunction 자체 안에서만 의미가 있습니다. 패턴의 다른 위치에서 이러한 캡처링 괄호에 대한 역참조는 항상 undefined 를 반환합니다. 패턴이 성공하려면 부정형 전방 탐색이 실패해야 하기 때문입니다. 예를 들어,
/(.*?)a (?!(a+)b\2c)\2 (.*)/.exec ("baaabaac" )
는 바로 뒤에 양의 수 n개의 a, b, 다시 n개의 a(첫 번째 \2가 지정) 및 c가 이어지지 않는 a를 찾습니다. 두 번째 \2는 부정형 전방 탐색 밖에 있으므로 undefined 와 일치하여 항상 성공합니다. 전체 표현식은 다음 배열을 반환합니다:
["baaabaac" , "ba" , undefined , "abaac" ]
Assertion ::
(?<=
Disjunction
)
m 을 인수 regexpRecord 및 backward 를 사용한 Disjunction 의 CompileSubpattern 으로 둡니다.m 을 캡처하고 호출될 때 다음 단계를 수행하는 매개변수 (matchState , continue )를 갖는 새로운 Matcher 를 반환합니다:단언 : matchState 는 MatchState 입니다.단언 : continue 는 MatcherContinuation 입니다.d 를 아무것도 캡처하지 않고 호출될 때 다음 단계를 수행하는 매개변수 (y )를 갖는 새로운 MatcherContinuation 으로 둡니다:단언 : y 는 MatchState 입니다.y 를 반환합니다.result 를 m (matchState , d )로 둡니다.result 가 failure 이면 failure 를 반환합니다.단언 : result 는 MatchState 입니다.capability 를 result .[[Captures]] 로 둡니다.input 을 matchState .[[Input]] 으로 둡니다.xe 를 matchState .[[EndIndex]] 로 둡니다.z 를 MatchState { [[Input]] : input , [[EndIndex]] : xe , [[Captures]] : capability }로 둡니다.continue (z )를 반환합니다.
Assertion ::
(?<!
Disjunction
)
m 을 인수 regexpRecord 및 backward 를 사용한 Disjunction 의 CompileSubpattern 으로 둡니다.m 을 캡처하고 호출될 때 다음 단계를 수행하는 매개변수 (matchState , continue )를 갖는 새로운 Matcher 를 반환합니다:단언 : matchState 는 MatchState 입니다.단언 : continue 는 MatcherContinuation 입니다.d 를 아무것도 캡처하지 않고 호출될 때 다음 단계를 수행하는 매개변수 (y )를 갖는 새로운 MatcherContinuation 으로 둡니다:단언 : y 는 MatchState 입니다.y 를 반환합니다.result 를 m (matchState , d )로 둡니다.result 가 failure 가 아니면 failure 를 반환합니다.continue (matchState )를 반환합니다.
22.2.2.4.1 IsWordChar ( regexpRecord , input , e )
추상 연산 IsWordChar. 인수 regexpRecord (RegExp 레코드 ), input (리스트 (요소: 문자)) 및 e (정수 ). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
inputLength 를 input 의 요소 수로 둡니다.e = -1 또는 e = inputLength 이면 false 를 반환합니다.char 를 문자 input [e ]로 둡니다.WordCharacters (regexpRecord )에 char 가 포함되어 있으면 true 를 반환합니다.false 를 반환합니다.
22.2.2.5 Runtime Semantics: CompileQuantifier
구문 지향 연산 CompileQuantifier. 인수 없음. 반환값: 레코드 (필드: [[Min]] (음이 아닌 정수), [[Max]] ((음이 아닌 정수 또는 +∞)), [[Greedy]] (Boolean)). 다음 생성 규칙별로 정의된다.
Quantifier :: QuantifierPrefix
qp 를 QuantifierPrefix 의 CompileQuantifierPrefix 로 둡니다.Record { [[Min]] : qp .[[Min]] , [[Max]] : qp .[[Max]] , [[Greedy]] : true }를 반환합니다.
Quantifier ::
QuantifierPrefix
?
qp 를 QuantifierPrefix 의 CompileQuantifierPrefix 로 둡니다.Record { [[Min]] : qp .[[Min]] , [[Max]] : qp .[[Max]] , [[Greedy]] : false }를 반환합니다.
22.2.2.6 Runtime Semantics: CompileQuantifierPrefix
구문 지향 연산 CompileQuantifierPrefix. 인수 없음. 반환값: 레코드 (필드: [[Min]] (음이 아닌 정수), [[Max]] ((음이 아닌 정수 또는 +∞))). 다음 생성 규칙별로 정의된다.
QuantifierPrefix :: *
Record { [[Min]] : 0, [[Max]] : +∞ }를 반환합니다.
QuantifierPrefix :: +
Record { [[Min]] : 1, [[Max]] : +∞ }를 반환합니다.
QuantifierPrefix :: ?
Record { [[Min]] : 0, [[Max]] : 1 }을 반환합니다.
QuantifierPrefix ::
{
DecimalDigits
}
i 를 DecimalDigits 의 MV로 둡니다(12.9.3 참조).Record { [[Min]] : i , [[Max]] : i }를 반환합니다.
QuantifierPrefix ::
{
DecimalDigits
,}
i 를 DecimalDigits 의 MV로 둡니다.Record { [[Min]] : i , [[Max]] : +∞ }를 반환합니다.
QuantifierPrefix ::
{
DecimalDigits
,
DecimalDigits
}
i 를 첫 번째 DecimalDigits 의 MV로 둡니다.j 를 두 번째 DecimalDigits 의 MV로 둡니다.Record { [[Min]] : i , [[Max]] : j }를 반환합니다.
22.2.2.7 Runtime Semantics: CompileAtom
구문 지향 연산 CompileAtom. 인수 regexpRecord (RegExp 레코드 ) 및 direction ((forward 또는 backward )). 반환값: Matcher .
참고 1
다음 생성 규칙별로 정의된다.
Atom :: PatternCharacter
char 를 PatternCharacter 와 일치하는 문자로 둡니다.charSet 을 문자 char 를 포함하는 한 요소 CharSet 으로 둡니다.CharacterSetMatcher (regexpRecord , charSet , false , direction )를 반환합니다.
Atom :: .
charSet 을 AllCharacters (regexpRecord )로 둡니다.regexpRecord .[[DotAll]] 이 true 가 아니면, 다음을 수행합니다.LineTerminator 생성식의 오른쪽에 있는 코드 포인트에 대응하는 모든 문자를 charSet 에서 제거합니다.CharacterSetMatcher (regexpRecord , charSet , false , direction )를 반환합니다.
Atom :: CharacterClass
cc 를 인수 regexpRecord 를 사용한 CharacterClass 의 CompileCharacterClass 로 둡니다.cs 를 cc .[[CharSet]] 으로 둡니다.regexpRecord .[[UnicodeSets]] 가 false 이거나 cs 의 모든 CharSetElement 가 단일 문자로 구성되어 있으면(cs 가 비어 있는 경우 포함) CharacterSetMatcher (regexpRecord , cs , cc .[[Invert]] , direction )를 반환합니다.단언 : cc .[[Invert]] 는 false 입니다.listOfMatchers 를 Matcher 의 빈 List 로 둡니다.csSequences 를 새로운 빈 List 로 둡니다.cs 의 각 CharSetElement s 에 대해 다음을 수행합니다.s 의 길이가 > 1이면 s 를 csSequences 에 추가합니다.각 CharSetElement 의 길이에 따라 csSequences 를 내림차순으로 정렬합니다. csSequences 의 각 CharSetElement s 에 대해 다음을 수행합니다.단언 : s 는 2개 이상의 코드 포인트 시퀀스입니다.remaining 을 s 의 코드 포인트로 구성된 List 로 둡니다.cs2 를 remaining 의 마지막 요소를 포함하는 한 요소 CharSet 으로 둡니다.m2 를 CharacterSetMatcher (regexpRecord , cs2 , false , direction )로 둡니다.remaining 의 마지막 요소를 제거합니다.remaining 의 각 코드 포인트 c1 에 대해 List 의 역순으로 다음을 수행합니다.cs1 을 c1 을 포함하는 한 요소 CharSet 으로 둡니다.m1 을 CharacterSetMatcher (regexpRecord , cs1 , false , direction )로 둡니다.m2 를 MatchSequence (m1 , m2 , direction )로 설정합니다.m2 를 listOfMatchers 에 추가합니다.singles 를 단일 문자로 구성된 cs 의 모든 CharSetElement 를 포함하는 CharSet 으로 둡니다.CharacterSetMatcher (regexpRecord , singles , false , direction )를 listOfMatchers 에 추가합니다.cs 에 빈 문자 시퀀스가 포함되어 있으면 EmptyMatcher ()를 listOfMatchers 에 추가합니다.m2 를 listOfMatchers 의 마지막 Matcher 로 둡니다.listOfMatchers 의 각 Matcher m1 에 대해 끝에서 두 번째 요소부터 역순으로 반복하며 다음을 수행합니다.m2 를 MatchTwoAlternatives (m1 , m2 )로 설정합니다.m2 를 반환합니다.
Atom ::
(
GroupSpecifier opt
Disjunction
)
m 을 인수 regexpRecord 및 direction 을 사용한 Disjunction 의 CompileSubpattern 으로 둡니다.parenIndex 를 CountLeftCapturingParensBefore (Atom )로 둡니다.direction , m 및 parenIndex 를 캡처하고 호출될 때 다음 단계를 수행하는 매개변수 (x , c )를 갖는 새로운 Matcher 를 반환합니다:단언 : x 는 MatchState 입니다.단언 : c 는 MatcherContinuation 입니다.d 를 x , c , direction 및 parenIndex 를 캡처하고 호출될 때 다음 단계를 수행하는 매개변수 (y )를 갖는 새로운 MatcherContinuation 으로 둡니다:단언 : y 는 MatchState 입니다.capability 를 y .[[Captures]] 의 복사본으로 둡니다.input 을 x .[[Input]] 으로 둡니다.xe 를 x .[[EndIndex]] 로 둡니다.ye 를 y .[[EndIndex]] 로 둡니다.direction 이 forward 이면, 다음을 수행합니다.단언 : xe ≤ ye 입니다.r 을 CaptureRange { [[StartIndex]] : xe , [[EndIndex]] : ye }로 둡니다.그렇지 않으면,단언 : direction 은 backward 입니다.단언 : ye ≤ xe 입니다.r 을 CaptureRange { [[StartIndex]] : ye , [[EndIndex]] : xe }로 둡니다. capability [parenIndex + 1]을 r 로 설정합니다.z 를 MatchState { [[Input]] : input , [[EndIndex]] : ye , [[Captures]] : capability }로 둡니다.c (z )를 반환합니다.m (x , d )를 반환합니다.
참고 2
( Disjunction ) 형식의 괄호는 Disjunction 패턴의 구성 요소를 함께 그룹화하고 일치 결과를 저장하는 두 역할을 모두 합니다. 결과는 역참조(\ 뒤에 0이 아닌 십진수가 이어짐)에서 사용하거나, replace String에서 참조하거나, 정규 표현식 일치 Abstract Closure 가 배열의 일부로 반환할 수 있습니다. 괄호의 캡처 동작을 억제하려면 대신 (?: Disjunction ) 형식을 사용하시기 바랍니다.
Atom ::
(?
RegularExpressionModifiers
:
Disjunction
)
addModifiers 를 RegularExpressionModifiers 와 일치하는 소스 텍스트 로 둡니다.removeModifiers 를 빈 String으로 둡니다.modifiedRer 를 UpdateModifiers (regexpRecord , CodePointsToString (addModifiers ), removeModifiers )로 둡니다.인수 modifiedRer 및 direction 을 사용한 Disjunction 의 CompileSubpattern 을 반환합니다.
Atom ::
(?
RegularExpressionModifiers
-
RegularExpressionModifiers
:
Disjunction
)
addModifiers 를 첫 번째 RegularExpressionModifiers 와 일치하는 소스 텍스트 로 둡니다.removeModifiers 를 두 번째 RegularExpressionModifiers 와 일치하는 소스 텍스트 로 둡니다.modifiedRer 를 UpdateModifiers (regexpRecord , CodePointsToString (addModifiers ), CodePointsToString (removeModifiers ))로 둡니다.인수 modifiedRer 및 direction 을 사용한 Disjunction 의 CompileSubpattern 을 반환합니다.
AtomEscape :: DecimalEscape
n 을 DecimalEscape 의 CapturingGroupNumber 로 둡니다.단언 : n ≤ regexpRecord .[[CapturingGroupsCount]] 입니다.BackreferenceMatcher (regexpRecord , « n », direction )를 반환합니다.
참고 3
\ 뒤에 0이 아닌 십진수 n 이 이어지는 형식의 이스케이프 시퀀스는 n th 캡처링 괄호 집합(22.2.2.1 )의 결과와 일치합니다. 정규 표현식에 캡처링 괄호가 n 개보다 적으면 오류입니다. 정규 표현식에 캡처링 괄호가 n 개 이상 있지만 n th 괄호가 아무것도 캡처하지 않아 undefined 이면 역참조는 항상 성공합니다.
AtomEscape :: CharacterEscape
charValue 를 CharacterEscape 의 CharacterValue 로 둡니다.char 를 문자 값이 charValue 인 문자로 둡니다.charSet 을 문자 char 를 포함하는 한 요소 CharSet 으로 둡니다.CharacterSetMatcher (regexpRecord , charSet , false , direction )를 반환합니다.
AtomEscape :: CharacterClassEscape
cs 를 인수 regexpRecord 를 사용한 CharacterClassEscape 의 CompileToCharSet 으로 둡니다.regexpRecord .[[UnicodeSets]] 가 false 이거나 cs 의 모든 CharSetElement 가 단일 문자로 구성되어 있으면(cs 가 비어 있는 경우 포함) CharacterSetMatcher (regexpRecord , cs , false , direction )를 반환합니다.listOfMatchers 를 Matcher 의 빈 List 로 둡니다.csSequences 를 새로운 빈 List 로 둡니다.cs 의 각 CharSetElement s 에 대해 다음을 수행합니다.s 의 길이가 > 1이면 s 를 csSequences 에 추가합니다.각 CharSetElement 의 길이에 따라 csSequences 를 내림차순으로 정렬합니다. csSequences 의 각 CharSetElement s 에 대해 다음을 수행합니다.단언 : s 는 2개 이상의 코드 포인트 시퀀스입니다.remaining 을 s 의 코드 포인트로 구성된 List 로 둡니다.cs2 를 remaining 의 마지막 요소를 포함하는 한 요소 CharSet 으로 둡니다.m2 를 CharacterSetMatcher (regexpRecord , cs2 , false , direction )로 둡니다.remaining 의 마지막 요소를 제거합니다.remaining 의 각 코드 포인트 c1 에 대해 List 의 역순으로 다음을 수행합니다.cs1 을 c1 을 포함하는 한 요소 CharSet 으로 둡니다.m1 을 CharacterSetMatcher (regexpRecord , cs1 , false , direction )로 둡니다.m2 를 MatchSequence (m1 , m2 , direction )로 설정합니다.m2 를 listOfMatchers 에 추가합니다.singles 를 단일 문자로 구성된 cs 의 모든 CharSetElement 를 포함하는 CharSet 으로 둡니다.CharacterSetMatcher (regexpRecord , singles , false , direction )를 listOfMatchers 에 추가합니다.cs 에 빈 문자 시퀀스가 포함되어 있으면 EmptyMatcher ()를 listOfMatchers 에 추가합니다.m2 를 listOfMatchers 의 마지막 Matcher 로 둡니다.listOfMatchers 의 각 Matcher m1 에 대해 끝에서 두 번째 요소부터 역순으로 반복하며 다음을 수행합니다.m2 를 MatchTwoAlternatives (m1 , m2 )로 설정합니다.m2 를 반환합니다.
AtomEscape ::
k
GroupName
matchingGroupSpecifiers 를 GroupSpecifiersThatMatch (GroupName )로 둡니다.parenIndices 를 새로운 빈 List 로 둡니다.matchingGroupSpecifiers 의 각 GroupSpecifier groupSpecifier 에 대해 다음을 수행합니다.parenIndex 를 CountLeftCapturingParensBefore (groupSpecifier )로 둡니다.parenIndex 를 parenIndices 에 추가합니다.BackreferenceMatcher (regexpRecord , parenIndices , direction )를 반환합니다.
22.2.2.7.1 CharacterSetMatcher ( regexpRecord , charSet , invert , direction )
추상 연산 CharacterSetMatcher. 인수 regexpRecord (RegExp 레코드 ), charSet (CharSet ), invert (Boolean) 및 direction ((forward 또는 backward )). 반환값: Matcher . 호출되면 다음 단계를 수행한다.
regexpRecord .[[UnicodeSets]] 가 true 이면, 다음을 수행합니다.단언 : invert 는 false 입니다.단언 : charSet 의 모든 CharSetElement 는 단일 문자로 구성됩니다.regexpRecord , charSet , invert 및 direction 을 캡처하고 호출될 때 다음 단계를 수행하는 매개변수 (x , c )를 갖는 새로운 Matcher 를 반환합니다:단언 : x 는 MatchState 입니다.단언 : c 는 MatcherContinuation 입니다.input 을 x .[[Input]] 으로 둡니다.endIndex 를 x .[[EndIndex]] 로 둡니다.direction 이 forward 이면 f 를 endIndex + 1로 둡니다.그렇지 않으면 f 를 endIndex - 1로 둡니다. inputLength 를 input 의 요소 수로 둡니다.f < 0 또는 f > inputLength 이면 failure 를 반환합니다.index 를 min (endIndex , f )로 둡니다.char 를 문자 input [index ]로 둡니다.cc 를 Canonicalize (regexpRecord , char )로 둡니다.charSet 에 정확히 하나의 문자 a 를 포함하며 Canonicalize (regexpRecord , a )가 cc 인 CharSetElement 가 존재하면 found 를 true 로 둡니다. 그렇지 않으면 found 를 false 로 둡니다.invert 가 false 이고 found 가 false 이면 failure 를 반환합니다.invert 가 true 이고 found 가 true 이면 failure 를 반환합니다.capability 를 x .[[Captures]] 로 둡니다.y 를 MatchState { [[Input]] : input , [[EndIndex]] : f , [[Captures]] : capability }로 둡니다.c (y )를 반환합니다.
22.2.2.7.2 BackreferenceMatcher ( regexpRecord , ns , direction )
추상 연산 BackreferenceMatcher. 인수 regexpRecord (RegExp 레코드 ), ns (리스트 (요소: 양의 정수 )) 및 direction ((forward 또는 backward )). 반환값: Matcher . 호출되면 다음 단계를 수행한다.
regexpRecord , ns 및 direction 을 캡처하고 호출될 때 다음 단계를 수행하는 매개변수 (x , c )를 갖는 새로운 Matcher 를 반환합니다:단언 : x 는 MatchState 입니다.단언 : c 는 MatcherContinuation 입니다.input 을 x .[[Input]] 으로 둡니다.capability 를 x .[[Captures]] 로 둡니다.r 을 undefined 로 둡니다.ns 의 각 정수 n 에 대해 다음을 수행합니다.capability [n ]이 undefined 가 아니면, 다음을 수행합니다.단언 : r 은 undefined 입니다.r 을 capability [n ]으로 설정합니다.r 이 undefined 이면 c (x )를 반환합니다.endIndex 를 x .[[EndIndex]] 로 둡니다.rs 를 r .[[StartIndex]] 로 둡니다.re 를 r .[[EndIndex]] 로 둡니다.length 를 re - rs 로 둡니다.direction 이 forward 이면 f 를 endIndex + length 로 둡니다.그렇지 않으면 f 를 endIndex - length 로 둡니다. inputLength 를 input 의 요소 수로 둡니다.f < 0 또는 f > inputLength 이면 failure 를 반환합니다.g 를 min (endIndex , f )로 둡니다.0(포함)부터 length (제외)까지의 구간 에 속하는 어떤 정수 i 에 대해 Canonicalize (regexpRecord , input [rs + i ])가 Canonicalize (regexpRecord , input [g + i ])가 아니면 failure 를 반환합니다. y 를 MatchState { [[Input]] : input , [[EndIndex]] : f , [[Captures]] : capability }로 둡니다.c (y )를 반환합니다.
22.2.2.7.3 Canonicalize ( regexpRecord , char )
추상 연산 Canonicalize. 인수 regexpRecord (RegExp 레코드 ) 및 char (문자). 반환값: 문자. 호출되면 다음 단계를 수행한다.
HasEitherUnicodeFlag (regexpRecord )이 true 이고 regexpRecord .[[IgnoreCase]] 가 true 이면, 다음을 수행합니다.Unicode Character Database의 CaseFolding.txt 파일이 char 에 대한 단순 또는 공통 대소문자 폴딩 매핑을 제공하면 해당 매핑을 char 에 적용한 결과를 반환합니다. char 를 반환합니다.regexpRecord .[[IgnoreCase]] 가 false 이면 char 를 반환합니다.단언 : char 는 UTF-16 코드 단위입니다.codePoint 를 숫자 값이 char 의 숫자 값인 코드 포인트로 둡니다.mappedCodePoints 를 Unicode Default Case Conversion 알고리즘에 따라 toUppercase(« codePoint »)로 둡니다.CodePointsToString (mappedCodePoints )의 길이 ≠ 1이면 char 를 반환합니다.단언 : mappedCodePoints 의 요소 수는 1입니다.mappedCodePoint 를 mappedCodePoints 의 유일한 코드 포인트 요소로 둡니다.char 의 숫자 값 ≥ 128이고 mappedCodePoint 의 숫자 값 < 128이면 char 를 반환합니다.숫자 값이 mappedCodePoint 의 숫자 값인 코드 단위를 반환합니다.
참고
HasEitherUnicodeFlag (regexpRecord )이 true 인 대소문자 비구분 일치에서는 모든 문자를 비교하기 직전에 유니코드 표준이 제공하는 단순 매핑을 사용하여 암묵적으로 대소문자 폴딩합니다. 단순 매핑은 항상 하나의 코드 포인트로 매핑하므로 예를 들어 ß (U+00DF LATIN SMALL LETTER SHARP S)를 ss 또는 SS로 매핑하지 않습니다. 그러나 Basic Latin 블록 밖의 코드 포인트를 그 안의 코드 포인트로 매핑할 수 있습니다. 예를 들어 ſ (U+017F LATIN SMALL LETTER LONG S)는 s (U+0073 LATIN SMALL LETTER S)로 대소문자 폴딩되고 K (U+212A KELVIN SIGN)는 k (U+006B LATIN SMALL LETTER K)로 대소문자 폴딩됩니다. 이러한 코드 포인트를 포함하는 String은 /[a-z]/ui와 같은 정규 표현식과 일치합니다.
HasEitherUnicodeFlag (regexpRecord )이 false 인 대소문자 비구분 일치에서는 매핑이 toCasefold가 아니라 Unicode Default Case Conversion 알고리즘의 toUppercase를 기반으로 하므로 미묘한 차이가 생깁니다. 예를 들어 Ω (U+2126 OHM SIGN)는 toUppercase에서 자기 자신으로 매핑되지만 toCasefold에서는 Ω (U+03A9 GREEK CAPITAL LETTER OMEGA)와 함께 ω (U+03C9 GREEK SMALL LETTER OMEGA)로 매핑되므로 "\u2126" 은 /[ω]/ui 및 /[\u03A9]/ui와 일치하지만 /[ω]/i 또는 /[\u03A9]/i와는 일치하지 않습니다. 또한 Basic Latin 블록 밖의 어떤 코드 포인트도 그 안의 코드 포인트로 매핑되지 않으므로 "\u017F ſ" 및 "\u212A K" 와 같은 String은 /[a-z]/i와 일치하지 않습니다.
22.2.2.7.4 UpdateModifiers ( regexpRecord , add , remove )
추상 연산 UpdateModifiers. 인수 regexpRecord (RegExp 레코드 ), add (String) 및 remove (String). 반환값: RegExp 레코드 . 호출되면 다음 단계를 수행한다.
단언 : add 와 remove 는 공통 요소를 갖지 않습니다.ignoreCase 를 regexpRecord .[[IgnoreCase]] 로 둡니다.multiline 을 regexpRecord .[[Multiline]] 으로 둡니다.dotAll 을 regexpRecord .[[DotAll]] 로 둡니다.unicode 를 regexpRecord .[[Unicode]] 로 둡니다.unicodeSets 를 regexpRecord .[[UnicodeSets]] 로 둡니다.capturingGroupsCount 를 regexpRecord .[[CapturingGroupsCount]] 로 둡니다.remove 에 "i" 가 포함되어 있으면 ignoreCase 를 false 로 설정합니다.그렇지 않고 add 에 "i" 가 포함되어 있으면 ignoreCase 를 true 로 설정합니다. remove 에 "m" 이 포함되어 있으면 multiline 을 false 로 설정합니다.그렇지 않고 add 에 "m" 이 포함되어 있으면 multiline 을 true 로 설정합니다. remove 에 "s" 가 포함되어 있으면 dotAll 을 false 로 설정합니다.그렇지 않고 add 에 "s" 가 포함되어 있으면 dotAll 을 true 로 설정합니다. RegExp Record { [[IgnoreCase]] : ignoreCase , [[Multiline]] : multiline , [[DotAll]] : dotAll , [[Unicode]] : unicode , [[UnicodeSets]] : unicodeSets , [[CapturingGroupsCount]] : capturingGroupsCount }를 반환합니다.
22.2.2.8 Runtime Semantics: CompileCharacterClass
구문 지향 연산 CompileCharacterClass. 인수 regexpRecord (RegExp 레코드 ). 반환값: 레코드 (필드: [[CharSet]] (CharSet ), [[Invert]] (Boolean)). 다음 생성 규칙별로 정의된다.
CharacterClass ::
[
ClassContents
]
charSet 을 인수 regexpRecord 를 사용한 ClassContents 의 CompileToCharSet 으로 둡니다.Record { [[CharSet]] : charSet , [[Invert]] : false }를 반환합니다.
CharacterClass ::
[^
ClassContents
]
charSet 을 인수 regexpRecord 를 사용한 ClassContents 의 CompileToCharSet 으로 둡니다.regexpRecord .[[UnicodeSets]] 가 true 이면, 다음을 수행합니다.Record { [[CharSet]] : CharacterComplement (regexpRecord , charSet ), [[Invert]] : false }를 반환합니다.Record { [[CharSet]] : charSet , [[Invert]] : true }를 반환합니다.
22.2.2.9 Runtime Semantics: CompileToCharSet
구문 지향 연산 CompileToCharSet. 인수 regexpRecord (RegExp 레코드 ). 반환값: CharSet .
참고 1
다음 생성 규칙별로 정의된다.
ClassContents :: [empty]
빈 CharSet 을 반환합니다.
NonemptyClassRanges ::
ClassAtom
NonemptyClassRangesNoDash
charSet 을 인수 regexpRecord 를 사용한 ClassAtom 의 CompileToCharSet 으로 둡니다.otherSet 을 인수 regexpRecord 를 사용한 NonemptyClassRangesNoDash 의 CompileToCharSet 으로 둡니다.CharSet charSet 과 otherSet 의 합집합을 반환합니다.
NonemptyClassRanges ::
ClassAtom
-
ClassAtom
ClassContents
charSet 을 인수 regexpRecord 를 사용한 첫 번째 ClassAtom 의 CompileToCharSet 으로 둡니다.otherSet 을 인수 regexpRecord 를 사용한 두 번째 ClassAtom 의 CompileToCharSet 으로 둡니다.remainingSet 을 인수 regexpRecord 를 사용한 ClassContents 의 CompileToCharSet 으로 둡니다.rangeSet 을 CharacterRange (charSet , otherSet )로 둡니다.rangeSet 과 remainingSet 의 합집합을 반환합니다.
NonemptyClassRangesNoDash ::
ClassAtomNoDash
NonemptyClassRangesNoDash
charSet 을 인수 regexpRecord 를 사용한 ClassAtomNoDash 의 CompileToCharSet 으로 둡니다.otherSet 을 인수 regexpRecord 를 사용한 NonemptyClassRangesNoDash 의 CompileToCharSet 으로 둡니다.CharSet charSet 과 otherSet 의 합집합을 반환합니다.
NonemptyClassRangesNoDash ::
ClassAtomNoDash
-
ClassAtom
ClassContents
charSet 을 인수 regexpRecord 를 사용한 ClassAtomNoDash 의 CompileToCharSet 으로 둡니다.otherSet 을 인수 regexpRecord 를 사용한 ClassAtom 의 CompileToCharSet 으로 둡니다.remainingSet 을 인수 regexpRecord 를 사용한 ClassContents 의 CompileToCharSet 으로 둡니다.rangeSet 을 CharacterRange (charSet , otherSet )로 둡니다.rangeSet 과 remainingSet 의 합집합을 반환합니다.
참고 2
ClassContents 는 단일 ClassAtom 및/또는 하이픈으로 구분된 두 ClassAtom 의 범위로 전개될 수 있습니다. 후자의 경우 ClassContents 에는 첫 번째 ClassAtom 과 두 번째 ClassAtom 사이의 모든 문자가 양 끝을 포함하여 들어갑니다. 어느 ClassAtom 이든 단일 문자를 나타내지 않거나(예: 하나가 \w인 경우), 첫 번째 ClassAtom 의 문자 값이 두 번째 ClassAtom 의 문자 값보다 엄격하게 크면 오류가 발생합니다.
참고 3
패턴이 대소문자를 무시하더라도 범위의 양 끝에서 대소문자는 어떤 문자가 범위에 속하는지 결정할 때 중요합니다. 따라서 예를 들어 패턴 /[E-F]/i는 문자 E, F, e, f에만 일치하지만, 패턴 /[E-f]/i는 유니코드 Basic Latin 블록의 모든 대문자와 소문자뿐만 아니라 기호 [, \, ], ^, _ 및 `에도 일치합니다.
참고 4
- 문자는 리터럴로 취급할 수도 있고 범위를 나타낼 수도 있습니다. ClassContents 의 첫 번째 또는 마지막 문자이거나, 범위 지정의 시작 또는 끝 경계이거나, 범위 지정 바로 뒤에 오는 경우 리터럴로 취급합니다.
ClassAtom :: -
단일 문자 - U+002D (HYPHEN-MINUS)를 포함하는 CharSet 을 반환합니다.
ClassAtomNoDash :: SourceCharacter but not one of \ or ] or -
SourceCharacter 와 일치하는 문자를 포함하는 CharSet 을 반환합니다.
ClassEscape ::
b
-
CharacterEscape
charValue 를 이 ClassEscape 의 CharacterValue 로 둡니다.char 를 문자 값이 charValue 인 문자로 둡니다.단일 문자 char 를 포함하는 CharSet 을 반환합니다.
참고 5
ClassAtom 은 \b, \B 및 역참조를 제외하고 정규 표현식의 나머지 부분에서 허용되는 모든 이스케이프 시퀀스를 사용할 수 있습니다. CharacterClass 안에서 \b는 백스페이스 문자를 의미하지만 \B와 역참조는 오류를 발생시킵니다. ClassAtom 안에서 역참조를 사용하면 오류가 발생합니다.
CharacterClassEscape :: d
문자 0, 1, 2, 3, 4, 5, 6, 7, 8, 9를 포함하는 10요소 CharSet 을 반환합니다.
CharacterClassEscape :: D
charSet 을
CharacterClassEscape :: d
가 반환한 CharSet 으로 둡니다.CharacterComplement (regexpRecord , charSet )를 반환합니다.
CharacterClassEscape :: s
WhiteSpace 또는 LineTerminator 생성식의 오른쪽에 있는 코드 포인트에 대응하는 모든 문자를 포함하는 CharSet 을 반환합니다.
CharacterClassEscape :: S
charSet 을
CharacterClassEscape :: s
가 반환한 CharSet 으로 둡니다.CharacterComplement (regexpRecord , charSet )를 반환합니다.
CharacterClassEscape :: w
MaybeSimpleCaseFolding (regexpRecord , WordCharacters (regexpRecord ))을 반환합니다.
CharacterClassEscape :: W
charSet 을
CharacterClassEscape :: w
가 반환한 CharSet 으로 둡니다.CharacterComplement (regexpRecord , charSet )를 반환합니다.
CharacterClassEscape ::
p{
UnicodePropertyValueExpression
}
인수 regexpRecord 를 사용한 UnicodePropertyValueExpression 의 CompileToCharSet 을 반환합니다.
CharacterClassEscape ::
P{
UnicodePropertyValueExpression
}
charSet 을 인수 regexpRecord 를 사용한 UnicodePropertyValueExpression 의 CompileToCharSet 으로 둡니다.단언 : charSet 은 단일 코드 포인트만 포함합니다.CharacterComplement (regexpRecord , charSet )를 반환합니다.
UnicodePropertyValueExpression ::
UnicodePropertyName
=
UnicodePropertyValue
ps 를 UnicodePropertyName 과 일치하는 소스 텍스트 로 둡니다.p 를 UnicodeMatchProperty (regexpRecord , ps )로 둡니다.단언 : p 는 표 65 의 “Property name and aliases ” 열에 나열된 Unicode property name 또는 프로퍼티 별칭입니다.vs 를 UnicodePropertyValue 와 일치하는 소스 텍스트 로 둡니다.v 를 UnicodeMatchPropertyValue (p , vs )로 둡니다.charSet 을 문자 데이터베이스 정의에 값 v 를 갖는 프로퍼티 p 가 포함된 모든 유니코드 코드 포인트를 포함하는 CharSet 으로 둡니다.MaybeSimpleCaseFolding (regexpRecord , charSet )을 반환합니다.
UnicodePropertyValueExpression :: LoneUnicodePropertyNameOrValue
s 를 LoneUnicodePropertyNameOrValue 과 일치하는 소스 텍스트 로 둡니다.UnicodeMatchPropertyValue (General_Category, s )가 PropertyValueAliases.txt 에 나열된 General_Category (gc) 프로퍼티의 유니코드 프로퍼티 값 또는 프로퍼티 값 별칭이면, 다음을 수행합니다.문자 데이터베이스 정의에 값 s 를 갖는 프로퍼티 “General_Category”가 포함된 모든 유니코드 코드 포인트를 포함하는 CharSet 을 반환합니다. p 를 UnicodeMatchProperty (regexpRecord , s )로 둡니다.단언 : p 는 표 66 의 “Property name and aliases ” 열에 나열된 이진 유니코드 프로퍼티 또는 이진 프로퍼티 별칭이거나, 표 67 의 “Property name ” 열에 나열된 문자열의 이진 유니코드 프로퍼티입니다.charSet 을 문자 데이터베이스 정의에 값 “True”를 갖는 프로퍼티 p 가 포함된 모든 CharSetElement 를 포함하는 CharSet 으로 둡니다.MaybeSimpleCaseFolding (regexpRecord , charSet )을 반환합니다.
ClassUnion ::
ClassSetRange
ClassUnion opt
charSet 을 인수 regexpRecord 를 사용한 ClassSetRange 의 CompileToCharSet 으로 둡니다.ClassUnion 이 존재하면, 다음을 수행합니다.otherSet 을 인수 regexpRecord 를 사용한 ClassUnion 의 CompileToCharSet 으로 둡니다.CharSet charSet 과 otherSet 의 합집합을 반환합니다.charSet 을 반환합니다.
ClassUnion ::
ClassSetOperand
ClassUnion opt
charSet 을 인수 regexpRecord 를 사용한 ClassSetOperand 의 CompileToCharSet 으로 둡니다.ClassUnion 이 존재하면, 다음을 수행합니다.otherSet 을 인수 regexpRecord 를 사용한 ClassUnion 의 CompileToCharSet 으로 둡니다.CharSet charSet 과 otherSet 의 합집합을 반환합니다.charSet 을 반환합니다.
ClassIntersection ::
ClassSetOperand
&&
ClassSetOperand
charSet 을 인수 regexpRecord 를 사용한 첫 번째 ClassSetOperand 의 CompileToCharSet 으로 둡니다.otherSet 을 인수 regexpRecord 를 사용한 두 번째 ClassSetOperand 의 CompileToCharSet 으로 둡니다.CharSet charSet 과 otherSet 의 교집합을 반환합니다.
ClassIntersection ::
ClassIntersection
&&
ClassSetOperand
charSet 을 인수 regexpRecord 를 사용한 ClassIntersection 의 CompileToCharSet 으로 둡니다.otherSet 을 인수 regexpRecord 를 사용한 ClassSetOperand 의 CompileToCharSet 으로 둡니다.CharSet charSet 과 otherSet 의 교집합을 반환합니다.
ClassSubtraction ::
ClassSetOperand
--
ClassSetOperand
charSet 을 인수 regexpRecord 를 사용한 첫 번째 ClassSetOperand 의 CompileToCharSet 으로 둡니다.otherSet 을 인수 regexpRecord 를 사용한 두 번째 ClassSetOperand 의 CompileToCharSet 으로 둡니다.otherSet 의 CharSetElement 이기도 한 요소를 제외한 charSet 의 CharSetElement 를 포함하는 CharSet 을 반환합니다.
ClassSubtraction ::
ClassSubtraction
--
ClassSetOperand
charSet 을 인수 regexpRecord 를 사용한 ClassSubtraction 의 CompileToCharSet 으로 둡니다.otherSet 을 인수 regexpRecord 를 사용한 ClassSetOperand 의 CompileToCharSet 으로 둡니다.otherSet 의 CharSetElement 이기도 한 요소를 제외한 charSet 의 CharSetElement 를 포함하는 CharSet 을 반환합니다.
ClassSetRange ::
ClassSetCharacter
-
ClassSetCharacter
charSet 을 인수 regexpRecord 를 사용한 첫 번째 ClassSetCharacter 의 CompileToCharSet 으로 둡니다.otherSet 을 인수 regexpRecord 를 사용한 두 번째 ClassSetCharacter 의 CompileToCharSet 으로 둡니다.MaybeSimpleCaseFolding (regexpRecord , CharacterRange (charSet , otherSet ))을 반환합니다.
참고 6
결과는 흔히 둘 이상의 범위로 구성됩니다. UnicodeSets가 true 이고 IgnoreCase가 true 이면 MaybeSimpleCaseFolding (regexpRecord , [Ā-č])에는 해당 범위의 홀수 번호 코드 포인트만 포함됩니다.
ClassSetOperand :: ClassSetCharacter
charSet 을 인수 regexpRecord 를 사용한 ClassSetCharacter 의 CompileToCharSet 으로 둡니다.MaybeSimpleCaseFolding (regexpRecord , charSet )을 반환합니다.
ClassSetOperand :: ClassStringDisjunction
charSet 을 인수 regexpRecord 를 사용한 ClassStringDisjunction 의 CompileToCharSet 으로 둡니다.MaybeSimpleCaseFolding (regexpRecord , charSet )을 반환합니다.
ClassSetOperand :: NestedClass
인수 regexpRecord 를 사용한 NestedClass 의 CompileToCharSet 을 반환합니다.
NestedClass ::
[
ClassContents
]
인수 regexpRecord 를 사용한 ClassContents 의 CompileToCharSet 을 반환합니다.
NestedClass ::
[^
ClassContents
]
charSet 을 인수 regexpRecord 를 사용한 ClassContents 의 CompileToCharSet 으로 둡니다.CharacterComplement (regexpRecord , charSet )를 반환합니다.
NestedClass ::
\
CharacterClassEscape
인수 regexpRecord 를 사용한 CharacterClassEscape 의 CompileToCharSet 을 반환합니다.
ClassStringDisjunction ::
\q{
ClassStringDisjunctionContents
}
인수 regexpRecord 를 사용한 ClassStringDisjunctionContents 의 CompileToCharSet 을 반환합니다.
ClassStringDisjunctionContents :: ClassString
s 를 인수 regexpRecord 를 사용한 ClassString 의 CompileClassSetString 으로 둡니다.하나의 문자열 s 를 포함하는 CharSet 을 반환합니다.
ClassStringDisjunctionContents ::
ClassString
|
ClassStringDisjunctionContents
s 를 인수 regexpRecord 를 사용한 ClassString 의 CompileClassSetString 으로 둡니다.charSet 을 하나의 문자열 s 를 포함하는 CharSet 으로 둡니다.otherSet 을 인수 regexpRecord 를 사용한 ClassStringDisjunctionContents 의 CompileToCharSet 으로 둡니다.CharSet charSet 과 otherSet 의 합집합을 반환합니다.
ClassSetCharacter ::
SourceCharacter but not ClassSetSyntaxCharacter
\
CharacterEscape
\
ClassSetReservedPunctuator
charValue 를 이 ClassSetCharacter 의 CharacterValue 로 둡니다.char 를 문자 값이 charValue 인 문자로 둡니다.단일 문자 char 를 포함하는 CharSet 을 반환합니다.
ClassSetCharacter :: \b
단일 문자 U+0008 (BACKSPACE)을 포함하는 CharSet 을 반환합니다.
22.2.2.9.1 CharacterRange ( charSet , otherSet )
추상 연산 CharacterRange. 인수 charSet (CharSet ) 및 otherSet (CharSet ). 반환값: CharSet . 호출되면 다음 단계를 수행한다.
단언 : charSet 과 otherSet 은 각각 정확히 하나의 문자를 포함합니다.a 를 CharSet charSet 의 유일한 문자로 둡니다.b 를 CharSet otherSet 의 유일한 문자로 둡니다.i 를 문자 a 의 문자 값으로 둡니다.j 를 문자 b 의 문자 값으로 둡니다.단언 : i ≤ j 입니다.i 부터 j 까지의 폐구간 에 속하는 문자 값을 갖는 모든 문자를 포함하는 CharSet 을 반환합니다.
22.2.2.9.2 HasEitherUnicodeFlag ( regexpRecord )
추상 연산 HasEitherUnicodeFlag. 인수 regexpRecord (RegExp 레코드 ). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
regexpRecord .[[Unicode]] 가 true 이거나 regexpRecord .[[UnicodeSets]] 가 true 이면 true 를 반환합니다.false 를 반환합니다.
22.2.2.9.3 WordCharacters ( regexpRecord )
추상 연산 WordCharacters. 인수 regexpRecord (RegExp 레코드 ). 반환값: CharSet . \b, \B, \w 및 \W의 목적상 “단어 문자”로 간주되는 문자를 포함하는 CharSet 을 반환합니다. 호출되면 다음 단계를 수행한다.
basicWordChars 를 ASCII 단어 문자 에 속하는 모든 문자를 포함하는 CharSet 으로 둡니다.extraWordChars 를 basicWordChars 에 속하지 않지만 Canonicalize (regexpRecord , c )가 basicWordChars 에 속하는 모든 문자 c 를 포함하는 CharSet 으로 둡니다.단언 : HasEitherUnicodeFlag (regexpRecord )이 true 이고 regexpRecord .[[IgnoreCase]] 가 true 인 경우를 제외하면 extraWordChars 는 비어 있습니다.basicWordChars 와 extraWordChars 의 합집합을 반환합니다.
22.2.2.9.4 AllCharacters ( regexpRecord )
추상 연산 AllCharacters. 인수 regexpRecord (RegExp 레코드 ). 반환값: CharSet . 정규 표현식 플래그에 따라 “모든 문자”의 집합을 반환합니다. 호출되면 다음 단계를 수행한다.
regexpRecord .[[UnicodeSets]] 가 true 이고 regexpRecord .[[IgnoreCase]] 가 true 이면, 다음을 수행합니다.Simple Case Folding 매핑이 없는 모든 유니코드 코드 포인트 c (즉, scf (c )=c )를 포함하는 CharSet 을 반환합니다.HasEitherUnicodeFlag (regexpRecord )이 true 이면, 다음을 수행합니다.모든 코드 포인트 값을 포함하는 CharSet 을 반환합니다. 모든 코드 단위 값을 포함하는 CharSet 을 반환합니다.
22.2.2.9.5 MaybeSimpleCaseFolding ( regexpRecord , charSet )
추상 연산 MaybeSimpleCaseFolding. 인수 regexpRecord (RegExp 레코드 ) 및 charSet (CharSet ). 반환값: CharSet . regexpRecord .[[UnicodeSets]] 가 false 이거나 regexpRecord .[[IgnoreCase]] 가 false 이면 charSet 을 반환합니다. 그렇지 않으면 Unicode Character Database의 CaseFolding.txt 파일에 있는 Simple Case Folding (scf(codePoint ) ) 정의(각각 단일 코드 포인트를 다른 단일 코드 포인트로 매핑함)를 사용하여 charSet 의 각 CharSetElement 를 문자별로 정규 형식으로 매핑하고 결과 CharSet 을 반환합니다. 호출되면 다음 단계를 수행한다.
regexpRecord .[[UnicodeSets]] 가 false 이거나 regexpRecord .[[IgnoreCase]] 가 false 이면 charSet 을 반환합니다.otherSet 을 새로운 빈 CharSet 으로 둡니다.charSet 의 각 CharSetElement s 에 대해 다음을 수행합니다.t 를 빈 문자 시퀀스로 둡니다.s 의 각 단일 코드 포인트 codePoint 에 대해 다음을 수행합니다.scf (codePoint )를 t 에 추가합니다.t 를 otherSet 에 추가합니다.otherSet 을 반환합니다.
22.2.2.9.6 CharacterComplement ( regexpRecord , complement )
추상 연산 CharacterComplement. 인수 regexpRecord (RegExp 레코드 ) 및 complement (CharSet ). 반환값: CharSet . 호출되면 다음 단계를 수행한다.
charSet 을 AllCharacters (regexpRecord )로 둡니다.complement 의 CharSetElement 이기도 한 요소를 제외한 charSet 의 CharSetElement 를 포함하는 CharSet 을 반환합니다.
22.2.2.9.7 UnicodeMatchProperty ( regexpRecord , p )
추상 연산 UnicodeMatchProperty. 인수 regexpRecord (RegExp 레코드 ) 및 p (ECMAScript 소스 텍스트 ). 반환값: a Unicode property name . 호출되면 다음 단계를 수행한다.
regexpRecord .[[UnicodeSets]] 가 true 이고 p 가 표 67 의 “Property name ” 열에 나열된 Unicode property name 이면, 다음을 수행합니다.유니코드 코드 포인트의 List p 를 반환합니다. 단언 : p 는 표 65 또는 표 66 의 “Property name and aliases ” 열에 나열된 Unicode property name 또는 프로퍼티 별칭입니다.c 를 해당 행의 “Canonical property name ” 열에 제시된 p 의 정규 property name 으로 둡니다.유니코드 코드 포인트의 List c 를 반환합니다.
구현체는 표 65 , 표 66 및 표 67 에 나열된 Unicode property name 과 별칭을 지원해야 합니다. 상호 운용성을 보장하기 위해 구현체는 다른 어떤 property name 이나 별칭도 지원해서는 안 됩니다.
참고 1
예를 들어 Script_Extensions(property name )와 scx(프로퍼티 별칭)는 유효하지만 script_extensions 또는 Scx는 유효하지 않습니다.
참고 2
나열된 프로퍼티는 UTS18 RL1.2 가 요구하는 것의 상위 집합을 구성합니다.
참고 3
이 표의 항목 철자(대소문자 포함)는 Unicode Character Database의 PropertyAliases.txt 파일에서 사용하는 철자와 일치합니다. 해당 파일의 정확한 철자는 안정적으로 유지됨이 보장됩니다 .
표 65: Non-binary Unicode property aliases and their canonical property names
표 66: Binary Unicode property aliases and their canonical property names
표 67: Binary Unicode properties of strings
Property name
Basic_Emoji
Emoji_Keycap_Sequence
RGI_Emoji_Modifier_Sequence
RGI_Emoji_Flag_Sequence
RGI_Emoji_Tag_Sequence
RGI_Emoji_ZWJ_Sequence
RGI_Emoji
22.2.2.9.8 UnicodeMatchPropertyValue ( p , v )
추상 연산 UnicodeMatchPropertyValue. 인수 p (ECMAScript 소스 텍스트 ) 및 v (ECMAScript 소스 텍스트 ). 반환값: a Unicode property value. 호출되면 다음 단계를 수행한다.
단언 : p 는 표 65 의 “Canonical property name ” 열에 나열된 정규이며 별칭이 아닌 Unicode property name 입니다.단언 : v 는 PropertyValueAliases.txt 에 나열된 유니코드 프로퍼티 p 의 프로퍼티 값 또는 프로퍼티 값 별칭입니다.value 를 해당 행의 “Canonical property value” 열에 제시된 v 의 정규 프로퍼티 값으로 둡니다.유니코드 코드 포인트의 List value 를 반환합니다.
구현체는 표 65 에 나열된 프로퍼티에 대해 PropertyValueAliases.txt 에 나열된 유니코드 프로퍼티 값 및 프로퍼티 값 별칭을 지원해야 합니다. 상호 운용성을 보장하기 위해 구현체는 다른 프로퍼티 값이나 프로퍼티 값 별칭을 지원해서는 안 됩니다.
참고 1
예를 들어 Xpeo와 Old_Persian은 유효한 Script_Extensions 값이지만 xpeo와 Old Persian은 유효하지 않습니다.
참고 2
이 알고리즘은 UAX44에 나열된 기호 값의 일치 규칙 과 다릅니다. 대소문자, 공백 , U+002D (HYPHEN-MINUS) 및 U+005F (LOW LINE)는 무시되지 않으며 Is 접두사는 지원되지 않습니다.
22.2.2.10 Runtime Semantics: CompileClassSetString
구문 지향 연산 CompileClassSetString. 인수 regexpRecord (RegExp 레코드 ). 반환값: a sequence of characters. 다음 생성 규칙별로 정의된다.
ClassString :: [empty]
빈 문자 시퀀스를 반환합니다.
ClassString :: NonEmptyClassString
인수 regexpRecord 를 사용한 NonEmptyClassString 의 CompileClassSetString 을 반환합니다.
NonEmptyClassString ::
ClassSetCharacter
NonEmptyClassString opt
cs 를 인수 regexpRecord 를 사용한 ClassSetCharacter 의 CompileToCharSet 으로 둡니다.s1 을 cs 의 유일한 CharSetElement 인 문자 시퀀스로 둡니다.NonEmptyClassString 이 존재하면, 다음을 수행합니다.s2 를 인수 regexpRecord 를 사용한 NonEmptyClassString 의 CompileClassSetString 으로 둡니다.s1 과 s2 의 연결을 반환합니다.s1 을 반환합니다.
22.2.3 RegExp 생성을 위한 추상 연산
22.2.3.1 RegExpCreate ( pattern , flags )
추상 연산 RegExpCreate. 인수 pattern (ECMAScript 언어 값 ) 및 flags ((String 또는 undefined )). 반환값: (정상 완료 (값: Object) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
obj 를 ! RegExpAlloc (%RegExp% )로 둡니다.? RegExpInitialize (obj , pattern , flags )를 반환합니다.
22.2.3.2 RegExpAlloc ( newTarget )
추상 연산 RegExpAlloc. 인수 newTarget (생성자 ). 반환값: (정상 완료 (값: Object) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
obj 를 ? OrdinaryCreateFromConstructor (newTarget , "%RegExp.prototype%" , « [[OriginalSource]] , [[OriginalFlags]] , [[RegExpRecord]] , [[RegExpMatcher]] »)로 둡니다.! DefinePropertyOrThrow (obj , "lastIndex" , PropertyDescriptor { [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : false })를 수행합니다. obj 를 반환합니다.
22.2.3.3 RegExpInitialize ( obj , pattern , flags )
추상 연산 RegExpInitialize. 인수 obj (Object), pattern (ECMAScript 언어 값 ) 및 flags (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: Object) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
pattern 이 undefined 이면 pattern 을 빈 String으로 설정합니다.그렇지 않으면 pattern 을 ? ToString (pattern )으로 설정합니다. flags 가 undefined 이면 flags 를 빈 String으로 설정합니다.그렇지 않으면 flags 를 ? ToString (flags )으로 설정합니다. flags 에 "d" , "g" , "i" , "m" , "s" , "u" , "v" 또는 "y" 이외의 코드 단위가 포함되어 있으면 SyntaxError 예외를 던집니다.flags 에 어떤 코드 단위가 두 번 이상 포함되어 있으면 SyntaxError 예외를 던집니다.flags 에 "i" 가 포함되어 있으면 i 를 true 로 둡니다. 그렇지 않으면 i 를 false 로 둡니다.flags 에 "m" 이 포함되어 있으면 m 을 true 로 둡니다. 그렇지 않으면 m 을 false 로 둡니다.flags 에 "s" 가 포함되어 있으면 s 를 true 로 둡니다. 그렇지 않으면 s 를 false 로 둡니다.flags 에 "u" 가 포함되어 있으면 u 를 true 로 둡니다. 그렇지 않으면 u 를 false 로 둡니다.flags 에 "v" 가 포함되어 있으면 v 를 true 로 둡니다. 그렇지 않으면 v 를 false 로 둡니다.u 가 true 이거나 v 가 true 이면, 다음을 수행합니다.patternText 를 StringToCodePoints (pattern )로 둡니다.그렇지 않으면,patternText 를 pattern 의 각 16비트 요소를 유니코드 BMP 코드 포인트로 해석한 결과로 둡니다. 요소에는 UTF-16 디코딩을 적용하지 않습니다. parseResult 를 ParsePattern (patternText , u , v )로 둡니다.parseResult 가 SyntaxError 객체의 비어 있지 않은 List 이면 SyntaxError 예외를 던집니다.단언 : parseResult 는 Pattern Parse Node입니다.obj .[[OriginalSource]] 를 pattern 으로 설정합니다.obj .[[OriginalFlags]] 를 flags 로 설정합니다.capturingGroupsCount 를 CountLeftCapturingParensWithin (parseResult )로 둡니다.regexpRecord 를 RegExp Record { [[IgnoreCase]] : i , [[Multiline]] : m , [[DotAll]] : s , [[Unicode]] : u , [[UnicodeSets]] : v , [[CapturingGroupsCount]] : capturingGroupsCount }로 둡니다.obj .[[RegExpRecord]] 를 regexpRecord 로 설정합니다.obj .[[RegExpMatcher]] 를 인수 regexpRecord 를 사용한 parseResult 의 CompilePattern 으로 설정합니다.? Set (obj , "lastIndex" , +0 𝔽 , true )를 수행합니다. obj 를 반환합니다.
22.2.3.4 Static Semantics: ParsePattern ( patternText , u , v )
추상 연산 ParsePattern. 인수 patternText (a sequence of Unicode code points), u (Boolean) 및 v (Boolean). 반환값: (구문 분석 노드 또는 a non-empty List of SyntaxError objects).
참고
호출되면 다음 단계를 수행한다.
v 가 true 이고 u 가 true 이면, 다음을 수행합니다.parseResult 를 하나 이상의 SyntaxError 객체를 포함하는 List 로 둡니다.그렇지 않고 v 가 true 이면, 다음을 수행합니다.parseResult 를 ParseText (patternText , Pattern [+UnicodeMode, +UnicodeSetsMode, +NamedCaptureGroups] )로 둡니다. 그렇지 않고 u 가 true 이면, 다음을 수행합니다.parseResult 를 ParseText (patternText , Pattern [+UnicodeMode, ~UnicodeSetsMode, +NamedCaptureGroups] )로 둡니다. 그렇지 않으면,parseResult 를 ParseText (patternText , Pattern [~UnicodeMode, ~UnicodeSetsMode, +NamedCaptureGroups] )로 둡니다. parseResult 를 반환합니다.
22.2.4 RegExp 생성자
RegExp 생성자 는:
%RegExp% 입니다.
전역 객체 의 "RegExp" 프로퍼티 초기 값입니다.
생성자 로 호출되면 새로운 RegExp 객체를 생성하고 초기화합니다.
생성자 가 아니라 함수로 호출되면 새로운 RegExp 객체를 반환하거나, 유일한 인수가 RegExp 객체이면 해당 인수 자체를 반환합니다.
클래스 정의의 extends 절 값으로 사용할 수 있습니다. 명시된 RegExp 동작을 상속하려는 하위 클래스 생성자 는 필요한 내부 슬롯을 갖는 하위 클래스 인스턴스를 생성하고 초기화하기 위해 RegExp 생성자 에 대한 super 호출을 포함해야 합니다.
22.2.4.1 RegExp ( patternOrRegexp , flags )
이 함수는 호출되면 다음 단계를 수행합니다:
patternIsRegExp 를 ? IsRegExp (patternOrRegexp )로 둡니다.NewTarget이 undefined 이면, 다음을 수행합니다.newTarget 을 활성 함수 객체 로 둡니다.patternIsRegExp 가 true 이고 flags 가 undefined 이면, 다음을 수행합니다.patternCtor 를 ? Get (patternOrRegexp , "constructor" )로 둡니다.SameValue (newTarget , patternCtor )가 true 이면 patternOrRegexp 를 반환합니다. 그렇지 않으면,newTarget 을 NewTarget으로 둡니다. patternOrRegexp 가 Object이고 patternOrRegexp 에 [[RegExpMatcher]] 내부 슬롯이 있으면, 다음을 수행합니다.patternSource 를 patternOrRegexp .[[OriginalSource]] 로 둡니다.flags 가 undefined 이면 flags 를 patternOrRegexp .[[OriginalFlags]] 로 설정합니다.그렇지 않고 patternIsRegExp 가 true 이면, 다음을 수행합니다.patternSource 를 ? Get (patternOrRegexp , "source" )로 둡니다.flags 가 undefined 이면, 다음을 수행합니다.flags 를 ? Get (patternOrRegexp , "flags" )로 설정합니다. 그렇지 않으면,patternSource 를 patternOrRegexp 로 둡니다. obj 를 ? RegExpAlloc (newTarget )로 둡니다.? RegExpInitialize (obj , patternSource , flags )를 반환합니다.
참고
pattern이 StringLiteral 을 사용하여 제공되면 String이 이 함수에 의해 처리되기 전에 일반적인 이스케이프 시퀀스 치환이 수행됩니다. 이 함수가 인식해야 하는 이스케이프 시퀀스를 pattern에 포함해야 한다면, StringLiteral 의 내용이 형성될 때 U+005C (REVERSE SOLIDUS) 코드 포인트가 제거되지 않도록 StringLiteral 안에서 이를 이스케이프해야 합니다.
22.2.5 RegExp 생성자의 프로퍼티
RegExp 생성자 는:
22.2.5.1 RegExp.escape ( string )
이 함수는 정규 표현식 Pattern 에서 특별할 가능성이 있는 문자를 동등한 이스케이프 시퀀스로 대체한 string 의 복사본을 반환합니다.
호출되면 다음 단계를 수행합니다:
string 이 String이 아니면 TypeError 예외를 던집니다.escaped 를 빈 String으로 둡니다.codePointList 를 StringToCodePoints (string )로 둡니다.codePointList 의 각 코드 포인트 codePoint 에 대해 다음을 수행합니다.escaped 가 빈 String이고 codePoint 가 DecimalDigit 또는 AsciiLetter 중 하나와 일치하면, 다음을 수행합니다.참고 : 선행 숫자를 이스케이프하면 출력이 \0 문자 이스케이프나 \1 같은 DecimalEscape 뒤에 사용될 수 있는 패턴 텍스트에 대응하면서도, 앞선 이스케이프 시퀀스의 확장으로 해석되는 대신 string 과 일치하도록 보장합니다. 선행 ASCII 문자를 이스케이프하는 것도 \c 뒤의 문맥에 대해 동일한 역할을 합니다.numericValue 를 codePoint 의 숫자 값으로 둡니다.hex 를 Number::toString (𝔽 (numericValue ), 16)으로 둡니다.단언 : hex 의 길이는 2입니다.escaped 를 코드 단위 0x005C (REVERSE SOLIDUS), "x" 및 hex 의 문자열 연결 로 설정합니다.그렇지 않으면,escaped 를 escaped 와 EncodeForRegExpEscape (codePoint )의 문자열 연결 로 설정합니다. escaped 를 반환합니다.
참고
이름은 비슷하지만 EscapeRegExpPattern 과 RegExp.escape는 비슷한 동작을 수행하지 않습니다. 전자는 문자열로 표현하기 위해 패턴을 이스케이프하고, 이 함수는 패턴 안에 표현하기 위해 문자열을 이스케이프합니다.
22.2.5.1.1 EncodeForRegExpEscape ( codePoint )
추상 연산 EncodeForRegExpEscape. 인수 codePoint (코드 포인트). 반환값: String. codePoint 와 일치하는 Pattern 을 나타내는 String을 반환합니다. codePoint 가 공백 또는 ASCII 문장 부호이면 반환 값은 이스케이프 시퀀스입니다. 그렇지 않으면 반환 값은 codePoint 자체의 String 표현입니다. 호출되면 다음 단계를 수행한다.
codePoint 가 SyntaxCharacter 와 일치하거나 codePoint 가 U+002F (SOLIDUS)이면, 다음을 수행합니다.0x005C (REVERSE SOLIDUS)와 UTF16EncodeCodePoint (codePoint )의 문자열 연결 을 반환합니다. codePoint 가 표 63 의 “Code Point” 열에 나열된 코드 포인트이면, 다음을 수행합니다.0x005C (REVERSE SOLIDUS)와 “Code Point” 열에 codePoint 가 포함된 행의 “ControlEscape” 열 문자열의 문자열 연결 을 반환합니다. otherPunctuators 를 ",-=<>#&!%:;@~'`" 와 코드 단위 0x0022 (QUOTATION MARK)의 문자열 연결 로 둡니다.toEscape 를 StringToCodePoints (otherPunctuators )로 둡니다.toEscape 에 codePoint 가 포함되어 있거나, codePoint 가 WhiteSpace 또는 LineTerminator 중 하나와 일치하거나, codePoint 가 선행 서로게이트 또는 후행 서로게이트 와 동일한 숫자 값을 가지면, 다음을 수행합니다.codePointNumber 를 codePoint 의 숫자 값으로 둡니다.codePointNumber ≤ 0xFF이면, 다음을 수행합니다.hex 를 Number::toString (𝔽 (codePointNumber ), 16)으로 둡니다.코드 단위 0x005C (REVERSE SOLIDUS), "x" 및 StringPad (hex , 2, "0" , start )의 문자열 연결 을 반환합니다. escaped 를 빈 String으로 둡니다.codeUnits 를 UTF16EncodeCodePoint (codePoint )로 둡니다.codeUnits 의 각 코드 단위 codeUnit 에 대해 다음을 수행합니다.escaped 를 escaped 와 UnicodeEscape (codeUnit )의 문자열 연결 로 설정합니다.escaped 를 반환합니다.UTF16EncodeCodePoint (codePoint )를 반환합니다.
22.2.5.2 RegExp.prototype
RegExp.prototype의 초기 값은 RegExp 프로토타입 객체 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
22.2.5.3 get RegExp [ %Symbol.species% ]
RegExp[%Symbol.species%]는 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
this 값을 반환합니다.
이 함수의 "name" 프로퍼티 값은 "get [Symbol.species]" 입니다.
참고
RegExp 프로토타입 메서드는 일반적으로 this 값의 생성자 를 사용하여 파생 객체를 생성합니다. 그러나 하위 클래스 생성자 는 자신의 %Symbol.species% 프로퍼티를 재정의하여 이 기본 동작을 재정의할 수 있습니다.
22.2.6 RegExp 프로토타입 객체의 프로퍼티
RegExp 프로토타입 객체 는:
%RegExp.prototype% 입니다.
일반 객체 입니다.
RegExp 인스턴스가 아니며 [[RegExpMatcher]] 내부 슬롯 또는 RegExp 인스턴스 객체의 다른 어떤 내부 슬롯도 갖지 않습니다.
값이 %Object.prototype% 인 [[Prototype]] 내부 슬롯을 갖습니다.
참고
RegExp 프로토타입 객체는 자체 "valueOf" 프로퍼티를 갖지 않습니다. 그러나 Object 프로토타입 객체 에서 "valueOf" 프로퍼티를 상속합니다.
22.2.6.1 RegExp.prototype.constructor
RegExp.prototype.constructor의 초기 값은 %RegExp% 입니다.
22.2.6.2 RegExp.prototype.exec ( string )
이 메서드는 string 에서 정규 표현식 패턴의 출현을 검색하고 일치 결과를 포함하는 Array를 반환하며, string 이 일치하지 않으면 null 을 반환합니다.
호출되면 다음 단계를 수행합니다:
regexp 를 this 값으로 둡니다.? RequireInternalSlot (regexp , [[RegExpMatcher]] )를 수행합니다. string 을 ? ToString (string )으로 설정합니다.? RegExpBuiltinExec (regexp , string )를 반환합니다.
22.2.6.3 get RegExp.prototype.dotAll
RegExp.prototype.dotAll은 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
regexp 를 this 값으로 둡니다.codeUnit 을 코드 단위 0x0073 (LATIN SMALL LETTER S)으로 둡니다.? RegExpHasFlag (regexp , codeUnit )를 반환합니다.
22.2.6.4 get RegExp.prototype.flags
RegExp.prototype.flags는 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
regexp 를 this 값으로 둡니다.regexp 가 Object가 아니면 TypeError 예외를 던집니다.codeUnits 를 새로운 빈 List 로 둡니다.hasIndices 를 ToBoolean (? Get (regexp , "hasIndices" ))로 둡니다.hasIndices 가 true 이면 코드 단위 0x0064 (LATIN SMALL LETTER D)를 codeUnits 에 추가합니다.global 을 ToBoolean (? Get (regexp , "global" ))로 둡니다.global 이 true 이면 코드 단위 0x0067 (LATIN SMALL LETTER G)를 codeUnits 에 추가합니다.ignoreCase 를 ToBoolean (? Get (regexp , "ignoreCase" ))로 둡니다.ignoreCase 가 true 이면 코드 단위 0x0069 (LATIN SMALL LETTER I)를 codeUnits 에 추가합니다.multiline 을 ToBoolean (? Get (regexp , "multiline" ))로 둡니다.multiline 이 true 이면 코드 단위 0x006D (LATIN SMALL LETTER M)를 codeUnits 에 추가합니다.dotAll 을 ToBoolean (? Get (regexp , "dotAll" ))로 둡니다.dotAll 이 true 이면 코드 단위 0x0073 (LATIN SMALL LETTER S)를 codeUnits 에 추가합니다.unicode 를 ToBoolean (? Get (regexp , "unicode" ))로 둡니다.unicode 가 true 이면 코드 단위 0x0075 (LATIN SMALL LETTER U)를 codeUnits 에 추가합니다.unicodeSets 를 ToBoolean (? Get (regexp , "unicodeSets" ))로 둡니다.unicodeSets 가 true 이면 코드 단위 0x0076 (LATIN SMALL LETTER V)를 codeUnits 에 추가합니다.sticky 를 ToBoolean (? Get (regexp , "sticky" ))로 둡니다.sticky 가 true 이면 코드 단위 0x0079 (LATIN SMALL LETTER Y)를 codeUnits 에 추가합니다.코드 단위가 List codeUnits 의 요소인 String 값을 반환합니다. codeUnits 에 요소가 없으면 빈 String을 반환합니다.
22.2.6.4.1 RegExpHasFlag ( regexp , codeUnit )
추상 연산 RegExpHasFlag. 인수 regexp (ECMAScript 언어 값 ) 및 codeUnit (코드 단위). 반환값: (정상 완료 (값: (Boolean 또는 undefined )) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
regexp 가 Object가 아니면 TypeError 예외를 던집니다.regexp 에 [[OriginalFlags]] 내부 슬롯이 없으면, 다음을 수행합니다.SameValue (regexp , %RegExp.prototype% )가 true 이면 undefined 를 반환합니다.TypeError 예외를 던집니다.flags 를 regexp .[[OriginalFlags]] 로 둡니다.flags 에 codeUnit 이 포함되어 있으면 true 를 반환합니다.false 를 반환합니다.
22.2.6.5 get RegExp.prototype.global
RegExp.prototype.global은 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
regexp 를 this 값으로 둡니다.codeUnit 을 코드 단위 0x0067 (LATIN SMALL LETTER G)로 둡니다.? RegExpHasFlag (regexp , codeUnit )를 반환합니다.
22.2.6.6 get RegExp.prototype.hasIndices
RegExp.prototype.hasIndices는 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
regexp 를 this 값으로 둡니다.codeUnit 을 코드 단위 0x0064 (LATIN SMALL LETTER D)로 둡니다.? RegExpHasFlag (regexp , codeUnit )를 반환합니다.
22.2.6.7 get RegExp.prototype.ignoreCase
RegExp.prototype.ignoreCase는 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
regexp 를 this 값으로 둡니다.codeUnit 을 코드 단위 0x0069 (LATIN SMALL LETTER I)로 둡니다.? RegExpHasFlag (regexp , codeUnit )를 반환합니다.
22.2.6.8 RegExp.prototype [ %Symbol.match% ] ( string )
이 메서드는 호출되면 다음 단계를 수행합니다:
regexp 를 this 값으로 둡니다.regexp 가 Object가 아니면 TypeError 예외를 던집니다.string 을 ? ToString (string )으로 설정합니다.flags 를 ? ToString (? Get (regexp , "flags" ))로 둡니다.flags 에 "g" 가 포함되어 있지 않으면 ? RegExpExec (regexp , string )를 반환합니다.flags 에 "u" 또는 "v" 가 포함되어 있으면 fullUnicode 를 true 로 둡니다. 그렇지 않으면 fullUnicode 를 false 로 둡니다.? Set (regexp , "lastIndex" , +0 𝔽 , true )를 수행합니다. array 를 ! ArrayCreate (0)으로 둡니다.matchCount 를 0으로 둡니다.다음을 반복합니다.result 를 ? RegExpExec (regexp , string )로 둡니다.result 가 null 이면, 다음을 수행합니다.matchCount = 0이면 null 을 반환합니다.array 를 반환합니다.matchString 을 ? ToString (? Get (result , "0" ))로 둡니다.! CreateDataPropertyOrThrow (array , ! ToString (𝔽 (matchCount )), matchString )을 수행합니다. matchString 이 빈 String이면, 다음을 수행합니다.thisIndex 를 ℝ (? ToLength (? Get (regexp , "lastIndex" )))로 둡니다.nextIndex 를 AdvanceStringIndex (string , thisIndex , fullUnicode )로 둡니다.? Set (regexp , "lastIndex" , 𝔽 (nextIndex ), true )를 수행합니다. matchCount 를 matchCount + 1로 설정합니다.
이 메서드의 "name" 프로퍼티 값은 "[Symbol.match]" 입니다.
참고
%Symbol.match% 프로퍼티는 IsRegExp 추상 연산 이 정규 표현식의 기본 동작을 갖는 객체를 식별하는 데 사용합니다. %Symbol.match% 프로퍼티가 없거나 해당 프로퍼티의 값이 Boolean으로 강제 변환되어 true 가 되지 않으면 해당 객체는 정규 표현식 객체로 사용하도록 의도되지 않은 것입니다.
22.2.6.9 RegExp.prototype [ %Symbol.matchAll% ] ( string )
이 메서드는 호출되면 다음 단계를 수행합니다:
regexp 를 this 값으로 둡니다.regexp 가 Object가 아니면 TypeError 예외를 던집니다.string 을 ? ToString (string )으로 설정합니다.speciesCtor 를 ? SpeciesConstructor (regexp , %RegExp% )로 둡니다.flags 를 ? ToString (? Get (regexp , "flags" ))로 둡니다.matcher 를 ? Construct (speciesCtor , « regexp , flags »)로 둡니다.lastIndex 를 ? ToLength (? Get (regexp , "lastIndex" ))로 둡니다.? Set (matcher , "lastIndex" , lastIndex , true )를 수행합니다. flags 에 "g" 가 포함되어 있으면 global 을 true 로 둡니다.그렇지 않으면 global 을 false 로 둡니다. flags 에 "u" 또는 "v" 가 포함되어 있으면 fullUnicode 를 true 로 둡니다.그렇지 않으면 fullUnicode 를 false 로 둡니다. CreateRegExpStringIterator (matcher , string , global , fullUnicode )를 반환합니다.
이 메서드의 "name" 프로퍼티 값은 "[Symbol.matchAll]" 입니다.
22.2.6.10 get RegExp.prototype.multiline
RegExp.prototype.multiline은 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
regexp 를 this 값으로 둡니다.codeUnit 을 코드 단위 0x006D (LATIN SMALL LETTER M)로 둡니다.? RegExpHasFlag (regexp , codeUnit )를 반환합니다.
22.2.6.11 RegExp.prototype [ %Symbol.replace% ] ( string , replaceValue )
이 메서드는 호출되면 다음 단계를 수행합니다:
regexp 를 this 값으로 둡니다.regexp 가 Object가 아니면 TypeError 예외를 던집니다.string 을 ? ToString (string )으로 설정합니다.stringLength 를 string 의 길이로 둡니다.functionalReplace 를 IsCallable (replaceValue )로 둡니다.functionalReplace 가 false 이면, 다음을 수행합니다.replaceValue 를 ? ToString (replaceValue )으로 설정합니다.flags 를 ? ToString (? Get (regexp , "flags" ))로 둡니다.flags 에 "g" 가 포함되어 있으면 global 을 true 로 둡니다. 그렇지 않으면 global 을 false 로 둡니다.global 이 true 이면, 다음을 수행합니다.? Set (regexp , "lastIndex" , +0 𝔽 , true )를 수행합니다. results 를 새로운 빈 List 로 둡니다.done 을 false 로 둡니다.done 이 false 인 동안 다음을 반복합니다.result 를 ? RegExpExec (regexp , string )로 둡니다.result 가 null 이면, 다음을 수행합니다.done 을 true 로 설정합니다.그렇지 않으면,result 를 results 에 추가합니다.global 이 false 이면, 다음을 수행합니다.done 을 true 로 설정합니다.그렇지 않으면,matchString 을 ? ToString (? Get (result , "0" ))로 둡니다.matchString 이 빈 String이면, 다음을 수행합니다.thisIndex 를 ℝ (? ToLength (? Get (regexp , "lastIndex" )))로 둡니다.flags 에 "u" 또는 "v" 가 포함되어 있으면 fullUnicode 를 true 로 둡니다. 그렇지 않으면 fullUnicode 를 false 로 둡니다.nextIndex 를 AdvanceStringIndex (string , thisIndex , fullUnicode )로 둡니다.? Set (regexp , "lastIndex" , 𝔽 (nextIndex ), true )를 수행합니다. accumulatedResult 를 빈 String으로 둡니다.nextSourcePosition 을 0으로 둡니다.results 의 각 요소 result 에 대해 다음을 수행합니다.resultLength 를 ? LengthOfArrayLike (result )로 둡니다.capturesCount 를 max (resultLength - 1, 0)으로 둡니다.matched 를 ? ToString (? Get (result , "0" ))로 둡니다.matchLength 를 matched 의 길이로 둡니다.position 을 ? ToIntegerOrInfinity (? Get (result , "index" ))로 둡니다.position 을 position 을 0과 stringLength 사이로 제한한 결과로 설정합니다.captures 를 새로운 빈 List 로 둡니다.captureNumber 를 1로 둡니다.captureNumber ≤ capturesCount 인 동안 다음을 반복합니다.capture 를 ? Get (result , ! ToString (𝔽 (captureNumber )))로 둡니다.capture 가 undefined 가 아니면, 다음을 수행합니다.capture 를 ? ToString (capture )으로 설정합니다.capture 를 captures 에 추가합니다.참고 : captureNumber = 1일 때 앞선 단계는 첫 번째 요소를 captures (인덱스 0)에 넣습니다. 더 일반적으로 captureNumber th 캡처(captureNumber th 캡처링 괄호 집합이 캡처한 문자)는 captures [captureNumber - 1]에 있습니다.captureNumber 를 captureNumber + 1로 설정합니다.namedCaptures 를 ? Get (result , "groups" )로 둡니다.functionalReplace 가 true 이면, 다음을 수행합니다.replacerArgs 를 « matched », captures 및 « 𝔽 (position ), string »의 목록 연결 로 둡니다.namedCaptures 가 undefined 가 아니면, 다음을 수행합니다.namedCaptures 를 replacerArgs 에 추가합니다.replacementValue 를 ? Call (replaceValue , undefined , replacerArgs )로 둡니다.replacementString 을 ? ToString (replacementValue )으로 둡니다.그렇지 않으면,namedCaptures 가 undefined 가 아니면, 다음을 수행합니다.namedCaptures 를 ? ToObject (namedCaptures )로 설정합니다.replacementString 을 ? GetSubstitution (matched , string , position , captures , namedCaptures , replaceValue )로 둡니다. position ≥ nextSourcePosition 이면, 다음을 수행합니다.참고 : position 은 일반적으로 뒤로 이동해서는 안 됩니다. 뒤로 이동하면 잘못 동작하는 RegExp 하위 클래스 또는 접근 시 발생하는 부수 효과를 이용하여 regexp 의 global 플래그나 다른 특성을 변경한 것을 나타냅니다. 이러한 경우 대응하는 치환은 무시됩니다.accumulatedResult 를 accumulatedResult , string 의 nextSourcePosition 부터 position 까지의 부분 문자열 및 replacementString 의 문자열 연결 로 설정합니다.nextSourcePosition 을 position + matchLength 로 설정합니다.nextSourcePosition ≥ stringLength 이면 accumulatedResult 를 반환합니다.accumulatedResult 와 string 의 nextSourcePosition 부터의 부분 문자열 의 문자열 연결 을 반환합니다.
이 메서드의 "name" 프로퍼티 값은 "[Symbol.replace]" 입니다.
22.2.6.12 RegExp.prototype [ %Symbol.search% ] ( string )
이 메서드는 호출되면 다음 단계를 수행합니다:
regexp 를 this 값으로 둡니다.regexp 가 Object가 아니면 TypeError 예외를 던집니다.string 을 ? ToString (string )으로 설정합니다.previousLastIndex 를 ? Get (regexp , "lastIndex" )로 둡니다.previousLastIndex 가 +0 𝔽 이 아니면, 다음을 수행합니다.? Set (regexp , "lastIndex" , +0 𝔽 , true )를 수행합니다. result 를 ? RegExpExec (regexp , string )로 둡니다.currentLastIndex 를 ? Get (regexp , "lastIndex" )로 둡니다.SameValue (currentLastIndex , previousLastIndex )가 false 이면, 다음을 수행합니다.? Set (regexp , "lastIndex" , previousLastIndex , true )를 수행합니다. result 가 null 이면 -1 𝔽 을 반환합니다.? Get (result , "index" )를 반환합니다.
이 메서드의 "name" 프로퍼티 값은 "[Symbol.search]" 입니다.
참고
검색을 수행할 때 이 RegExp 객체의 "lastIndex" 및 "global" 프로퍼티는 무시됩니다. "lastIndex" 프로퍼티는 변경되지 않은 채 유지됩니다.
22.2.6.13 get RegExp.prototype.source
RegExp.prototype.source는 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
regexp 를 this 값으로 둡니다.regexp 가 Object가 아니면 TypeError 예외를 던집니다.regexp 에 [[OriginalSource]] 내부 슬롯이 없으면, 다음을 수행합니다.SameValue (regexp , %RegExp.prototype% )가 true 이면 "(?:)" 를 반환합니다.TypeError 예외를 던집니다.단언 : regexp 에는 [[OriginalFlags]] 내부 슬롯이 있습니다.source 를 regexp .[[OriginalSource]] 로 둡니다.flags 를 regexp .[[OriginalFlags]] 로 둡니다.EscapeRegExpPattern (source , flags )을 반환합니다.
22.2.6.13.1 EscapeRegExpPattern ( pattern , flags )
추상 연산 EscapeRegExpPattern. 인수 pattern (String) 및 flags (String). 반환값: String. 호출되면 다음 단계를 수행한다.
flags 에 "v" 가 포함되어 있으면, 다음을 수행합니다.patternSymbol 을 Pattern [+UnicodeMode, +UnicodeSetsMode] 로 둡니다.그렇지 않고 flags 에 "u" 가 포함되어 있으면, 다음을 수행합니다.patternSymbol 을 Pattern [+UnicodeMode, ~UnicodeSetsMode] 로 둡니다. 그렇지 않으면,patternSymbol 을 Pattern [~UnicodeMode, ~UnicodeSetsMode] 로 둡니다. escapedPattern 을 UTF-16 인코딩 유니코드 코드 포인트(6.1.4 )로 해석된 pattern 과 동등한 patternSymbol 형식의 String으로 둡니다. 여기서 특정 코드 포인트는 아래 설명에 따라 이스케이프됩니다. escapedPattern 은 pattern 과 다를 수도 있고 다르지 않을 수도 있습니다. 그러나 escapedPattern 을 patternSymbol 로 평가하여 생성되는 Abstract Closure 는 생성된 객체의 [[RegExpMatcher]] 내부 슬롯이 제공하는 Abstract Closure 와 동일하게 동작해야 합니다. 동일한 pattern 및 flags 값으로 이 추상 연산 을 여러 번 호출하면 동일한 결과를 생성해야 합니다.패턴에 나타나는 코드 포인트 / 또는 모든 LineTerminator 는 "/" , escapedPattern , "/" 및 flags 의 문자열 연결 이 (적절한 어휘 문맥에서) 생성된 정규 표현식과 동일하게 동작하는 RegularExpressionLiteral 로 파싱될 수 있도록 필요한 경우 escapedPattern 에서 이스케이프해야 합니다. 예를 들어 pattern 이 "/" 이면 escapedPattern 은 여러 가능성 중 "\/" 또는 "\u002F" 일 수 있지만 "/" 일 수는 없습니다. flags 뒤의 ///는 RegularExpressionLiteral 이 아니라 SingleLineComment 로 파싱되기 때문입니다. pattern 이 빈 String이면 escapedPattern 을 "(?:)" 로 두어 이 명세를 충족할 수 있습니다. escapedPattern 을 반환합니다.
참고
이름은 비슷하지만 RegExp.escape와 EscapeRegExpPattern은 비슷한 동작을 수행하지 않습니다. 전자는 패턴 안에 표현하기 위해 문자열을 이스케이프하고, 이 함수는 문자열로 표현하기 위해 패턴을 이스케이프합니다.
22.2.6.14 RegExp.prototype [ %Symbol.split% ] ( string , limit )
참고 1
이 메서드는 string 을 String으로 변환한 결과의 부분 문자열 을 저장한 Array를 반환합니다. 부분 문자열 은 왼쪽에서 오른쪽으로 this 값 정규 표현식의 일치를 검색하여 결정됩니다. 이러한 출현은 반환되는 배열의 어떤 String에도 포함되지 않고 String 값을 나누는 역할을 합니다.
this 값은 빈 정규 표현식 또는 빈 String과 일치할 수 있는 정규 표현식일 수 있습니다. 이 경우 정규 표현식은 입력 String의 시작이나 끝에 있는 빈 부분 문자열 과 일치하지 않으며 이전 구분자 일치의 끝에 있는 빈 부분 문자열 과도 일치하지 않습니다. (예를 들어 정규 표현식이 빈 String과 일치하면 String은 개별 코드 단위 요소로 분할됩니다. 결과 배열의 길이는 String의 길이와 같고 각 부분 문자열 에는 하나의 코드 단위가 포함됩니다.) 백트래킹을 통해 해당 인덱스에서 비어 있지 않은 부분 문자열 일치를 얻을 수 있더라도 String의 특정 인덱스에서는 첫 번째 일치만 고려합니다. (예를 들어 /a*?/[Symbol.split]("ab")는 배열 ["a", "b"]로 평가되지만 /a*/[Symbol.split]("ab")는 배열 ["","b"]로 평가됩니다.)
string 이 빈 String이거나 빈 String으로 변환되는 경우 결과는 정규 표현식이 빈 String과 일치할 수 있는지에 따라 달라집니다. 일치할 수 있으면 결과 배열에는 요소가 없습니다. 그렇지 않으면 결과 배열에는 빈 String인 하나의 요소가 있습니다.
정규 표현식에 캡처링 괄호가 포함되어 있으면 separator 가 일치할 때마다 캡처링 괄호의 결과(undefined 결과 포함)가 출력 배열에 삽입됩니다. 예를 들어,
/<(\/)?([^<> ]+)>/[Symbol.split]("A<B > bold</B > and<CODE > coded</CODE > ")
는 다음 배열로 평가됩니다.
["A" , undefined , "B" , "bold" , "/" , "B" , "and" , undefined , "CODE" , "coded" , "/" , "CODE" , "" ]
limit 가 undefined 가 아니면 출력 배열은 limit 개보다 많은 요소를 포함하지 않도록 잘립니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
regexp 를 this 값으로 둡니다.regexp 가 Object가 아니면 TypeError 예외를 던집니다.string 을 ? ToString (string )으로 설정합니다.speciesCtor 를 ? SpeciesConstructor (regexp , %RegExp% )로 둡니다.flags 를 ? ToString (? Get (regexp , "flags" ))로 둡니다.flags 에 "u" 또는 "v" 가 포함되어 있으면 unicodeMatching 을 true 로 둡니다.그렇지 않으면 unicodeMatching 을 false 로 둡니다. flags 에 "y" 가 포함되어 있으면 newFlags 를 flags 로 둡니다.그렇지 않으면 newFlags 를 flags 와 "y" 의 문자열 연결 로 둡니다. splitter 를 ? Construct (speciesCtor , « regexp , newFlags »)로 둡니다.array 를 ! ArrayCreate (0)으로 둡니다.lengthA 를 0으로 둡니다.limit 가 undefined 이면 lim 을 232 - 1로 둡니다. 그렇지 않으면 lim 을 ℝ (? ToUint32 (limit ))로 둡니다.lim = 0이면 array 를 반환합니다.string 이 빈 String이면, 다음을 수행합니다.matchResult 를 ? RegExpExec (splitter , string )로 둡니다.matchResult 가 null 이 아니면 array 를 반환합니다.! CreateDataPropertyOrThrow (array , "0" , string )을 수행합니다. array 를 반환합니다.size 를 string 의 길이로 둡니다.lastMatchEnd 를 0으로 둡니다.searchIndex 를 lastMatchEnd 로 둡니다.searchIndex < size 인 동안 다음을 반복합니다.? Set (splitter , "lastIndex" , 𝔽 (searchIndex ), true )를 수행합니다. matchResult 를 ? RegExpExec (splitter , string )로 둡니다.matchResult 가 null 이면, 다음을 수행합니다.searchIndex 를 AdvanceStringIndex (string , searchIndex , unicodeMatching )로 설정합니다.그렇지 않으면,matchEnd 를 ℝ (? ToLength (? Get (splitter , "lastIndex" )))로 둡니다.matchEnd 를 min (matchEnd , size )로 설정합니다.matchEnd = lastMatchEnd 이면, 다음을 수행합니다.searchIndex 를 AdvanceStringIndex (string , searchIndex , unicodeMatching )로 설정합니다.그렇지 않으면,substring 을 string 의 lastMatchEnd 부터 searchIndex 까지의 부분 문자열 로 둡니다.! CreateDataPropertyOrThrow (array , ! ToString (𝔽 (lengthA )), substring )을 수행합니다. lengthA 를 lengthA + 1로 설정합니다.lengthA = lim 이면 array 를 반환합니다.lastMatchEnd 를 matchEnd 로 설정합니다.numberOfCaptures 를 ? LengthOfArrayLike (matchResult )로 둡니다.numberOfCaptures 를 max (numberOfCaptures - 1, 0)으로 설정합니다.captureIndex 를 1로 둡니다.captureIndex ≤ numberOfCaptures 인 동안 다음을 반복합니다.nextCapture 를 ? Get (matchResult , ! ToString (𝔽 (captureIndex )))로 둡니다.! CreateDataPropertyOrThrow (array , ! ToString (𝔽 (lengthA )), nextCapture )를 수행합니다. captureIndex 를 captureIndex + 1로 설정합니다.lengthA 를 lengthA + 1로 설정합니다.lengthA = lim 이면 array 를 반환합니다.searchIndex 를 lastMatchEnd 로 설정합니다. substring 을 string 의 lastMatchEnd 부터 size 까지의 부분 문자열 로 둡니다.! CreateDataPropertyOrThrow (array , ! ToString (𝔽 (lengthA )), substring )을 수행합니다. array 를 반환합니다.
이 메서드의 "name" 프로퍼티 값은 "[Symbol.split]" 입니다.
참고 2
이 메서드는 이 RegExp 객체의 "global" 및 "sticky" 프로퍼티 값을 무시합니다.
22.2.6.15 get RegExp.prototype.sticky
RegExp.prototype.sticky는 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
regexp 를 this 값으로 둡니다.codeUnit 을 코드 단위 0x0079 (LATIN SMALL LETTER Y)로 둡니다.? RegExpHasFlag (regexp , codeUnit )를 반환합니다.
22.2.6.16 RegExp.prototype.test ( string )
이 메서드는 호출되면 다음 단계를 수행합니다:
regexp 를 this 값으로 둡니다.regexp 가 Object가 아니면 TypeError 예외를 던집니다.string 을 ? ToString (string )으로 설정합니다.match 를 ? RegExpExec (regexp , string )로 둡니다.match 가 null 이면 false 를 반환합니다.true 를 반환합니다.
22.2.6.17 RegExp.prototype.toString ( )
regexp 를 this 값으로 둡니다.regexp 가 Object가 아니면 TypeError 예외를 던집니다.pattern 을 ? ToString (? Get (regexp , "source" ))로 둡니다.flags 를 ? ToString (? Get (regexp , "flags" ))로 둡니다.result 를 "/" , pattern , "/" 및 flags 의 문자열 연결 로 둡니다.result 를 반환합니다.
참고
반환된 String은 이 객체와 동일한 동작을 하는 다른 RegExp 객체로 평가되는 RegularExpressionLiteral 형식을 갖습니다.
22.2.6.18 get RegExp.prototype.unicode
RegExp.prototype.unicode는 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
regexp 를 this 값으로 둡니다.codeUnit 을 코드 단위 0x0075 (LATIN SMALL LETTER U)로 둡니다.? RegExpHasFlag (regexp , codeUnit )를 반환합니다.
22.2.6.19 get RegExp.prototype.unicodeSets
RegExp.prototype.unicodeSets는 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
regexp 를 this 값으로 둡니다.codeUnit 을 코드 단위 0x0076 (LATIN SMALL LETTER V)로 둡니다.? RegExpHasFlag (regexp , codeUnit )를 반환합니다.
22.2.7 RegExp 일치를 위한 추상 연산
22.2.7.1 RegExpExec ( regexp , string )
추상 연산 RegExpExec. 인수 regexp (Object) 및 string (String). 반환값: (정상 완료 (값: (Object 또는 null )) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
exec 을 ? Get (regexp , "exec" )로 둡니다.IsCallable (exec )이 true 이면, 다음을 수행합니다.result 를 ? Call (exec , regexp , « string »)로 둡니다.result 가 Object가 아니고 result 가 null 도 아니면 TypeError 예외를 던집니다.result 를 반환합니다.? RequireInternalSlot (regexp , [[RegExpMatcher]] )를 수행합니다. ? RegExpBuiltinExec (regexp , string )를 반환합니다.
참고
호출 가능한 "exec" 프로퍼티를 찾지 못하면 이 알고리즘은 내장 RegExp 일치 알고리즘 사용을 시도하는 방식으로 대체합니다. 이는 정규 표현식을 사용하는 대부분의 내장 알고리즘이 "exec" 의 동적 프로퍼티 조회를 수행하지 않았던 이전 판을 위해 작성된 코드와 호환되는 동작을 제공합니다.
22.2.7.2 RegExpBuiltinExec ( regexp , string )
추상 연산 RegExpBuiltinExec. 인수 regexp (an initialized RegExp instance) 및 string (String). 반환값: (정상 완료 (값: (Array 특수 객체 또는 null )) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
length 를 string 의 길이로 둡니다.lastIndex 를 ℝ (? ToLength (! Get (regexp , "lastIndex" )))로 둡니다.flags 를 regexp .[[OriginalFlags]] 로 둡니다.flags 에 "g" 가 포함되어 있으면 global 을 true 로 둡니다. 그렇지 않으면 global 을 false 로 둡니다.flags 에 "y" 가 포함되어 있으면 sticky 를 true 로 둡니다. 그렇지 않으면 sticky 를 false 로 둡니다.flags 에 "d" 가 포함되어 있으면 hasIndices 를 true 로 둡니다. 그렇지 않으면 hasIndices 를 false 로 둡니다.global 이 false 이고 sticky 가 false 이면 lastIndex 를 0으로 설정합니다.matcher 를 regexp .[[RegExpMatcher]] 로 둡니다.flags 에 "u" 또는 "v" 가 포함되어 있으면 fullUnicode 를 true 로 둡니다. 그렇지 않으면 fullUnicode 를 false 로 둡니다.matchSucceeded 를 false 로 둡니다.fullUnicode 가 true 이면 input 을 StringToCodePoints (string )로 둡니다. 그렇지 않으면 input 을 string 의 요소인 코드 단위로 구성된 List 로 둡니다.참고 : input 의 각 요소는 문자로 간주됩니다.matchSucceeded 가 false 인 동안 다음을 반복합니다.lastIndex > length 이면, 다음을 수행합니다.global 이 true 이거나 sticky 가 true 이면, 다음을 수행합니다.? Set (regexp , "lastIndex" , +0 𝔽 , true )를 수행합니다. null 을 반환합니다.inputIndex 를 string 의 요소 lastIndex 에서 얻은 문자의 input 안의 인덱스로 둡니다.result 를 matcher (input , inputIndex )로 둡니다.result 가 failure 이면, 다음을 수행합니다.sticky 가 true 이면, 다음을 수행합니다.? Set (regexp , "lastIndex" , +0 𝔽 , true )를 수행합니다. null 을 반환합니다.lastIndex 를 AdvanceStringIndex (string , lastIndex , fullUnicode )로 설정합니다.그렇지 않으면,단언 : result 는 MatchState 입니다.matchSucceeded 를 true 로 설정합니다. endIndex 를 result .[[EndIndex]] 로 둡니다.fullUnicode 가 true 이면 endIndex 를 GetStringIndex (string , endIndex )로 설정합니다.global 이 true 이거나 sticky 가 true 이면, 다음을 수행합니다.? Set (regexp , "lastIndex" , 𝔽 (endIndex ), true )를 수행합니다. capturingGroupsCount 를 result .[[Captures]] 의 요소 수로 둡니다.단언 : capturingGroupsCount = regexp .[[RegExpRecord]] .[[CapturingGroupsCount]] 입니다.단언 : capturingGroupsCount < 232 - 1입니다.array 를 ! ArrayCreate (capturingGroupsCount + 1)로 둡니다.단언 : array 의 "length" 프로퍼티의 수학적 값 은 capturingGroupsCount + 1입니다.! CreateDataPropertyOrThrow (array , "index" , 𝔽 (lastIndex ))를 수행합니다. ! CreateDataPropertyOrThrow (array , "input" , string )을 수행합니다. match 를 Match Record { [[StartIndex]] : lastIndex , [[EndIndex]] : endIndex }로 둡니다.indices 를 새로운 빈 List 로 둡니다.groupNames 를 새로운 빈 List 로 둡니다.match 를 indices 에 추가합니다.matchedSubstring 을 GetMatchString (string , match )으로 둡니다.! CreateDataPropertyOrThrow (array , "0" , matchedSubstring )을 수행합니다. regexp 에 어떤 GroupName 이라도 포함되어 있으면, 다음을 수행합니다.groups 를 OrdinaryObjectCreate (null )로 둡니다.hasGroups 를 true 로 둡니다.그렇지 않으면,groups 를 undefined 로 둡니다.hasGroups 를 false 로 둡니다. ! CreateDataPropertyOrThrow (array , "groups" , groups )를 수행합니다. matchedGroupNames 를 새로운 빈 List 로 둡니다.1 ≤ i ≤ capturingGroupsCount 를 만족하는 각 정수 i 에 대해 오름차순으로 다음을 수행합니다.capture 를 result .[[Captures]] 의 i th 요소로 둡니다.capture 가 undefined 이면, 다음을 수행합니다.capturedValue 를 undefined 로 둡니다.undefined 를 indices 에 추가합니다.그렇지 않으면,captureStart 를 capture .[[StartIndex]] 로 둡니다.captureEnd 를 capture .[[EndIndex]] 로 둡니다.fullUnicode 가 true 이면, 다음을 수행합니다.captureStart 를 GetStringIndex (string , captureStart )로 설정합니다.captureEnd 를 GetStringIndex (string , captureEnd )로 설정합니다.captureRecord 를 Match Record { [[StartIndex]] : captureStart , [[EndIndex]] : captureEnd }로 둡니다.capturedValue 를 GetMatchString (string , captureRecord )으로 둡니다.captureRecord 를 indices 에 추가합니다. ! CreateDataPropertyOrThrow (array , ! ToString (𝔽 (i )), capturedValue )를 수행합니다. regexp 의 i th 캡처가 GroupName 으로 정의되어 있으면, 다음을 수행합니다.groupName 을 해당 GroupName 의 CapturingGroupName 으로 둡니다.matchedGroupNames 에 groupName 이 포함되어 있으면, 다음을 수행합니다.단언 : capturedValue 는 undefined 입니다.undefined 를 groupNames 에 추가합니다.그렇지 않으면,capturedValue 가 undefined 가 아니면 groupName 을 matchedGroupNames 에 추가합니다.참고 : 이름이 groupName 인 그룹이 여러 개 있으면 이 시점에 groups 가 이미 groupName 프로퍼티를 가질 수 있습니다. 그러나 groups 는 모든 프로퍼티가 쓰기 가능한 데이터 프로퍼티 인 일반 객체 이므로 CreateDataPropertyOrThrow 호출은 그럼에도 반드시 성공합니다.! CreateDataPropertyOrThrow (groups , groupName , capturedValue )를 수행합니다. groupName 을 groupNames 에 추가합니다. 그렇지 않으면,undefined 를 groupNames 에 추가합니다. hasIndices 가 true 이면, 다음을 수행합니다.indicesArray 를 MakeMatchIndicesIndexPairArray (string , indices , groupNames , hasGroups )로 둡니다.! CreateDataPropertyOrThrow (array , "indices" , indicesArray )를 수행합니다. array 를 반환합니다.
22.2.7.3 AdvanceStringIndex ( string , index , unicode )
추상 연산 AdvanceStringIndex. 인수 string (String), index (음이 아닌 정수) 및 unicode (Boolean). 반환값: 음이 아닌 정수. 호출되면 다음 단계를 수행한다.
단언 : index ≤ 253 - 1입니다.unicode 가 false 이면 index + 1을 반환합니다.length 를 string 의 길이로 둡니다.index + 1 ≥ length 이면 index + 1을 반환합니다.codePoint 를 CodePointAt (string , index )로 둡니다.index + codePoint .[[CodeUnitCount]] 를 반환합니다.
22.2.7.4 GetStringIndex ( string , codePointIndex )
추상 연산 GetStringIndex. 인수 string (String) 및 codePointIndex (음이 아닌 정수). 반환값: 음이 아닌 정수. 6.1.4 에 설명된 대로 string 을 UTF-16 인코딩 코드 포인트 시퀀스로 해석하고, 해당 인덱스가 존재하면 코드 포인트 인덱스 codePointIndex 에 대응하는 코드 단위 인덱스를 반환합니다. 그렇지 않으면 string 의 길이를 반환합니다. 호출되면 다음 단계를 수행한다.
string 이 빈 String이면 0을 반환합니다.length 를 string 의 길이로 둡니다.codeUnitCount 를 0으로 둡니다.codePointCount 를 0으로 둡니다.codeUnitCount < length 인 동안 다음을 반복합니다.codePointCount = codePointIndex 이면 codeUnitCount 를 반환합니다.codePoint 를 CodePointAt (string , codeUnitCount )로 둡니다.codeUnitCount 를 codeUnitCount + codePoint .[[CodeUnitCount]] 로 설정합니다.codePointCount 를 codePointCount + 1로 설정합니다.length 를 반환합니다.
22.2.7.5 Match Record
Match Record 는 정규 표현식 일치 또는 캡처의 시작 및 끝 인덱스를 캡슐화하는 데 사용하는 Record 입니다.
Match Record에는 표 68 에 나열된 필드가 있습니다.
표 68: Match Record 필드
필드 이름
값
의미
[[StartIndex]]
a non-negative integer
일치가 시작하는 문자열의 시작부터의 코드 단위 수(포함)입니다.
[[EndIndex]]
an integer ≥ [[StartIndex]]
일치가 끝나는 문자열의 시작부터의 코드 단위 수(제외)입니다.
22.2.7.6 GetMatchString ( string , match )
추상 연산 GetMatchString. 인수 string (String) 및 match (Match 레코드 ). 반환값: String. 호출되면 다음 단계를 수행한다.
단언 : match .[[StartIndex]] ≤ match .[[EndIndex]] ≤ string 의 길이입니다.string 의 match .[[StartIndex]] 부터 match .[[EndIndex]] 까지의 부분 문자열 을 반환합니다.
22.2.7.7 GetMatchIndexPair ( string , match )
추상 연산 GetMatchIndexPair. 인수 string (String) 및 match (Match 레코드 ). 반환값: Array. 호출되면 다음 단계를 수행한다.
단언 : match .[[StartIndex]] ≤ match .[[EndIndex]] ≤ string 의 길이입니다.CreateArrayFromList (« 𝔽 (match .[[StartIndex]] ), 𝔽 (match .[[EndIndex]] ) »)를 반환합니다.
22.2.7.8 MakeMatchIndicesIndexPairArray ( string , indices , groupNames , hasGroups )
추상 연산 MakeMatchIndicesIndexPairArray. 인수 string (String), indices (리스트 (요소: (Match 레코드 또는 undefined ))), groupNames (리스트 (요소: (String 또는 undefined ))) 및 hasGroups (Boolean). 반환값: Array. 호출되면 다음 단계를 수행한다.
n 을 indices 의 요소 수로 둡니다.단언 : n < 232 - 1입니다.단언 : groupNames 에는 n - 1개의 요소가 있습니다.참고 : groupNames List 에는 indices [1]부터 indices List 와 정렬된 요소가 포함되어 있습니다.array 를 ! ArrayCreate (n )으로 둡니다.hasGroups 가 true 이면, 다음을 수행합니다.groups 를 OrdinaryObjectCreate (null )로 둡니다.그렇지 않으면,groups 를 undefined 로 둡니다. ! CreateDataPropertyOrThrow (array , "groups" , groups )를 수행합니다. 0 ≤ i < n 을 만족하는 각 정수 i 에 대해 오름차순으로 다음을 수행합니다.matchIndices 를 indices [i ]로 둡니다.matchIndices 가 undefined 가 아니면, 다음을 수행합니다.matchIndexPair 를 GetMatchIndexPair (string , matchIndices )로 둡니다.그렇지 않으면,matchIndexPair 를 undefined 로 둡니다. ! CreateDataPropertyOrThrow (array , ! ToString (𝔽 (i )), matchIndexPair )를 수행합니다. i > 0이면, 다음을 수행합니다.name 을 groupNames [i - 1]로 둡니다.name 이 undefined 가 아니면, 다음을 수행합니다.단언 : groups 는 undefined 가 아닙니다.참고 : 이름이 name 인 그룹이 여러 개 있으면 이 시점에 groups 가 이미 name 프로퍼티를 가질 수 있습니다. 그러나 groups 는 모든 프로퍼티가 쓰기 가능한 데이터 프로퍼티 인 일반 객체 이므로 CreateDataPropertyOrThrow 호출은 그럼에도 반드시 성공합니다.! CreateDataPropertyOrThrow (groups , name , matchIndexPair )를 수행합니다. array 를 반환합니다.
22.2.8 RegExp 인스턴스의 프로퍼티
RegExp 인스턴스는 RegExp 프로토타입 객체 에서 프로퍼티를 상속하는 일반 객체 입니다. RegExp 인스턴스에는 [[OriginalSource]] , [[OriginalFlags]] , [[RegExpRecord]] 및 [[RegExpMatcher]] 내부 슬롯이 있습니다. [[RegExpMatcher]] 내부 슬롯의 값은 RegExp 객체의 Pattern 을 나타내는 Abstract Closure 입니다.
참고
ECMAScript 2015 이전에는 RegExp 인스턴스가 자체 데이터 프로퍼티 "source" , "global" , "ignoreCase" 및 "multiline" 을 갖는 것으로 명시되었습니다. 이러한 프로퍼티는 이제 RegExp.prototype의 접근자 프로퍼티 로 명시됩니다.
RegExp 인스턴스에는 다음 프로퍼티도 있습니다:
22.2.8.1 lastIndex
"lastIndex" 프로퍼티의 값은 다음 일치를 시작할 String 인덱스를 지정합니다. 사용될 때 정수 Number로 강제 변환됩니다(22.2.7.2 참조). 이 프로퍼티는 { [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : false } 속성을 가져야 합니다.
22.2.9 RegExp String Iterator 객체
RegExp String Iterator 는 특정 RegExp 인스턴스 객체에 대해 일치시키면서 특정 String 인스턴스 객체를 특정 방식으로 순회하는 객체입니다. RegExp String Iterator 객체에는 이름 있는 생성자 가 없습니다. 대신 RegExp String Iterator 객체는 RegExp 인스턴스 객체의 특정 메서드를 호출하여 생성됩니다.
22.2.9.1 CreateRegExpStringIterator ( regexp , string , global , fullUnicode )
추상 연산 CreateRegExpStringIterator. 인수 regexp (Object), string (String), global (Boolean) 및 fullUnicode (Boolean). 반환값: Object. 호출되면 다음 단계를 수행한다.
iterator 를 OrdinaryObjectCreate (%RegExpStringIteratorPrototype% , « [[IteratingRegExp]] , [[IteratedString]] , [[Global]] , [[Unicode]] , [[Done]] »)로 둡니다.iterator .[[IteratingRegExp]] 를 regexp 로 설정합니다.iterator .[[IteratedString]] 을 string 으로 설정합니다.iterator .[[Global]] 을 global 로 설정합니다.iterator .[[Unicode]] 를 fullUnicode 로 설정합니다.iterator .[[Done]] 을 false 로 설정합니다.iterator 를 반환합니다.
22.2.9.2 %RegExpStringIteratorPrototype% 객체
%RegExpStringIteratorPrototype% 객체는:
22.2.9.2.1 %RegExpStringIteratorPrototype%.next ( )
iteratorObj 를 this 값으로 둡니다.iteratorObj 가 Object가 아니면 TypeError 예외를 던집니다.iteratorObj 가 RegExp String Iterator Object Instance의 모든 내부 슬롯을 갖지 않으면(22.2.9.3 참조) TypeError 예외를 던집니다.iteratorObj .[[Done]] 이 true 이면, 다음을 수행합니다.CreateIteratorResultObject (undefined , true )를 반환합니다.regexp 를 iteratorObj .[[IteratingRegExp]] 로 둡니다.string 을 iteratorObj .[[IteratedString]] 으로 둡니다.global 을 iteratorObj .[[Global]] 로 둡니다.fullUnicode 를 iteratorObj .[[Unicode]] 로 둡니다.match 를 ? RegExpExec (regexp , string )로 둡니다.match 가 null 이면, 다음을 수행합니다.iteratorObj .[[Done]] 을 true 로 설정합니다.CreateIteratorResultObject (undefined , true )를 반환합니다.global 이 false 이면, 다음을 수행합니다.iteratorObj .[[Done]] 을 true 로 설정합니다.CreateIteratorResultObject (match , false )를 반환합니다.matchString 을 ? ToString (? Get (match , "0" ))로 둡니다.matchString 이 빈 String이면, 다음을 수행합니다.thisIndex 를 ℝ (? ToLength (? Get (regexp , "lastIndex" )))로 둡니다.nextIndex 를 AdvanceStringIndex (string , thisIndex , fullUnicode )로 둡니다.? Set (regexp , "lastIndex" , 𝔽 (nextIndex ), true )를 수행합니다. CreateIteratorResultObject (match , false )를 반환합니다.
22.2.9.2.2 %RegExpStringIteratorPrototype% [ %Symbol.toStringTag% ]
%Symbol.toStringTag% 프로퍼티의 초기 값은 String 값 "RegExp String Iterator" 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
22.2.9.3 RegExp String Iterator 인스턴스의 프로퍼티
RegExp String Iterator 인스턴스는 %RegExpStringIteratorPrototype% 내재 객체에서 프로퍼티를 상속하는 일반 객체 입니다. RegExp String Iterator 인스턴스는 처음에 표 69 에 나열된 내부 슬롯을 갖도록 생성됩니다.
표 69: RegExp String Iterator 인스턴스의 내부 슬롯
내부 슬롯
타입
설명
[[IteratingRegExp]]
an Object
순회에 사용하는 정규 표현식입니다. IsRegExp ([[IteratingRegExp]] )의 초기 값은 true 입니다.
[[IteratedString]]
a String
순회 중인 String 값입니다.
[[Global]]
a Boolean
[[IteratingRegExp]] 가 전역인지 여부를 나타냅니다.
[[Unicode]]
a Boolean
[[IteratingRegExp]] 가 유니코드 모드인지 여부를 나타냅니다.
[[Done]]
a Boolean
순회가 완료되었는지 여부를 나타냅니다.
23 인덱스 컬렉션
23.1 Array 객체
Array는 특정 종류의 프로퍼티 이름 을 특별하게 처리하는 특수 객체 입니다. 이러한 특별한 처리의 정의는 10.4.2 를 참조하시기 바랍니다.
23.1.1 Array 생성자
Array 생성자 는:
%Array% 입니다.
전역 객체 의 "Array" 프로퍼티의 초기 값입니다.
생성자 로 호출되면 새로운 Array를 생성하고 초기화합니다.
생성자 가 아니라 함수로 호출되는 경우에도 새로운 Array를 생성하고 초기화합니다. 따라서 함수 호출 Array(…)는 동일한 인수를 갖는 객체 생성 표현식 new Array(…)와 동등합니다.
인수의 수와 타입에 따라 동작이 달라지는 함수입니다.
클래스 정의의 extends 절 값으로 사용할 수 있습니다. 특수한 Array 동작을 상속하려는 하위 클래스 생성자 는 Array 특수 객체 인 하위 클래스 인스턴스를 초기화하기 위해 Array 생성자 에 대한 super 호출을 포함해야 합니다. 그러나 대부분의 Array.prototype 메서드는 this 값이 Array 특수 객체 인지에 의존하지 않는 일반 메서드입니다.
23.1.1.1 Array ( ...values )
이 함수는 호출되면 다음 단계를 수행합니다:
NewTarget이 undefined 이면 newTarget 을 활성 함수 객체 로 둡니다. 그렇지 않으면 newTarget 을 NewTarget으로 둡니다. proto 를 ? GetPrototypeFromConstructor (newTarget , "%Array.prototype%" )로 둡니다.numberOfArgs 를 values 의 요소 수로 둡니다.numberOfArgs = 0이면 ! ArrayCreate (0, proto )를 반환합니다.numberOfArgs = 1이면, 다음을 수행합니다.length 를 values [0]으로 둡니다.array 를 ! ArrayCreate (0, proto )로 둡니다.length 가 Number가 아니면, 다음을 수행합니다.! CreateDataPropertyOrThrow (array , "0" , length )를 수행합니다. intLength 를 1 𝔽 로 둡니다.그렇지 않으면,intLength 를 ! ToUint32 (length )로 둡니다.SameValueZero (intLength , length )가 false 이면 RangeError 예외를 던집니다. ! Set (array , "length" , intLength , true )를 수행합니다. array 를 반환합니다.단언 : numberOfArgs ≥ 2입니다.array 를 ? ArrayCreate (numberOfArgs , proto )로 둡니다.k 를 0으로 둡니다.k < numberOfArgs 인 동안 다음을 반복합니다.propertyKey 를 ! ToString (𝔽 (k ))로 둡니다.itemK 를 values [k ]로 둡니다.! CreateDataPropertyOrThrow (array , propertyKey , itemK )를 수행합니다. k 를 k + 1로 설정합니다.단언 : array 의 "length" 프로퍼티의 수학적 값 은 numberOfArgs 입니다.array 를 반환합니다.
23.1.2 Array 생성자의 프로퍼티
Array 생성자 는:
23.1.2.1 Array.from ( items [ , mapper [ , thisArg ] ] )
이 함수는 호출되면 다음 단계를 수행합니다:
ctor 를 this 값으로 둡니다.mapper 가 undefined 이면, 다음을 수행합니다.mapping 을 false 로 둡니다.그렇지 않으면,IsCallable (mapper )가 false 이면 TypeError 예외를 던집니다.mapping 을 true 로 둡니다. usingIterator 를 ? GetMethod (items , %Symbol.iterator% )로 둡니다.usingIterator 가 undefined 가 아니면, 다음을 수행합니다.IsConstructor (ctor )가 true 이면, 다음을 수행합니다.array 를 ? Construct (ctor )로 둡니다.그렇지 않으면,array 를 ! ArrayCreate (0)으로 둡니다. iteratorRecord 를 ? GetIteratorFromMethod (items , usingIterator )로 둡니다.k 를 0으로 둡니다.다음을 반복합니다.k ≥ 253 - 1이면, 다음을 수행합니다.error 를 ThrowCompletion (새로 생성된 TypeError 객체)로 둡니다.? IteratorClose (iteratorRecord , error )를 반환합니다. propertyKey 를 ! ToString (𝔽 (k ))로 둡니다.next 를 ? IteratorStepValue (iteratorRecord )로 둡니다.next 가 done 이면, 다음을 수행합니다.? Set (array , "length" , 𝔽 (k ), true )를 수행합니다. array 를 반환합니다.mapping 이 true 이면, 다음을 수행합니다.mappedValue 를 Completion (Call (mapper , thisArg , « next , 𝔽 (k ) »))로 둡니다.IfAbruptCloseIterator (mappedValue , iteratorRecord ).그렇지 않으면,mappedValue 를 next 로 둡니다. defineStatus 를 Completion (CreateDataPropertyOrThrow (array , propertyKey , mappedValue ))로 둡니다.IfAbruptCloseIterator (defineStatus , iteratorRecord ).k 를 k + 1로 설정합니다. 참고 : items 는 반복 가능하지 않으므로 배열과 유사한 객체 라고 가정합니다.arrayLike 를 ! ToObject (items )로 둡니다.length 를 ? LengthOfArrayLike (arrayLike )로 둡니다.IsConstructor (ctor )가 true 이면, 다음을 수행합니다.array 를 ? Construct (ctor , « 𝔽 (length ) »)로 둡니다.그렇지 않으면,array 를 ? ArrayCreate (length )로 둡니다. k 를 0으로 둡니다.k < length 인 동안 다음을 반복합니다.propertyKey 를 ! ToString (𝔽 (k ))로 둡니다.kValue 를 ? Get (arrayLike , propertyKey )로 둡니다.mapping 이 true 이면, 다음을 수행합니다.mappedValue 를 ? Call (mapper , thisArg , « kValue , 𝔽 (k ) »)로 둡니다.그렇지 않으면,mappedValue 를 kValue 로 둡니다. ? CreateDataPropertyOrThrow (array , propertyKey , mappedValue )를 수행합니다. k 를 k + 1로 설정합니다.? Set (array , "length" , 𝔽 (length ), true )를 수행합니다. array 를 반환합니다.
참고
이 메서드는 의도적으로 일반적인 팩터리 메서드이며 this 값이 Array 생성자 일 것을 요구하지 않습니다. 따라서 단일 숫자 인수로 호출할 수 있는 다른 모든 생성자 로 옮기거나 그러한 생성자 가 상속할 수 있습니다.
23.1.2.2 Array.fromAsync ( items [ , mapper [ , thisArg ] ] )
이 비동기 함수는 호출되면 다음 단계를 수행합니다:
ctor 를 this 값으로 둡니다.mapping 을 false 로 둡니다.mapper 가 undefined 가 아니면, 다음을 수행합니다.IsCallable (mapper )가 false 이면 TypeError 예외를 던집니다.mapping 을 true 로 설정합니다.iteratorRecord 를 undefined 로 둡니다.usingAsyncIterator 를 ? GetMethod (items , %Symbol.asyncIterator% )로 둡니다.usingAsyncIterator 가 undefined 이면, 다음을 수행합니다.usingSyncIterator 를 ? GetMethod (items , %Symbol.iterator% )로 둡니다.usingSyncIterator 가 undefined 가 아니면, 다음을 수행합니다.iteratorRecord 를 CreateAsyncFromSyncIterator (? GetIteratorFromMethod (items , usingSyncIterator ))로 설정합니다.그렇지 않으면,iteratorRecord 를 ? GetIteratorFromMethod (items , usingAsyncIterator )로 설정합니다. iteratorRecord 가 undefined 가 아니면, 다음을 수행합니다.IsConstructor (ctor )가 true 이면, 다음을 수행합니다.array 를 ? Construct (ctor )로 둡니다.그렇지 않으면,array 를 ! ArrayCreate (0)으로 둡니다. k 를 0으로 둡니다.다음을 반복합니다.k ≥ 253 - 1이면, 다음을 수행합니다.error 를 ThrowCompletion (새로 생성된 TypeError 객체)로 둡니다.? AsyncIteratorClose (iteratorRecord , error )를 반환합니다. propertyKey 를 ! ToString (𝔽 (k ))로 둡니다.nextResult 를 ? Call (iteratorRecord .[[NextMethod]] , iteratorRecord .[[Iterator]] )로 둡니다.nextResult 를 ? Await (nextResult )로 설정합니다.nextResult 가 Object가 아니면 TypeError 예외를 던집니다.done 을 ? IteratorComplete (nextResult )로 둡니다.done 이 true 이면, 다음을 수행합니다.? Set (array , "length" , 𝔽 (k ), true )를 수행합니다. array 를 반환합니다.nextValue 를 ? IteratorValue (nextResult )로 둡니다.mapping 이 true 이면, 다음을 수행합니다.mappedValue 를 Completion (Call (mapper , thisArg , « nextValue , 𝔽 (k ) »))로 둡니다.IfAbruptCloseAsyncIterator (mappedValue , iteratorRecord ).mappedValue 를 Completion (Await (mappedValue ))로 설정합니다.IfAbruptCloseAsyncIterator (mappedValue , iteratorRecord ).그렇지 않으면,mappedValue 를 nextValue 로 둡니다. defineStatus 를 Completion (CreateDataPropertyOrThrow (array , propertyKey , mappedValue ))로 둡니다.IfAbruptCloseAsyncIterator (defineStatus , iteratorRecord ).k 를 k + 1로 설정합니다. 그렇지 않으면,참고 : items 는 비동기 반복 가능 객체도 반복 가능 객체도 아니므로 배열과 유사한 객체 라고 가정합니다.arrayLike 를 ! ToObject (items )로 둡니다.length 를 ? LengthOfArrayLike (arrayLike )로 둡니다.IsConstructor (ctor )가 true 이면, 다음을 수행합니다.array 를 ? Construct (ctor , « 𝔽 (length ) »)로 둡니다.그렇지 않으면,array 를 ? ArrayCreate (length )로 둡니다. k 를 0으로 둡니다.k < length 인 동안 다음을 반복합니다.propertyKey 를 ! ToString (𝔽 (k ))로 둡니다.kValue 를 ? Get (arrayLike , propertyKey )로 둡니다.kValue 를 ? Await (kValue )로 설정합니다.mapping 이 true 이면, 다음을 수행합니다.mappedValue 를 ? Call (mapper , thisArg , « kValue , 𝔽 (k ) »)로 둡니다.mappedValue 를 ? Await (mappedValue )로 설정합니다.그렇지 않으면,mappedValue 를 kValue 로 둡니다. ? CreateDataPropertyOrThrow (array , propertyKey , mappedValue )를 수행합니다. k 를 k + 1로 설정합니다.? Set (array , "length" , 𝔽 (length ), true )를 수행합니다. array 를 반환합니다.
참고
이 메서드는 의도적으로 일반적인 팩터리 메서드이며 this 값이 Array 생성자 일 것을 요구하지 않습니다. 따라서 단일 숫자 인수로 호출할 수 있는 다른 모든 생성자 로 옮기거나 그러한 생성자 가 상속할 수 있습니다.
23.1.2.3 Array.isArray ( arg )
이 함수는 호출되면 다음 단계를 수행합니다:
? IsArray (arg )를 반환합니다.
23.1.2.4 Array.of ( ...items )
이 메서드는 호출되면 다음 단계를 수행합니다:
length 를 items 의 요소 수로 둡니다.lengthNumber 를 𝔽 (length )로 둡니다.ctor 를 this 값으로 둡니다.IsConstructor (ctor )가 true 이면, 다음을 수행합니다.array 를 ? Construct (ctor , « lengthNumber »)로 둡니다.그렇지 않으면,array 를 ? ArrayCreate (length )로 둡니다. k 를 0으로 둡니다.k < length 인 동안 다음을 반복합니다.kValue 를 items [k ]로 둡니다.propertyKey 를 ! ToString (𝔽 (k ))로 둡니다.? CreateDataPropertyOrThrow (array , propertyKey , kValue )를 수행합니다. k 를 k + 1로 설정합니다.? Set (array , "length" , lengthNumber , true )를 수행합니다. array 를 반환합니다.
참고
이 메서드는 의도적으로 일반적인 팩터리 메서드이며 this 값이 Array 생성자 일 것을 요구하지 않습니다. 따라서 단일 숫자 인수로 호출할 수 있는 다른 생성자 로 옮기거나 그러한 생성자 가 상속할 수 있습니다.
23.1.2.5 Array.prototype
Array.prototype의 값은 Array 프로토타입 객체 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
23.1.2.6 get Array [ %Symbol.species% ]
Array[%Symbol.species%]는 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
this 값을 반환합니다.
이 함수의 "name" 프로퍼티 값은 "get [Symbol.species]" 입니다.
참고
Array 프로토타입 메서드는 일반적으로 this 값의 생성자 를 사용하여 파생 객체를 생성합니다. 그러나 하위 클래스 생성자 는 자신의 %Symbol.species% 프로퍼티를 재정의하여 이 기본 동작을 재정의할 수 있습니다.
23.1.3 Array 프로토타입 객체의 프로퍼티
Array 프로토타입 객체 는:
%Array.prototype% 입니다.
Array 특수 객체 이며 그러한 객체에 지정된 내부 메서드를 갖습니다.
초기 값이 +0 𝔽 이고 속성이 { [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : false }인 "length" 프로퍼티를 갖습니다.
값이 %Object.prototype% 인 [[Prototype]] 내부 슬롯을 갖습니다.
참고
Array 프로토타입 객체가 Array 특수 객체 로 지정된 것은 ECMAScript 2015 명세 이전에 작성된 ECMAScript 코드와의 호환성을 보장하기 위한 것입니다.
23.1.3.1 Array.prototype.at ( index )
obj 를 ? ToObject (this 값)으로 둡니다.length 를 ? LengthOfArrayLike (obj )로 둡니다.k 를 ? ToAbsoluteIndex (index , length )로 둡니다.k < 0 또는 k ≥ length 이면 undefined 를 반환합니다.? Get (obj , ! ToString (𝔽 (k )))를 반환합니다.
23.1.3.2 Array.prototype.concat ( ...items )
이 메서드는 객체의 배열 요소 뒤에 각 인수의 배열 요소가 이어지는 배열을 반환합니다.
호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.array 를 ? ArraySpeciesCreate (obj , 0)으로 둡니다.nextIndex 를 0으로 둡니다.obj 를 items 의 앞에 추가합니다.items 의 각 요소 item 에 대해 다음을 수행합니다.spreadable 을 ? IsConcatSpreadable (item )로 둡니다.spreadable 이 true 이면, 다음을 수행합니다.length 를 ? LengthOfArrayLike (item )로 둡니다.nextIndex + length > 253 - 1이면 TypeError 예외를 던집니다.sourceIndex 를 0으로 둡니다.sourceIndex < length 인 동안 다음을 반복합니다.propertyKey 를 ! ToString (𝔽 (sourceIndex ))로 둡니다.exists 를 ? HasProperty (item , propertyKey )로 둡니다.exists 가 true 이면, 다음을 수행합니다.subElement 를 ? Get (item , propertyKey )로 둡니다.? CreateDataPropertyOrThrow (array , ! ToString (𝔽 (nextIndex )), subElement )를 수행합니다. nextIndex 를 nextIndex + 1로 설정합니다.sourceIndex 를 sourceIndex + 1로 설정합니다.그렇지 않으면,참고 : item 은 펼쳐지지 않고 단일 항목으로 추가됩니다.nextIndex ≥ 253 - 1이면 TypeError 예외를 던집니다.? CreateDataPropertyOrThrow (array , ! ToString (𝔽 (nextIndex )), item )을 수행합니다. nextIndex 를 nextIndex + 1로 설정합니다. ? Set (array , "length" , 𝔽 (nextIndex ), true )를 수행합니다. array 를 반환합니다.
이 메서드의 "length" 프로퍼티는 1 𝔽 입니다.
참고 1
6 단계에서 "length" 프로퍼티를 명시적으로 설정하는 것은 items 의 마지막 비어 있지 않은 요소 뒤에 빈 슬롯이 있거나 array 가 내장 Array가 아닌 경우에도 길이가 올바르도록 보장하기 위한 것입니다.
참고 2
이 메서드는 의도적으로 일반적이며 this 값이 Array일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
23.1.3.2.1 IsConcatSpreadable ( obj )
추상 연산 IsConcatSpreadable. 인수 obj (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
obj 가 Object가 아니면 false 를 반환합니다.spreadable 을 ? Get (obj , %Symbol.isConcatSpreadable% )로 둡니다.spreadable 이 undefined 가 아니면 ToBoolean (spreadable )을 반환합니다.? IsArray (obj )를 반환합니다.
23.1.3.3 Array.prototype.constructor
Array.prototype.constructor의 초기 값은 %Array% 입니다.
23.1.3.4 Array.prototype.copyWithin ( target , start [ , end ] )
참고 1
end 인수는 선택 사항입니다. 제공되지 않으면 this 값의 길이를 사용합니다.
참고 2
target 이 음수이면 배열의 길이인 length 에 대해 length + target 으로 처리합니다. start 가 음수이면 length + start 로 처리합니다. end 가 음수이면 length + end 로 처리합니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.length 를 ? LengthOfArrayLike (obj )로 둡니다.to 를 ? ToClampedIndex (target , length )로 둡니다.from 을 ? ToClampedIndex (start , length )로 둡니다.end 가 undefined 이면 final 을 length 로 둡니다. 그렇지 않으면 final 을 ? ToClampedIndex (end , length )로 둡니다.count 를 min (final - from , length - to )로 둡니다.from < to 이고 to < from + count 이면, 다음을 수행합니다.direction 을 -1로 둡니다.from 을 from + count - 1로 설정합니다.to 를 to + count - 1로 설정합니다.그렇지 않으면,direction 을 1로 둡니다. count > 0인 동안 다음을 반복합니다.fromKey 를 ! ToString (𝔽 (from ))로 둡니다.toKey 를 ! ToString (𝔽 (to ))로 둡니다.fromPresent 를 ? HasProperty (obj , fromKey )로 둡니다.fromPresent 가 true 이면, 다음을 수행합니다.fromValue 를 ? Get (obj , fromKey )로 둡니다.? Set (obj , toKey , fromValue , true )를 수행합니다. 그렇지 않으면,단언 : fromPresent 는 false 입니다.? DeletePropertyOrThrow (obj , toKey )를 수행합니다. from 을 from + direction 으로 설정합니다.to 를 to + direction 으로 설정합니다.count 를 count - 1로 설정합니다.obj 를 반환합니다.
참고 3
이 메서드는 의도적으로 일반적이며 this 값이 Array일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
23.1.3.5 Array.prototype.entries ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.CreateArrayIterator (obj , key+value )를 반환합니다.
23.1.3.6 Array.prototype.every ( callback [ , thisArg ] )
참고 1
callback 은 세 인수를 받고 Boolean 값으로 강제 변환할 수 있는 값을 반환하는 함수여야 합니다. every는 callback 이 false 를 반환하는 요소를 찾을 때까지 배열에 실제로 존재하는 각 요소에 대해 오름차순으로 callback 을 한 번씩 호출합니다. 그러한 요소를 찾으면 every는 즉시 false 를 반환합니다. 그렇지 않으면 every는 true 를 반환합니다. callback 은 배열에 실제로 존재하는 요소에 대해서만 호출되며, 존재하지 않는 요소에 대해서는 호출되지 않습니다.
thisArg 매개변수가 제공되면 callback 을 호출할 때마다 this 값으로 사용됩니다. 제공되지 않으면 대신 undefined 를 사용합니다.
callback 은 요소의 값, 요소의 인덱스, 순회 중인 객체라는 세 인수로 호출됩니다.
every는 호출된 객체를 직접 변경하지 않지만 callback 호출에 의해 객체가 변경될 수 있습니다.
every가 처리할 요소의 범위는 callback 을 처음 호출하기 전에 설정됩니다. every 호출이 시작된 후 배열에 추가된 요소는 callback 이 방문하지 않습니다. 배열의 기존 요소가 변경되면 callback 에 전달되는 값은 every가 해당 요소를 방문할 때의 값입니다. every 호출이 시작된 후 방문되기 전에 삭제된 요소는 방문되지 않습니다. every는 수학의 “모든 것에 대해” 한정자처럼 동작합니다. 특히 빈 배열에서는 true 를 반환합니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.length 를 ? LengthOfArrayLike (obj )로 둡니다.IsCallable (callback )이 false 이면 TypeError 예외를 던집니다.k 를 0으로 둡니다.k < length 인 동안 다음을 반복합니다.propertyKey 를 ! ToString (𝔽 (k ))로 둡니다.kPresent 를 ? HasProperty (obj , propertyKey )로 둡니다.kPresent 가 true 이면, 다음을 수행합니다.kValue 를 ? Get (obj , propertyKey )로 둡니다.testResult 를 ToBoolean (? Call (callback , thisArg , « kValue , 𝔽 (k ), obj »))로 둡니다.testResult 가 false 이면 false 를 반환합니다.k 를 k + 1로 설정합니다.true 를 반환합니다.
참고 2
이 메서드는 의도적으로 일반적이며 this 값이 Array일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
23.1.3.7 Array.prototype.fill ( value [ , start [ , end ] ] )
참고 1
start 인수는 선택 사항입니다. 제공되지 않으면 +0 𝔽 을 사용합니다.
end 인수는 선택 사항입니다. 제공되지 않으면 this 값의 길이를 사용합니다.
참고 2
start 가 음수이면 배열의 길이인 length 에 대해 length + start 로 처리합니다. end 가 음수이면 length + end 로 처리합니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.length 를 ? LengthOfArrayLike (obj )로 둡니다.k 를 ? ToClampedIndex (start , length )로 둡니다.end 가 undefined 이면 final 을 length 로 둡니다. 그렇지 않으면 final 을 ? ToClampedIndex (end , length )로 둡니다.k < final 인 동안 다음을 반복합니다.propertyKey 를 ! ToString (𝔽 (k ))로 둡니다.? Set (obj , propertyKey , value , true )를 수행합니다. k 를 k + 1로 설정합니다.obj 를 반환합니다.
참고 3
이 메서드는 의도적으로 일반적이며 this 값이 Array일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
23.1.3.8 Array.prototype.filter ( callback [ , thisArg ] )
참고 1
callback 은 세 인수를 받고 Boolean 값으로 강제 변환할 수 있는 값을 반환하는 함수여야 합니다. filter는 배열의 각 요소에 대해 오름차순으로 callback 을 한 번씩 호출하고 callback 이 true 를 반환한 모든 값으로 새로운 배열을 구성합니다. callback 은 배열에 실제로 존재하는 요소에 대해서만 호출되며, 존재하지 않는 요소에 대해서는 호출되지 않습니다.
thisArg 매개변수가 제공되면 callback 을 호출할 때마다 this 값으로 사용됩니다. 제공되지 않으면 대신 undefined 를 사용합니다.
callback 은 요소의 값, 요소의 인덱스, 순회 중인 객체라는 세 인수로 호출됩니다.
filter는 호출된 객체를 직접 변경하지 않지만 callback 호출에 의해 객체가 변경될 수 있습니다.
filter가 처리할 요소의 범위는 callback 을 처음 호출하기 전에 설정됩니다. filter 호출이 시작된 후 배열에 추가된 요소는 callback 이 방문하지 않습니다. 배열의 기존 요소가 변경되면 callback 에 전달되는 값은 filter가 해당 요소를 방문할 때의 값입니다. filter 호출이 시작된 후 방문되기 전에 삭제된 요소는 방문되지 않습니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.length 를 ? LengthOfArrayLike (obj )로 둡니다.IsCallable (callback )이 false 이면 TypeError 예외를 던집니다.array 를 ? ArraySpeciesCreate (obj , 0)으로 둡니다.k 를 0으로 둡니다.to 를 0으로 둡니다.k < length 인 동안 다음을 반복합니다.propertyKey 를 ! ToString (𝔽 (k ))로 둡니다.kPresent 를 ? HasProperty (obj , propertyKey )로 둡니다.kPresent 가 true 이면, 다음을 수행합니다.kValue 를 ? Get (obj , propertyKey )로 둡니다.selected 를 ToBoolean (? Call (callback , thisArg , « kValue , 𝔽 (k ), obj »))로 둡니다.selected 가 true 이면, 다음을 수행합니다.? CreateDataPropertyOrThrow (array , ! ToString (𝔽 (to )), kValue )를 수행합니다. to 를 to + 1로 설정합니다.k 를 k + 1로 설정합니다.array 를 반환합니다.
참고 2
이 메서드는 의도적으로 일반적이며 this 값이 Array일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
23.1.3.9 Array.prototype.find ( predicate [ , thisArg ] )
참고 1
이 메서드는 predicate 가 true 로 강제 변환되는 값을 반환하는 요소를 찾을 때까지 배열의 각 요소에 대해 인덱스 오름차순으로 predicate 를 한 번씩 호출합니다. 그러한 요소를 찾으면 find는 즉시 해당 요소 값을 반환합니다. 그렇지 않으면 find는 undefined 를 반환합니다.
추가 정보는 FindViaPredicate 를 참조하시기 바랍니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.length 를 ? LengthOfArrayLike (obj )로 둡니다.findRecord 를 ? FindViaPredicate (obj , length , ascending , predicate , thisArg )로 둡니다.findRecord .[[Value]] 를 반환합니다.
참고 2
이 메서드는 의도적으로 일반적이며 this 값이 Array일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
23.1.3.10 Array.prototype.findIndex ( predicate [ , thisArg ] )
참고 1
이 메서드는 predicate 가 true 로 강제 변환되는 값을 반환하는 요소를 찾을 때까지 배열의 각 요소에 대해 인덱스 오름차순으로 predicate 를 한 번씩 호출합니다. 그러한 요소를 찾으면 findIndex는 즉시 해당 요소 값의 인덱스를 반환합니다. 그렇지 않으면 findIndex는 -1을 반환합니다.
추가 정보는 FindViaPredicate 를 참조하시기 바랍니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.length 를 ? LengthOfArrayLike (obj )로 둡니다.findRecord 를 ? FindViaPredicate (obj , length , ascending , predicate , thisArg )로 둡니다.findRecord .[[Index]] 를 반환합니다.
참고 2
이 메서드는 의도적으로 일반적이며 this 값이 Array일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
23.1.3.11 Array.prototype.findLast ( predicate [ , thisArg ] )
참고 1
이 메서드는 predicate 가 true 로 강제 변환되는 값을 반환하는 요소를 찾을 때까지 배열의 각 요소에 대해 인덱스 내림차순으로 predicate 를 한 번씩 호출합니다. 그러한 요소를 찾으면 findLast는 즉시 해당 요소 값을 반환합니다. 그렇지 않으면 findLast는 undefined 를 반환합니다.
추가 정보는 FindViaPredicate 를 참조하시기 바랍니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.length 를 ? LengthOfArrayLike (obj )로 둡니다.findRecord 를 ? FindViaPredicate (obj , length , descending , predicate , thisArg )로 둡니다.findRecord .[[Value]] 를 반환합니다.
참고 2
이 메서드는 의도적으로 일반적이며 this 값이 Array 객체일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
23.1.3.12 Array.prototype.findLastIndex ( predicate [ , thisArg ] )
참고 1
이 메서드는 predicate 가 true 로 강제 변환되는 값을 반환하는 요소를 찾을 때까지 배열의 각 요소에 대해 인덱스 내림차순으로 predicate 를 한 번씩 호출합니다. 그러한 요소를 찾으면 findLastIndex는 즉시 해당 요소 값의 인덱스를 반환합니다. 그렇지 않으면 findLastIndex는 -1을 반환합니다.
추가 정보는 FindViaPredicate 를 참조하시기 바랍니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.length 를 ? LengthOfArrayLike (obj )로 둡니다.findRecord 를 ? FindViaPredicate (obj , length , descending , predicate , thisArg )로 둡니다.findRecord .[[Index]] 를 반환합니다.
참고 2
이 메서드는 의도적으로 일반적이며 this 값이 Array 객체일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
23.1.3.12.1 FindViaPredicate ( obj , length , direction , predicate , thisArg )
추상 연산 FindViaPredicate. 인수 obj (Object), length (음이 아닌 정수), direction ((ascending 또는 descending )), predicate (ECMAScript 언어 값 ) 및 thisArg (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: 레코드 (필드: [[Index]] (정수인 Number ), [[Value]] (ECMAScript 언어 값 ))) 또는 throw 완료 ).
obj 는 배열과 유사한 객체 또는 TypedArray 여야 합니다. 이 연산은 predicate 가 true 로 강제 변환되는 값을 반환하는 요소를 찾을 때까지 direction 이 나타내는 대로 인덱스 오름차순 또는 내림차순으로 obj 의 각 요소에 대해 predicate 를 한 번씩 호출합니다. 그러한 요소를 찾으면 이 연산은 찾은 요소의 인덱스와 값을 제공하는 Record 를 반환합니다. 그러한 요소를 찾지 못하면 인덱스에 -1 𝔽 , 값에 undefined 를 지정하는 Record 를 반환합니다.
predicate 는 함수여야 합니다. 배열의 요소에 대해 호출되면 요소의 값, 요소의 인덱스, 순회 중인 객체라는 세 인수가 전달됩니다. 반환 값은 Boolean 값으로 강제 변환됩니다.
thisArg 는 predicate 를 호출할 때마다 this 값으로 사용됩니다.
이 연산은 호출된 객체를 직접 변경하지 않지만 predicate 호출에 의해 객체가 변경될 수 있습니다.
처리할 요소의 범위는 순회가 시작되기 직전, predicate 을 처음 호출하기 전에 설정됩니다. 그 후 배열에 추가된 요소는 predicate 이 방문하지 않습니다. 배열의 기존 요소가 변경되면 predicate 에 전달되는 값은 이 연산이 해당 요소를 방문할 때의 값입니다. 순회가 시작된 후 방문되기 전에 삭제된 요소도 여전히 방문되며, 프로토타입에서 조회되거나 undefined 가 됩니다.
호출되면 다음 단계를 수행한다.
IsCallable (predicate )이 false 이면 TypeError 예외를 던집니다.direction 이 ascending 이면, 다음을 수행합니다.indices 를 0(포함)부터 length (제외)까지의 구간 에 속하는 정수 를 오름차순으로 포함하는 List 로 둡니다.그렇지 않으면,indices 를 0(포함)부터 length (제외)까지의 구간 에 속하는 정수 를 내림차순으로 포함하는 List 로 둡니다. indices 의 각 정수 k 에 대해 다음을 수행합니다.propertyKey 를 ! ToString (𝔽 (k ))로 둡니다.참고 : obj 가 TypedArray 이면 다음 Get 호출은 정상 완료 를 반환합니다.kValue 를 ? Get (obj , propertyKey )로 둡니다.testResult 를 ? Call (predicate , thisArg , « kValue , 𝔽 (k ), obj »)로 둡니다.ToBoolean (testResult )가 true 이면 Record { [[Index]] : 𝔽 (k ), [[Value]] : kValue }를 반환합니다.Record { [[Index]] : -1 𝔽 , [[Value]] : undefined }를 반환합니다.
23.1.3.13 Array.prototype.flat ( [ depth ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.sourceLength 를 ? LengthOfArrayLike (obj )로 둡니다.depthNumber 를 1로 둡니다.depth 가 undefined 가 아니면, 다음을 수행합니다.depthNumber 를 ? ToIntegerOrInfinity (depth )로 설정합니다.depthNumber < 0이면 depthNumber 를 0으로 설정합니다.array 를 ? ArraySpeciesCreate (obj , 0)으로 둡니다.? FlattenIntoArray (array , obj , sourceLength , 0, depthNumber )를 수행합니다. array 를 반환합니다.
23.1.3.13.1 FlattenIntoArray ( target , source , sourceLength , start , depth [ , mapperFunc [ , thisArg ] ] )
추상 연산 FlattenIntoArray. 인수 target (Object), source (Object), sourceLength (음이 아닌 정수), start (음이 아닌 정수) 및 depth ((음이 아닌 정수 또는 +∞)) 및 선택적 인수 mapperFunc (함수 객체 ) 및 thisArg (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: 음이 아닌 정수) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
단언 : mapperFunc 가 존재하면 IsCallable (mapperFunc )은 true 이고, thisArg 가 존재하며, depth 는 1입니다.targetIndex 를 start 로 둡니다.sourceIndex 를 0으로 둡니다.sourceIndex < sourceLength 인 동안 다음을 반복합니다.propertyKey 를 ! ToString (𝔽 (sourceIndex ))로 둡니다.exists 를 ? HasProperty (source , propertyKey )로 둡니다.exists 가 true 이면, 다음을 수행합니다.element 를 ? Get (source , propertyKey )로 둡니다.mapperFunc 가 존재하면, 다음을 수행합니다.element 를 ? Call (mapperFunc , thisArg , « element , 𝔽 (sourceIndex ), source »)로 설정합니다.shouldFlatten 을 false 로 둡니다.depth > 0이면, 다음을 수행합니다.shouldFlatten 을 ? IsArray (element )로 설정합니다.shouldFlatten 이 true 이면, 다음을 수행합니다.depth = +∞이면 newDepth 를 +∞로 둡니다.그렇지 않으면 newDepth 를 depth - 1로 둡니다. elementLength 를 ? LengthOfArrayLike (element )로 둡니다.targetIndex 를 ? FlattenIntoArray (target , element , elementLength , targetIndex , newDepth )로 설정합니다.그렇지 않으면,targetIndex ≥ 253 - 1이면 TypeError 예외를 던집니다.? CreateDataPropertyOrThrow (target , ! ToString (𝔽 (targetIndex )), element )를 수행합니다. targetIndex 를 targetIndex + 1로 설정합니다. sourceIndex 를 sourceIndex + 1로 설정합니다.targetIndex 를 반환합니다.
23.1.3.14 Array.prototype.flatMap ( mapperFunc [ , thisArg ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.sourceLength 를 ? LengthOfArrayLike (obj )로 둡니다.IsCallable (mapperFunc )이 false 이면 TypeError 예외를 던집니다.array 를 ? ArraySpeciesCreate (obj , 0)으로 둡니다.? FlattenIntoArray (array , obj , sourceLength , 0, 1, mapperFunc , thisArg )를 수행합니다. array 를 반환합니다.
23.1.3.15 Array.prototype.forEach ( callback [ , thisArg ] )
참고 1
callback 은 세 인수를 받는 함수여야 합니다. forEach는 배열에 존재하는 각 요소에 대해 오름차순으로 callback 을 한 번씩 호출합니다. callback 은 배열에 실제로 존재하는 요소에 대해서만 호출되며, 존재하지 않는 요소에 대해서는 호출되지 않습니다.
thisArg 매개변수가 제공되면 callback 을 호출할 때마다 this 값으로 사용됩니다. 제공되지 않으면 대신 undefined 를 사용합니다.
callback 은 요소의 값, 요소의 인덱스, 순회 중인 객체라는 세 인수로 호출됩니다.
forEach는 호출된 객체를 직접 변경하지 않지만 callback 호출에 의해 객체가 변경될 수 있습니다.
forEach가 처리할 요소의 범위는 callback 을 처음 호출하기 전에 설정됩니다. forEach 호출이 시작된 후 배열에 추가된 요소는 callback 이 방문하지 않습니다. 배열의 기존 요소가 변경되면 callback 에 전달되는 값은 forEach가 해당 요소를 방문할 때의 값입니다. forEach 호출이 시작된 후 방문되기 전에 삭제된 요소는 방문되지 않습니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.length 를 ? LengthOfArrayLike (obj )로 둡니다.IsCallable (callback )이 false 이면 TypeError 예외를 던집니다.k 를 0으로 둡니다.k < length 인 동안 다음을 반복합니다.propertyKey 를 ! ToString (𝔽 (k ))로 둡니다.kPresent 를 ? HasProperty (obj , propertyKey )로 둡니다.kPresent 가 true 이면, 다음을 수행합니다.kValue 를 ? Get (obj , propertyKey )로 둡니다.? Call (callback , thisArg , « kValue , 𝔽 (k ), obj »)를 수행합니다. k 를 k + 1로 설정합니다.undefined 를 반환합니다.
참고 2
이 메서드는 의도적으로 일반적이며 this 값이 Array일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
23.1.3.16 Array.prototype.includes ( searchElement [ , fromIndex ] )
참고 1
이 메서드는 SameValueZero 알고리즘을 사용하여 searchElement 를 배열의 요소와 오름차순으로 비교하고, 어느 위치에서든 찾으면 true 를 반환합니다. 그렇지 않으면 false 를 반환합니다.
선택적 두 번째 인수 fromIndex 의 기본값은 +0 𝔽 입니다(즉, 전체 배열을 검색합니다). 배열의 길이 이상이면 false 를 반환하며, 즉 배열을 검색하지 않습니다. -0 𝔽 보다 작으면 배열 끝에서의 오프셋으로 사용하여 fromIndex 를 계산합니다. 계산된 인덱스가 +0 𝔽 이하이면 전체 배열을 검색합니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.length 를 ? LengthOfArrayLike (obj )로 둡니다.length = 0이면 false 를 반환합니다.k 를 ? ToClampedIndex (fromIndex , length )로 둡니다.k < length 인 동안 다음을 반복합니다.elementK 를 ? Get (obj , ! ToString (𝔽 (k )))로 둡니다.SameValueZero (searchElement , elementK )가 true 이면 true 를 반환합니다.k 를 k + 1로 설정합니다.false 를 반환합니다.
참고 2
이 메서드는 의도적으로 일반적이며 this 값이 Array일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
참고 3
이 메서드는 유사한 indexOf 메서드와 의도적으로 두 가지 점에서 다릅니다. 첫째, IsStrictlyEqual 대신 SameValueZero 알고리즘을 사용하므로 NaN 배열 요소를 감지할 수 있습니다. 둘째, 존재하지 않는 배열 요소를 건너뛰지 않고 undefined 로 처리합니다.
23.1.3.17 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
이 메서드는 IsStrictlyEqual 알고리즘을 사용하여 searchElement 를 배열의 요소와 오름차순으로 비교하고, 하나 이상의 인덱스에서 찾으면 그러한 인덱스 중 가장 작은 값을 반환합니다. 그렇지 않으면 -1 𝔽 을 반환합니다.
참고 1
선택적 두 번째 인수 fromIndex 의 기본값은 +0 𝔽 입니다(즉, 전체 배열을 검색합니다). 배열의 길이 이상이면 -1 𝔽 을 반환하며, 즉 배열을 검색하지 않습니다. -0 𝔽 보다 작으면 배열 끝에서의 오프셋을 계산하는 데 사용합니다. 계산된 인덱스가 +0 𝔽 이하이면 전체 배열을 검색합니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.length 를 ? LengthOfArrayLike (obj )로 둡니다.length = 0이면 -1 𝔽 을 반환합니다.k 를 ? ToClampedIndex (fromIndex , length )로 둡니다.k < length 인 동안 다음을 반복합니다.propertyKey 를 ! ToString (𝔽 (k ))로 둡니다.kPresent 를 ? HasProperty (obj , propertyKey )로 둡니다.kPresent 가 true 이면, 다음을 수행합니다.elementK 를 ? Get (obj , propertyKey )로 둡니다.IsStrictlyEqual (searchElement , elementK )가 true 이면 𝔽 (k )를 반환합니다.k 를 k + 1로 설정합니다.-1 𝔽 을 반환합니다.
참고 2
이 메서드는 의도적으로 일반적이며 this 값이 Array일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
23.1.3.18 Array.prototype.join ( separator )
이 메서드는 배열의 요소를 String으로 변환한 다음 separator 가 나타나는 것으로 구분하여 이러한 String을 연결합니다. 구분자를 제공하지 않으면 하나의 쉼표를 구분자로 사용합니다.
호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.length 를 ? LengthOfArrayLike (obj )로 둡니다.separator 가 undefined 이면 separatorString 을 "," 로 둡니다; 그렇지 않으면 separatorString 을 ? ToString (separator )으로 둡니다.? JoinIndexedProperties (obj , length , separatorString )를 반환합니다.
참고
이 메서드는 의도적으로 범용적으로 설계되었으며, this 값이 Array일 필요는 없습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
23.1.3.18.1 JoinIndexedProperties ( obj , length , separator [ , methodName [ , methodArgs ] ] )
추상 연산 JoinIndexedProperties. 인수 obj (Object), length (음이 아닌 정수) 및 separator (String) 및 선택적 인수 methodName (프로퍼티 키 ) 및 methodArgs (리스트 (요소: ECMAScript 언어 값 )). 반환값: (정상 완료 (값: String) 또는 throw 완료 ). 0부터 length - 1까지 양 끝을 포함하는 구간 에 있는 obj 의 정수 인덱스 속성을 String으로 변환한 다음(선택적으로 메서드 호출을 통해), 각 String 사이에 구분자 String을 삽입하여 연결합니다. 호출되면 다음 단계를 수행한다.
methodName 이 제공되고 methodArgs 가 제공되지 않았으면 methodArgs 를 새로운 빈 List 로 설정합니다.result 를 빈 String으로 둡니다.k 를 0으로 둡니다.k < length 인 동안 다음 단계를 반복합니다,k > 0이면 result 를 result 와 separator 를 연결한 문자열로 설정합니다.참고 : obj 가 TypedArray 인 경우 다음 Get 호출은 정상 완료 를 반환합니다.element 를 ? Get (obj , ! ToString (𝔽 (k )))으로 둡니다.element 가 undefined 도 null 도 아니면 다음을 수행합니다.methodName 이 제공된 경우 다음을 수행합니다.elementString 을 ? ToString (? Invoke (element , methodName , methodArgs ))으로 둡니다.그렇지 않으면,참고 : obj 가 TypedArray 인 경우 다음 ToString 호출은 정상 완료 를 반환합니다.elementString 을 ? ToString (element )으로 둡니다. result 를 result 와 elementString 을 연결한 문자열로 설정합니다.k 를 k + 1로 설정합니다.result 를 반환합니다.
참고
methodArgs 매개변수는 ECMA-402와 같이 이 연산에 의존하는 다른 명세에서 사용하기 위한 것입니다.
23.1.3.19 Array.prototype.keys ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.CreateArrayIterator (obj , key )를 반환합니다.
23.1.3.20 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
참고 1
이 메서드는 IsStrictlyEqual 알고리즘을 사용하여 searchElement 를 배열의 요소와 내림차순으로 비교하고, 하나 이상의 인덱스에서 찾으면 그러한 인덱스 중 가장 큰 값을 반환합니다. 그렇지 않으면 -1 𝔽 을 반환합니다.
선택적 두 번째 인수 fromIndex 의 기본값은 배열의 길이에서 1을 뺀 값입니다(즉, 전체 배열을 검색합니다). 배열의 길이 이상이면 전체 배열을 검색합니다. -0 𝔽 보다 작으면 배열 끝에서의 오프셋을 계산하는 데 사용합니다. 계산된 인덱스가 -0 𝔽 보다 작으면 -1 𝔽 을 반환합니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.length 를 ? LengthOfArrayLike (obj )로 둡니다.length = 0이면 -1 𝔽 을 반환합니다.fromIndex 가 존재하지 않으면 k 를 length - 1로 둡니다. 그렇지 않으면 k 를 min (? ToAbsoluteIndex (fromIndex , length ), length - 1)로 둡니다.k ≥ 0인 동안 다음을 반복합니다.propertyKey 를 ! ToString (𝔽 (k ))로 둡니다.kPresent 를 ? HasProperty (obj , propertyKey )로 둡니다.kPresent 가 true 이면, 다음을 수행합니다.elementK 를 ? Get (obj , propertyKey )로 둡니다.IsStrictlyEqual (searchElement , elementK )가 true 이면 𝔽 (k )를 반환합니다.k 를 k - 1로 설정합니다.-1 𝔽 을 반환합니다.
참고 2
이 메서드는 의도적으로 일반적이며 this 값이 Array일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
23.1.3.21 Array.prototype.map ( callback [ , thisArg ] )
참고 1
callback 은 세 인수를 받는 함수여야 합니다. map은 배열의 각 요소에 대해 오름차순으로 callback 을 한 번씩 호출하고 그 결과로 새로운 Array를 구성합니다. callback 은 배열에 실제로 존재하는 요소에 대해서만 호출되며, 존재하지 않는 요소에 대해서는 호출되지 않습니다.
thisArg 매개변수가 제공되면 callback 을 호출할 때마다 this 값으로 사용됩니다. 제공되지 않으면 대신 undefined 를 사용합니다.
callback 은 요소의 값, 요소의 인덱스, 순회 중인 객체라는 세 인수로 호출됩니다.
map은 호출된 객체를 직접 변경하지 않지만 callback 호출에 의해 객체가 변경될 수 있습니다.
map이 처리할 요소의 범위는 callback 을 처음 호출하기 전에 설정됩니다. map 호출이 시작된 후 배열에 추가된 요소는 callback 이 방문하지 않습니다. 배열의 기존 요소가 변경되면 callback 에 전달되는 값은 map이 해당 요소를 방문할 때의 값입니다. map 호출이 시작된 후 방문되기 전에 삭제된 요소는 방문되지 않습니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.length 를 ? LengthOfArrayLike (obj )로 둡니다.IsCallable (callback )이 false 이면 TypeError 예외를 던집니다.array 를 ? ArraySpeciesCreate (obj , length )로 둡니다.k 를 0으로 둡니다.k < length 인 동안 다음을 반복합니다.propertyKey 를 ! ToString (𝔽 (k ))로 둡니다.kPresent 를 ? HasProperty (obj , propertyKey )로 둡니다.kPresent 가 true 이면, 다음을 수행합니다.kValue 를 ? Get (obj , propertyKey )로 둡니다.mappedValue 를 ? Call (callback , thisArg , « kValue , 𝔽 (k ), obj »)로 둡니다.? CreateDataPropertyOrThrow (array , propertyKey , mappedValue )를 수행합니다. k 를 k + 1로 설정합니다.array 를 반환합니다.
참고 2
이 메서드는 의도적으로 일반적이며 this 값이 Array일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
23.1.3.22 Array.prototype.pop ( )
참고 1
이 메서드는 배열의 마지막 요소를 제거하고 반환합니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.length 를 ? LengthOfArrayLike (obj )로 둡니다.length = 0이면, 다음을 수행합니다.? Set (obj , "length" , +0 𝔽 , true )를 수행합니다. undefined 를 반환합니다.단언 : length > 0입니다.newLength 를 𝔽 (length - 1)로 둡니다.index 를 ! ToString (newLength )로 둡니다.element 를 ? Get (obj , index )로 둡니다.? DeletePropertyOrThrow (obj , index )를 수행합니다. ? Set (obj , "length" , newLength , true )를 수행합니다. element 를 반환합니다.
참고 2
이 메서드는 의도적으로 일반적이며 this 값이 Array일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
23.1.3.23 Array.prototype.push ( ...items )
참고 1
이 메서드는 인수를 나타나는 순서대로 배열의 끝에 추가합니다. 배열의 새로운 길이를 반환합니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.length 를 ? LengthOfArrayLike (obj )로 둡니다.argCount 를 items 의 요소 수로 둡니다.length + argCount > 253 - 1이면 TypeError 예외를 던집니다.items 의 각 요소 item 에 대해 다음을 수행합니다.? Set (obj , ! ToString (𝔽 (length )), item , true )를 수행합니다. length 를 length + 1로 설정합니다.? Set (obj , "length" , 𝔽 (length ), true )를 수행합니다. 𝔽 (length )를 반환합니다.
이 메서드의 "length" 프로퍼티는 1 𝔽 입니다.
참고 2
이 메서드는 의도적으로 일반적이며 this 값이 Array일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
23.1.3.24 Array.prototype.reduce ( callback [ , initialValue ] )
참고 1
callback 은 네 인수를 받는 함수여야 합니다. reduce는 배열에 존재하는 각 요소에 대해 오름차순으로 callback 을 한 번씩 호출하며, initialValue 가 제공되지 않은 경우 첫 번째 요소를 건너뜁니다.
callback 은 previousValue (callback 을 이전에 호출한 결과 값), currentValue (현재 요소의 값), currentIndex , 순회 중인 객체라는 네 인수로 호출됩니다. callback이 처음 호출될 때 previousValue 와 currentValue 는 두 가지 경우 중 하나가 될 수 있습니다. reduce 호출에 initialValue 가 제공되었다면 previousValue 는 initialValue 이고 currentValue 는 배열의 첫 번째 값입니다. initialValue 가 제공되지 않았다면 previousValue 는 배열의 첫 번째 값이고 currentValue 는 두 번째 값입니다. 배열에 요소가 없고 initialValue 가 제공되지 않으면 TypeError 입니다.
reduce는 호출된 객체를 직접 변경하지 않지만 callback 호출에 의해 객체가 변경될 수 있습니다.
reduce가 처리할 요소의 범위는 callback 을 처음 호출하기 전에 설정됩니다. reduce 호출이 시작된 후 배열에 추가된 요소는 callback 이 방문하지 않습니다. 배열의 기존 요소가 변경되면 callback 에 전달되는 값은 reduce가 해당 요소를 방문할 때의 값입니다. reduce 호출이 시작된 후 방문되기 전에 삭제된 요소는 방문되지 않습니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.length 를 ? LengthOfArrayLike (obj )로 둡니다.IsCallable (callback )이 false 이면 TypeError 예외를 던집니다.length = 0이고 initialValue 가 존재하지 않으면 TypeError 예외를 던집니다.k 를 0으로 둡니다.accumulator 를 undefined 로 둡니다.initialValue 가 존재하면, 다음을 수행합니다.accumulator 를 initialValue 로 설정합니다.그렇지 않으면,kPresent 를 false 로 둡니다.kPresent 가 false 이고 k < length 인 동안 다음을 반복합니다.propertyKey 를 ! ToString (𝔽 (k ))로 둡니다.kPresent 를 ? HasProperty (obj , propertyKey )로 설정합니다.kPresent 가 true 이면, 다음을 수행합니다.accumulator 를 ? Get (obj , propertyKey )로 설정합니다.k 를 k + 1로 설정합니다.kPresent 가 false 이면 TypeError 예외를 던집니다. k < length 인 동안 다음을 반복합니다.propertyKey 를 ! ToString (𝔽 (k ))로 둡니다.kPresent 를 ? HasProperty (obj , propertyKey )로 둡니다.kPresent 가 true 이면, 다음을 수행합니다.kValue 를 ? Get (obj , propertyKey )로 둡니다.accumulator 를 ? Call (callback , undefined , « accumulator , kValue , 𝔽 (k ), obj »)로 설정합니다.k 를 k + 1로 설정합니다.accumulator 를 반환합니다.
참고 2
이 메서드는 의도적으로 일반적이며 this 값이 Array일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
23.1.3.25 Array.prototype.reduceRight ( callback [ , initialValue ] )
참고 1
callback 은 네 인수를 받는 함수여야 합니다. reduceRight는 배열에 존재하는 각 요소에 대해 내림차순으로 callback 을 한 번씩 호출하며, initialValue 가 제공되지 않은 경우 첫 번째 호출을 건너뜁니다.
callback 은 previousValue (callback 을 이전에 호출한 결과 값), currentValue (현재 요소의 값), currentIndex , 순회 중인 객체라는 네 인수로 호출됩니다. 함수가 처음 호출될 때 previousValue 와 currentValue 는 두 가지 경우 중 하나가 될 수 있습니다. reduceRight 호출에 initialValue 가 제공되었다면 previousValue 는 initialValue 이고 currentValue 는 배열의 마지막 값입니다. initialValue 가 제공되지 않았다면 previousValue 는 배열의 마지막 값이고 currentValue 는 끝에서 두 번째 값입니다. 배열에 요소가 없고 initialValue 가 제공되지 않으면 TypeError 입니다.
reduceRight는 호출된 객체를 직접 변경하지 않지만 callback 호출에 의해 객체가 변경될 수 있습니다.
reduceRight가 처리할 요소의 범위는 callback 을 처음 호출하기 전에 설정됩니다. reduceRight 호출이 시작된 후 배열에 추가된 요소는 callback 이 방문하지 않습니다. 배열의 기존 요소가 callback 에 의해 변경되면 callback 에 전달되는 값은 reduceRight가 해당 요소를 방문할 때의 값입니다. reduceRight 호출이 시작된 후 방문되기 전에 삭제된 요소는 방문되지 않습니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.length 를 ? LengthOfArrayLike (obj )로 둡니다.IsCallable (callback )이 false 이면 TypeError 예외를 던집니다.length = 0이고 initialValue 가 존재하지 않으면 TypeError 예외를 던집니다.k 를 length - 1로 둡니다.accumulator 를 undefined 로 둡니다.initialValue 가 존재하면, 다음을 수행합니다.accumulator 를 initialValue 로 설정합니다.그렇지 않으면,kPresent 를 false 로 둡니다.kPresent 가 false 이고 k ≥ 0인 동안 다음을 반복합니다.propertyKey 를 ! ToString (𝔽 (k ))로 둡니다.kPresent 를 ? HasProperty (obj , propertyKey )로 설정합니다.kPresent 가 true 이면, 다음을 수행합니다.accumulator 를 ? Get (obj , propertyKey )로 설정합니다.k 를 k - 1로 설정합니다.kPresent 가 false 이면 TypeError 예외를 던집니다. k ≥ 0인 동안 다음을 반복합니다.propertyKey 를 ! ToString (𝔽 (k ))로 둡니다.kPresent 를 ? HasProperty (obj , propertyKey )로 둡니다.kPresent 가 true 이면, 다음을 수행합니다.kValue 를 ? Get (obj , propertyKey )로 둡니다.accumulator 를 ? Call (callback , undefined , « accumulator , kValue , 𝔽 (k ), obj »)로 설정합니다.k 를 k - 1로 설정합니다.accumulator 를 반환합니다.
참고 2
이 메서드는 의도적으로 일반적이며 this 값이 Array일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
23.1.3.26 Array.prototype.reverse ( )
참고 1
이 메서드는 배열 요소의 순서를 반대로 재배열합니다. 반전된 배열을 반환합니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.length 를 ? LengthOfArrayLike (obj )로 둡니다.middle 을 floor (length / 2)로 둡니다.lower 를 0으로 둡니다.lower ≠ middle 인 동안 다음을 반복합니다.upper 를 length - lower - 1로 둡니다.upperP 를 ! ToString (𝔽 (upper ))로 둡니다.lowerP 를 ! ToString (𝔽 (lower ))로 둡니다.lowerExists 를 ? HasProperty (obj , lowerP )로 둡니다.lowerExists 가 true 이면, 다음을 수행합니다.lowerValue 를 ? Get (obj , lowerP )로 둡니다.upperExists 를 ? HasProperty (obj , upperP )로 둡니다.upperExists 가 true 이면, 다음을 수행합니다.upperValue 를 ? Get (obj , upperP )로 둡니다.lowerExists 가 true 이고 upperExists 가 true 이면, 다음을 수행합니다.? Set (obj , lowerP , upperValue , true )를 수행합니다. ? Set (obj , upperP , lowerValue , true )를 수행합니다. 그렇지 않고 lowerExists 가 false 이고 upperExists 가 true 이면, 다음을 수행합니다.? Set (obj , lowerP , upperValue , true )를 수행합니다. ? DeletePropertyOrThrow (obj , upperP )를 수행합니다. 그렇지 않고 lowerExists 가 true 이고 upperExists 가 false 이면, 다음을 수행합니다.? DeletePropertyOrThrow (obj , lowerP )를 수행합니다. ? Set (obj , upperP , lowerValue , true )를 수행합니다. 그렇지 않으면,단언 : lowerExists 와 upperExists 는 모두 false 입니다.참고 : 어떤 동작도 필요하지 않습니다. lower 를 lower + 1로 설정합니다.obj 를 반환합니다.
참고 2
이 메서드는 의도적으로 일반적이며 this 값이 Array일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
23.1.3.27 Array.prototype.shift ( )
이 메서드는 배열의 첫 번째 요소를 제거하고 반환합니다.
호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.length 를 ? LengthOfArrayLike (obj )로 둡니다.length = 0이면, 다음을 수행합니다.? Set (obj , "length" , +0 𝔽 , true )를 수행합니다. undefined 를 반환합니다.first 를 ? Get (obj , "0" )로 둡니다.k 를 1로 둡니다.k < length 인 동안 다음을 반복합니다.from 을 ! ToString (𝔽 (k ))로 둡니다.to 를 ! ToString (𝔽 (k - 1))로 둡니다.fromPresent 를 ? HasProperty (obj , from )로 둡니다.fromPresent 가 true 이면, 다음을 수행합니다.fromValue 를 ? Get (obj , from )로 둡니다.? Set (obj , to , fromValue , true )를 수행합니다. 그렇지 않으면,단언 : fromPresent 는 false 입니다.? DeletePropertyOrThrow (obj , to )를 수행합니다. k 를 k + 1로 설정합니다.? DeletePropertyOrThrow (obj , ! ToString (𝔽 (length - 1)))를 수행합니다. ? Set (obj , "length" , 𝔽 (length - 1), true )를 수행합니다. first 를 반환합니다.
참고
이 메서드는 의도적으로 일반적이며 this 값이 Array일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
23.1.3.28 Array.prototype.slice ( start , end )
이 메서드는 배열의 요소 start 부터 요소 end 직전까지(end 가 undefined 이면 배열의 끝까지)의 요소를 포함하는 배열을 반환합니다. start 가 음수이면 배열의 길이인 length 에 대해 length + start 로 처리합니다. end 가 음수이면 배열의 길이인 length 에 대해 length + end 로 처리합니다.
호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.length 를 ? LengthOfArrayLike (obj )로 둡니다.k 를 ? ToClampedIndex (start , length )로 둡니다.end 가 undefined 이면 final 을 length 로 둡니다. 그렇지 않으면 final 을 ? ToClampedIndex (end , length )로 둡니다.count 를 max (final - k , 0)으로 둡니다.array 를 ? ArraySpeciesCreate (obj , count )로 둡니다.resultIndex 를 0으로 둡니다.k < final 인 동안 다음을 반복합니다.propertyKey 를 ! ToString (𝔽 (k ))로 둡니다.kPresent 를 ? HasProperty (obj , propertyKey )로 둡니다.kPresent 가 true 이면, 다음을 수행합니다.kValue 를 ? Get (obj , propertyKey )로 둡니다.? CreateDataPropertyOrThrow (array , ! ToString (𝔽 (resultIndex )), kValue )를 수행합니다. k 를 k + 1로 설정합니다.resultIndex 를 resultIndex + 1로 설정합니다.? Set (array , "length" , 𝔽 (resultIndex ), true )를 수행합니다. array 를 반환합니다.
참고 1
9 단계에서 "length" 프로퍼티를 명시적으로 설정하는 것은 array 가 내장 Array가 아닌 경우에도 길이가 올바르도록 보장하기 위한 것입니다.
참고 2
이 메서드는 의도적으로 일반적이며 this 값이 Array일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
23.1.3.29 Array.prototype.some ( callback [ , thisArg ] )
참고 1
callback 은 세 인수를 받고 Boolean 값으로 강제 변환할 수 있는 값을 반환하는 함수여야 합니다. some은 callback 이 true 를 반환하는 요소를 찾을 때까지 배열에 존재하는 각 요소에 대해 오름차순으로 callback 을 한 번씩 호출합니다. 그러한 요소를 찾으면 some은 즉시 true 를 반환합니다. 그렇지 않으면 some은 false 를 반환합니다. callback 은 배열에 실제로 존재하는 요소에 대해서만 호출되며, 존재하지 않는 요소에 대해서는 호출되지 않습니다.
thisArg 매개변수가 제공되면 callback 을 호출할 때마다 this 값으로 사용됩니다. 제공되지 않으면 대신 undefined 를 사용합니다.
callback 은 요소의 값, 요소의 인덱스, 순회 중인 객체라는 세 인수로 호출됩니다.
some은 호출된 객체를 직접 변경하지 않지만 callback 호출에 의해 객체가 변경될 수 있습니다.
some이 처리할 요소의 범위는 callback 을 처음 호출하기 전에 설정됩니다. some 호출이 시작된 후 배열에 추가된 요소는 callback 이 방문하지 않습니다. 배열의 기존 요소가 변경되면 callback 에 전달되는 값은 some이 해당 요소를 방문할 때의 값입니다. some 호출이 시작된 후 방문되기 전에 삭제된 요소는 방문되지 않습니다. some은 수학의 “존재한다” 한정자처럼 동작합니다. 특히 빈 배열에서는 false 를 반환합니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.length 를 ? LengthOfArrayLike (obj )로 둡니다.IsCallable (callback )이 false 이면 TypeError 예외를 던집니다.k 를 0으로 둡니다.k < length 인 동안 다음을 반복합니다.propertyKey 를 ! ToString (𝔽 (k ))로 둡니다.kPresent 를 ? HasProperty (obj , propertyKey )로 둡니다.kPresent 가 true 이면, 다음을 수행합니다.kValue 를 ? Get (obj , propertyKey )로 둡니다.testResult 를 ToBoolean (? Call (callback , thisArg , « kValue , 𝔽 (k ), obj »))로 둡니다.testResult 가 true 이면 true 를 반환합니다.k 를 k + 1로 설정합니다.false 를 반환합니다.
참고 2
이 메서드는 의도적으로 일반적이며 this 값이 Array일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
23.1.3.30 Array.prototype.sort ( comparator )
이 메서드는 이 배열의 요소를 정렬합니다. comparator 가 undefined 가 아니면 두 인수 x 와 y 를 받고 x < y 이면 음수 Number, x > y 이면 양수 Number, 그 밖의 경우 0을 반환하는 함수여야 합니다.
호출되면 다음 단계를 수행합니다:
comparator 가 undefined 가 아니고 IsCallable (comparator )이 false 이면 TypeError 예외를 던집니다.obj 를 ? ToObject (this 값)으로 둡니다.length 를 ? LengthOfArrayLike (obj )로 둡니다.sortCompare 를 comparator 를 캡처하고 호출될 때 다음 단계를 수행하는 매개변수 (x , y )를 갖는 새로운 Abstract Closure 로 둡니다:? CompareArrayElements (x , y , comparator )를 반환합니다. sortedList 를 ? SortIndexedProperties (obj , length , sortCompare , skip-holes )로 둡니다.itemCount 를 sortedList 의 요소 수로 둡니다.j 를 0으로 둡니다.j < itemCount 인 동안 다음을 반복합니다.? Set (obj , ! ToString (𝔽 (j )), sortedList [j ], true )를 수행합니다. j 를 j + 1로 설정합니다.참고 : 5 단계의 SortIndexedProperties 호출은 skip-holes 를 사용합니다. 감지되어 정렬에서 제외된 빈 슬롯의 수를 보존하기 위해 남은 인덱스를 삭제합니다.j < length 인 동안 다음을 반복합니다.? DeletePropertyOrThrow (obj , ! ToString (𝔽 (j )))를 수행합니다. j 를 j + 1로 설정합니다.obj 를 반환합니다.
참고 1
존재하지 않는 프로퍼티 값은 항상 undefined 프로퍼티 값보다 큰 것으로 비교되고, undefined 는 항상 다른 모든 값보다 큰 것으로 비교되므로(CompareArrayElements 참조), undefined 프로퍼티 값은 항상 결과의 끝으로 정렬되고 그 뒤에 존재하지 않는 프로퍼티 값이 옵니다.
참고 2
5 및 6 단계의 ToString 추상 연산 이 수행하는 메서드 호출로 인해 sortCompare 가 일관된 비교기 로 동작하지 않을 수 있습니다.
참고 3
이 메서드는 의도적으로 일반적이며 this 값이 Array일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
23.1.3.30.1 SortIndexedProperties ( obj , length , sortCompare , holes )
추상 연산 SortIndexedProperties. 인수 obj (Object), length (음이 아닌 정수), sortCompare (매개변수가 두 개인 추상 클로저 ) 및 holes ((skip-holes 또는 read-through-holes )). 반환값: (정상 완료 (값: 리스트 (요소: ECMAScript 언어 값 )) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
items 를 새로운 빈 List 로 둡니다.k 를 0으로 둡니다.k < length 인 동안 다음을 반복합니다.propertyKey 를 ! ToString (𝔽 (k ))로 둡니다.holes 가 skip-holes 이면, 다음을 수행합니다.kRead 를 ? HasProperty (obj , propertyKey )로 둡니다.그렇지 않으면,단언 : holes 는 read-through-holes 입니다.kRead 를 true 로 둡니다. kRead 가 true 이면, 다음을 수행합니다.kValue 를 ? Get (obj , propertyKey )로 둡니다.kValue 를 items 에 추가합니다.k 를 k + 1로 설정합니다.구현체 정의 순서의 sortCompare 호출 을 사용하여 items 를 정렬합니다. 그러한 호출 중 하나가 갑작스러운 완료를 반환하면 sortCompare 에 대한 추가 호출을 수행하기 전에 중단하고 해당 Completion Record 를 반환합니다.items 를 반환합니다.
정렬 순서 는 위 알고리즘의 4 단계가 완료된 후의 items 순서입니다. sortCompare 가 items 요소에 대해 일관된 비교기 가 아니면 정렬 순서 는 구현체 정의 입니다. SortIndexedProperties가 Array.prototype.sort 또는 Array.prototype.toSorted 에 의해 호출될 때, comparator 가 undefined 이고 sortCompare 에 인수로 전달된 특정 값에 대한 모든 ToString 적용이 동일한 결과를 생성하지 않는 경우에도 정렬 순서 는 구현체 정의 입니다.
정렬 순서 가 구현체 정의 라고 명시되지 않는 한 다음 조건을 모두 만족해야 합니다:
itemCount 보다 작은 음이 아닌 정수 의 어떤 수학적 순열 π가 존재하여, itemCount 보다 작은 모든 음이 아닌 정수 j 에 대해 요소 old[j ] 가 new[π(j )] 와 정확히 같아야 합니다.
그러면 각각 itemCount 보다 작은 모든 음이 아닌 정수 j 와 k 에 대해 ℝ (sortCompare (old[j ], old[k ])) < 0 이면 π(j ) < π(k ) 입니다.
또한 j < k < itemCount 를 만족하는 모든 음이 아닌 정수 j 와 k 에 대해 ℝ (sortCompare (old[j ], old[k ])) = 0 이면 π(j ) < π(k ) 입니다. 즉, 정렬은 안정적입니다.
여기서 표기 old[j ] 는 4 단계가 실행되기 전의 items [j ] 를, 표기 new[j ] 는 4 단계가 실행된 후의 items [j ] 를 나타내는 데 사용됩니다.
Abstract Closure 또는 함수 comparator 는 집합 values 안의 모든 값 a , b , c (같은 값일 수도 있음)에 대해 아래 요구 사항을 모두 만족하면 값 집합 values 의 일관된 비교기 입니다. 표기 a <C b 는 ℝ (comparator (a , b )) < 0 을 의미하고, a =C b 는 ℝ (comparator (a , b )) = 0 을 의미하며, a >C b 는 ℝ (comparator (a , b )) > 0 을 의미합니다.
특정 값 쌍 a 와 b 를 두 인수로 제공하면 comparator (a , b ) 호출은 항상 동일한 값 v 를 반환합니다. 또한 v 는 Number이고 NaN 이 아닙니다. 이는 주어진 a 와 b 쌍에 대해 a <C b , a =C b , a >C b 중 정확히 하나만 참임을 의미합니다.
comparator (a , b ) 호출은 obj 또는 obj 의 프로토타입 체인에 있는 어떤 객체도 변경하지 않습니다.
a =C a (반사성)
a =C b 이면 b =C a 입니다(대칭성).
a =C b 이고 b =C c 이면 a =C c 입니다(=C 의 추이성).
a <C b 이고 b <C c 이면 a <C c 입니다(<C 의 추이성).
a >C b 이고 b >C c 이면 a >C c 입니다(>C 의 추이성).
참고
위 조건은 comparator 가 집합 values 를 동치류로 나누고 이러한 동치류가 전순서를 이루도록 보장하기 위한 필요충분조건입니다.
23.1.3.30.2 CompareArrayElements ( x , y , comparator )
추상 연산 CompareArrayElements. 인수 x (ECMAScript 언어 값 ), y (ECMAScript 언어 값 ) 및 comparator ((함수 객체 또는 undefined )). 반환값: (정상 완료 (값: Number) 또는 중도 완료). 호출되면 다음 단계를 수행한다.
x 가 undefined 이고 y 가 undefined 이면 +0 𝔽 을 반환합니다.x 가 undefined 이면 1 𝔽 을 반환합니다.y 가 undefined 이면 -1 𝔽 을 반환합니다.comparator 가 undefined 가 아니면, 다음을 수행합니다.result 를 ? ToNumber (? Call (comparator , undefined , « x , y »))로 둡니다.result 가 NaN 이면 +0 𝔽 을 반환합니다.result 를 반환합니다.xString 을 ? ToString (x )로 둡니다.yString 을 ? ToString (y )로 둡니다.xSmaller 를 ! IsLessThan (xString , yString , true )로 둡니다.xSmaller 가 true 이면 -1 𝔽 을 반환합니다.ySmaller 를 ! IsLessThan (yString , xString , true )로 둡니다.ySmaller 가 true 이면 1 𝔽 을 반환합니다.+0 𝔽 을 반환합니다.
23.1.3.31 Array.prototype.splice ( start , deleteCount , ...items )
참고 1
이 메서드는 정수 인덱스 start 에서 시작하는 배열의 deleteCount 개 요소를 삭제하고 이를 items 의 요소로 대체합니다. 삭제된 요소가 있으면 이를 포함하는 Array를 반환합니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.length 를 ? LengthOfArrayLike (obj )로 둡니다.actualStart 를 ? ToClampedIndex (start , length )로 둡니다.itemCount 를 items 의 요소 수로 둡니다.start 가 존재하지 않으면, 다음을 수행합니다.actualDeleteCount 를 0으로 둡니다.그렇지 않고 deleteCount 가 존재하지 않으면, 다음을 수행합니다.actualDeleteCount 를 length - actualStart 로 둡니다.단언 : actualDeleteCount ≥ 0입니다. 그렇지 않으면,dc 를 ? ToIntegerOrInfinity (deleteCount )로 둡니다.actualDeleteCount 를 dc 를 0과 length - actualStart 사이로 제한한 결과로 둡니다. length + itemCount - actualDeleteCount > 253 - 1이면 TypeError 예외를 던집니다.deletedArray 를 ? ArraySpeciesCreate (obj , actualDeleteCount )로 둡니다.k 를 0으로 둡니다.k < actualDeleteCount 인 동안 다음을 반복합니다.from 을 ! ToString (𝔽 (actualStart + k ))로 둡니다.? HasProperty (obj , from )가 true 이면, 다음을 수행합니다.fromValue 를 ? Get (obj , from )로 둡니다.? CreateDataPropertyOrThrow (deletedArray , ! ToString (𝔽 (k )), fromValue )를 수행합니다. k 를 k + 1로 설정합니다.? Set (deletedArray , "length" , 𝔽 (actualDeleteCount ), true )를 수행합니다. itemCount < actualDeleteCount 이면, 다음을 수행합니다.k 를 actualStart 로 설정합니다.k < (length - actualDeleteCount )인 동안 다음을 반복합니다.from 을 ! ToString (𝔽 (k + actualDeleteCount ))로 둡니다.to 를 ! ToString (𝔽 (k + itemCount ))로 둡니다.? HasProperty (obj , from )가 true 이면, 다음을 수행합니다.fromValue 를 ? Get (obj , from )로 둡니다.? Set (obj , to , fromValue , true )를 수행합니다. 그렇지 않으면,? DeletePropertyOrThrow (obj , to )를 수행합니다. k 를 k + 1로 설정합니다.k 를 length 로 설정합니다.k > (length - actualDeleteCount + itemCount )인 동안 다음을 반복합니다.? DeletePropertyOrThrow (obj , ! ToString (𝔽 (k - 1)))를 수행합니다. k 를 k - 1로 설정합니다.그렇지 않고 itemCount > actualDeleteCount 이면, 다음을 수행합니다.k 를 (length - actualDeleteCount )로 설정합니다.k > actualStart 인 동안 다음을 반복합니다.from 을 ! ToString (𝔽 (k + actualDeleteCount - 1))로 둡니다.to 를 ! ToString (𝔽 (k + itemCount - 1))로 둡니다.? HasProperty (obj , from )가 true 이면, 다음을 수행합니다.fromValue 를 ? Get (obj , from )로 둡니다.? Set (obj , to , fromValue , true )를 수행합니다. 그렇지 않으면,? DeletePropertyOrThrow (obj , to )를 수행합니다. k 를 k - 1로 설정합니다. k 를 actualStart 로 설정합니다.items 의 각 요소 item 에 대해 다음을 수행합니다.? Set (obj , ! ToString (𝔽 (k )), item , true )를 수행합니다. k 를 k + 1로 설정합니다.? Set (obj , "length" , 𝔽 (length - actualDeleteCount + itemCount ), true )를 수행합니다. deletedArray 를 반환합니다.
참고 2
12 및 17 단계에서 "length" 프로퍼티를 명시적으로 설정하는 것은 객체가 내장 Array가 아닌 경우에도 길이가 올바르도록 보장하기 위한 것입니다.
참고 3
이 메서드는 의도적으로 일반적이며 this 값이 Array일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
23.1.3.32 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )
ECMA-402 국제화 API를 포함하는 ECMAScript 구현체는 ECMA-402에 명시된 대로 이 메서드를 구현해야 합니다. 그렇지 않으면 다음과 같은 이 메서드 명세가 사용됩니다.
참고 1
ECMA-402의 초판에는 이 메서드에 대한 대체 명세가 포함되어 있지 않았습니다.
이 메서드의 선택적 매개변수의 의미는 ECMA-402에 정의되어 있습니다. ECMA-402 지원을 포함하지 않는 구현체는 해당 매개변수 위치를 다른 용도로 사용해서는 안 됩니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
array 를 ? ToObject (this 값)으로 둡니다.length 를 ? LengthOfArrayLike (array )로 둡니다.? JoinIndexedProperties (array , length , LocalizedListSeparator (), "toLocaleString" )을 반환합니다.
참고 2
이 메서드는 toString과 유사하지만, 호스트 환경 의 현재 로캘 관례에 따라 로캘에 민감한 결과를 생성하도록 설계되었습니다.
참고 3
이 메서드는 의도적으로 범용적으로 설계되었으며, this 값이 Array일 필요는 없습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
23.1.3.32.1 LocalizedListSeparator ( )
구현 정의 추상 연산 LocalizedListSeparator. 인수 없음. 반환값: String. 호스트 환경 의 현재 로캘에서 목록 구분자로 사용하기에 적합한 구현 정의 String(예: ", " )을 반환합니다.
23.1.3.33 Array.prototype.toReversed ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.length 를 ? LengthOfArrayLike (obj )로 둡니다.array 를 ? ArrayCreate (length )로 둡니다.k 를 0으로 둡니다.k < length 인 동안 다음을 반복합니다.from 을 ! ToString (𝔽 (length - k - 1))로 둡니다.propertyKey 를 ! ToString (𝔽 (k ))로 둡니다.fromValue 를 ? Get (obj , from )로 둡니다.! CreateDataPropertyOrThrow (array , propertyKey , fromValue )를 수행합니다. k 를 k + 1로 설정합니다.array 를 반환합니다.
23.1.3.34 Array.prototype.toSorted ( comparator )
이 메서드는 호출되면 다음 단계를 수행합니다:
comparator 가 undefined 가 아니고 IsCallable (comparator )이 false 이면 TypeError 예외를 던집니다.obj 를 ? ToObject (this 값)으로 둡니다.length 를 ? LengthOfArrayLike (obj )로 둡니다.array 를 ? ArrayCreate (length )로 둡니다.sortCompare 를 comparator 를 캡처하고 호출될 때 다음 단계를 수행하는 매개변수 (x , y )를 갖는 새로운 Abstract Closure 로 둡니다:? CompareArrayElements (x , y , comparator )를 반환합니다. sortedList 를 ? SortIndexedProperties (obj , length , sortCompare , read-through-holes )로 둡니다.j 를 0으로 둡니다.j < length 인 동안 다음을 반복합니다.! CreateDataPropertyOrThrow (array , ! ToString (𝔽 (j )), sortedList [j ])를 수행합니다. j 를 j + 1로 설정합니다.array 를 반환합니다.
23.1.3.35 Array.prototype.toSpliced ( start , skipCount , ...items )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.length 를 ? LengthOfArrayLike (obj )로 둡니다.actualStart 를 ? ToClampedIndex (start , length )로 둡니다.insertCount 를 items 의 요소 수로 둡니다.maxSkipCount 를 length - actualStart 로 둡니다.start 가 존재하지 않으면, 다음을 수행합니다.actualSkipCount 를 0으로 둡니다.그렇지 않고 skipCount 가 존재하지 않으면, 다음을 수행합니다.actualSkipCount 를 maxSkipCount 로 둡니다. 그렇지 않으면,actualSkipCount 를 ? ToIntegerOrInfinity (skipCount )을 0과 maxSkipCount 사이로 제한한 결과로 둡니다. newLength 를 length + insertCount - actualSkipCount 로 둡니다.단언 : newLength ≥ 0입니다.newLength > 253 - 1이면 TypeError 예외를 던집니다.newArray 를 ? ArrayCreate (newLength )로 둡니다.writeIndex 를 0으로 둡니다.readIndex 를 actualStart + actualSkipCount 로 둡니다.writeIndex < actualStart 인 동안 다음을 반복합니다.propertyKey 를 ! ToString (𝔽 (writeIndex ))로 둡니다.iValue 를 ? Get (obj , propertyKey )로 둡니다.! CreateDataPropertyOrThrow (newArray , propertyKey , iValue )를 수행합니다. writeIndex 를 writeIndex + 1로 설정합니다.items 의 각 요소 item 에 대해 다음을 수행합니다.propertyKey 를 ! ToString (𝔽 (writeIndex ))로 둡니다.! CreateDataPropertyOrThrow (newArray , propertyKey , item )을 수행합니다. writeIndex 를 writeIndex + 1로 설정합니다.writeIndex < newLength 인 동안 다음을 반복합니다.propertyKey 를 ! ToString (𝔽 (writeIndex ))로 둡니다.from 을 ! ToString (𝔽 (readIndex ))로 둡니다.fromValue 를 ? Get (obj , from )로 둡니다.! CreateDataPropertyOrThrow (newArray , propertyKey , fromValue )를 수행합니다. writeIndex 를 writeIndex + 1로 설정합니다.readIndex 를 readIndex + 1로 설정합니다.newArray 를 반환합니다.
23.1.3.36 Array.prototype.toString ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
array 를 ? ToObject (this 값)으로 둡니다.func 를 ? Get (array , "join" )로 둡니다.IsCallable (func )이 false 이면 func 를 내재 함수 %Object.prototype.toString%으로 설정합니다.? Call (func , array )를 반환합니다.
참고
이 메서드는 의도적으로 일반적이며 this 값이 Array일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
23.1.3.37 Array.prototype.unshift ( ...items )
이 메서드는 인수를 배열의 시작 부분에 추가하며, 배열 안에서의 순서는 인수 목록에 나타나는 순서와 같습니다.
호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.length 를 ? LengthOfArrayLike (obj )로 둡니다.argCount 를 items 의 요소 수로 둡니다.argCount > 0이면, 다음을 수행합니다.length + argCount > 253 - 1이면 TypeError 예외를 던집니다.k 를 length 로 둡니다.k > 0인 동안 다음을 반복합니다.from 을 ! ToString (𝔽 (k - 1))로 둡니다.to 를 ! ToString (𝔽 (k + argCount - 1))로 둡니다.fromPresent 를 ? HasProperty (obj , from )로 둡니다.fromPresent 가 true 이면, 다음을 수행합니다.fromValue 를 ? Get (obj , from )로 둡니다.? Set (obj , to , fromValue , true )를 수행합니다. 그렇지 않으면,단언 : fromPresent 는 false 입니다.? DeletePropertyOrThrow (obj , to )를 수행합니다. k 를 k - 1로 설정합니다.j 를 0으로 둡니다.items 의 각 요소 item 에 대해 다음을 수행합니다.? Set (obj , ! ToString (𝔽 (j )), item , true )를 수행합니다. j 를 j + 1로 설정합니다.? Set (obj , "length" , 𝔽 (length + argCount ), true )를 수행합니다. 𝔽 (length + argCount )를 반환합니다.
이 메서드의 "length" 프로퍼티는 1 𝔽 입니다.
참고
이 메서드는 의도적으로 일반적이며 this 값이 Array일 것을 요구하지 않습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
23.1.3.38 Array.prototype.values ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.CreateArrayIterator (obj , value )를 반환합니다.
23.1.3.39 Array.prototype.with ( index , value )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 ? ToObject (this 값)으로 둡니다.length 를 ? LengthOfArrayLike (obj )로 둡니다.actualIndex 를 ? ToAbsoluteIndex (index , length )로 둡니다.actualIndex < 0 또는 actualIndex ≥ length 이면 RangeError 예외를 던집니다.array 를 ? ArrayCreate (length )로 둡니다.k 를 0으로 둡니다.k < length 인 동안 다음을 반복합니다.propertyKey 를 ! ToString (𝔽 (k ))로 둡니다.k = actualIndex 이면 fromValue 를 value 로 둡니다.그렇지 않으면 fromValue 를 ? Get (obj , propertyKey )로 둡니다. ! CreateDataPropertyOrThrow (array , propertyKey , fromValue )를 수행합니다. k 를 k + 1로 설정합니다.array 를 반환합니다.
23.1.3.40 Array.prototype [ %Symbol.iterator% ] ( )
%Symbol.iterator% 프로퍼티의 초기 값은 23.1.3.38 에 정의된 %Array.prototype.values%입니다.
23.1.3.41 Array.prototype [ %Symbol.unscopables% ]
%Symbol.unscopables% 데이터 프로퍼티 의 초기 값은 다음 단계로 생성된 객체입니다:
unscopableList 를 OrdinaryObjectCreate (null )로 둡니다.! CreateDataPropertyOrThrow (unscopableList , "at" , true )를 수행합니다. ! CreateDataPropertyOrThrow (unscopableList , "copyWithin" , true )를 수행합니다. ! CreateDataPropertyOrThrow (unscopableList , "entries" , true )를 수행합니다. ! CreateDataPropertyOrThrow (unscopableList , "fill" , true )를 수행합니다. ! CreateDataPropertyOrThrow (unscopableList , "find" , true )를 수행합니다. ! CreateDataPropertyOrThrow (unscopableList , "findIndex" , true )를 수행합니다. ! CreateDataPropertyOrThrow (unscopableList , "findLast" , true )를 수행합니다. ! CreateDataPropertyOrThrow (unscopableList , "findLastIndex" , true )를 수행합니다. ! CreateDataPropertyOrThrow (unscopableList , "flat" , true )를 수행합니다. ! CreateDataPropertyOrThrow (unscopableList , "flatMap" , true )를 수행합니다. ! CreateDataPropertyOrThrow (unscopableList , "includes" , true )를 수행합니다. ! CreateDataPropertyOrThrow (unscopableList , "keys" , true )를 수행합니다. ! CreateDataPropertyOrThrow (unscopableList , "toReversed" , true )를 수행합니다. ! CreateDataPropertyOrThrow (unscopableList , "toSorted" , true )를 수행합니다. ! CreateDataPropertyOrThrow (unscopableList , "toSpliced" , true )를 수행합니다. ! CreateDataPropertyOrThrow (unscopableList , "values" , true )를 수행합니다. unscopableList 를 반환합니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
참고
이 객체의 자체 프로퍼티 이름 은 ECMAScript 2015 명세 이전에 Array.prototype의 표준 프로퍼티로 포함되지 않았던 프로퍼티 이름 입니다. 이러한 이름 중 하나를 외부 스코프의 바인딩으로 사용하는 기존 코드에서, 바인딩 객체가 Array인 with 문이 해당 바인딩을 가리는 경우의 동작을 보존하기 위해 이 이름들은 with 문 바인딩에서 무시됩니다.
"with" 가 unscopableList 에 포함되지 않은 이유는 이미 예약어 이기 때문입니다.
23.1.4 Array 인스턴스의 프로퍼티
Array 인스턴스는 Array 특수 객체 이며 그러한 객체에 지정된 내부 메서드를 갖습니다. Array 인스턴스는 Array 프로토타입 객체 에서 프로퍼티를 상속합니다.
Array 인스턴스에는 "length" 프로퍼티와 배열 인덱스 이름을 갖는 열거 가능한 프로퍼티 집합이 있습니다.
23.1.4.1 length
Array 인스턴스의 "length" 프로퍼티는 이름이 배열 인덱스 인 모든 설정 가능한 자체 프로퍼티 이름 보다 항상 숫자적으로 큰 값을 갖는 데이터 프로퍼티 입니다.
"length" 프로퍼티는 처음에 { [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
참고
"length" 프로퍼티 값을 줄이면 배열 인덱스 가 이전 길이 값과 새 길이 값 사이에 있는 자체 배열 요소가 삭제되는 부수 효과가 있습니다. 그러나 설정 불가능한 프로퍼티는 삭제할 수 없습니다. Array의 "length" 프로퍼티를 배열의 기존 설정 불가능한 배열 인덱스 프로퍼티 중 가장 큰 숫자 자체 프로퍼티 이름 이하의 값으로 설정하려고 하면, 길이는 해당 설정 불가능한 숫자 자체 프로퍼티 이름 보다 1 큰 숫자 값으로 설정됩니다. 10.4.2.1 를 참조하시기 바랍니다.
23.1.5 Array Iterator 객체
Array Iterator 는 특정 Array 인스턴스 객체에 대한 특정 순회를 나타내는 객체입니다. Array Iterator 객체에는 이름 있는 생성자 가 없습니다. 대신 Array Iterator 객체는 Array 인스턴스 객체의 특정 메서드를 호출하여 생성됩니다.
23.1.5.1 CreateArrayIterator ( array , kind )
추상 연산 CreateArrayIterator. 인수 array (Object) 및 kind ((key+value , key 또는 value )). 반환값: Object. 그러한 반복자를 반환하는 Array 메서드의 반복자 객체를 생성하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
iterator 를 OrdinaryObjectCreate (%ArrayIteratorPrototype% , « [[IteratedArrayLike]] , [[ArrayLikeNextIndex]] , [[ArrayLikeIterationKind]] »)로 둡니다.iterator .[[IteratedArrayLike]] 를 array 로 설정합니다.iterator .[[ArrayLikeNextIndex]] 를 0으로 설정합니다.iterator .[[ArrayLikeIterationKind]] 를 kind 로 설정합니다.iterator 를 반환합니다.
23.1.5.2 %ArrayIteratorPrototype% 객체
%ArrayIteratorPrototype% 객체는:
23.1.5.2.1 %ArrayIteratorPrototype%.next ( )
iteratorObj 를 this 값으로 둡니다.iteratorObj 가 Object가 아니면 TypeError 예외를 던집니다.iteratorObj 가 Array Iterator Instance의 모든 내부 슬롯(23.1.5.3 )을 갖지 않으면 TypeError 예외를 던집니다.array 를 iteratorObj .[[IteratedArrayLike]] 로 둡니다.array 가 undefined 이면 CreateIteratorResultObject (undefined , true )를 반환합니다.index 를 iteratorObj .[[ArrayLikeNextIndex]] 로 둡니다.kind 를 iteratorObj .[[ArrayLikeIterationKind]] 로 둡니다.array 에 [[TypedArrayName]] 내부 슬롯이 있으면, 다음을 수행합니다.taRecord 를 ? ValidateTypedArrayBounds (array , seq-cst )로 둡니다.length 를 TypedArrayLength (taRecord )로 둡니다.그렇지 않으면,length 를 ? LengthOfArrayLike (array )로 둡니다. index ≥ length 이면, 다음을 수행합니다.iteratorObj .[[IteratedArrayLike]] 를 undefined 로 설정합니다.CreateIteratorResultObject (undefined , true )를 반환합니다.iteratorObj .[[ArrayLikeNextIndex]] 를 index + 1로 설정합니다.indexNumber 를 𝔽 (index )로 둡니다.kind 가 key 이면, 다음을 수행합니다.result 를 indexNumber 로 둡니다.그렇지 않으면,elementKey 를 ! ToString (indexNumber )로 둡니다.elementValue 를 ? Get (array , elementKey )로 둡니다.kind 가 value 이면, 다음을 수행합니다.result 를 elementValue 로 둡니다.그렇지 않으면,단언 : kind 는 key+value 입니다.result 를 CreateArrayFromList (« indexNumber , elementValue »)로 둡니다. CreateIteratorResultObject (result , false )를 반환합니다.
23.1.5.2.2 %ArrayIteratorPrototype% [ %Symbol.toStringTag% ]
%Symbol.toStringTag% 프로퍼티의 초기 값은 String 값 "Array Iterator" 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
23.1.5.3 Array Iterator 인스턴스의 프로퍼티
Array Iterator 인스턴스는 %ArrayIteratorPrototype% 내재 객체에서 프로퍼티를 상속하는 일반 객체 입니다. Array Iterator 인스턴스는 처음에 표 70 에 나열된 내부 슬롯을 갖도록 생성됩니다.
표 70: Array Iterator 인스턴스의 내부 슬롯
내부 슬롯
타입
설명
[[IteratedArrayLike]]
an Object or undefined
순회 중인 배열과 유사한 객체 입니다.
[[ArrayLikeNextIndex]]
a non-negative integer
이 반복자가 다음에 검사할 요소의 정수 인덱스 입니다.
[[ArrayLikeIterationKind]]
key+value , key , or value
순회의 각 요소에 대해 무엇을 반환할지 식별하는 값입니다.
23.2 TypedArray 객체
TypedArray 는 기반 이진 데이터 버퍼(25.1 )를 배열과 유사하게 볼 수 있도록 합니다. TypedArray 요소 타입 은 TypedArray 인스턴스의 모든 요소가 갖는 기반 이진 스칼라 데이터 타입입니다. 지원되는 각 요소 타입에는 표 71 에 나열된 고유한 TypedArray 생성자 가 있습니다. 표 71 의 각 생성자 에는 대응하는 고유한 프로토타입 객체가 있습니다.
표 71: TypedArray 생성자
생성자 이름 및 내재 객체
요소 타입
요소 크기
변환 연산
설명
Int8Array
%Int8Array%
int8
1
ToInt8
8비트 2의 보수 부호 있는 정수
Uint8Array
%Uint8Array%
uint8
1
ToUint8
8비트 부호 없는 정수
Uint8ClampedArray
%Uint8ClampedArray%
uint8clamped
1
ToUint8Clamp
8비트 부호 없는 정수 (제한 변환)
Int16Array
%Int16Array%
int16
2
ToInt16
16비트 2의 보수 부호 있는 정수
Uint16Array
%Uint16Array%
uint16
2
ToUint16
16비트 부호 없는 정수
Int32Array
%Int32Array%
int32
4
ToInt32
32비트 2의 보수 부호 있는 정수
Uint32Array
%Uint32Array%
uint32
4
ToUint32
32비트 부호 없는 정수
BigInt64Array
%BigInt64Array%
bigint64
8
ToBigInt64
64비트 2의 보수 부호 있는 정수
BigUint64Array
%BigUint64Array%
biguint64
8
ToBigUint64
64비트 부호 없는 정수
Float16Array
%Float16Array%
float16
2
16비트 IEEE 부동 소수점
Float32Array
%Float32Array%
float32
4
32비트 IEEE 부동 소수점
Float64Array
%Float64Array%
float64
8
64비트 IEEE 부동 소수점
아래 정의에서 TypedArray 에 대한 참조는 위 표의 적절한 생성자 이름으로 대체해야 합니다.
23.2.1 %TypedArray% 내재 객체
%TypedArray% 내재 객체는:
모든 TypedArray 생성자 객체가 상속하는 생성자 함수 객체 입니다.
대응하는 프로토타입 객체와 함께 모든 TypedArray 생성자 및 그 인스턴스가 상속하는 공통 프로퍼티를 제공합니다.
전역 이름을 갖지 않으며 전역 객체 의 프로퍼티로 나타나지 않습니다.
여러 TypedArray 생성자 의 추상 상위 클래스 역할을 합니다.
추상 클래스 생성자 이므로 호출되면 오류를 던집니다. TypedArray 생성자 는 이에 대한 super 호출을 수행하지 않습니다.
23.2.1.1 %TypedArray% ( )
이 함수는 호출되면 다음 단계를 수행합니다:
TypeError 예외를 던집니다.
이 함수의 "length" 프로퍼티는 +0 𝔽 입니다.
23.2.2 %TypedArray% 내재 객체의 프로퍼티
%TypedArray% 내재 객체는:
값이 %Function.prototype% 인 [[Prototype]] 내부 슬롯을 갖습니다.
값이 "TypedArray" 인 "name" 프로퍼티를 갖습니다.
다음 프로퍼티를 갖습니다:
23.2.2.1 %TypedArray%.from ( source [ , mapper [ , thisArg ] ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
ctor 를 this 값으로 둡니다.IsConstructor (ctor )가 false 이면 TypeError 예외를 던집니다.mapper 가 undefined 이면, 다음을 수행합니다.mapping 을 false 로 둡니다.그렇지 않으면,IsCallable (mapper )가 false 이면 TypeError 예외를 던집니다.mapping 을 true 로 둡니다. usingIterator 를 ? GetMethod (source , %Symbol.iterator% )로 둡니다.usingIterator 가 undefined 가 아니면, 다음을 수행합니다.values 를 ? IteratorToList (? GetIteratorFromMethod (source , usingIterator ))로 둡니다.length 를 values 의 요소 수로 둡니다.targetObj 를 ? TypedArrayCreateFromConstructor (ctor , « 𝔽 (length ) »)로 둡니다.k 를 0으로 둡니다.k < length 인 동안 다음을 반복합니다.kValue 를 values [k ]로 둡니다.mapping 이 true 이면, 다음을 수행합니다.mappedValue 를 ? Call (mapper , thisArg , « kValue , 𝔽 (k ) »)로 둡니다.그렇지 않으면,mappedValue 를 kValue 로 둡니다. ? TypedArraySetElement (targetObj , 𝔽 (k ), mappedValue )를 수행합니다. k 를 k + 1로 설정합니다.targetObj 를 반환합니다.참고 : source 는 반복 가능 객체가 아니므로 이미 배열과 유사한 객체 라고 가정합니다.arrayLike 를 ! ToObject (source )로 둡니다.length 를 ? LengthOfArrayLike (arrayLike )로 둡니다.targetObj 를 ? TypedArrayCreateFromConstructor (ctor , « 𝔽 (length ) »)로 둡니다.k 를 0으로 둡니다.k < length 인 동안 다음을 반복합니다.propertyKey 를 ! ToString (𝔽 (k ))로 둡니다.kValue 를 ? Get (arrayLike , propertyKey )로 둡니다.mapping 이 true 이면, 다음을 수행합니다.mappedValue 를 ? Call (mapper , thisArg , « kValue , 𝔽 (k ) »)로 둡니다.그렇지 않으면,mappedValue 를 kValue 로 둡니다. ? TypedArraySetElement (targetObj , 𝔽 (k ), mappedValue )를 수행합니다. k 를 k + 1로 설정합니다.targetObj 를 반환합니다.
23.2.2.2 %TypedArray%.of ( ...items )
이 메서드는 호출되면 다음 단계를 수행합니다:
length 를 items 의 요소 수로 둡니다.ctor 를 this 값으로 둡니다.IsConstructor (ctor )가 false 이면 TypeError 예외를 던집니다.newObj 를 ? TypedArrayCreateFromConstructor (ctor , « 𝔽 (length ) »)로 둡니다.k 를 0으로 둡니다.k < length 인 동안 다음을 반복합니다.kValue 를 items [k ]로 둡니다.? TypedArraySetElement (newObj , 𝔽 (k ), kValue )를 수행합니다. k 를 k + 1로 설정합니다.newObj 를 반환합니다.
23.2.2.3 %TypedArray%.prototype
%TypedArray% .prototype의 초기 값은 %TypedArray% 프로토타입 객체 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
23.2.2.4 get %TypedArray% [ %Symbol.species% ]
%TypedArray% [%Symbol.species%]는 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
this 값을 반환합니다.
이 함수의 "name" 프로퍼티 값은 "get [Symbol.species]" 입니다.
참고
%TypedArray.prototype% 메서드는 일반적으로 this 값의 생성자 를 사용하여 파생 객체를 생성합니다. 그러나 하위 클래스 생성자 는 자신의 %Symbol.species% 프로퍼티를 재정의하여 이 기본 동작을 재정의할 수 있습니다.
23.2.3 %TypedArray% 프로토타입 객체의 프로퍼티
%TypedArray% 프로토타입 객체 는:
값이 %Object.prototype% 인 [[Prototype]] 내부 슬롯을 갖습니다.
%TypedArray.prototype% 입니다.
일반 객체 입니다.
[[ViewedArrayBuffer]] 또는 TypedArray 인스턴스 객체에 고유한 다른 어떤 내부 슬롯도 갖지 않습니다.
23.2.3.1 %TypedArray%.prototype.at ( index )
obj 를 this 값으로 둡니다.taRecord 를 ? ValidateTypedArray (obj , seq-cst )로 둡니다.length 를 TypedArrayLength (taRecord )로 둡니다.k 를 ? ToAbsoluteIndex (index , length )로 둡니다.k < 0 또는 k ≥ length 이면 undefined 를 반환합니다.TypedArrayGetElement (obj , 𝔽 (k ))를 반환합니다.
23.2.3.2 get %TypedArray%.prototype.buffer
%TypedArray% .prototype.buffer는 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.? RequireInternalSlot (obj , [[TypedArrayName]] )를 수행합니다. 단언 : obj 에는 [[ViewedArrayBuffer]] 내부 슬롯이 있습니다.buffer 를 obj .[[ViewedArrayBuffer]] 로 둡니다.buffer 를 반환합니다.
23.2.3.3 get %TypedArray%.prototype.byteLength
%TypedArray% .prototype.byteLength는 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.? RequireInternalSlot (obj , [[TypedArrayName]] )를 수행합니다. 단언 : obj 에는 [[ViewedArrayBuffer]] 내부 슬롯이 있습니다.taRecord 를 MakeTypedArrayWithBufferWitnessRecord (obj , seq-cst )로 둡니다.IsTypedArrayOutOfBounds (taRecord )가 true 이면 +0 𝔽 을 반환합니다.size 를 TypedArrayByteLength (taRecord )로 둡니다.𝔽 (size )를 반환합니다.
23.2.3.4 get %TypedArray%.prototype.byteOffset
%TypedArray% .prototype.byteOffset은 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.? RequireInternalSlot (obj , [[TypedArrayName]] )를 수행합니다. 단언 : obj 에는 [[ViewedArrayBuffer]] 내부 슬롯이 있습니다.taRecord 를 MakeTypedArrayWithBufferWitnessRecord (obj , seq-cst )로 둡니다.IsTypedArrayOutOfBounds (taRecord )가 true 이면 +0 𝔽 을 반환합니다.offset 을 obj .[[ByteOffset]] 으로 둡니다.𝔽 (offset )을 반환합니다.
23.2.3.5 %TypedArray%.prototype.constructor
%TypedArray% .prototype.constructor의 초기 값은 %TypedArray% 입니다.
23.2.3.6 %TypedArray%.prototype.copyWithin ( target , start [ , end ] )
이 메서드의 인수를 해석하고 사용하는 방식은 23.1.3.4 에 정의된 Array.prototype.copyWithin과 같습니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.taRecord 를 ? ValidateTypedArray (obj , seq-cst )로 둡니다.length 를 TypedArrayLength (taRecord )로 둡니다.targetIndex 를 ? ToClampedIndex (target , length )로 둡니다.startIndex 를 ? ToClampedIndex (start , length )로 둡니다.end 가 undefined 이면 endIndex 를 length 로 둡니다. 그렇지 않으면 endIndex 를 ? ToClampedIndex (end , length )로 둡니다.count 를 min (endIndex - startIndex , length - targetIndex )로 둡니다.count > 0이면, 다음을 수행합니다.참고 : 복사는 소스 데이터의 비트 수준 인코딩을 보존하는 방식으로 수행해야 합니다.buffer 를 obj .[[ViewedArrayBuffer]] 로 둡니다.taRecord 를 ? ValidateTypedArrayBounds (obj , seq-cst )로 설정합니다.length 를 TypedArrayLength (taRecord )로 설정합니다.참고 : 위 단계의 부수 효과로 obj 의 크기가 줄어들었을 수 있으며, 이 경우 여전히 적용 가능한 가장 긴 접두사에 대해 복사를 계속해야 합니다.count 를 min (count , length - startIndex , length - targetIndex )로 설정합니다.elementSize 를 TypedArrayElementSize (obj )로 둡니다.byteOffset 을 obj .[[ByteOffset]] 으로 둡니다.toByteIndex 를 (targetIndex × elementSize ) + byteOffset 으로 둡니다.fromByteIndex 를 (startIndex × elementSize ) + byteOffset 으로 둡니다.countBytes 를 count × elementSize 로 둡니다.fromByteIndex < toByteIndex 이고 toByteIndex < fromByteIndex + countBytes 이면, 다음을 수행합니다.direction 을 -1로 둡니다.fromByteIndex 를 fromByteIndex + countBytes - 1로 설정합니다.toByteIndex 를 toByteIndex + countBytes - 1로 설정합니다.그렇지 않으면,direction 을 1로 둡니다. countBytes > 0인 동안 다음을 반복합니다.단언 : fromByteIndex ≥ 0이고 toByteIndex ≥ 0입니다.value 를 GetValueFromBuffer (buffer , fromByteIndex , uint8 , true , unordered )로 둡니다.SetValueInBuffer (buffer , toByteIndex , uint8 , value , true , unordered )를 수행합니다.fromByteIndex 를 fromByteIndex + direction 으로 설정합니다.toByteIndex 를 toByteIndex + direction 으로 설정합니다.countBytes 를 countBytes - 1로 설정합니다.obj 를 반환합니다.
23.2.3.7 %TypedArray%.prototype.entries ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.? ValidateTypedArray (obj , seq-cst )를 수행합니다. CreateArrayIterator (obj , key+value )를 반환합니다.
23.2.3.8 %TypedArray%.prototype.every ( callback [ , thisArg ] )
이 메서드의 인수를 해석하고 사용하는 방식은 23.1.3.6 에 정의된 Array.prototype.every와 같습니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.taRecord 를 ? ValidateTypedArray (obj , seq-cst )로 둡니다.length 를 TypedArrayLength (taRecord )로 둡니다.IsCallable (callback )이 false 이면 TypeError 예외를 던집니다.k 를 0으로 둡니다.k < length 인 동안 다음을 반복합니다.kValue 를 TypedArrayGetElement (obj , 𝔽 (k ))로 둡니다.testResult 를 ToBoolean (? Call (callback , thisArg , « kValue , 𝔽 (k ), obj »))로 둡니다.testResult 가 false 이면 false 를 반환합니다.k 를 k + 1로 설정합니다.true 를 반환합니다.
이 메서드는 일반적이지 않습니다. this 값은 [[TypedArrayName]] 내부 슬롯을 갖는 객체여야 합니다.
23.2.3.9 %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )
이 메서드의 인수를 해석하고 사용하는 방식은 23.1.3.7 에 정의된 Array.prototype.fill과 같습니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.taRecord 를 ? ValidateTypedArray (obj , seq-cst )로 둡니다.length 를 TypedArrayLength (taRecord )로 둡니다.obj .[[ContentType]] 이 bigint 이면 value 를 ? ToBigInt (value )로 설정합니다.그렇지 않으면 value 를 ? ToNumber (value )로 설정합니다. startIndex 를 ? ToClampedIndex (start , length )로 둡니다.end 가 undefined 이면 endIndex 를 length 로 둡니다. 그렇지 않으면 endIndex 를 ? ToClampedIndex (end , length )로 둡니다.taRecord 를 ? ValidateTypedArrayBounds (obj , seq-cst )로 설정합니다.length 를 TypedArrayLength (taRecord )로 설정합니다.endIndex 를 min (endIndex , length )로 설정합니다.k 를 startIndex 로 둡니다.k < endIndex 인 동안 다음을 반복합니다.! TypedArraySetElement (obj , 𝔽 (k ), value )를 수행합니다. k 를 k + 1로 설정합니다.obj 를 반환합니다.
23.2.3.10 %TypedArray%.prototype.filter ( callback [ , thisArg ] )
이 메서드의 인수를 해석하고 사용하는 방식은 23.1.3.8 에 정의된 Array.prototype.filter와 같습니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.taRecord 를 ? ValidateTypedArray (obj , seq-cst )로 둡니다.length 를 TypedArrayLength (taRecord )로 둡니다.IsCallable (callback )이 false 이면 TypeError 예외를 던집니다.kept 를 새로운 빈 List 로 둡니다.captured 를 0으로 둡니다.k 를 0으로 둡니다.k < length 인 동안 반복합니다.kValue 를 TypedArrayGetElement (obj , 𝔽 (k ))로 둡니다.selected 를 ToBoolean (? Call (callback , thisArg , « kValue , 𝔽 (k ), obj »))로 둡니다.selected 가 true 이면 다음을 수행합니다.kept 에 kValue 를 추가합니다.captured 를 captured + 1로 설정합니다.k 를 k + 1로 설정합니다.result 를 ? TypedArraySpeciesCreate (obj , « 𝔽 (captured ) »)로 둡니다.n 을 0으로 둡니다.kept 의 각 요소 element 에 대해 다음을 수행합니다.참고 : callback 을 호출하여 obj 의 기반 버퍼가 분리되거나 축소되면 element 는 undefined 일 수 있습니다.다음을 수행합니다: ? TypedArraySetElement (result , 𝔽 (n ), element ). n 을 n + 1로 설정합니다.result 를 반환합니다.
이 메서드는 일반적이지 않습니다. this 값은 [[TypedArrayName]] 내부 슬롯을 갖는 객체여야 합니다.
23.2.3.11 %TypedArray%.prototype.find ( predicate [ , thisArg ] )
이 메서드의 인수를 해석하고 사용하는 방식은 23.1.3.9 에 정의된 Array.prototype.find와 같습니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.taRecord 를 ? ValidateTypedArray (obj , seq-cst )로 둡니다.length 를 TypedArrayLength (taRecord )로 둡니다.findRecord 를 ? FindViaPredicate (obj , length , ascending , predicate , thisArg )로 둡니다.findRecord .[[Value]] 를 반환합니다.
이 메서드는 일반적이지 않습니다. this 값은 [[TypedArrayName]] 내부 슬롯을 갖는 객체여야 합니다.
23.2.3.12 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] )
이 메서드의 인수를 해석하고 사용하는 방식은 23.1.3.10 에 정의된 Array.prototype.findIndex와 같습니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.taRecord 를 ? ValidateTypedArray (obj , seq-cst )로 둡니다.length 를 TypedArrayLength (taRecord )로 둡니다.findRecord 를 ? FindViaPredicate (obj , length , ascending , predicate , thisArg )로 둡니다.findRecord .[[Index]] 를 반환합니다.
이 메서드는 일반적이지 않습니다. this 값은 [[TypedArrayName]] 내부 슬롯을 갖는 객체여야 합니다.
23.2.3.13 %TypedArray%.prototype.findLast ( predicate [ , thisArg ] )
이 메서드의 인수를 해석하고 사용하는 방식은 23.1.3.11 에 정의된 Array.prototype.findLast와 같습니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.taRecord 를 ? ValidateTypedArray (obj , seq-cst )로 둡니다.length 를 TypedArrayLength (taRecord )로 둡니다.findRecord 를 ? FindViaPredicate (obj , length , descending , predicate , thisArg )로 둡니다.findRecord .[[Value]] 를 반환합니다.
이 메서드는 일반적이지 않습니다. this 값은 [[TypedArrayName]] 내부 슬롯을 갖는 객체여야 합니다.
23.2.3.14 %TypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] )
이 메서드의 인수를 해석하고 사용하는 방식은 23.1.3.12 에 정의된 Array.prototype.findLastIndex와 같습니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.taRecord 를 ? ValidateTypedArray (obj , seq-cst )로 둡니다.length 를 TypedArrayLength (taRecord )로 둡니다.findRecord 를 ? FindViaPredicate (obj , length , descending , predicate , thisArg )로 둡니다.findRecord .[[Index]] 를 반환합니다.
이 메서드는 일반적이지 않습니다. this 값은 [[TypedArrayName]] 내부 슬롯을 갖는 객체여야 합니다.
23.2.3.15 %TypedArray%.prototype.forEach ( callback [ , thisArg ] )
이 메서드의 인수를 해석하고 사용하는 방식은 23.1.3.15 에 정의된 Array.prototype.forEach와 같습니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.taRecord 를 ? ValidateTypedArray (obj , seq-cst )로 둡니다.length 를 TypedArrayLength (taRecord )로 둡니다.IsCallable (callback )이 false 이면 TypeError 예외를 던집니다.k 를 0으로 둡니다.k < length 인 동안 다음을 반복합니다.kValue 를 TypedArrayGetElement (obj , 𝔽 (k ))로 둡니다.? Call (callback , thisArg , « kValue , 𝔽 (k ), obj »)를 수행합니다. k 를 k + 1로 설정합니다.undefined 를 반환합니다.
이 메서드는 일반적이지 않습니다. this 값은 [[TypedArrayName]] 내부 슬롯을 갖는 객체여야 합니다.
23.2.3.16 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
이 메서드의 인수를 해석하고 사용하는 방식은 23.1.3.16 에 정의된 Array.prototype.includes와 같습니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.taRecord 를 ? ValidateTypedArray (obj , seq-cst )로 둡니다.length 를 TypedArrayLength (taRecord )로 둡니다.length = 0이면 false 를 반환합니다.k 를 ? ToClampedIndex (fromIndex , length )로 둡니다.k < length 인 동안 다음을 반복합니다.elementK 를 TypedArrayGetElement (obj , 𝔽 (k ))로 둡니다.SameValueZero (searchElement , elementK )가 true 이면 true 를 반환합니다.k 를 k + 1로 설정합니다.false 를 반환합니다.
이 메서드는 일반적이지 않습니다. this 값은 [[TypedArrayName]] 내부 슬롯을 갖는 객체여야 합니다.
23.2.3.17 %TypedArray%.prototype.indexOf ( searchElement [ , fromIndex ] )
이 메서드의 인수를 해석하고 사용하는 방식은 23.1.3.17 에 정의된 Array.prototype.indexOf와 같습니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.taRecord 를 ? ValidateTypedArray (obj , seq-cst )로 둡니다.length 를 TypedArrayLength (taRecord )로 둡니다.length = 0이면 -1 𝔽 을 반환합니다.k 를 ? ToClampedIndex (fromIndex , length )로 둡니다.k < length 인 동안 다음을 반복합니다.propertyKey 를 ! ToString (𝔽 (k ))로 둡니다.kPresent 를 ! HasProperty (obj , propertyKey )로 둡니다.kPresent 가 true 이면, 다음을 수행합니다.elementK 를 TypedArrayGetElement (obj , 𝔽 (k ))로 둡니다.IsStrictlyEqual (searchElement , elementK )가 true 이면 𝔽 (k )를 반환합니다.k 를 k + 1로 설정합니다.-1 𝔽 을 반환합니다.
이 메서드는 일반적이지 않습니다. this 값은 [[TypedArrayName]] 내부 슬롯을 갖는 객체여야 합니다.
23.2.3.18 %TypedArray%.prototype.join ( separator )
이 메서드의 인수를 해석하고 사용하는 방식은 23.1.3.18 에 정의된 Array.prototype.join과 같습니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.taRecord 를 ? ValidateTypedArray (obj , seq-cst )로 둡니다.length 를 TypedArrayLength (taRecord )로 둡니다.separator 가 undefined 이면 separatorString 을 "," 로 둡니다; 그렇지 않으면 separatorString 을 ? ToString (separator )으로 둡니다.? JoinIndexedProperties (obj , length , separatorString )를 반환합니다.
이 메서드는 일반적이지 않습니다. this 값은 [[TypedArrayName]] 내부 슬롯을 갖는 객체여야 합니다.
23.2.3.19 %TypedArray%.prototype.keys ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.? ValidateTypedArray (obj , seq-cst )를 수행합니다. CreateArrayIterator (obj , key )를 반환합니다.
23.2.3.20 %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
이 메서드의 인수를 해석하고 사용하는 방식은 23.1.3.20 에 정의된 Array.prototype.lastIndexOf와 같습니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.taRecord 를 ? ValidateTypedArray (obj , seq-cst )로 둡니다.length 를 TypedArrayLength (taRecord )로 둡니다.length = 0이면 -1 𝔽 을 반환합니다.fromIndex 가 존재하지 않으면 k 를 length - 1로 둡니다. 그렇지 않으면 k 를 min (? ToAbsoluteIndex (fromIndex , length ), length - 1)로 둡니다.k ≥ 0인 동안 다음을 반복합니다.propertyKey 를 ! ToString (𝔽 (k ))로 둡니다.kPresent 를 ! HasProperty (obj , propertyKey )로 둡니다.kPresent 가 true 이면, 다음을 수행합니다.elementK 를 TypedArrayGetElement (obj , 𝔽 (k ))로 둡니다.IsStrictlyEqual (searchElement , elementK )가 true 이면 𝔽 (k )를 반환합니다.k 를 k - 1로 설정합니다.-1 𝔽 을 반환합니다.
이 메서드는 일반적이지 않습니다. this 값은 [[TypedArrayName]] 내부 슬롯을 갖는 객체여야 합니다.
23.2.3.21 get %TypedArray%.prototype.length
%TypedArray% .prototype.length는 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.? RequireInternalSlot (obj , [[TypedArrayName]] )를 수행합니다. 단언 : obj 에는 [[ViewedArrayBuffer]] 및 [[ArrayLength]] 내부 슬롯이 있습니다.taRecord 를 MakeTypedArrayWithBufferWitnessRecord (obj , seq-cst )로 둡니다.IsTypedArrayOutOfBounds (taRecord )가 true 이면 +0 𝔽 을 반환합니다.length 를 TypedArrayLength (taRecord )로 둡니다.𝔽 (length )를 반환합니다.
이 함수는 일반적이지 않습니다. this 값은 [[TypedArrayName]] 내부 슬롯을 갖는 객체여야 합니다.
23.2.3.22 %TypedArray%.prototype.map ( callback [ , thisArg ] )
이 메서드의 인수를 해석하고 사용하는 방식은 23.1.3.21 에 정의된 Array.prototype.map과 같습니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.taRecord 를 ? ValidateTypedArray (obj , seq-cst )로 둡니다.length 를 TypedArrayLength (taRecord )로 둡니다.IsCallable (callback )이 false 이면 TypeError 예외를 던집니다.result 를 ? TypedArraySpeciesCreate (obj , « 𝔽 (length ) »)로 둡니다.k 를 0으로 둡니다.k < length 인 동안 다음을 반복합니다.kValue 를 TypedArrayGetElement (obj , 𝔽 (k ))로 둡니다.mappedValue 를 ? Call (callback , thisArg , « kValue , 𝔽 (k ), obj »)로 둡니다.? TypedArraySetElement (result , 𝔽 (k ), mappedValue )를 수행합니다. k 를 k + 1로 설정합니다.result 를 반환합니다.
이 메서드는 일반적이지 않습니다. this 값은 [[TypedArrayName]] 내부 슬롯을 갖는 객체여야 합니다.
23.2.3.23 %TypedArray%.prototype.reduce ( callback [ , initialValue ] )
이 메서드의 인수를 해석하고 사용하는 방식은 23.1.3.24 에 정의된 Array.prototype.reduce와 같습니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.taRecord 를 ? ValidateTypedArray (obj , seq-cst )로 둡니다.length 를 TypedArrayLength (taRecord )로 둡니다.IsCallable (callback )이 false 이면 TypeError 예외를 던집니다.length = 0이고 initialValue 가 존재하지 않으면 TypeError 예외를 던집니다.k 를 0으로 둡니다.accumulator 를 undefined 로 둡니다.initialValue 가 존재하면, 다음을 수행합니다.accumulator 를 initialValue 로 설정합니다.그렇지 않으면,accumulator 를 TypedArrayGetElement (obj , 𝔽 (k ))로 설정합니다.k 를 k + 1로 설정합니다. k < length 인 동안 다음을 반복합니다.kValue 를 TypedArrayGetElement (obj , 𝔽 (k ))로 둡니다.accumulator 를 ? Call (callback , undefined , « accumulator , kValue , 𝔽 (k ), obj »)로 설정합니다.k 를 k + 1로 설정합니다.accumulator 를 반환합니다.
이 메서드는 일반적이지 않습니다. this 값은 [[TypedArrayName]] 내부 슬롯을 갖는 객체여야 합니다.
23.2.3.24 %TypedArray%.prototype.reduceRight ( callback [ , initialValue ] )
이 메서드의 인수를 해석하고 사용하는 방식은 23.1.3.25 에 정의된 Array.prototype.reduceRight와 같습니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.taRecord 를 ? ValidateTypedArray (obj , seq-cst )로 둡니다.length 를 TypedArrayLength (taRecord )로 둡니다.IsCallable (callback )이 false 이면 TypeError 예외를 던집니다.length = 0이고 initialValue 가 존재하지 않으면 TypeError 예외를 던집니다.k 를 length - 1로 둡니다.accumulator 를 undefined 로 둡니다.initialValue 가 존재하면, 다음을 수행합니다.accumulator 를 initialValue 로 설정합니다.그렇지 않으면,accumulator 를 TypedArrayGetElement (obj , 𝔽 (k ))로 설정합니다.k 를 k - 1로 설정합니다. k ≥ 0인 동안 다음을 반복합니다.kValue 를 TypedArrayGetElement (obj , 𝔽 (k ))로 둡니다.accumulator 를 ? Call (callback , undefined , « accumulator , kValue , 𝔽 (k ), obj »)로 설정합니다.k 를 k - 1로 설정합니다.accumulator 를 반환합니다.
이 메서드는 일반적이지 않습니다. this 값은 [[TypedArrayName]] 내부 슬롯을 갖는 객체여야 합니다.
23.2.3.25 %TypedArray%.prototype.reverse ( )
이 메서드의 인수를 해석하고 사용하는 방식은 23.1.3.26 에 정의된 Array.prototype.reverse와 같습니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.taRecord 를 ? ValidateTypedArray (obj , seq-cst )로 둡니다.length 를 TypedArrayLength (taRecord )로 둡니다.middle 을 floor (length / 2)로 둡니다.lower 를 0으로 둡니다.lower ≠ middle 인 동안 다음을 반복합니다.upper 를 length - lower - 1로 둡니다.lowerValue 를 TypedArrayGetElement (obj , 𝔽 (lower ))로 둡니다.upperValue 를 TypedArrayGetElement (obj , 𝔽 (upper ))로 둡니다.! TypedArraySetElement (obj , 𝔽 (lower ), upperValue )를 수행합니다. ! TypedArraySetElement (obj , 𝔽 (upper ), lowerValue )를 수행합니다. lower 를 lower + 1로 설정합니다.obj 를 반환합니다.
이 메서드는 일반적이지 않습니다. this 값은 [[TypedArrayName]] 내부 슬롯을 갖는 객체여야 합니다.
23.2.3.26 %TypedArray%.prototype.set ( source [ , offset ] )
이 메서드는 source 에서 값을 읽어 이 TypedArray 에 여러 값을 설정합니다. 세부 사항은 source 의 타입에 따라 다릅니다. 선택적 offset 값은 이 TypedArray 에서 값을 쓰기 시작할 첫 번째 요소 인덱스를 나타냅니다. 생략하면 0으로 간주합니다.
호출되면 다음 단계를 수행합니다:
target 을 this 값으로 둡니다.? RequireInternalSlot (target , [[TypedArrayName]] )를 수행합니다. 단언 : target 에는 [[ViewedArrayBuffer]] 내부 슬롯이 있습니다.targetOffset 을 ? ToIntegerOrInfinity (offset )로 둡니다.targetOffset < 0이면 RangeError 예외를 던집니다.source 가 [[TypedArrayName]] 내부 슬롯을 갖는 Object이면, 다음을 수행합니다.? SetTypedArrayFromTypedArray (target , targetOffset , source )를 수행합니다. 그렇지 않으면,? SetTypedArrayFromArrayLike (target , targetOffset , source )를 수행합니다. undefined 를 반환합니다.
이 메서드는 일반적이지 않습니다. this 값은 [[TypedArrayName]] 내부 슬롯을 갖는 객체여야 합니다.
23.2.3.26.1 SetTypedArrayFromArrayLike ( target , targetOffset , source )
추상 연산 SetTypedArrayFromArrayLike. 인수 target (TypedArray ), targetOffset ((음이 아닌 정수 또는 +∞)) 및 source (an ECMAScript language value, but not a TypedArray ). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). source 에서 값을 읽어 인덱스 targetOffset 부터 시작하여 target 에 여러 값을 설정합니다. 호출되면 다음 단계를 수행한다.
targetRecord 를 ? ValidateTypedArrayBounds (target , seq-cst )로 둡니다.targetLength 를 TypedArrayLength (targetRecord )로 둡니다.source 를 ? ToObject (source )로 설정합니다.sourceLength 를 ? LengthOfArrayLike (source )로 둡니다.targetOffset = +∞이면 RangeError 예외를 던집니다.sourceLength + targetOffset > targetLength 이면 RangeError 예외를 던집니다.k 를 0으로 둡니다.k < sourceLength 인 동안 다음을 반복합니다.propertyKey 를 ! ToString (𝔽 (k ))로 둡니다.value 를 ? Get (source , propertyKey )로 둡니다.targetIndex 를 𝔽 (targetOffset + k )로 둡니다.? TypedArraySetElement (target , targetIndex , value )를 수행합니다. k 를 k + 1로 설정합니다.unused 를 반환합니다.
23.2.3.26.2 SetTypedArrayFromTypedArray ( target , targetOffset , source )
추상 연산 SetTypedArrayFromTypedArray. 인수 target (TypedArray ), targetOffset ((음이 아닌 정수 또는 +∞)) 및 source (TypedArray ). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). source 에서 값을 읽어 인덱스 targetOffset 부터 시작하여 target 에 여러 값을 설정합니다. 호출되면 다음 단계를 수행한다.
targetBuffer 를 target .[[ViewedArrayBuffer]] 로 둡니다.targetRecord 를 ? ValidateTypedArrayBounds (target , seq-cst )로 둡니다.targetLength 를 TypedArrayLength (targetRecord )로 둡니다.sourceBuffer 를 source .[[ViewedArrayBuffer]] 로 둡니다.sourceRecord 를 ? ValidateTypedArrayBounds (source , seq-cst )로 둡니다.sourceLength 를 TypedArrayLength (sourceRecord )로 둡니다.targetType 을 TypedArrayElementType (target )로 둡니다.targetElementSize 를 TypedArrayElementSize (target )로 둡니다.targetByteOffset 을 target .[[ByteOffset]] 으로 둡니다.sourceType 을 TypedArrayElementType (source )로 둡니다.sourceElementSize 를 TypedArrayElementSize (source )로 둡니다.sourceByteOffset 을 source .[[ByteOffset]] 으로 둡니다.targetOffset = +∞이면 RangeError 예외를 던집니다.sourceLength + targetOffset > targetLength 이면 RangeError 예외를 던집니다.target .[[ContentType]] 이 source .[[ContentType]] 이 아니면 TypeError 예외를 던집니다.IsSharedArrayBuffer (sourceBuffer )가 true 이고 IsSharedArrayBuffer (targetBuffer )가 true 이며 sourceBuffer .[[ArrayBufferData]] 가 targetBuffer .[[ArrayBufferData]] 이면 sameSharedArrayBuffer 를 true 로 둡니다. 그렇지 않으면 sameSharedArrayBuffer 를 false 로 둡니다.SameValue (sourceBuffer , targetBuffer )가 true 이거나 sameSharedArrayBuffer 가 true 이면, 다음을 수행합니다.sourceByteLength 를 TypedArrayByteLength (sourceRecord )로 둡니다.sourceBuffer 를 ? CloneArrayBuffer (sourceBuffer , sourceByteOffset , sourceByteLength )로 설정합니다.sourceByteIndex 를 0으로 둡니다.그렇지 않으면,sourceByteIndex 를 sourceByteOffset 으로 둡니다. targetByteIndex 를 (targetOffset × targetElementSize ) + targetByteOffset 으로 둡니다.limit 을 targetByteIndex + (targetElementSize × sourceLength )로 둡니다.sourceType 이 targetType 이면, 다음을 수행합니다.참고 : 전송은 소스 데이터의 비트 수준 인코딩을 보존하는 방식으로 수행해야 합니다.targetByteIndex < limit 인 동안 다음을 반복합니다.value 를 GetValueFromBuffer (sourceBuffer , sourceByteIndex , uint8 , true , unordered )로 둡니다.SetValueInBuffer (targetBuffer , targetByteIndex , uint8 , value , true , unordered )를 수행합니다.sourceByteIndex 를 sourceByteIndex + 1로 설정합니다.targetByteIndex 를 targetByteIndex + 1로 설정합니다.그렇지 않으면,targetByteIndex < limit 인 동안 다음을 반복합니다.value 를 GetValueFromBuffer (sourceBuffer , sourceByteIndex , sourceType , true , unordered )로 둡니다.SetValueInBuffer (targetBuffer , targetByteIndex , targetType , value , true , unordered )를 수행합니다.sourceByteIndex 를 sourceByteIndex + sourceElementSize 로 설정합니다.targetByteIndex 를 targetByteIndex + targetElementSize 로 설정합니다. unused 를 반환합니다.
23.2.3.27 %TypedArray%.prototype.slice ( start , end )
이 메서드의 인수를 해석하고 사용하는 방식은 23.1.3.28 에 정의된 Array.prototype.slice와 같습니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.taRecord 를 ? ValidateTypedArray (obj , seq-cst )로 둡니다.sourceArrayLength 를 TypedArrayLength (taRecord )로 둡니다.startIndex 를 ? ToClampedIndex (start , sourceArrayLength )로 둡니다.end 가 undefined 이면 endIndex 를 sourceArrayLength 로 둡니다. 그렇지 않으면 endIndex 를 ? ToClampedIndex (end , sourceArrayLength )로 둡니다.countBytes 를 max (endIndex - startIndex , 0)으로 둡니다.resultArray 를 ? TypedArraySpeciesCreate (obj , « 𝔽 (countBytes ) »)로 둡니다.countBytes > 0이면, 다음을 수행합니다.taRecord 를 ? ValidateTypedArrayBounds (obj , seq-cst )로 설정합니다.endIndex 를 min (endIndex , TypedArrayLength (taRecord ))로 설정합니다.countBytes 를 max (endIndex - startIndex , 0)으로 설정합니다.sourceType 을 TypedArrayElementType (obj )로 둡니다.targetType 을 TypedArrayElementType (resultArray )로 둡니다.sourceType 이 targetType 이면, 다음을 수행합니다.참고 : 전송은 소스 데이터의 비트 수준 인코딩을 보존하는 방식으로 수행해야 합니다.sourceBuffer 를 obj .[[ViewedArrayBuffer]] 로 둡니다.targetBuffer 를 resultArray .[[ViewedArrayBuffer]] 로 둡니다.elementSize 를 TypedArrayElementSize (obj )로 둡니다.sourceByteOffset 을 obj .[[ByteOffset]] 으로 둡니다.sourceByteIndex 를 (startIndex × elementSize ) + sourceByteOffset 으로 둡니다.targetByteIndex 를 resultArray .[[ByteOffset]] 으로 둡니다.endByteIndex 를 targetByteIndex + (countBytes × elementSize )로 둡니다.targetByteIndex < endByteIndex 인 동안 다음을 반복합니다.value 를 GetValueFromBuffer (sourceBuffer , sourceByteIndex , uint8 , true , unordered )로 둡니다.SetValueInBuffer (targetBuffer , targetByteIndex , uint8 , value , true , unordered )를 수행합니다.sourceByteIndex 를 sourceByteIndex + 1로 설정합니다.targetByteIndex 를 targetByteIndex + 1로 설정합니다.그렇지 않으면,n 을 0으로 둡니다.k 를 startIndex 로 둡니다.k < endIndex 인 동안 다음을 반복합니다.kValue 를 TypedArrayGetElement (obj , 𝔽 (k ))로 둡니다.! TypedArraySetElement (resultArray , 𝔽 (n ), kValue )를 수행합니다. k 를 k + 1로 설정합니다.n 을 n + 1로 설정합니다. resultArray 를 반환합니다.
이 메서드는 일반적이지 않습니다. this 값은 [[TypedArrayName]] 내부 슬롯을 갖는 객체여야 합니다.
23.2.3.28 %TypedArray%.prototype.some ( callback [ , thisArg ] )
이 메서드의 인수를 해석하고 사용하는 방식은 23.1.3.29 에 정의된 Array.prototype.some과 같습니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.taRecord 를 ? ValidateTypedArray (obj , seq-cst )로 둡니다.length 를 TypedArrayLength (taRecord )로 둡니다.IsCallable (callback )이 false 이면 TypeError 예외를 던집니다.k 를 0으로 둡니다.k < length 인 동안 다음을 반복합니다.kValue 를 TypedArrayGetElement (obj , 𝔽 (k ))로 둡니다.testResult 를 ToBoolean (? Call (callback , thisArg , « kValue , 𝔽 (k ), obj »))로 둡니다.testResult 가 true 이면 true 를 반환합니다.k 를 k + 1로 설정합니다.false 를 반환합니다.
이 메서드는 일반적이지 않습니다. this 값은 [[TypedArrayName]] 내부 슬롯을 갖는 객체여야 합니다.
23.2.3.29 %TypedArray%.prototype.sort ( comparator )
이 메서드는 별개의 메서드이지만 아래에 설명된 사항을 제외하면 23.1.3.30 에 정의된 Array.prototype.sort와 동일한 요구 사항을 구현합니다. this 값이 고정된 길이를 가지며 정수 인덱스 프로퍼티가 희소하지 않은 객체라는 사실을 이용하여 이 메서드의 구현을 최적화할 수 있습니다.
이 메서드는 일반적이지 않습니다. this 값은 [[TypedArrayName]] 내부 슬롯을 갖는 객체여야 합니다.
호출되면 다음 단계를 수행합니다:
comparator 가 undefined 가 아니고 IsCallable (comparator )이 false 이면 TypeError 예외를 던집니다.obj 를 this 값으로 둡니다.taRecord 를 ? ValidateTypedArray (obj , seq-cst )로 둡니다.length 를 TypedArrayLength (taRecord )로 둡니다.참고 : 다음 클로저는 23.1.3.30 에서 사용하는 문자열 비교 대신 숫자 비교를 수행합니다.sortCompare 를 comparator 를 캡처하고 호출될 때 다음 단계를 수행하는 매개변수 (x , y )를 갖는 새로운 Abstract Closure 로 둡니다:? CompareTypedArrayElements (x , y , comparator )를 반환합니다. sortedList 를 ? SortIndexedProperties (obj , length , sortCompare , read-through-holes )로 둡니다.j 를 0으로 둡니다.j < length 인 동안 다음을 반복합니다.! TypedArraySetElement (obj , 𝔽 (j ), sortedList [j ])를 수행합니다. j 를 j + 1로 설정합니다.obj 를 반환합니다.
참고
NaN 은 항상 다른 모든 값보다 큰 것으로 비교되므로(CompareTypedArrayElements 참조), comparator 가 제공되지 않은 경우 NaN 프로퍼티 값은 항상 결과의 끝으로 정렬됩니다.
23.2.3.30 %TypedArray%.prototype.subarray ( start , end )
이 메서드는 요소 타입이 이 TypedArray 의 요소 타입이고 ArrayBuffer가 이 TypedArray 의 ArrayBuffer이며, start (포함)부터 end (제외)까지의 구간 에 있는 요소를 참조하는 새로운 TypedArray 를 반환합니다. start 또는 end 가 음수이면 배열의 시작이 아니라 끝에서부터의 인덱스를 나타냅니다.
호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.? RequireInternalSlot (obj , [[TypedArrayName]] )를 수행합니다. 단언 : obj 에는 [[ViewedArrayBuffer]] 내부 슬롯이 있습니다.buffer 를 obj .[[ViewedArrayBuffer]] 로 둡니다.sourceRecord 를 MakeTypedArrayWithBufferWitnessRecord (obj , seq-cst )로 둡니다.IsTypedArrayOutOfBounds (sourceRecord )가 true 이면, 다음을 수행합니다.sourceLength 를 0으로 둡니다.그렇지 않으면,sourceLength 를 TypedArrayLength (sourceRecord )로 둡니다. startIndex 를 ? ToClampedIndex (start , sourceLength )로 둡니다.elementSize 를 TypedArrayElementSize (obj )로 둡니다.sourceByteOffset 을 obj .[[ByteOffset]] 으로 둡니다.beginByteOffset 을 sourceByteOffset + (startIndex × elementSize )로 둡니다.obj .[[ArrayLength]] 가 auto 이고 end 가 undefined 이면, 다음을 수행합니다.? TypedArraySpeciesCreate (obj , « buffer , 𝔽 (beginByteOffset ) »)를 반환합니다. end 가 undefined 이면 endIndex 를 sourceLength 로 둡니다. 그렇지 않으면 endIndex 를 ? ToClampedIndex (end , sourceLength )로 둡니다.newLength 를 max (endIndex - startIndex , 0)으로 둡니다.? TypedArraySpeciesCreate (obj , « buffer , 𝔽 (beginByteOffset ), 𝔽 (newLength ) »)를 반환합니다.
이 메서드는 일반적이지 않습니다. this 값은 [[TypedArrayName]] 내부 슬롯을 갖는 객체여야 합니다.
23.2.3.31 %TypedArray%.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )
ECMA-402 국제화 API를 포함하는 ECMAScript 구현은 ECMA-402에 명시된 대로 이 메서드를 구현해야 합니다. 그렇지 않은 경우에는 다음에 제시된 이 메서드의 명세를 사용합니다.
이 메서드의 인수를 해석하고 사용하는 방식은 23.1.3.32 에 정의된 Array.prototype.toLocaleString의 경우와 동일합니다.
이 메서드는 호출될 때 다음 단계를 수행합니다.
obj 를 this 값으로 둡니다.taRecord 를 ? ValidateTypedArray (obj , seq-cst )로 둡니다.length 를 TypedArrayLength (taRecord )로 둡니다.? JoinIndexedProperties (obj , length , LocalizedListSeparator (), "toLocaleString" )을 반환합니다.
23.2.3.32 %TypedArray%.prototype.toReversed ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.taRecord 를 ? ValidateTypedArray (obj , seq-cst )로 둡니다.length 를 TypedArrayLength (taRecord )로 둡니다.resultArray 를 ? TypedArrayCreateSameType (obj , length )로 둡니다.k 를 0으로 둡니다.k < length 인 동안 다음을 반복합니다.from 을 length - k - 1로 둡니다.fromValue 를 TypedArrayGetElement (obj , 𝔽 (from ))로 둡니다.! TypedArraySetElement (resultArray , 𝔽 (k ), fromValue )를 수행합니다. k 를 k + 1로 설정합니다.resultArray 를 반환합니다.
23.2.3.33 %TypedArray%.prototype.toSorted ( comparator )
이 메서드는 호출되면 다음 단계를 수행합니다:
comparator 가 undefined 가 아니고 IsCallable (comparator )이 false 이면 TypeError 예외를 던집니다.obj 를 this 값으로 둡니다.taRecord 를 ? ValidateTypedArray (obj , seq-cst )로 둡니다.length 를 TypedArrayLength (taRecord )로 둡니다.resultArray 를 ? TypedArrayCreateSameType (obj , length )로 둡니다.참고 : 다음 클로저는 23.1.3.34 에서 사용하는 문자열 비교 대신 숫자 비교를 수행합니다.sortCompare 를 comparator 를 캡처하고 호출될 때 다음 단계를 수행하는 매개변수 (x , y )를 갖는 새로운 Abstract Closure 로 둡니다:? CompareTypedArrayElements (x , y , comparator )를 반환합니다. sortedList 를 ? SortIndexedProperties (obj , length , sortCompare , read-through-holes )로 둡니다.j 를 0으로 둡니다.j < length 인 동안 다음을 반복합니다.! TypedArraySetElement (resultArray , 𝔽 (j ), sortedList [j ])를 수행합니다. j 를 j + 1로 설정합니다.resultArray 를 반환합니다.
23.2.3.34 %TypedArray%.prototype.toString ( )
"toString" 프로퍼티의 초기 값은 23.1.3.36 에 정의된 %Array.prototype.toString%입니다.
23.2.3.35 %TypedArray%.prototype.values ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.? ValidateTypedArray (obj , seq-cst )를 수행합니다. CreateArrayIterator (obj , value )를 반환합니다.
23.2.3.36 %TypedArray%.prototype.with ( index , value )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.taRecord 를 ? ValidateTypedArray (obj , seq-cst )로 둡니다.length 를 TypedArrayLength (taRecord )로 둡니다.actualIndex 를 ? ToAbsoluteIndex (index , length )로 둡니다.obj .[[ContentType]] 이 bigint 이면 numericValue 를 ? ToBigInt (value )로 둡니다.그렇지 않으면 numericValue 를 ? ToNumber (value )로 둡니다. IsValidIntegerIndex (obj , 𝔽 (actualIndex ))가 false 이면 RangeError 예외를 던집니다.resultArray 를 ? TypedArrayCreateSameType (obj , length )로 둡니다.k 를 0으로 둡니다.k < length 인 동안 반복합니다.k = actualIndex 이면 fromValue 를 numericValue 로 둡니다.그렇지 않으면 fromValue 를 TypedArrayGetElement (obj , 𝔽 (k ))로 둡니다. 참고 : index 또는 value 가 Number나 BigInt로 변환될 때 코드를 실행하는 객체이고, 해당 코드가 obj 의 기반 버퍼를 축소하면 fromValue 는 undefined 일 수 있습니다.다음을 수행합니다: ? TypedArraySetElement (resultArray , 𝔽 (k ), fromValue ). k 를 k + 1로 설정합니다.resultArray 를 반환합니다.
23.2.3.37 %TypedArray%.prototype [ %Symbol.iterator% ] ( )
%Symbol.iterator% 프로퍼티의 초기 값은 23.2.3.35 에 정의된 %TypedArray.prototype.values%입니다.
23.2.3.38 get %TypedArray%.prototype [ %Symbol.toStringTag% ]
%TypedArray% .prototype[%Symbol.toStringTag%]는 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.obj 가 Object가 아니면 undefined 를 반환합니다.obj 에 [[TypedArrayName]] 내부 슬롯이 없으면 undefined 를 반환합니다.name 을 obj .[[TypedArrayName]] 으로 둡니다.단언 : name 은 String입니다.name 을 반환합니다.
이 프로퍼티는 { [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
이 함수의 "name" 프로퍼티의 초기 값은 "get [Symbol.toStringTag]" 입니다.
23.2.4 TypedArray 객체를 위한 추상 연산
23.2.4.1 TypedArrayCreateFromConstructor ( ctor , argList )
추상 연산 TypedArrayCreateFromConstructor. 인수 ctor (생성자 ) 및 argList (리스트 (요소: ECMAScript 언어 값 )). 반환값: (정상 완료 (값: TypedArray ) 또는 throw 완료 ). 생성자 함수를 사용하여 새로운 TypedArray 를 생성하는 것을 명시하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
ta 를 ? Construct (ctor , argList )로 둡니다.taRecord 를 ? ValidateTypedArray (ta , seq-cst )로 둡니다.단언 : ta 는 TypedArray 인스턴스의 프로퍼티 에서 언급된 모든 내부 슬롯을 갖습니다.argList 의 요소 수가 1이고 argList [0]이 Number이면, 다음을 수행합니다.IsTypedArrayOutOfBounds (taRecord )가 true 이면 TypeError 예외를 던집니다.length 를 TypedArrayLength (taRecord )로 둡니다.length < ℝ (argList [0])이면 TypeError 예외를 던집니다.ta 를 반환합니다.
23.2.4.2 TypedArrayCreateSameType ( exemplar , length )
추상 연산 TypedArrayCreateSameType. 인수 exemplar (TypedArray ) 및 length (음이 아닌 정수). 반환값: (정상 완료 (값: TypedArray ) 또는 throw 완료 ). exemplar 에서 파생된 생성자 함수를 사용하여 새로운 TypedArray 를 생성하는 것을 명시하는 데 사용됩니다. %Symbol.species% 를 사용하여 사용자 정의 TypedArray 하위 클래스를 생성할 수 있는 TypedArraySpeciesCreate 와 달리 이 연산은 항상 내장 TypedArray 생성자 중 하나를 사용합니다. 호출되면 다음 단계를 수행한다.
ctor 를 표 71 에서 생성자 이름 exemplar .[[TypedArrayName]] 과 연결된 내재 객체로 둡니다.result 를 ? TypedArrayCreateFromConstructor (ctor , « 𝔽 (length ) »)로 둡니다.단언 : result 에는 [[TypedArrayName]] 및 [[ContentType]] 내부 슬롯이 있습니다.단언 : result .[[ContentType]] 은 exemplar .[[ContentType]] 입니다.result 를 반환합니다.
23.2.4.3 TypedArraySpeciesCreate ( exemplar , argList )
추상 연산 TypedArraySpeciesCreate. 인수 exemplar (TypedArray ) 및 argList (리스트 (요소: ECMAScript 언어 값 )). 반환값: (정상 완료 (값: TypedArray ) 또는 throw 완료 ). exemplar 에서 파생된 생성자 함수를 사용하여 새로운 TypedArray 를 생성하는 것을 명시하는 데 사용됩니다. %Symbol.species% 를 사용하여 Array가 아닌 객체를 생성할 수 있는 ArraySpeciesCreate 와 달리 이 연산은 생성자 함수가 실제 TypedArray 를 생성하도록 강제합니다. 호출되면 다음 단계를 수행한다.
defaultCtor 를 표 71 에서 생성자 이름 exemplar .[[TypedArrayName]] 과 연결된 내재 객체로 둡니다.ctor 를 ? SpeciesConstructor (exemplar , defaultCtor )로 둡니다.result 를 ? TypedArrayCreateFromConstructor (ctor , argList )로 둡니다.result .[[ContentType]] 이 exemplar .[[ContentType]] 이 아니면 TypeError 예외를 던집니다.result 를 반환합니다.
23.2.4.4 ValidateTypedArray ( obj , order )
추상 연산 ValidateTypedArray. 인수 obj (ECMAScript 언어 값 ) 및 order ((seq-cst 또는 unordered )). 반환값: (정상 완료 (값: TypedArray With Buffer Witness 레코드 ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
? RequireInternalSlot (obj , [[TypedArrayName]] )를 수행합니다. 단언 : obj 에는 [[ViewedArrayBuffer]] 내부 슬롯이 있습니다.? ValidateTypedArrayBounds (obj , order )를 반환합니다.
23.2.4.5 ValidateTypedArrayBounds ( ta , order )
추상 연산 ValidateTypedArrayBounds. 인수 ta (TypedArray ) 및 order ((seq-cst 또는 unordered )). 반환값: (정상 완료 (값: TypedArray With Buffer Witness 레코드 ) 또는 throw 완료 ). ta 가 기반 버퍼의 범위를 초과하지 않는지 검증합니다. 호출되면 다음 단계를 수행한다.
taRecord 를 MakeTypedArrayWithBufferWitnessRecord (ta , order )로 둡니다.IsTypedArrayOutOfBounds (taRecord )가 true 이면 TypeError 예외를 던집니다.taRecord 를 반환합니다.
23.2.4.6 TypedArrayElementSize ( obj )
추상 연산 TypedArrayElementSize. 인수 obj (TypedArray ). 반환값: 음이 아닌 정수. 호출되면 다음 단계를 수행한다.
obj .[[TypedArrayName]] 에 대해 표 71 에 지정된 Element Size 값을 반환합니다.
23.2.4.7 TypedArrayElementType ( obj )
추상 연산 TypedArrayElementType. 인수 obj (TypedArray ). 반환값: TypedArray 요소 타입 . 호출되면 다음 단계를 수행한다.
obj .[[TypedArrayName]] 에 대해 표 71 에 지정된 Element Type 값을 반환합니다.
23.2.4.8 CompareTypedArrayElements ( x , y , comparator )
추상 연산 CompareTypedArrayElements. 인수 x ((Number 또는 BigInt)), y ((Number 또는 BigInt)) 및 comparator ((함수 객체 또는 undefined )). 반환값: (정상 완료 (값: Number) 또는 중도 완료). 호출되면 다음 단계를 수행한다.
단언 : x 가 Number이고 y 가 Number이거나, x 가 BigInt이고 y 가 BigInt입니다.comparator 가 undefined 가 아니면, 다음을 수행합니다.result 를 ? ToNumber (? Call (comparator , undefined , « x , y »))로 둡니다.result 가 NaN 이면 +0 𝔽 을 반환합니다.result 를 반환합니다.x 가 NaN 이고 y 가 NaN 이면 +0 𝔽 을 반환합니다.x 가 NaN 이면 1 𝔽 을 반환합니다.y 가 NaN 이면 -1 𝔽 을 반환합니다.x < y 이면 -1 𝔽 을 반환합니다.x > y 이면 1 𝔽 을 반환합니다.x 가 -0 𝔽 이고 y 가 +0 𝔽 이면 -1 𝔽 을 반환합니다.x 가 +0 𝔽 이고 y 가 -0 𝔽 이면 1 𝔽 을 반환합니다.+0 𝔽 을 반환합니다.
참고
이는
23.1.3.30.2 에서 사용하는 문자열 비교 대신 숫자 비교를 수행합니다.
23.2.5 TypedArray 생성자
각 TypedArray 생성자 는:
달리 언급된 경우를 제외하고 표 71 에서 TypedArray 대신 생성자 이름으로 사용되는 이름만 다르며 아래에 설명된 구조를 갖는 내재 객체입니다.
인수의 수와 타입에 따라 동작이 달라지는 함수입니다. TypedArray 호출의 실제 동작은 전달되는 인수의 수와 종류에 따라 달라집니다.
함수로 호출하도록 의도되지 않았으며 그러한 방식으로 호출되면 예외를 던집니다.
클래스 정의의 extends 절 값으로 사용할 수 있습니다. 지정된 TypedArray 동작을 상속하려는 하위 클래스 생성자 는 %TypedArray% .prototype의 내장 메서드를 지원하는 데 필요한 내부 상태를 갖도록 하위 클래스 인스턴스를 생성하고 초기화하기 위해 TypedArray 생성자 에 대한 super 호출을 포함해야 합니다.
23.2.5.1 TypedArray ( ...args )
각 TypedArray 생성자 는 호출되면 다음 단계를 수행합니다:
NewTarget이 undefined 이면 TypeError 예외를 던집니다. ctorName 을 이 TypedArray 생성자 에 대해 표 71 에 지정된 Constructor Name 값의 String 값으로 둡니다.proto 를 "%TypedArray .prototype%"로 둡니다.numberOfArgs 를 args 의 요소 수로 둡니다.numberOfArgs = 0이면 ? AllocateTypedArray (ctorName , NewTarget, proto , 0)을 반환합니다.firstArg 를 args [0]으로 둡니다.firstArg 가 Object이면, 다음을 수행합니다.obj 를 ? AllocateTypedArray (ctorName , NewTarget, proto )로 둡니다.firstArg 에 [[TypedArrayName]] 내부 슬롯이 있으면, 다음을 수행합니다.? InitializeTypedArrayFromTypedArray (obj , firstArg )를 수행합니다. 그렇지 않고 firstArg 에 [[ArrayBufferData]] 내부 슬롯이 있으면, 다음을 수행합니다.numberOfArgs > 1이면 byteOffset 을 args [1]로 둡니다. 그렇지 않으면 byteOffset 을 undefined 로 둡니다.numberOfArgs > 2이면 length 를 args [2]로 둡니다. 그렇지 않으면 length 를 undefined 로 둡니다.? InitializeTypedArrayFromArrayBuffer (obj , firstArg , byteOffset , length )를 수행합니다. 그렇지 않으면,단언 : firstArg 는 Object이고 firstArg 에는 [[TypedArrayName]] 또는 [[ArrayBufferData]] 내부 슬롯 중 어느 것도 없습니다.usingIterator 를 ? GetMethod (firstArg , %Symbol.iterator% )로 둡니다.usingIterator 가 undefined 가 아니면, 다음을 수행합니다.values 를 ? IteratorToList (? GetIteratorFromMethod (firstArg , usingIterator ))로 둡니다.? InitializeTypedArrayFromList (obj , values )를 수행합니다. 그렇지 않으면,참고 : firstArg 는 반복 가능 객체가 아니므로 이미 배열과 유사한 객체 라고 가정합니다.? InitializeTypedArrayFromArrayLike (obj , firstArg )를 수행합니다. obj 를 반환합니다.단언 : firstArg 는 Object가 아닙니다.elementLength 를 ? ToIndex (firstArg )로 둡니다.? AllocateTypedArray (ctorName , NewTarget, proto , elementLength )를 반환합니다.
23.2.5.1.1 AllocateTypedArray ( ctorName , newTarget , defaultProto [ , length ] )
추상 연산 AllocateTypedArray. 인수 ctorName (a String which is the name of a TypedArray constructor in 표 71 ), newTarget (생성자 ) 및 defaultProto (String) 및 선택적 인수 length (음이 아닌 정수). 반환값: (정상 완료 (값: TypedArray ) 또는 throw 완료 ). TypedArray 생성자 의 인스턴스를 검증하고 생성하는 데 사용됩니다. length 인수가 전달되면 해당 길이의 ArrayBuffer도 할당하여 새로운 TypedArray 인스턴스와 연결합니다. AllocateTypedArray는 TypedArray 가 사용하는 공통 의미론을 제공합니다. 호출되면 다음 단계를 수행한다.
proto 를 ? GetPrototypeFromConstructor (newTarget , defaultProto )로 둡니다.obj 를 TypedArrayCreate (proto )로 둡니다.단언 : obj .[[ViewedArrayBuffer]] 는 undefined 입니다.obj .[[TypedArrayName]] 을 ctorName 으로 설정합니다.ctorName 이 "BigInt64Array" 또는 "BigUint64Array" 중 하나이면 obj .[[ContentType]] 을 bigint 로 설정합니다.그렇지 않으면 obj .[[ContentType]] 을 number 로 설정합니다. length 가 존재하지 않으면, 다음을 수행합니다.obj .[[ByteLength]] 를 0으로 설정합니다.obj .[[ByteOffset]] 을 0으로 설정합니다.obj .[[ArrayLength]] 를 0으로 설정합니다.그렇지 않으면,? AllocateTypedArrayBuffer (obj , length )를 수행합니다. obj 를 반환합니다.
23.2.5.1.2 InitializeTypedArrayFromTypedArray ( obj , sourceArray )
추상 연산 InitializeTypedArrayFromTypedArray. 인수 obj (TypedArray ) 및 sourceArray (TypedArray ). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
sourceData 를 sourceArray .[[ViewedArrayBuffer]] 로 둡니다.elementType 을 TypedArrayElementType (obj )로 둡니다.elementSize 를 TypedArrayElementSize (obj )로 둡니다.sourceType 을 TypedArrayElementType (sourceArray )로 둡니다.sourceElementSize 를 TypedArrayElementSize (sourceArray )로 둡니다.sourceByteOffset 을 sourceArray .[[ByteOffset]] 으로 둡니다.sourceRecord 를 ? ValidateTypedArrayBounds (sourceArray , seq-cst )로 둡니다.elementLength 를 TypedArrayLength (sourceRecord )로 둡니다.byteLength 를 elementSize × elementLength 로 둡니다.elementType 이 sourceType 이면, 다음을 수행합니다.data 를 ? CloneArrayBuffer (sourceData , sourceByteOffset , byteLength )로 둡니다.그렇지 않으면,data 를 ? AllocateArrayBuffer (%ArrayBuffer% , byteLength )로 둡니다.sourceArray .[[ContentType]] 이 obj .[[ContentType]] 이 아니면 TypeError 예외를 던집니다.sourceByteIndex 를 sourceByteOffset 으로 둡니다.targetByteIndex 를 0으로 둡니다.count 를 elementLength 로 둡니다.count > 0인 동안 다음을 반복합니다.value 를 GetValueFromBuffer (sourceData , sourceByteIndex , sourceType , true , unordered )로 둡니다.SetValueInBuffer (data , targetByteIndex , elementType , value , true , unordered )를 수행합니다.sourceByteIndex 를 sourceByteIndex + sourceElementSize 로 설정합니다.targetByteIndex 를 targetByteIndex + elementSize 로 설정합니다.count 를 count - 1로 설정합니다. obj .[[ViewedArrayBuffer]] 를 data 로 설정합니다.obj .[[ByteLength]] 를 byteLength 로 설정합니다.obj .[[ByteOffset]] 을 0으로 설정합니다.obj .[[ArrayLength]] 를 elementLength 로 설정합니다.unused 를 반환합니다.
23.2.5.1.3 InitializeTypedArrayFromArrayBuffer ( obj , buffer , byteOffset , length )
추상 연산 InitializeTypedArrayFromArrayBuffer. 인수 obj (TypedArray ), buffer ((ArrayBuffer 또는 SharedArrayBuffer)), byteOffset (ECMAScript 언어 값 ) 및 length (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
elementSize 를 TypedArrayElementSize (obj )로 둡니다.offset 을 ? ToIndex (byteOffset )로 둡니다.offset modulo elementSize ≠ 0이면 RangeError 예외를 던집니다.bufferIsFixedLength 를 IsFixedLengthArrayBuffer (buffer )로 둡니다.length 가 undefined 가 아니면, 다음을 수행합니다.newLength 를 ? ToIndex (length )로 둡니다.IsDetachedBuffer (buffer )가 true 이면 TypeError 예외를 던집니다.bufferByteLength 를 ArrayBufferByteLength (buffer , seq-cst )로 둡니다.length 가 undefined 이고 bufferIsFixedLength 가 false 이면, 다음을 수행합니다.offset > bufferByteLength 이면 RangeError 예외를 던집니다.obj .[[ByteLength]] 를 auto 로 설정합니다.obj .[[ArrayLength]] 를 auto 로 설정합니다.그렇지 않으면,length 가 undefined 이면, 다음을 수행합니다.bufferByteLength modulo elementSize ≠ 0이면 RangeError 예외를 던집니다.newByteLength 를 bufferByteLength - offset 으로 둡니다.newByteLength < 0이면 RangeError 예외를 던집니다.그렇지 않으면,newByteLength 를 newLength × elementSize 로 둡니다.offset + newByteLength > bufferByteLength 이면 RangeError 예외를 던집니다. obj .[[ByteLength]] 를 newByteLength 로 설정합니다.obj .[[ArrayLength]] 를 newByteLength / elementSize 로 설정합니다. obj .[[ViewedArrayBuffer]] 를 buffer 로 설정합니다.obj .[[ByteOffset]] 을 offset 으로 설정합니다.unused 를 반환합니다.
23.2.5.1.4 InitializeTypedArrayFromList ( obj , values )
추상 연산 InitializeTypedArrayFromList. 인수 obj (TypedArray ) 및 values (리스트 (요소: ECMAScript 언어 값 )). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
length 를 values 의 요소 수로 둡니다.? AllocateTypedArrayBuffer (obj , length )를 수행합니다. k 를 0으로 둡니다.k < length 인 동안 다음을 반복합니다.kValue 를 values [k ]로 둡니다.? TypedArraySetElement (obj , 𝔽 (k ), kValue )를 수행합니다. k 를 k + 1로 설정합니다.unused 를 반환합니다.
23.2.5.1.5 InitializeTypedArrayFromArrayLike ( obj , arrayLike )
추상 연산 InitializeTypedArrayFromArrayLike. 인수 obj (TypedArray ) 및 arrayLike (an Object, but not a TypedArray or an ArrayBuffer). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
length 를 ? LengthOfArrayLike (arrayLike )로 둡니다.? AllocateTypedArrayBuffer (obj , length )를 수행합니다. k 를 0으로 둡니다.k < length 인 동안 다음을 반복합니다.propertyKey 를 ! ToString (𝔽 (k ))로 둡니다.kValue 를 ? Get (arrayLike , propertyKey )로 둡니다.? TypedArraySetElement (obj , 𝔽 (k ), kValue )를 수행합니다. k 를 k + 1로 설정합니다.unused 를 반환합니다.
23.2.5.1.6 AllocateTypedArrayBuffer ( obj , length )
추상 연산 AllocateTypedArrayBuffer. 인수 obj (TypedArray ) 및 length (음이 아닌 정수). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). ArrayBuffer를 할당하여 obj 와 연결합니다. 호출되면 다음 단계를 수행한다.
단언 : obj .[[ViewedArrayBuffer]] 는 undefined 입니다.elementSize 를 TypedArrayElementSize (obj )로 둡니다.byteLength 를 elementSize × length 로 둡니다.data 를 ? AllocateArrayBuffer (%ArrayBuffer% , byteLength )로 둡니다.obj .[[ViewedArrayBuffer]] 를 data 로 설정합니다.obj .[[ByteLength]] 를 byteLength 로 설정합니다.obj .[[ByteOffset]] 을 0으로 설정합니다.obj .[[ArrayLength]] 를 length 로 설정합니다.unused 를 반환합니다.
23.2.6 TypedArray 생성자의 프로퍼티
각 TypedArray 생성자 는:
값이 %TypedArray% 인 [[Prototype]] 내부 슬롯을 갖습니다.
값이 3 𝔽 인 "length" 프로퍼티를 갖습니다.
값이 표 71 에서 해당 생성자 에 지정된 생성자 이름의 String 값인 "name" 프로퍼티를 갖습니다.
다음 프로퍼티를 갖습니다:
23.2.6.1 TypedArray .BYTES_PER_ELEMENT
TypedArray .BYTES_PER_ELEMENT의 값은 TypedArray 에 대해 표 71 에 지정된 Element Size 값입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
23.2.6.2 TypedArray .prototype
TypedArray .prototype의 초기 값은 대응하는 TypedArray 프로토타입 내재 객체(23.2.7 )입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
23.2.7 TypedArray 프로토타입 객체의 프로퍼티
각 TypedArray 프로토타입 객체는:
23.2.7.1 TypedArray .prototype.BYTES_PER_ELEMENT
TypedArray .prototype.BYTES_PER_ELEMENT의 값은 TypedArray 에 대해 표 71 에 지정된 Element Size 값입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
23.2.7.2 TypedArray .prototype.constructor
주어진 TypedArray 생성자 의 프로토타입에 있는 "constructor" 프로퍼티의 초기 값은 해당 생성자 자체입니다.
23.2.8 TypedArray 인스턴스의 프로퍼티
TypedArray 인스턴스는 TypedArray 입니다. 각 TypedArray 인스턴스는 대응하는 TypedArray 프로토타입 객체에서 프로퍼티를 상속합니다. 각 TypedArray 인스턴스는 [[ViewedArrayBuffer]] , [[TypedArrayName]] , [[ContentType]] , [[ByteLength]] , [[ByteOffset]] , [[ArrayLength]] 내부 슬롯을 갖습니다.
23.3 Uint8Array 객체
Uint8Array는 위에서 설명한 특정 종류의 TypedArray 입니다. 또한 Uint8Array 생성자 (23.3.1 )와 Uint8Array 프로토타입 객체(23.3.2 )에는 추가 메서드가 있습니다.
23.3.1 Uint8Array 생성자의 추가 프로퍼티
23.3.1.1 Uint8Array.fromBase64 ( string [ , options ] )
string 이 String이 아니면 TypeError 예외를 던집니다.optionsObj 를 ? GetOptionsObject (options )로 둡니다.alphabet 을 ? Get (optionsObj , "alphabet" )로 둡니다.alphabet 이 undefined 이면 alphabet 을 "base64" 로 설정합니다.alphabet 이 "base64" 도 "base64url" 도 아니면 TypeError 예외를 던집니다.lastChunkHandling 을 ? Get (optionsObj , "lastChunkHandling" )로 둡니다.lastChunkHandling 이 undefined 이면 lastChunkHandling 을 "loose" 로 설정합니다.lastChunkHandling 이 "loose" , "strict" 또는 "stop-before-partial" 중 하나가 아니면 TypeError 예외를 던집니다.result 를 FromBase64 (string , alphabet , lastChunkHandling )로 둡니다.result .[[Error]] 가 none 이 아니면, 다음을 수행합니다.result .[[Error]] 를 던집니다.resultLength 를 result .[[Bytes]] 의 요소 수로 둡니다.ta 를 ? AllocateTypedArray ("Uint8Array" , %Uint8Array% , "%Uint8Array.prototype%" , resultLength )로 둡니다.단언 : ta .[[ViewedArrayBuffer]] .[[ArrayBufferByteLength]] 는 result .[[Bytes]] 의 요소 수입니다.ta .[[ViewedArrayBuffer]] .[[ArrayBufferData]] 의 각 인덱스 값을 result .[[Bytes]] 의 대응하는 인덱스 값으로 설정합니다.ta 를 반환합니다.
23.3.1.2 Uint8Array.fromHex ( string )
string 이 String이 아니면 TypeError 예외를 던집니다.result 를 FromHex (string )로 둡니다.result .[[Error]] 가 none 이 아니면, 다음을 수행합니다.result .[[Error]] 를 던집니다.resultLength 를 result .[[Bytes]] 의 요소 수로 둡니다.ta 를 ? AllocateTypedArray ("Uint8Array" , %Uint8Array% , "%Uint8Array.prototype%" , resultLength )로 둡니다.단언 : ta .[[ViewedArrayBuffer]] .[[ArrayBufferByteLength]] 는 result .[[Bytes]] 의 요소 수입니다.ta .[[ViewedArrayBuffer]] .[[ArrayBufferData]] 의 각 인덱스 값을 result .[[Bytes]] 의 대응하는 인덱스 값으로 설정합니다.ta 를 반환합니다.
23.3.2 Uint8Array 프로토타입 객체의 추가 프로퍼티
23.3.2.1 Uint8Array.prototype.setFromBase64 ( string [ , options ] )
into 를 this 값으로 둡니다.? ValidateUint8Array (into )를 수행합니다. string 이 String이 아니면 TypeError 예외를 던집니다.optionsObj 를 ? GetOptionsObject (options )로 둡니다.alphabet 을 ? Get (optionsObj , "alphabet" )로 둡니다.alphabet 이 undefined 이면 alphabet 을 "base64" 로 설정합니다.alphabet 이 "base64" 도 "base64url" 도 아니면 TypeError 예외를 던집니다.lastChunkHandling 을 ? Get (optionsObj , "lastChunkHandling" )로 둡니다.lastChunkHandling 이 undefined 이면 lastChunkHandling 을 "loose" 로 설정합니다.lastChunkHandling 이 "loose" , "strict" 또는 "stop-before-partial" 중 하나가 아니면 TypeError 예외를 던집니다.taRecord 를 ? ValidateTypedArrayBounds (into , seq-cst )로 둡니다.byteLength 를 TypedArrayLength (taRecord )로 둡니다.result 를 FromBase64 (string , alphabet , lastChunkHandling , byteLength )로 둡니다.bytes 를 result .[[Bytes]] 로 둡니다.written 을 bytes 의 요소 수로 둡니다.참고 : FromBase64 는 사용자 코드를 호출하지 않으므로 into 의 기반 ArrayBuffer는 분리되거나 축소될 수 없습니다.단언 : written ≤ byteLength 입니다.SetUint8ArrayBytes (into , bytes )를 수행합니다.result .[[Error]] 가 none 이 아니면, 다음을 수행합니다.result .[[Error]] 를 던집니다.resultObj 를 OrdinaryObjectCreate (%Object.prototype% )로 둡니다.! CreateDataPropertyOrThrow (resultObj , "read" , 𝔽 (result .[[Read]] ))를 수행합니다. ! CreateDataPropertyOrThrow (resultObj , "written" , 𝔽 (written ))을 수행합니다. resultObj 를 반환합니다.
23.3.2.2 Uint8Array.prototype.setFromHex ( string )
into 를 this 값으로 둡니다.? ValidateUint8Array (into )를 수행합니다. string 이 String이 아니면 TypeError 예외를 던집니다.taRecord 를 ? ValidateTypedArrayBounds (into , seq-cst )로 둡니다.byteLength 를 TypedArrayLength (taRecord )로 둡니다.result 를 FromHex (string , byteLength )로 둡니다.bytes 를 result .[[Bytes]] 로 둡니다.written 을 bytes 의 요소 수로 둡니다.참고 : FromHex 는 사용자 코드를 호출하지 않으므로 into 의 기반 ArrayBuffer는 분리되거나 축소될 수 없습니다.단언 : written ≤ byteLength 입니다.SetUint8ArrayBytes (into , bytes )를 수행합니다.result .[[Error]] 가 none 이 아니면, 다음을 수행합니다.result .[[Error]] 를 던집니다.resultObj 를 OrdinaryObjectCreate (%Object.prototype% )로 둡니다.! CreateDataPropertyOrThrow (resultObj , "read" , 𝔽 (result .[[Read]] ))를 수행합니다. ! CreateDataPropertyOrThrow (resultObj , "written" , 𝔽 (written ))을 수행합니다. resultObj 를 반환합니다.
23.3.2.3 Uint8Array.prototype.toBase64 ( [ options ] )
obj 를 this 값으로 둡니다.? ValidateUint8Array (obj )를 수행합니다. optionsObj 를 ? GetOptionsObject (options )로 둡니다.alphabet 을 ? Get (optionsObj , "alphabet" )로 둡니다.alphabet 이 undefined 이면 alphabet 을 "base64" 로 설정합니다.alphabet 이 "base64" 도 "base64url" 도 아니면 TypeError 예외를 던집니다.omitPadding 을 ToBoolean (? Get (optionsObj , "omitPadding" ))으로 둡니다.toEncode 를 ? GetUint8ArrayBytes (obj )로 둡니다.alphabet 이 "base64" 이면, 다음을 수행합니다.outAscii 를 RFC 4648 제4절에 지정된 base64 인코딩에 따라 toEncode 를 인코딩한 결과인 코드 포인트 시퀀스로 둡니다. 패딩은 omitPadding 이 false 인 경우에만 포함됩니다.그렇지 않으면,단언 : alphabet 은 "base64url" 입니다.outAscii 를 RFC 4648 제5절에 지정된 base64url 인코딩에 따라 toEncode 를 인코딩한 결과인 코드 포인트 시퀀스로 둡니다. 패딩은 omitPadding 이 false 인 경우에만 포함됩니다. CodePointsToString (outAscii )을 반환합니다.
23.3.2.4 Uint8Array.prototype.toHex ( )
obj 를 this 값으로 둡니다.? ValidateUint8Array (obj )를 수행합니다. toEncode 를 ? GetUint8ArrayBytes (obj )로 둡니다.out 을 빈 String으로 둡니다.toEncode 의 각 바이트 byte 에 대해 다음을 수행합니다.hex 를 Number::toString (𝔽 (byte ), 16)으로 둡니다.hex 를 StringPad (hex , 2, "0" , start )로 설정합니다.out 을 out 과 hex 의 문자열 연결 로 설정합니다.out 을 반환합니다.
23.3.3 Uint8Array 객체를 위한 추상 연산
23.3.3.1 ValidateUint8Array ( ta )
추상 연산 ValidateUint8Array. 인수 ta (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
? RequireInternalSlot (ta , [[TypedArrayName]] )를 수행합니다. ta .[[TypedArrayName]] 이 "Uint8Array" 가 아니면 TypeError 예외를 던집니다.unused 를 반환합니다.
23.3.3.2 GetUint8ArrayBytes ( ta )
추상 연산 GetUint8ArrayBytes. 인수 ta (Uint8Array). 반환값: (정상 완료 (값: 리스트 (요소: 바이트 값 )) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
buffer 를 ta .[[ViewedArrayBuffer]] 로 둡니다.taRecord 를 ? ValidateTypedArrayBounds (ta , seq-cst )로 둡니다.length 를 TypedArrayLength (taRecord )로 둡니다.byteOffset 을 ta .[[ByteOffset]] 으로 둡니다.bytes 를 새로운 빈 List 로 둡니다.index 를 0으로 둡니다.index < length 인 동안 다음을 반복합니다.byteIndex 를 byteOffset + index 로 둡니다.byte 를 ℝ (GetValueFromBuffer (buffer , byteIndex , uint8 , true , unordered ))로 둡니다.byte 를 bytes 에 추가합니다.index 를 index + 1로 설정합니다.bytes 를 반환합니다.
23.3.3.3 SetUint8ArrayBytes ( into , bytes )
추상 연산 SetUint8ArrayBytes. 인수 into (Uint8Array) 및 bytes (리스트 (요소: 바이트 값 )). 반환값: unused . 호출되면 다음 단계를 수행한다.
offset 을 into .[[ByteOffset]] 으로 둡니다.length 를 bytes 의 요소 수로 둡니다.index 를 0으로 둡니다.index < length 인 동안 다음을 반복합니다.byte 를 bytes [index ]로 둡니다.byteIndexInBuffer 를 index + offset 으로 둡니다.SetValueInBuffer (into .[[ViewedArrayBuffer]] , byteIndexInBuffer , uint8 , 𝔽 (byte ), true , unordered )를 수행합니다.index 를 index + 1로 설정합니다.unused 를 반환합니다.
23.3.3.4 SkipAsciiWhitespace ( string , index )
추상 연산 SkipAsciiWhitespace. 인수 string (String) 및 index (음이 아닌 정수). 반환값: 음이 아닌 정수. 호출되면 다음 단계를 수행한다.
length 를 string 의 길이로 둡니다.index < length 인 동안 다음을 반복합니다.char 를 string 안의 인덱스 index 에 있는 코드 단위로 둡니다.char 가 0x0009 (TAB), 0x000A (LF), 0x000C (FF), 0x000D (CR) 또는 0x0020 (SPACE) 중 하나가 아니면, 다음을 수행합니다.index 를 반환합니다.index 를 index + 1로 설정합니다.index 를 반환합니다.
23.3.3.5 DecodeFinalBase64Chunk ( chunk , throwOnExtraBits )
추상 연산 DecodeFinalBase64Chunk. 인수 chunk ((a String of length 2 또는 3)) 및 throwOnExtraBits (Boolean). 반환값: (정상 완료 (값: 리스트 (요소: 바이트 값 )) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
chunkLength 를 chunk 의 길이로 둡니다.chunkLength = 2이면, 다음을 수행합니다.chunk 를 chunk 과 "AA" 의 문자열 연결 로 설정합니다.그렇지 않으면,단언 : chunkLength 는 3입니다.chunk 를 chunk 과 "A" 의 문자열 연결 로 설정합니다. bytes 를 DecodeFullLengthBase64Chunk (chunk )로 둡니다.chunkLength = 2이면, 다음을 수행합니다.throwOnExtraBits 가 true 이고 bytes [1] ≠ 0이면 SyntaxError 예외를 던집니다.« bytes [0] »을 반환합니다. throwOnExtraBits 가 true 이고 bytes [2] ≠ 0이면 SyntaxError 예외를 던집니다.« bytes [0], bytes [1] »을 반환합니다.
23.3.3.6 DecodeFullLengthBase64Chunk ( chunk )
추상 연산 DecodeFullLengthBase64Chunk. 인수 chunk (a String of length 4). 반환값: 리스트 (요소: byte values of length 3).
표준 base64 알파벳 은 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" 입니다. 즉, 유니코드 Basic Latin 블록의 모든 문자와 숫자에 대응하는 코드 단위에 "+" 및 "/" 를 더한 것을 요소로 갖는 String입니다.
byteSequence 를 chunk 를 base64로 디코딩하여 얻는 고유한 3바이트 시퀀스로 둡니다(즉, RFC 4648 제4절에 지정된 base64 인코딩을 byteSequence 에 적용하면 chunk 가 생성되는 시퀀스).byteSequence 의 요소를 순서대로 요소로 갖는 List 를 반환합니다.
23.3.3.7 FromBase64 ( string , alphabet , lastChunkHandling [ , maxLength ] )
추상 연산 FromBase64. 인수 string (String), alphabet (("base64" 또는 "base64url" )) 및 lastChunkHandling (("loose" , "strict" 또는 "stop-before-partial" )) 및 선택적 인수 maxLength (음이 아닌 정수). 반환값: 레코드 (필드: [[Read]] (정수 ), [[Bytes]] (리스트 (요소: 바이트 값 )), [[Error]] ((a SyntaxError object 또는 none ))). 호출되면 다음 단계를 수행한다.
maxLength 가 존재하지 않으면, 다음을 수행합니다.maxLength 를 253 - 1로 설정합니다.참고 : 입력이 String이므로 String의 길이는 253 - 1자로 제한되고, 출력에 필요한 바이트 수는 입력의 문자 수보다 많지 않으므로 이 제한에는 절대 도달할 수 없습니다. 그러나 편집상 maxLength 에 유한 값을 사용하는 것이 편리합니다.참고 : 아래 알고리즘에서 검증과 디코딩의 순서는 관찰할 수 없습니다. 구현체는 가장 효율적인 순서로 수행하는 것이 권장되며, 검증과 디코딩을 서로 섞어서 수행할 수도 있습니다.maxLength = 0이면, 다음을 수행합니다.Record { [[Read]] : 0, [[Bytes]] : « », [[Error]] : none }을 반환합니다.read 를 0으로 둡니다.bytes 를 새로운 빈 List 로 둡니다.chunk 을 빈 String으로 둡니다.chunkLength 를 0으로 둡니다.index 를 0으로 둡니다.length 를 string 의 길이로 둡니다.다음을 반복합니다.단언 : bytes 의 요소 수는 3으로 나누어떨어집니다.index 를 SkipAsciiWhitespace (string , index )로 설정합니다.index = length 이면, 다음을 수행합니다.chunkLength > 0이면, 다음을 수행합니다.lastChunkHandling 이 "stop-before-partial" 이면, 다음을 수행합니다.Record { [[Read]] : read , [[Bytes]] : bytes , [[Error]] : none }을 반환합니다.lastChunkHandling 이 "strict" 이면, 다음을 수행합니다.error 를 새로 생성된 SyntaxError 객체로 둡니다.Record { [[Read]] : read , [[Bytes]] : bytes , [[Error]] : error }를 반환합니다.단언 : lastChunkHandling 은 "loose" 입니다.chunkLength = 1이면, 다음을 수행합니다.error 를 새로 생성된 SyntaxError 객체로 둡니다.Record { [[Read]] : read , [[Bytes]] : bytes , [[Error]] : error }를 반환합니다.bytes 를 bytes 와 ! DecodeFinalBase64Chunk (chunk , false )의 목록 연결 로 설정합니다.Record { [[Read]] : length , [[Bytes]] : bytes , [[Error]] : none }을 반환합니다.char 를 string 의 index 부터 index + 1까지의 부분 문자열 로 둡니다.index 를 index + 1로 설정합니다.char 가 "=" 이면, 다음을 수행합니다.chunkLength < 2이면, 다음을 수행합니다.error 를 새로 생성된 SyntaxError 객체로 둡니다.Record { [[Read]] : read , [[Bytes]] : bytes , [[Error]] : error }를 반환합니다.index 를 SkipAsciiWhitespace (string , index )로 설정합니다.chunkLength = 2이면, 다음을 수행합니다.index = length 이면, 다음을 수행합니다.lastChunkHandling 이 "stop-before-partial" 이면, 다음을 수행합니다.Record { [[Read]] : read , [[Bytes]] : bytes , [[Error]] : none }을 반환합니다.error 를 새로 생성된 SyntaxError 객체로 둡니다.Record { [[Read]] : read , [[Bytes]] : bytes , [[Error]] : error }를 반환합니다.char 를 string 의 index 부터 index + 1까지의 부분 문자열 로 설정합니다.char 가 "=" 이면, 다음을 수행합니다.index 를 SkipAsciiWhitespace (string , index + 1)로 설정합니다.index < length 이면, 다음을 수행합니다.error 를 새로 생성된 SyntaxError 객체로 둡니다.Record { [[Read]] : read , [[Bytes]] : bytes , [[Error]] : error }를 반환합니다.lastChunkHandling 이 "strict" 이면 throwOnExtraBits 를 true 로 둡니다. 그렇지 않으면 throwOnExtraBits 를 false 로 둡니다.decodeResult 를 Completion (DecodeFinalBase64Chunk (chunk , throwOnExtraBits ))로 둡니다.decodeResult 가 갑작스러운 완료이면, 다음을 수행합니다.error 를 decodeResult .[[Value]] 로 둡니다.Record { [[Read]] : read , [[Bytes]] : bytes , [[Error]] : error }를 반환합니다.bytes 를 bytes 와 ! decodeResult 의 목록 연결 로 설정합니다.Record { [[Read]] : length , [[Bytes]] : bytes , [[Error]] : none }을 반환합니다.alphabet 이 "base64url" 이면, 다음을 수행합니다.char 가 "+" 또는 "/" 중 하나이면, 다음을 수행합니다.error 를 새로 생성된 SyntaxError 객체로 둡니다.Record { [[Read]] : read , [[Bytes]] : bytes , [[Error]] : error }를 반환합니다.그렇지 않고 char 가 "-" 이면, 다음을 수행합니다.char 를 "+" 로 설정합니다. 그렇지 않고 char 가 "_" 이면, 다음을 수행합니다.char 를 "/" 로 설정합니다. char 의 유일한 코드 단위가 표준 base64 알파벳 의 요소가 아니면, 다음을 수행합니다.error 를 새로 생성된 SyntaxError 객체로 둡니다.Record { [[Read]] : read , [[Bytes]] : bytes , [[Error]] : error }를 반환합니다.remaining 을 maxLength - bytes 의 요소 수로 둡니다.remaining = 1이고 chunkLength = 2이거나, remaining = 2이고 chunkLength = 3이면, 다음을 수행합니다.Record { [[Read]] : read , [[Bytes]] : bytes , [[Error]] : none }을 반환합니다.chunk 을 chunk 과 char 의 문자열 연결 로 설정합니다.chunkLength 를 chunk 의 길이로 설정합니다.chunkLength = 4이면, 다음을 수행합니다.bytes 를 bytes 와 DecodeFullLengthBase64Chunk (chunk )의 목록 연결 로 설정합니다.chunk 을 빈 String으로 설정합니다.chunkLength 를 0으로 설정합니다.read 를 index 로 설정합니다.bytes 의 요소 수 = maxLength 이면, 다음을 수행합니다.Record { [[Read]] : read , [[Bytes]] : bytes , [[Error]] : none }을 반환합니다.
23.3.3.8 FromHex ( string [ , maxLength ] )
추상 연산 FromHex. 인수 string (String) 및 선택적 인수 maxLength (음이 아닌 정수). 반환값: 레코드 (필드: [[Read]] (정수 ), [[Bytes]] (리스트 (요소: 바이트 값 )), [[Error]] ((a SyntaxError object 또는 none ))). 호출되면 다음 단계를 수행한다.
maxLength 가 존재하지 않으면 maxLength 를 253 - 1로 설정합니다.length 를 string 의 길이로 둡니다.bytes 를 새로운 빈 List 로 둡니다.read 를 0으로 둡니다.length modulo 2 ≠ 0이면, 다음을 수행합니다.error 를 새로 생성된 SyntaxError 객체로 둡니다.Record { [[Read]] : read , [[Bytes]] : bytes , [[Error]] : error }를 반환합니다.read < length 이고 bytes 의 요소 수 < maxLength 인 동안 다음을 반복합니다.hexits 를 string 의 read 부터 read + 2까지의 부분 문자열 로 둡니다.hexits 에 "0123456789abcdefABCDEF" 에 포함되지 않은 코드 단위가 있으면, 다음을 수행합니다.error 를 새로 생성된 SyntaxError 객체로 둡니다.Record { [[Read]] : read , [[Bytes]] : bytes , [[Error]] : error }를 반환합니다.read 를 read + 2로 설정합니다.byte 를 16진법 표기에서 hexits 가 나타내는 정수 값으로 둡니다. 값 10부터 15까지의 숫자에는 문자 A 부터 F 및 a 부터 f 를 사용합니다.byte 를 bytes 에 추가합니다.Record { [[Read]] : read , [[Bytes]] : bytes , [[Error]] : none }을 반환합니다.
24 키 컬렉션
24.1 Map 객체
Map은 키와 값 모두 임의의 ECMAScript language value일 수 있는 키/값 쌍의 컬렉션입니다. 서로 다른 키 값은 Map의 컬렉션 안에서 하나의 키/값 쌍에만 존재할 수 있습니다. 서로 다른 키 값은 SameValueZero 비교 알고리즘의 의미론을 사용하여 구별합니다.
Map은 평균적으로 컬렉션의 요소 수에 대해 선형보다 빠른 접근 시간을 제공하는 해시 테이블이나 그 밖의 메커니즘을 사용하여 구현해야 합니다. 이 명세에서 사용하는 데이터 구조는 Map에 요구되는 관찰 가능한 의미론을 설명하기 위한 것일 뿐입니다. 실제 구현 모델로 사용하려는 것은 아닙니다.
24.1.1 Map 생성자
Map 생성자 는:
%Map% 입니다.
전역 객체 의 "Map" 프로퍼티의 초기 값입니다.
생성자 로 호출되면 새로운 Map을 생성하고 초기화합니다.
함수로 호출하도록 의도되지 않았으며 그러한 방식으로 호출되면 예외를 던집니다.
클래스 정의의 extends 절에서 값으로 사용할 수 있습니다. 지정된 Map 동작을 상속하려는 하위 클래스 생성자 는 Map.prototype의 내장 메서드를 지원하는 데 필요한 내부 상태를 갖도록 하위 클래스 인스턴스를 생성하고 초기화하기 위해 Map 생성자 에 대한 super 호출을 포함해야 합니다.
24.1.1.1 Map ( [ iterable ] )
이 함수는 호출되면 다음 단계를 수행합니다:
NewTarget이 undefined 이면 TypeError 예외를 던집니다. map 을 ? OrdinaryCreateFromConstructor (NewTarget, "%Map.prototype%" , « [[MapData]] »)로 둡니다.map .[[MapData]] 를 새로운 빈 List 로 설정합니다.iterable 이 undefined 또는 null 이면 map 을 반환합니다.adder 를 ? Get (map , "set" )으로 둡니다.IsCallable (adder )가 false 이면 TypeError 예외를 던집니다.? AddEntriesFromIterable (map , iterable , adder )를 반환합니다.
참고
매개변수 iterable 이 존재하는 경우, 첫 번째 요소는 Map 키로 사용할 값이고 두 번째 요소는 해당 키와 연결할 값인 두 요소의 배열과 유사한 객체 를 생성하는 반복자 객체를 반환하는 %Symbol.iterator% 메서드를 구현한 객체일 것으로 예상됩니다.
24.1.1.2 AddEntriesFromIterable ( target , iterable , adder )
추상 연산 AddEntriesFromIterable. 인수 target (Object), iterable (an ECMAScript language value, but not undefined or null ) 및 adder (함수 객체 ). 반환값: (정상 완료 (값: Object) 또는 throw 완료 ). adder 는 target 을 수신자로 하여 호출됩니다. 호출되면 다음 단계를 수행한다.
iteratorRecord 를 ? GetIterator (iterable , sync )로 둡니다.다음을 반복합니다.next 를 ? IteratorStepValue (iteratorRecord )로 둡니다.next 가 done 이면 target 을 반환합니다.next 가 Object가 아니면, 다음을 수행합니다.error 를 ThrowCompletion (새로 생성된 TypeError 객체)로 둡니다.? IteratorClose (iteratorRecord , error )를 반환합니다. key 를 Completion (Get (next , "0" ))으로 둡니다.IfAbruptCloseIterator (key , iteratorRecord ).value 를 Completion (Get (next , "1" ))으로 둡니다.IfAbruptCloseIterator (value , iteratorRecord ).status 를 Completion (Call (adder , target , « key , value »))로 둡니다.IfAbruptCloseIterator (status , iteratorRecord ).
참고
매개변수 iterable 은 첫 번째 요소는 Map 키로 사용할 값이고 두 번째 요소는 해당 키와 연결할 값인 두 요소의 배열과 유사한 객체 를 생성하는 반복자 객체를 반환하는 %Symbol.iterator% 메서드를 구현한 객체일 것으로 예상됩니다.
24.1.2 Map 생성자의 프로퍼티
Map 생성자 는:
24.1.2.1 Map.groupBy ( items , callback )
참고
callback 은 두 인수를 받는 함수여야 합니다. groupBy는 items 의 각 요소에 대해 오름차순으로 callback 을 한 번씩 호출하고 새로운 Map을 구성합니다. callback 이 반환하는 각 값은 Map의 키로 사용됩니다. 그러한 각 키에 대해 결과 Map에는 해당 키를 키로 하고 callback 이 해당 키를 반환한 모든 요소를 포함하는 배열을 값으로 하는 항목이 있습니다.
callback 은 요소의 값과 요소의 인덱스라는 두 인수로 호출됩니다.
groupBy의 반환 값은 Map입니다.
이 함수는 호출되면 다음 단계를 수행합니다:
groups 를 ? GroupBy (items , callback , collection )로 둡니다.map 을 ! Construct (%Map% )으로 둡니다.groups 의 각 Record { [[Key]] , [[Elements]] } group 에 대해 다음을 수행합니다.elements 를 CreateArrayFromList (group .[[Elements]] )로 둡니다.entry 를 Record { [[Key]] : group .[[Key]] , [[Value]] : elements }로 둡니다.entry 를 map .[[MapData]] 에 추가합니다.map 을 반환합니다.
24.1.2.2 Map.prototype
Map.prototype의 초기 값은 Map 프로토타입 객체 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
24.1.2.3 get Map [ %Symbol.species% ]
Map[%Symbol.species%]는 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
this 값을 반환합니다.
이 함수의 "name" 프로퍼티 값은 "get [Symbol.species]" 입니다.
참고
파생 컬렉션 객체를 생성하는 메서드는 파생 객체를 생성하는 데 사용할 생성자 를 결정하기 위해 %Symbol.species% 를 호출해야 합니다. 하위 클래스 생성자 는 기본 생성자 할당을 변경하기 위해 %Symbol.species% 를 재정의할 수 있습니다.
24.1.3 Map 프로토타입 객체의 프로퍼티
Map 프로토타입 객체 는:
24.1.3.1 Map.prototype.clear ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
map 을 this 값으로 둡니다.? RequireInternalSlot (map , [[MapData]] )를 수행합니다. map .[[MapData]] 의 각 Record { [[Key]] , [[Value]] } entry 에 대해 다음을 수행합니다.entry .[[Key]] 를 empty 로 설정합니다.entry .[[Value]] 를 empty 로 설정합니다.undefined 를 반환합니다.
참고
해당 List 를 순회하는 도중 일시 중단된 기존 Map Iterator 객체가 있을 수 있으므로 기존 [[MapData]] List 를 유지합니다.
24.1.3.2 Map.prototype.constructor
Map.prototype.constructor의 초기 값은 %Map% 입니다.
24.1.3.3 Map.prototype.delete ( key )
이 메서드는 호출되면 다음 단계를 수행합니다:
map 을 this 값으로 둡니다.? RequireInternalSlot (map , [[MapData]] )를 수행합니다. key 를 CanonicalizeKeyedCollectionKey (key )로 설정합니다.map .[[MapData]] 의 각 Record { [[Key]] , [[Value]] } entry 에 대해 다음을 수행합니다.entry .[[Key]] 가 empty 가 아니고 SameValue (entry .[[Key]] , key )가 true 이면, 다음을 수행합니다.entry .[[Key]] 를 empty 로 설정합니다.entry .[[Value]] 를 empty 로 설정합니다.true 를 반환합니다.false 를 반환합니다.
참고
값 empty 는 항목이 삭제되었음을 나타내기 위한 명세상의 장치로 사용됩니다. 실제 구현체는 내부 데이터 구조에서 항목을 물리적으로 제거하는 등의 다른 동작을 수행할 수 있습니다.
24.1.3.4 Map.prototype.entries ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
map 을 this 값으로 둡니다.? CreateMapIterator (map , key+value )를 반환합니다.
24.1.3.5 Map.prototype.forEach ( callback [ , thisArg ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
map 을 this 값으로 둡니다.? RequireInternalSlot (map , [[MapData]] )를 수행합니다. IsCallable (callback )이 false 이면 TypeError 예외를 던집니다.entries 를 map .[[MapData]] 로 둡니다.entriesCount 를 entries 의 요소 수로 둡니다.index 를 0으로 둡니다.index < entriesCount 인 동안 다음을 반복합니다.entry 를 entries [index ]로 둡니다.index 를 index + 1로 설정합니다.entry .[[Key]] 가 empty 가 아니면, 다음을 수행합니다.? Call (callback , thisArg , « entry .[[Value]] , entry .[[Key]] , map »)를 수행합니다. 참고 : callback 실행 중 entries 의 요소 수가 증가했을 수 있습니다.entriesCount 를 entries 의 요소 수로 설정합니다.undefined 를 반환합니다.
참고
callback 은 세 인수를 받는 함수여야 합니다. forEach는 Map에 존재하는 각 키/값 쌍에 대해 키 삽입 순서로 callback 을 한 번씩 호출합니다. callback 은 Map에 실제로 존재하는 키에 대해서만 호출되며 Map에서 삭제된 키에 대해서는 호출되지 않습니다.
thisArg 매개변수가 제공되면 callback 을 호출할 때마다 this 값으로 사용됩니다. 제공되지 않으면 대신 undefined 를 사용합니다.
callback 은 항목의 값, 항목의 키, 순회 중인 Map이라는 세 인수로 호출됩니다.
forEach는 호출된 객체를 직접 변경하지 않지만 callback 호출에 의해 객체가 변경될 수 있습니다. Map의 [[MapData]] 에 있는 각 항목은 한 번만 방문됩니다. forEach 호출이 시작된 후 추가된 새로운 키는 방문됩니다. 키가 방문된 후 삭제되고 forEach 호출이 완료되기 전에 다시 추가되면 해당 키를 다시 방문합니다. forEach 호출이 시작된 후 방문되기 전에 삭제된 키는 forEach 호출이 완료되기 전에 다시 추가되지 않는 한 방문되지 않습니다.
24.1.3.6 Map.prototype.get ( key )
이 메서드는 호출되면 다음 단계를 수행합니다:
map 을 this 값으로 둡니다.? RequireInternalSlot (map , [[MapData]] )를 수행합니다. key 를 CanonicalizeKeyedCollectionKey (key )로 설정합니다.map .[[MapData]] 의 각 Record { [[Key]] , [[Value]] } entry 에 대해 다음을 수행합니다.entry .[[Key]] 가 empty 가 아니고 SameValue (entry .[[Key]] , key )가 true 이면 entry .[[Value]] 를 반환합니다.undefined 를 반환합니다.
24.1.3.7 Map.prototype.getOrInsert ( key , value )
이 메서드는 호출되면 다음 단계를 수행합니다:
map 을 this 값으로 둡니다.? RequireInternalSlot (map , [[MapData]] )를 수행합니다. key 를 CanonicalizeKeyedCollectionKey (key )로 설정합니다.map .[[MapData]] 의 각 Record { [[Key]] , [[Value]] } entry 에 대해 다음을 수행합니다.entry .[[Key]] 가 empty 가 아니고 SameValue (entry .[[Key]] , key )가 true 이면 entry .[[Value]] 를 반환합니다.entry 를 Record { [[Key]] : key , [[Value]] : value }로 둡니다.entry 를 map .[[MapData]] 에 추가합니다.value 를 반환합니다.
24.1.3.8 Map.prototype.getOrInsertComputed ( key , callback )
이 메서드는 호출되면 다음 단계를 수행합니다:
map 을 this 값으로 둡니다.? RequireInternalSlot (map , [[MapData]] )를 수행합니다. IsCallable (callback )이 false 이면 TypeError 예외를 던집니다.key 를 CanonicalizeKeyedCollectionKey (key )로 설정합니다.map .[[MapData]] 의 각 Record { [[Key]] , [[Value]] } entry 에 대해 다음을 수행합니다.entry .[[Key]] 가 empty 가 아니고 SameValue (entry .[[Key]] , key )가 true 이면 entry .[[Value]] 를 반환합니다.value 를 ? Call (callback , undefined , « key »)로 둡니다.참고 : callback 실행 중 Map이 변경되었을 수 있습니다.map .[[MapData]] 의 각 Record { [[Key]] , [[Value]] } entry 에 대해 다음을 수행합니다.entry .[[Key]] 가 empty 가 아니고 SameValue (entry .[[Key]] , key )가 true 이면, 다음을 수행합니다.entry .[[Value]] 를 value 로 설정합니다.value 를 반환합니다.entry 를 Record { [[Key]] : key , [[Value]] : value }로 둡니다.entry 를 map .[[MapData]] 에 추가합니다.value 를 반환합니다.
24.1.3.9 Map.prototype.has ( key )
이 메서드는 호출되면 다음 단계를 수행합니다:
map 을 this 값으로 둡니다.? RequireInternalSlot (map , [[MapData]] )를 수행합니다. key 를 CanonicalizeKeyedCollectionKey (key )로 설정합니다.map .[[MapData]] 의 각 Record { [[Key]] , [[Value]] } entry 에 대해 다음을 수행합니다.entry .[[Key]] 가 empty 가 아니고 SameValue (entry .[[Key]] , key )가 true 이면 true 를 반환합니다.false 를 반환합니다.
24.1.3.10 Map.prototype.keys ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
map 을 this 값으로 둡니다.? CreateMapIterator (map , key )를 반환합니다.
24.1.3.11 Map.prototype.set ( key , value )
이 메서드는 호출되면 다음 단계를 수행합니다:
map 을 this 값으로 둡니다.? RequireInternalSlot (map , [[MapData]] )를 수행합니다. key 를 CanonicalizeKeyedCollectionKey (key )로 설정합니다.map .[[MapData]] 의 각 Record { [[Key]] , [[Value]] } entry 에 대해 다음을 수행합니다.entry .[[Key]] 가 empty 가 아니고 SameValue (entry .[[Key]] , key )가 true 이면, 다음을 수행합니다.entry .[[Value]] 를 value 로 설정합니다.map 을 반환합니다.entry 를 Record { [[Key]] : key , [[Value]] : value }로 둡니다.entry 를 map .[[MapData]] 에 추가합니다.map 을 반환합니다.
24.1.3.12 get Map.prototype.size
Map.prototype.size는 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
map 을 this 값으로 둡니다.? RequireInternalSlot (map , [[MapData]] )를 수행합니다. count 를 0으로 둡니다.map .[[MapData]] 의 각 Record { [[Key]] , [[Value]] } entry 에 대해 다음을 수행합니다.entry .[[Key]] 가 empty 가 아니면 count 를 count + 1로 설정합니다.𝔽 (count )를 반환합니다.
24.1.3.13 Map.prototype.values ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
map 을 this 값으로 둡니다.? CreateMapIterator (map , value )를 반환합니다.
24.1.3.14 Map.prototype [ %Symbol.iterator% ] ( )
%Symbol.iterator% 프로퍼티의 초기 값은 24.1.3.4 에 정의된 %Map.prototype.entries%입니다.
24.1.3.15 Map.prototype [ %Symbol.toStringTag% ]
%Symbol.toStringTag% 프로퍼티의 초기 값은 String 값 "Map" 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
24.1.4 Map 인스턴스의 프로퍼티
Map 인스턴스는 Map 프로토타입 객체 에서 프로퍼티를 상속하는 일반 객체 입니다. Map 인스턴스는 [[MapData]] 내부 슬롯도 갖습니다.
24.1.5 Map Iterator 객체
Map Iterator 는 특정 Map 인스턴스 객체에 대한 특정 순회를 나타내는 객체입니다. Map Iterator 객체에는 이름 있는 생성자 가 없습니다. 대신 Map Iterator 객체는 Map 인스턴스 객체의 특정 메서드를 호출하여 생성됩니다.
24.1.5.1 CreateMapIterator ( map , kind )
추상 연산 CreateMapIterator. 인수 map (ECMAScript 언어 값 ) 및 kind ((key+value , key 또는 value )). 반환값: (정상 완료 (값: Generator) 또는 throw 완료 ). 그러한 반복자를 반환하는 Map 메서드의 반복자 객체를 생성하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
? RequireInternalSlot (map , [[MapData]] )를 수행합니다. closure 를 매개변수가 없고 map 과 kind 를 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:entries 를 map .[[MapData]] 로 둡니다.index 를 0으로 둡니다.entriesCount 를 entries 의 요소 수로 둡니다.index < entriesCount 인 동안 다음을 반복합니다.entry 를 entries [index ]로 둡니다.index 를 index + 1로 설정합니다.entry .[[Key]] 가 empty 가 아니면, 다음을 수행합니다.kind 가 key 이면, 다음을 수행합니다.result 를 entry .[[Key]] 로 둡니다.그렇지 않고 kind 가 value 이면, 다음을 수행합니다.result 를 entry .[[Value]] 로 둡니다. 그렇지 않으면,단언 : kind 는 key+value 입니다.result 를 CreateArrayFromList (« entry .[[Key]] , entry .[[Value]] »)로 둡니다. ? GeneratorYield (CreateIteratorResultObject (result , false ))를 수행합니다. 참고 : GeneratorYield 에 의해 이 추상 연산 의 실행이 일시 중단된 동안 entries 의 요소 수가 증가했을 수 있습니다.entriesCount 를 entries 의 요소 수로 설정합니다.NormalCompletion (unused )을 반환합니다.CreateIteratorFromClosure (closure , "%MapIteratorPrototype%" , %MapIteratorPrototype% )을 반환합니다.
24.1.5.2 %MapIteratorPrototype% 객체
%MapIteratorPrototype% 객체는:
24.1.5.2.1 %MapIteratorPrototype%.next ( )
? GeneratorResume (this 값, empty , "%MapIteratorPrototype%" )를 반환합니다.
24.1.5.2.2 %MapIteratorPrototype% [ %Symbol.toStringTag% ]
%Symbol.toStringTag% 프로퍼티의 초기 값은 String 값 "Map Iterator" 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
24.2 Set 객체
Set 객체 는 ECMAScript language value의 컬렉션입니다. Set은 서로 다른 각 값을 최대 한 번만 포함할 수 있습니다. 서로 다른 값은 SameValueZero 비교 알고리즘의 의미론을 사용하여 구별합니다.
Set 객체는 평균적으로 컬렉션의 요소 수에 대해 선형보다 빠른 접근 시간을 제공하는 해시 테이블이나 그 밖의 메커니즘을 사용하여 구현해야 합니다. 이 명세에서 사용하는 데이터 구조는 Set 객체에 요구되는 관찰 가능한 의미론을 설명하기 위한 것일 뿐입니다. 실제 구현 모델로 사용하려는 것은 아닙니다.
24.2.1 Set 객체를 위한 추상 연산
24.2.1.1 Set Records
Set Record 는 Set 또는 유사한 객체의 인터페이스를 캡슐화하는 데 사용되는 Record 입니다.
Set Records에는 표 72 에 나열된 필드가 있습니다.
표 72: Set Record 필드
필드 이름
값
의미
[[SetObject]]
an Object
Set 또는 유사한 객체입니다.
[[Size]]
a non-negative integer or +∞
보고된 객체의 크기입니다.
[[Has]]
a function object
객체의 has 메서드입니다.
[[Keys]]
a function object
객체의 keys 메서드입니다.
24.2.1.2 GetSetRecord ( obj )
추상 연산 GetSetRecord. 인수 obj (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: Set 레코드 ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
obj 가 Object가 아니면 TypeError 예외를 던집니다.rawSize 를 ? Get (obj , "size" )로 둡니다.numberSize 를 ? ToNumber (rawSize )로 둡니다.참고 : rawSize 가 undefined 이면 numberSize 는 NaN 이 됩니다.numberSize 가 NaN 이면 TypeError 예외를 던집니다.intSize 를 ! ToIntegerOrInfinity (numberSize )로 둡니다.intSize < 0이면 RangeError 예외를 던집니다.has 를 ? Get (obj , "has" )로 둡니다.IsCallable (has )가 false 이면 TypeError 예외를 던집니다.keys 를 ? Get (obj , "keys" )로 둡니다.IsCallable (keys )가 false 이면 TypeError 예외를 던집니다.새로운 Set Record { [[SetObject]] : obj , [[Size]] : intSize , [[Has]] : has , [[Keys]] : keys }를 반환합니다.
24.2.1.3 SetDataHas ( setData , value )
추상 연산 SetDataHas. 인수 setData (리스트 (요소: (ECMAScript 언어 값 또는 empty ))) 및 value (ECMAScript 언어 값 ). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
SetDataIndex (setData , value )가 not-found 이면 false 를 반환합니다.true 를 반환합니다.
24.2.1.4 SetDataIndex ( setData , value )
추상 연산 SetDataIndex. 인수 setData (리스트 (요소: (ECMAScript 언어 값 또는 empty ))) 및 value (ECMAScript 언어 값 ). 반환값: (음이 아닌 정수 또는 not-found ). 호출되면 다음 단계를 수행한다.
value 를 CanonicalizeKeyedCollectionKey (value )로 설정합니다.size 를 setData 의 요소 수로 둡니다.index 를 0으로 둡니다.index < size 인 동안 다음을 반복합니다.element 를 setData [index ]로 둡니다.element 가 empty 가 아니고 element 가 value 이면, 다음을 수행합니다.index 를 반환합니다.index 를 index + 1로 설정합니다.not-found 를 반환합니다.
24.2.1.5 SetDataSize ( setData )
추상 연산 SetDataSize. 인수 setData (리스트 (요소: (ECMAScript 언어 값 또는 empty ))). 반환값: 음이 아닌 정수. 호출되면 다음 단계를 수행한다.
count 를 0으로 둡니다.setData 의 각 요소 element 에 대해 다음을 수행합니다.element 가 empty 가 아니면 count 를 count + 1로 설정합니다.count 를 반환합니다.
24.2.2 Set 생성자
Set 생성자 는:
%Set% 입니다.
전역 객체 의 "Set" 프로퍼티의 초기 값입니다.
생성자 로 호출되면 새로운 Set 객체 를 생성하고 초기화합니다.
함수로 호출하도록 의도되지 않았으며 그러한 방식으로 호출되면 예외를 던집니다.
클래스 정의의 extends 절에서 값으로 사용할 수 있습니다. 지정된 Set 동작을 상속하려는 하위 클래스 생성자 는 Set.prototype의 내장 메서드를 지원하는 데 필요한 내부 상태를 갖도록 하위 클래스 인스턴스를 생성하고 초기화하기 위해 Set 생성자 에 대한 super 호출을 포함해야 합니다.
24.2.2.1 Set ( [ iterable ] )
이 함수는 호출되면 다음 단계를 수행합니다:
NewTarget이 undefined 이면 TypeError 예외를 던집니다. set 을 ? OrdinaryCreateFromConstructor (NewTarget, "%Set.prototype%" , « [[SetData]] »)로 둡니다.set .[[SetData]] 를 새로운 빈 List 로 설정합니다.iterable 이 undefined 또는 null 이면 set 을 반환합니다.adder 를 ? Get (set , "add" )로 둡니다.IsCallable (adder )가 false 이면 TypeError 예외를 던집니다.iteratorRecord 를 ? GetIterator (iterable , sync )로 둡니다.다음을 반복합니다.next 를 ? IteratorStepValue (iteratorRecord )로 둡니다.next 가 done 이면 set 을 반환합니다.status 를 Completion (Call (adder , set , « next »))로 둡니다.IfAbruptCloseIterator (status , iteratorRecord ).
24.2.3 Set 생성자의 프로퍼티
Set 생성자 는:
24.2.3.1 Set.prototype
Set.prototype의 초기 값은 Set 프로토타입 객체 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
24.2.3.2 get Set [ %Symbol.species% ]
Set[%Symbol.species%]는 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
this 값을 반환합니다.
이 함수의 "name" 프로퍼티 값은 "get [Symbol.species]" 입니다.
참고
파생 컬렉션 객체를 생성하는 메서드는 파생 객체를 생성하는 데 사용할 생성자 를 결정하기 위해 %Symbol.species% 를 호출해야 합니다. 하위 클래스 생성자 는 기본 생성자 할당을 변경하기 위해 %Symbol.species% 를 재정의할 수 있습니다.
24.2.4 Set 프로토타입 객체의 프로퍼티
Set 프로토타입 객체 는:
24.2.4.1 Set.prototype.add ( value )
이 메서드는 호출되면 다음 단계를 수행합니다:
set 을 this 값으로 둡니다.? RequireInternalSlot (set , [[SetData]] )를 수행합니다. value 를 CanonicalizeKeyedCollectionKey (value )로 설정합니다.set .[[SetData]] 의 각 요소 entry 에 대해 다음을 수행합니다.entry 가 empty 가 아니고 SameValue (entry , value )가 true 이면, 다음을 수행합니다.set 을 반환합니다.value 를 set .[[SetData]] 에 추가합니다.set 을 반환합니다.
24.2.4.2 Set.prototype.clear ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
set 을 this 값으로 둡니다.? RequireInternalSlot (set , [[SetData]] )를 수행합니다. set .[[SetData]] 의 각 요소 entry 에 대해 다음을 수행합니다.값이 entry 인 set .[[SetData]] 의 요소를 값이 empty 인 요소로 대체합니다. undefined 를 반환합니다.
참고
해당 List 를 순회하는 도중 일시 중단된 기존 Set Iterator 객체가 있을 수 있으므로 기존 [[SetData]] List 를 유지합니다.
24.2.4.3 Set.prototype.constructor
Set.prototype.constructor의 초기 값은 %Set% 입니다.
24.2.4.4 Set.prototype.delete ( value )
이 메서드는 호출되면 다음 단계를 수행합니다:
set 을 this 값으로 둡니다.? RequireInternalSlot (set , [[SetData]] )를 수행합니다. value 를 CanonicalizeKeyedCollectionKey (value )로 설정합니다.set .[[SetData]] 의 각 요소 entry 에 대해 다음을 수행합니다.entry 가 empty 가 아니고 SameValue (entry , value )가 true 이면, 다음을 수행합니다.값이 entry 인 set .[[SetData]] 의 요소를 값이 empty 인 요소로 대체합니다. true 를 반환합니다.false 를 반환합니다.
참고
값 empty 는 항목이 삭제되었음을 나타내기 위한 명세상의 장치로 사용됩니다. 실제 구현체는 내부 데이터 구조에서 항목을 물리적으로 제거하는 등의 다른 동작을 수행할 수 있습니다.
24.2.4.5 Set.prototype.difference ( other )
이 메서드는 호출되면 다음 단계를 수행합니다:
set 을 this 값으로 둡니다.? RequireInternalSlot (set , [[SetData]] )를 수행합니다. otherRecord 를 ? GetSetRecord (other )로 둡니다.resultSetData 를 set .[[SetData]] 의 복사본으로 둡니다.SetDataSize (set .[[SetData]] ) ≤ otherRecord .[[Size]] 이면, 다음을 수행합니다.thisSize 를 set .[[SetData]] 의 요소 수로 둡니다.index 를 0으로 둡니다.index < thisSize 인 동안 다음을 반복합니다.entry 를 resultSetData [index ]로 둡니다.entry 가 empty 가 아니면, 다음을 수행합니다.inOther 를 ToBoolean (? Call (otherRecord .[[Has]] , otherRecord .[[SetObject]] , « entry »))로 둡니다.inOther 가 true 이면, 다음을 수행합니다.resultSetData [index ]를 empty 로 설정합니다.index 를 index + 1로 설정합니다.그렇지 않으면,keysIterator 를 ? GetIteratorFromMethod (otherRecord .[[SetObject]] , otherRecord .[[Keys]] )로 둡니다.next 를 not-started 로 둡니다.next 가 done 이 아닌 동안 다음을 반복합니다.next 를 ? IteratorStepValue (keysIterator )로 설정합니다.next 가 done 이 아니면, 다음을 수행합니다.next 를 CanonicalizeKeyedCollectionKey (next )로 설정합니다.valueIndex 를 SetDataIndex (resultSetData , next )로 둡니다.valueIndex 가 not-found 가 아니면, 다음을 수행합니다.resultSetData [valueIndex ]를 empty 로 설정합니다. result 를 OrdinaryObjectCreate (%Set.prototype% , « [[SetData]] »)로 둡니다.result .[[SetData]] 를 resultSetData 로 설정합니다.result 를 반환합니다.
24.2.4.6 Set.prototype.entries ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
set 을 this 값으로 둡니다.? CreateSetIterator (set , key+value )를 반환합니다.
참고
순회 목적에서 Set은 각 항목의 키와 값이 동일한 Map과 유사하게 보입니다.
24.2.4.7 Set.prototype.forEach ( callback [ , thisArg ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
set 을 this 값으로 둡니다.? RequireInternalSlot (set , [[SetData]] )를 수행합니다. IsCallable (callback )이 false 이면 TypeError 예외를 던집니다.entries 를 set .[[SetData]] 로 둡니다.entriesCount 를 entries 의 요소 수로 둡니다.index 를 0으로 둡니다.index < entriesCount 인 동안 다음을 반복합니다.entry 를 entries [index ]로 둡니다.index 를 index + 1로 설정합니다.entry 가 empty 가 아니면, 다음을 수행합니다.? Call (callback , thisArg , « entry , entry , set »)를 수행합니다. 참고 : callback 실행 중 entries 의 요소 수가 증가했을 수 있습니다.entriesCount 를 entries 의 요소 수로 설정합니다.undefined 를 반환합니다.
참고
callback 은 세 인수를 받는 함수여야 합니다. forEach는 Set 객체 에 존재하는 각 값에 대해 값 삽입 순서로 callback 을 한 번씩 호출합니다. callback 은 Set에 실제로 존재하는 값에 대해서만 호출되며 Set에서 삭제된 키에 대해서는 호출되지 않습니다.
thisArg 매개변수가 제공되면 callback 을 호출할 때마다 this 값으로 사용됩니다. 제공되지 않으면 대신 undefined 를 사용합니다.
callback 은 세 인수로 호출됩니다. 처음 두 인수는 Set에 포함된 값입니다. 두 인수 모두에 동일한 값이 전달됩니다. 순회 중인 Set 객체 는 세 번째 인수로 전달됩니다.
callback 은 Map 및 Array의 forEach 메서드가 사용하는 콜백 함수와 일관성을 유지하기 위해 세 인수로 호출됩니다. Set에서는 각 항목 값이 키이자 값으로 간주됩니다.
forEach는 호출된 객체를 직접 변경하지 않지만 callback 호출에 의해 객체가 변경될 수 있습니다.
각 값은 일반적으로 한 번만 방문됩니다. 그러나 값이 방문된 후 삭제되고 forEach 호출이 완료되기 전에 다시 추가되면 다시 방문됩니다. forEach 호출이 시작된 후 방문되기 전에 삭제된 값은 forEach 호출이 완료되기 전에 다시 추가되지 않는 한 방문되지 않습니다. forEach 호출이 시작된 후 추가된 새로운 값은 방문됩니다.
24.2.4.8 Set.prototype.has ( value )
이 메서드는 호출되면 다음 단계를 수행합니다:
set 을 this 값으로 둡니다.? RequireInternalSlot (set , [[SetData]] )를 수행합니다. value 를 CanonicalizeKeyedCollectionKey (value )로 설정합니다.set .[[SetData]] 의 각 요소 entry 에 대해 다음을 수행합니다.entry 가 empty 가 아니고 SameValue (entry , value )가 true 이면 true 를 반환합니다.false 를 반환합니다.
24.2.4.9 Set.prototype.intersection ( other )
이 메서드는 호출되면 다음 단계를 수행합니다:
set 을 this 값으로 둡니다.? RequireInternalSlot (set , [[SetData]] )를 수행합니다. otherRecord 를 ? GetSetRecord (other )로 둡니다.resultSetData 를 새로운 빈 List 로 둡니다.SetDataSize (set .[[SetData]] ) ≤ otherRecord .[[Size]] 이면, 다음을 수행합니다.thisSize 를 set .[[SetData]] 의 요소 수로 둡니다.index 를 0으로 둡니다.index < thisSize 인 동안 다음을 반복합니다.entry 를 set .[[SetData]] [index ]로 둡니다.index 를 index + 1로 설정합니다.entry 가 empty 가 아니면, 다음을 수행합니다.inOther 를 ToBoolean (? Call (otherRecord .[[Has]] , otherRecord .[[SetObject]] , « entry »))로 둡니다.inOther 가 true 이면, 다음을 수행합니다.참고 : 이전의 otherRecord .[[Has]] 호출이 set .[[SetData]] 의 요소를 제거한 뒤 다시 추가할 수 있으므로 이 순회 중 동일한 요소를 두 번 방문할 수 있습니다.SetDataHas (resultSetData , entry )가 false 이면, 다음을 수행합니다.entry 를 resultSetData 에 추가합니다.참고 : otherRecord .[[Has]] 실행 중 set .[[SetData]] 의 요소 수가 증가했을 수 있습니다.thisSize 를 set .[[SetData]] 의 요소 수로 설정합니다.그렇지 않으면,keysIterator 를 ? GetIteratorFromMethod (otherRecord .[[SetObject]] , otherRecord .[[Keys]] )로 둡니다.next 를 not-started 로 둡니다.next 가 done 이 아닌 동안 다음을 반복합니다.next 를 ? IteratorStepValue (keysIterator )로 설정합니다.next 가 done 이 아니면, 다음을 수행합니다.next 를 CanonicalizeKeyedCollectionKey (next )로 설정합니다.inThis 를 SetDataHas (set .[[SetData]] , next )로 둡니다.inThis 가 true 이면, 다음을 수행합니다.참고 : other 는 임의의 객체이므로 해당 "keys" 반복자가 동일한 값을 두 번 이상 생성할 수 있습니다.SetDataHas (resultSetData , next )가 false 이면, 다음을 수행합니다.next 를 resultSetData 에 추가합니다. result 를 OrdinaryObjectCreate (%Set.prototype% , « [[SetData]] »)로 둡니다.result .[[SetData]] 를 resultSetData 로 설정합니다.result 를 반환합니다.
24.2.4.10 Set.prototype.isDisjointFrom ( other )
이 메서드는 호출되면 다음 단계를 수행합니다:
set 을 this 값으로 둡니다.? RequireInternalSlot (set , [[SetData]] )를 수행합니다. otherRecord 를 ? GetSetRecord (other )로 둡니다.SetDataSize (set .[[SetData]] ) ≤ otherRecord .[[Size]] 이면, 다음을 수행합니다.thisSize 를 set .[[SetData]] 의 요소 수로 둡니다.index 를 0으로 둡니다.index < thisSize 인 동안 다음을 반복합니다.entry 를 set .[[SetData]] [index ]로 둡니다.index 를 index + 1로 설정합니다.entry 가 empty 가 아니면, 다음을 수행합니다.inOther 를 ToBoolean (? Call (otherRecord .[[Has]] , otherRecord .[[SetObject]] , « entry »))로 둡니다.inOther 가 true 이면 false 를 반환합니다.참고 : otherRecord .[[Has]] 실행 중 set .[[SetData]] 의 요소 수가 증가했을 수 있습니다.thisSize 를 set .[[SetData]] 의 요소 수로 설정합니다.그렇지 않으면,keysIterator 를 ? GetIteratorFromMethod (otherRecord .[[SetObject]] , otherRecord .[[Keys]] )로 둡니다.next 를 not-started 로 둡니다.next 가 done 이 아닌 동안 다음을 반복합니다.next 를 ? IteratorStepValue (keysIterator )로 설정합니다.next 가 done 이 아니면, 다음을 수행합니다.SetDataHas (set .[[SetData]] , next )가 true 이면, 다음을 수행합니다.? IteratorClose (keysIterator , NormalCompletion (unused ))를 수행합니다. false 를 반환합니다. true 를 반환합니다.
24.2.4.11 Set.prototype.isSubsetOf ( other )
이 메서드는 호출되면 다음 단계를 수행합니다:
set 을 this 값으로 둡니다.? RequireInternalSlot (set , [[SetData]] )를 수행합니다. otherRecord 를 ? GetSetRecord (other )로 둡니다.SetDataSize (set .[[SetData]] ) > otherRecord .[[Size]] 이면 false 를 반환합니다.thisSize 를 set .[[SetData]] 의 요소 수로 둡니다.index 를 0으로 둡니다.index < thisSize 인 동안 다음을 반복합니다.entry 를 set .[[SetData]] [index ]로 둡니다.index 를 index + 1로 설정합니다.entry 가 empty 가 아니면, 다음을 수행합니다.inOther 를 ToBoolean (? Call (otherRecord .[[Has]] , otherRecord .[[SetObject]] , « entry »))로 둡니다.inOther 가 false 이면 false 를 반환합니다.참고 : otherRecord .[[Has]] 실행 중 set .[[SetData]] 의 요소 수가 증가했을 수 있습니다.thisSize 를 set .[[SetData]] 의 요소 수로 설정합니다.true 를 반환합니다.
24.2.4.12 Set.prototype.isSupersetOf ( other )
이 메서드는 호출되면 다음 단계를 수행합니다:
set 을 this 값으로 둡니다.? RequireInternalSlot (set , [[SetData]] )를 수행합니다. otherRecord 를 ? GetSetRecord (other )로 둡니다.SetDataSize (set .[[SetData]] ) < otherRecord .[[Size]] 이면 false 를 반환합니다.keysIterator 를 ? GetIteratorFromMethod (otherRecord .[[SetObject]] , otherRecord .[[Keys]] )로 둡니다.next 를 not-started 로 둡니다.next 가 done 이 아닌 동안 다음을 반복합니다.next 를 ? IteratorStepValue (keysIterator )로 설정합니다.next 가 done 이 아니면, 다음을 수행합니다.SetDataHas (set .[[SetData]] , next )가 false 이면, 다음을 수행합니다.? IteratorClose (keysIterator , NormalCompletion (unused ))를 수행합니다. false 를 반환합니다.true 를 반환합니다.
24.2.4.13 Set.prototype.keys ( )
"keys" 프로퍼티의 초기 값은 24.2.4.17 에 정의된 %Set.prototype.values%입니다.
참고
순회 목적에서 Set은 각 항목의 키와 값이 동일한 Map과 유사하게 보입니다.
24.2.4.14 get Set.prototype.size
Set.prototype.size는 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
set 을 this 값으로 둡니다.? RequireInternalSlot (set , [[SetData]] )를 수행합니다. size 를 SetDataSize (set .[[SetData]] )로 둡니다.𝔽 (size )를 반환합니다.
24.2.4.15 Set.prototype.symmetricDifference ( other )
이 메서드는 호출되면 다음 단계를 수행합니다:
set 을 this 값으로 둡니다.? RequireInternalSlot (set , [[SetData]] )를 수행합니다. otherRecord 를 ? GetSetRecord (other )로 둡니다.keysIterator 를 ? GetIteratorFromMethod (otherRecord .[[SetObject]] , otherRecord .[[Keys]] )로 둡니다.resultSetData 를 set .[[SetData]] 의 복사본으로 둡니다.next 를 not-started 로 둡니다.next 가 done 이 아닌 동안 다음을 반복합니다.next 를 ? IteratorStepValue (keysIterator )로 설정합니다.next 가 done 이 아니면, 다음을 수행합니다.next 를 CanonicalizeKeyedCollectionKey (next )로 설정합니다.resultIndex 를 SetDataIndex (resultSetData , next )로 둡니다.resultIndex 가 not-found 이면 alreadyInResult 를 false 로 둡니다. 그렇지 않으면 alreadyInResult 를 true 로 둡니다.SetDataHas (set .[[SetData]] , next )가 true 이면, 다음을 수행합니다.alreadyInResult 가 true 이면 resultSetData [resultIndex ]를 empty 로 설정합니다.그렇지 않으면,alreadyInResult 가 false 이면 next 를 resultSetData 에 추가합니다. result 를 OrdinaryObjectCreate (%Set.prototype% , « [[SetData]] »)로 둡니다.result .[[SetData]] 를 resultSetData 로 설정합니다.result 를 반환합니다.
24.2.4.16 Set.prototype.union ( other )
이 메서드는 호출되면 다음 단계를 수행합니다:
set 을 this 값으로 둡니다.? RequireInternalSlot (set , [[SetData]] )를 수행합니다. otherRecord 를 ? GetSetRecord (other )로 둡니다.keysIterator 를 ? GetIteratorFromMethod (otherRecord .[[SetObject]] , otherRecord .[[Keys]] )로 둡니다.resultSetData 를 set .[[SetData]] 의 복사본으로 둡니다.next 를 not-started 로 둡니다.next 가 done 이 아닌 동안 다음을 반복합니다.next 를 ? IteratorStepValue (keysIterator )로 설정합니다.next 가 done 이 아니면, 다음을 수행합니다.next 를 CanonicalizeKeyedCollectionKey (next )로 설정합니다.SetDataHas (resultSetData , next )가 false 이면, 다음을 수행합니다.next 를 resultSetData 에 추가합니다.result 를 OrdinaryObjectCreate (%Set.prototype% , « [[SetData]] »)로 둡니다.result .[[SetData]] 를 resultSetData 로 설정합니다.result 를 반환합니다.
24.2.4.17 Set.prototype.values ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
set 을 this 값으로 둡니다.? CreateSetIterator (set , value )를 반환합니다.
24.2.4.18 Set.prototype [ %Symbol.iterator% ] ( )
%Symbol.iterator% 프로퍼티의 초기 값은 24.2.4.17 에 정의된 %Set.prototype.values%입니다.
24.2.4.19 Set.prototype [ %Symbol.toStringTag% ]
%Symbol.toStringTag% 프로퍼티의 초기 값은 String 값 "Set" 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
24.2.5 Set 인스턴스의 프로퍼티
Set 인스턴스는 Set 프로토타입 객체 에서 프로퍼티를 상속하는 일반 객체 입니다. Set 인스턴스는 [[SetData]] 내부 슬롯도 갖습니다.
24.2.6 Set Iterator 객체
Set Iterator 는 아래에 정의된 구조를 가지며 특정 Set 인스턴스 객체에 대한 특정 순회를 나타내는 일반 객체 입니다. Set Iterator 객체에는 이름 있는 생성자 가 없습니다. 대신 Set Iterator 객체는 Set 인스턴스 객체의 특정 메서드를 호출하여 생성됩니다.
24.2.6.1 CreateSetIterator ( set , kind )
추상 연산 CreateSetIterator. 인수 set (ECMAScript 언어 값 ) 및 kind ((key+value 또는 value )). 반환값: (정상 완료 (값: Generator) 또는 throw 완료 ). 그러한 반복자를 반환하는 Set 메서드의 반복자 객체를 생성하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
? RequireInternalSlot (set , [[SetData]] )를 수행합니다. closure 를 매개변수가 없고 set 과 kind 를 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:index 를 0으로 둡니다.entries 를 set .[[SetData]] 로 둡니다.entriesCount 를 entries 의 요소 수로 둡니다.index < entriesCount 인 동안 다음을 반복합니다.entry 를 entries [index ]로 둡니다.index 를 index + 1로 설정합니다.entry 가 empty 가 아니면, 다음을 수행합니다.kind 가 key+value 이면, 다음을 수행합니다.result 를 CreateArrayFromList (« entry , entry »)로 둡니다.? GeneratorYield (CreateIteratorResultObject (result , false ))를 수행합니다. 그렇지 않으면,단언 : kind 는 value 입니다.? GeneratorYield (CreateIteratorResultObject (entry , false ))를 수행합니다. 참고 : GeneratorYield 에 의해 이 추상 연산 의 실행이 일시 중단된 동안 entries 의 요소 수가 증가했을 수 있습니다.entriesCount 를 entries 의 요소 수로 설정합니다.NormalCompletion (unused )을 반환합니다.CreateIteratorFromClosure (closure , "%SetIteratorPrototype%" , %SetIteratorPrototype% )을 반환합니다.
24.2.6.2 %SetIteratorPrototype% 객체
%SetIteratorPrototype% 객체는:
24.2.6.2.1 %SetIteratorPrototype%.next ( )
? GeneratorResume (this 값, empty , "%SetIteratorPrototype%" )를 반환합니다.
24.2.6.2.2 %SetIteratorPrototype% [ %Symbol.toStringTag% ]
%Symbol.toStringTag% 프로퍼티의 초기 값은 String 값 "Set Iterator" 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
24.3 WeakMap 객체
WeakMap은 키가 객체 및/또는 Symbol이고 값은 임의의 ECMAScript language value일 수 있는 키/값 쌍의 컬렉션입니다. WeakMap에 특정 키를 갖는 키/값 쌍이 포함되어 있는지 조회할 수 있지만, 키로 보유하는 값을 열거하는 메커니즘은 제공되지 않습니다. 특정 조건에서는 9.9.3 에 설명된 대로 생존하지 않는 값이 WeakMap 키에서 제거됩니다.
구현체는 WeakMap의 키/값 쌍에 접근할 수 없게 된 시점과 해당 키/값 쌍이 WeakMap에서 제거되는 시점 사이에 임의로 정한 지연 시간을 둘 수 있습니다. 이 지연 시간을 ECMAScript 프로그램이 관찰할 수 있다면 프로그램 실행에 영향을 줄 수 있는 비결정성의 원인이 됩니다. 따라서 ECMAScript 구현체는 관찰자가 관찰 대상 키를 제시하지 않고도 WeakMap의 키를 관찰할 수 있는 수단을 제공해서는 안 됩니다.
WeakMap은 평균적으로 컬렉션의 키/값 쌍 수에 대해 선형보다 빠른 접근 시간을 제공하는 해시 테이블이나 그 밖의 메커니즘을 사용하여 구현해야 합니다. 이 명세에서 사용하는 데이터 구조는 WeakMap에 요구되는 관찰 가능한 의미론을 설명하기 위한 것일 뿐입니다. 실제 구현 모델로 사용하려는 것은 아닙니다.
참고
WeakMap과 WeakSet은 WeakMap 또는 WeakSet 인스턴스가 없었다면 객체나 Symbol에 더 이상 접근할 수 없게 되어 구현체의 가비지 컬렉션 메커니즘에 의해 리소스 회수 대상이 되었을 경우 메모리 리소스를 “누수”하지 않는 방식으로 객체 또는 Symbol에 상태를 동적으로 연결하는 메커니즘을 제공하기 위한 것입니다. 이 특성은 객체/Symbol별로 WeakMap 또는 WeakSet 인스턴스를 키에 역매핑하는 방식을 사용하여 달성할 수 있습니다. 또는 각 WeakMap이나 WeakSet 인스턴스가 내부적으로 키와 값 데이터를 저장할 수도 있지만, 이 접근 방식은 WeakMap 또는 WeakSet 구현체와 가비지 컬렉터 사이의 조정이 필요합니다. 다음 참고 문헌에서는 WeakMap과 WeakSet 구현체에 유용할 수 있는 메커니즘을 설명합니다:
Barry Hayes. 1997. Ephemerons: a new finalization mechanism. In Proceedings of the 12th ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications (OOPSLA '97) , A. Michael Berman (Ed.). ACM, New York, NY, USA, 176-183, http://doi.acm.org/10.1145/263698.263733 .
Alexandra Barros, Roberto Ierusalimschy, Eliminating Cycles in Weak Tables. Journal of Universal Computer Science - J.UCS, vol. 14, no. 21, pp. 3481-3497, 2008, http://www.jucs.org/jucs_14_21/eliminating_cycles_in_weak
24.3.1 WeakMap 생성자
WeakMap 생성자 는:
%WeakMap% 입니다.
전역 객체 의 "WeakMap" 프로퍼티의 초기 값입니다.
생성자 로 호출되면 새로운 WeakMap을 생성하고 초기화합니다.
함수로 호출하도록 의도되지 않았으며 그러한 방식으로 호출되면 예외를 던집니다.
클래스 정의의 extends 절에서 값으로 사용할 수 있습니다. 지정된 WeakMap 동작을 상속하려는 하위 클래스 생성자 는 WeakMap.prototype의 내장 메서드를 지원하는 데 필요한 내부 상태를 갖도록 하위 클래스 인스턴스를 생성하고 초기화하기 위해 WeakMap 생성자 에 대한 super 호출을 포함해야 합니다.
24.3.1.1 WeakMap ( [ iterable ] )
이 함수는 호출되면 다음 단계를 수행합니다:
NewTarget이 undefined 이면 TypeError 예외를 던집니다. map 을 ? OrdinaryCreateFromConstructor (NewTarget, "%WeakMap.prototype%" , « [[WeakMapData]] »)로 둡니다.map .[[WeakMapData]] 를 새로운 빈 List 로 설정합니다.iterable 이 undefined 또는 null 이면 map 을 반환합니다.adder 를 ? Get (map , "set" )으로 둡니다.IsCallable (adder )가 false 이면 TypeError 예외를 던집니다.? AddEntriesFromIterable (map , iterable , adder )를 반환합니다.
참고
매개변수 iterable 이 존재하는 경우, 첫 번째 요소는 WeakMap 키로 사용할 값이고 두 번째 요소는 해당 키와 연결할 값인 두 요소의 배열과 유사한 객체 를 생성하는 반복자 객체를 반환하는 %Symbol.iterator% 메서드를 구현한 객체일 것으로 예상됩니다.
24.3.2 WeakMap 생성자의 프로퍼티
WeakMap 생성자 는:
24.3.2.1 WeakMap.prototype
WeakMap.prototype의 초기 값은 WeakMap 프로토타입 객체 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
24.3.3 WeakMap 프로토타입 객체의 프로퍼티
WeakMap 프로토타입 객체 는:
%WeakMap.prototype% 입니다.
값이 %Object.prototype% 인 [[Prototype]] 내부 슬롯을 갖습니다.
일반 객체 입니다.
[[WeakMapData]] 내부 슬롯을 갖지 않습니다.
24.3.3.1 WeakMap.prototype.constructor
WeakMap.prototype.constructor의 초기 값은 %WeakMap% 입니다.
24.3.3.2 WeakMap.prototype.delete ( key )
이 메서드는 호출되면 다음 단계를 수행합니다:
weakMap 을 this 값으로 둡니다.? RequireInternalSlot (weakMap , [[WeakMapData]] )를 수행합니다. CanBeHeldWeakly (key )가 false 이면 false 를 반환합니다.weakMap .[[WeakMapData]] 의 각 Record { [[Key]] , [[Value]] } entry 에 대해 다음을 수행합니다.entry .[[Key]] 가 empty 가 아니고 SameValue (entry .[[Key]] , key )가 true 이면, 다음을 수행합니다.entry .[[Key]] 를 empty 로 설정합니다.entry .[[Value]] 를 empty 로 설정합니다.true 를 반환합니다.false 를 반환합니다.
참고
값 empty 는 항목이 삭제되었음을 나타내기 위한 명세상의 장치로 사용됩니다. 실제 구현체는 내부 데이터 구조에서 항목을 물리적으로 제거하는 등의 다른 동작을 수행할 수 있습니다.
24.3.3.3 WeakMap.prototype.get ( key )
이 메서드는 호출되면 다음 단계를 수행합니다:
weakMap 을 this 값으로 둡니다.? RequireInternalSlot (weakMap , [[WeakMapData]] )를 수행합니다. CanBeHeldWeakly (key )가 false 이면 undefined 를 반환합니다.weakMap .[[WeakMapData]] 의 각 Record { [[Key]] , [[Value]] } entry 에 대해 다음을 수행합니다.entry .[[Key]] 가 empty 가 아니고 SameValue (entry .[[Key]] , key )가 true 이면 entry .[[Value]] 를 반환합니다.undefined 를 반환합니다.
24.3.3.4 WeakMap.prototype.getOrInsert ( key , value )
이 메서드는 호출되면 다음 단계를 수행합니다:
weakMap 을 this 값으로 둡니다.? RequireInternalSlot (weakMap , [[WeakMapData]] )를 수행합니다. CanBeHeldWeakly (key )가 false 이면 TypeError 예외를 던집니다.weakMap .[[WeakMapData]] 의 각 Record { [[Key]] , [[Value]] } entry 에 대해 다음을 수행합니다.entry .[[Key]] 가 empty 가 아니고 SameValue (entry .[[Key]] , key )가 true 이면 entry .[[Value]] 를 반환합니다.entry 를 Record { [[Key]] : key , [[Value]] : value }로 둡니다.entry 를 weakMap .[[WeakMapData]] 에 추가합니다.value 를 반환합니다.
24.3.3.5 WeakMap.prototype.getOrInsertComputed ( key , callback )
이 메서드는 호출되면 다음 단계를 수행합니다:
weakMap 을 this 값으로 둡니다.? RequireInternalSlot (weakMap , [[WeakMapData]] )를 수행합니다. CanBeHeldWeakly (key )가 false 이면 TypeError 예외를 던집니다.IsCallable (callback )이 false 이면 TypeError 예외를 던집니다.weakMap .[[WeakMapData]] 의 각 Record { [[Key]] , [[Value]] } entry 에 대해 다음을 수행합니다.entry .[[Key]] 가 empty 가 아니고 SameValue (entry .[[Key]] , key )가 true 이면 entry .[[Value]] 를 반환합니다.value 를 ? Call (callback , undefined , « key »)로 둡니다.참고 : callback 실행 중 WeakMap이 변경되었을 수 있습니다.weakMap .[[WeakMapData]] 의 각 Record { [[Key]] , [[Value]] } entry 에 대해 다음을 수행합니다.entry .[[Key]] 가 empty 가 아니고 SameValue (entry .[[Key]] , key )가 true 이면, 다음을 수행합니다.entry .[[Value]] 를 value 로 설정합니다.value 를 반환합니다.entry 를 Record { [[Key]] : key , [[Value]] : value }로 둡니다.entry 를 weakMap .[[WeakMapData]] 에 추가합니다.value 를 반환합니다.
24.3.3.6 WeakMap.prototype.has ( key )
이 메서드는 호출되면 다음 단계를 수행합니다:
weakMap 을 this 값으로 둡니다.? RequireInternalSlot (weakMap , [[WeakMapData]] )를 수행합니다. CanBeHeldWeakly (key )가 false 이면 false 를 반환합니다.weakMap .[[WeakMapData]] 의 각 Record { [[Key]] , [[Value]] } entry 에 대해 다음을 수행합니다.entry .[[Key]] 가 empty 가 아니고 SameValue (entry .[[Key]] , key )가 true 이면 true 를 반환합니다.false 를 반환합니다.
24.3.3.7 WeakMap.prototype.set ( key , value )
이 메서드는 호출되면 다음 단계를 수행합니다:
weakMap 을 this 값으로 둡니다.? RequireInternalSlot (weakMap , [[WeakMapData]] )를 수행합니다. CanBeHeldWeakly (key )가 false 이면 TypeError 예외를 던집니다.weakMap .[[WeakMapData]] 의 각 Record { [[Key]] , [[Value]] } entry 에 대해 다음을 수행합니다.entry .[[Key]] 가 empty 가 아니고 SameValue (entry .[[Key]] , key )가 true 이면, 다음을 수행합니다.entry .[[Value]] 를 value 로 설정합니다.weakMap 을 반환합니다.entry 를 Record { [[Key]] : key , [[Value]] : value }로 둡니다.entry 를 weakMap .[[WeakMapData]] 에 추가합니다.weakMap 을 반환합니다.
24.3.3.8 WeakMap.prototype [ %Symbol.toStringTag% ]
%Symbol.toStringTag% 프로퍼티의 초기 값은 String 값 "WeakMap" 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
24.3.4 WeakMap 인스턴스의 프로퍼티
WeakMap 인스턴스는 WeakMap 프로토타입 객체 에서 프로퍼티를 상속하는 일반 객체 입니다. WeakMap 인스턴스는 [[WeakMapData]] 내부 슬롯도 갖습니다.
24.4 WeakSet 객체
WeakSet은 객체 및/또는 Symbol의 컬렉션입니다. 서로 다른 객체나 Symbol은 WeakSet의 컬렉션에 요소로 한 번만 나타날 수 있습니다. WeakSet에 특정 값이 포함되어 있는지 조회할 수 있지만, 보유하는 값을 열거하는 메커니즘은 제공되지 않습니다. 특정 조건에서는 9.9.3 에 설명된 대로 생존하지 않는 값이 WeakSet 요소에서 제거됩니다.
구현체는 WeakSet에 포함된 값에 접근할 수 없게 된 시점과 해당 값이 WeakSet에서 제거되는 시점 사이에 임의로 정한 지연 시간을 둘 수 있습니다. 이 지연 시간을 ECMAScript 프로그램이 관찰할 수 있다면 프로그램 실행에 영향을 줄 수 있는 비결정성의 원인이 됩니다. 따라서 ECMAScript 구현체는 관찰자가 관찰 대상 값을 제시하지 않고도 WeakSet에 특정 값이 포함되어 있는지 판단할 수 있는 수단을 제공해서는 안 됩니다.
WeakSet은 평균적으로 컬렉션의 요소 수에 대해 선형보다 빠른 접근 시간을 제공하는 해시 테이블이나 그 밖의 메커니즘을 사용하여 구현해야 합니다. 이 명세에서 사용하는 데이터 구조는 WeakSet에 요구되는 관찰 가능한 의미론을 설명하기 위한 것일 뿐입니다. 실제 구현 모델로 사용하려는 것은 아닙니다.
참고
24.4.1 WeakSet 생성자
WeakSet 생성자 는:
%WeakSet% 입니다.
전역 객체 의 "WeakSet" 프로퍼티의 초기 값입니다.
생성자 로 호출되면 새로운 WeakSet을 생성하고 초기화합니다.
함수로 호출하도록 의도되지 않았으며 그러한 방식으로 호출되면 예외를 던집니다.
클래스 정의의 extends 절에서 값으로 사용할 수 있습니다. 지정된 WeakSet 동작을 상속하려는 하위 클래스 생성자 는 WeakSet.prototype의 내장 메서드를 지원하는 데 필요한 내부 상태를 갖도록 하위 클래스 인스턴스를 생성하고 초기화하기 위해 WeakSet 생성자 에 대한 super 호출을 포함해야 합니다.
24.4.1.1 WeakSet ( [ iterable ] )
이 함수는 호출되면 다음 단계를 수행합니다:
NewTarget이 undefined 이면 TypeError 예외를 던집니다. set 을 ? OrdinaryCreateFromConstructor (NewTarget, "%WeakSet.prototype%" , « [[WeakSetData]] »)로 둡니다.set .[[WeakSetData]] 를 새로운 빈 List 로 설정합니다.iterable 이 undefined 또는 null 이면 set 을 반환합니다.adder 를 ? Get (set , "add" )로 둡니다.IsCallable (adder )가 false 이면 TypeError 예외를 던집니다.iteratorRecord 를 ? GetIterator (iterable , sync )로 둡니다.다음을 반복합니다.next 를 ? IteratorStepValue (iteratorRecord )로 둡니다.next 가 done 이면 set 을 반환합니다.status 를 Completion (Call (adder , set , « next »))로 둡니다.IfAbruptCloseIterator (status , iteratorRecord ).
24.4.2 WeakSet 생성자의 프로퍼티
WeakSet 생성자 는:
24.4.2.1 WeakSet.prototype
WeakSet.prototype의 초기 값은 WeakSet 프로토타입 객체 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
24.4.3 WeakSet 프로토타입 객체의 프로퍼티
WeakSet 프로토타입 객체 는:
%WeakSet.prototype% 입니다.
값이 %Object.prototype% 인 [[Prototype]] 내부 슬롯을 갖습니다.
일반 객체 입니다.
[[WeakSetData]] 내부 슬롯을 갖지 않습니다.
24.4.3.1 WeakSet.prototype.add ( value )
이 메서드는 호출되면 다음 단계를 수행합니다:
weakSet 을 this 값으로 둡니다.? RequireInternalSlot (weakSet , [[WeakSetData]] )를 수행합니다. CanBeHeldWeakly (value )가 false 이면 TypeError 예외를 던집니다.weakSet .[[WeakSetData]] 의 각 요소 entry 에 대해 다음을 수행합니다.entry 가 empty 가 아니고 SameValue (entry , value )가 true 이면, 다음을 수행합니다.weakSet 을 반환합니다.value 를 weakSet .[[WeakSetData]] 에 추가합니다.weakSet 을 반환합니다.
24.4.3.2 WeakSet.prototype.constructor
WeakSet.prototype.constructor의 초기 값은 %WeakSet% 입니다.
24.4.3.3 WeakSet.prototype.delete ( value )
이 메서드는 호출되면 다음 단계를 수행합니다:
weakSet 을 this 값으로 둡니다.? RequireInternalSlot (weakSet , [[WeakSetData]] )를 수행합니다. CanBeHeldWeakly (value )가 false 이면 false 를 반환합니다.weakSet .[[WeakSetData]] 의 각 요소 entry 에 대해 다음을 수행합니다.entry 가 empty 가 아니고 SameValue (entry , value )가 true 이면, 다음을 수행합니다.값이 entry 인 weakSet .[[WeakSetData]] 의 요소를 값이 empty 인 요소로 대체합니다. true 를 반환합니다.false 를 반환합니다.
참고
값 empty 는 항목이 삭제되었음을 나타내기 위한 명세상의 장치로 사용됩니다. 실제 구현체는 내부 데이터 구조에서 항목을 물리적으로 제거하는 등의 다른 동작을 수행할 수 있습니다.
24.4.3.4 WeakSet.prototype.has ( value )
이 메서드는 호출되면 다음 단계를 수행합니다:
weakSet 을 this 값으로 둡니다.? RequireInternalSlot (weakSet , [[WeakSetData]] )를 수행합니다. CanBeHeldWeakly (value )가 false 이면 false 를 반환합니다.weakSet .[[WeakSetData]] 의 각 요소 entry 에 대해 다음을 수행합니다.entry 가 empty 가 아니고 SameValue (entry , value )가 true 이면 true 를 반환합니다.false 를 반환합니다.
24.4.3.5 WeakSet.prototype [ %Symbol.toStringTag% ]
%Symbol.toStringTag% 프로퍼티의 초기 값은 String 값 "WeakSet" 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
24.4.4 WeakSet 인스턴스의 프로퍼티
WeakSet 인스턴스는 WeakSet 프로토타입 객체 에서 프로퍼티를 상속하는 일반 객체 입니다. WeakSet 인스턴스는 [[WeakSetData]] 내부 슬롯도 갖습니다.
24.5 키 컬렉션을 위한 추상 연산
24.5.1 CanonicalizeKeyedCollectionKey ( key )
추상 연산 CanonicalizeKeyedCollectionKey. 인수 key (ECMAScript 언어 값 ). 반환값: ECMAScript 언어 값 . 호출되면 다음 단계를 수행한다.
key 가 -0 𝔽 이면 +0 𝔽 을 반환합니다.key 를 반환합니다.
25 구조화된 데이터
25.1 ArrayBuffer 객체
25.1.1 표기법
이 절, 25.4 , 29 의 아래 설명에서는 read-modify-write 수정 함수 내부 데이터 구조를 사용합니다.
read-modify-write 수정 함수 는 바이트 값 의 두 List 를 인수로 받고 바이트 값 의 List 를 반환하는 Abstract Closure 로 표현되는 수학적 함수입니다. 이러한 Abstract Closure 는 다음 프로퍼티를 모두 만족합니다:
모든 알고리즘 단계를 원자적으로 수행합니다.
개별 알고리즘 단계는 관찰할 수 없습니다.
참고
read-modify-write 수정 함수의 알고리즘 단계가 순수한 수학적 함수를 구성하는지 검증하는 데 도움이 되도록 다음 편집 관례를 권장합니다:
25.1.2 고정 길이 및 크기 조절 가능한 ArrayBuffer 객체
고정 길이 ArrayBuffer 는 생성된 후 바이트 길이를 변경할 수 없는 ArrayBuffer입니다.
크기 조절 가능한 ArrayBuffer 는 ArrayBuffer.prototype.resize ( newLength ) 호출을 통해 생성 후 바이트 길이를 변경할 수 있는 ArrayBuffer입니다.
생성되는 ArrayBuffer 객체의 종류는 ArrayBuffer ( length [ , options ] ) 에 전달되는 인수에 따라 달라집니다.
25.1.3 ArrayBuffer 객체를 위한 추상 연산
25.1.3.1 AllocateArrayBuffer ( ctor , byteLength [ , maxByteLength ] )
추상 연산 AllocateArrayBuffer. 인수 ctor (생성자 ) 및 byteLength (음이 아닌 정수) 및 선택적 인수 maxByteLength ((음이 아닌 정수 또는 empty )). 반환값: (정상 완료 (값: ArrayBuffer) 또는 throw 완료 ). ArrayBuffer를 생성하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
slots 를 « [[ArrayBufferData]] , [[ArrayBufferByteLength]] , [[ArrayBufferDetachKey]] »로 둡니다.maxByteLength 가 존재하고 maxByteLength 가 empty 가 아니면 allocatingResizableBuffer 를 true 로 두고, 그렇지 않으면 allocatingResizableBuffer 를 false 로 둡니다.allocatingResizableBuffer 가 true 이면, 다음을 수행합니다.byteLength > maxByteLength 이면 RangeError 예외를 던집니다.slots 에 [[ArrayBufferMaxByteLength]] 를 추가합니다.obj 를 ? OrdinaryCreateFromConstructor (ctor , "%ArrayBuffer.prototype%" , slots )로 둡니다.block 을 ? CreateByteDataBlock (byteLength )으로 둡니다.obj .[[ArrayBufferData]] 를 block 으로 설정합니다.obj .[[ArrayBufferByteLength]] 를 byteLength 로 설정합니다.allocatingResizableBuffer 가 true 이면, 다음을 수행합니다.maxByteLength 바이트로 구성된 Data Block block 을 생성할 수 없으면 RangeError 예외를 던집니다.참고 : 크기 조절 가능한 ArrayBuffer 는 제자리 확장으로 구현할 수 있도록 설계되었습니다. 예를 들어 가상 메모리를 미리 예약할 수 없는 경우 구현체는 예외를 던질 수 있습니다.obj .[[ArrayBufferMaxByteLength]] 를 maxByteLength 로 설정합니다.obj 를 반환합니다.
25.1.3.2 ArrayBufferByteLength ( arrayBuffer , order )
추상 연산 ArrayBufferByteLength. 인수 arrayBuffer ((ArrayBuffer 또는 SharedArrayBuffer)) 및 order ((seq-cst 또는 unordered )). 반환값: 음이 아닌 정수. 호출되면 다음 단계를 수행한다.
IsGrowableSharedArrayBuffer (arrayBuffer )가 true 이면, 다음을 수행합니다.bufferByteLengthBlock 을 arrayBuffer .[[ArrayBufferByteLengthData]] 로 둡니다.rawLength 를 GetRawBytesFromSharedBlock (bufferByteLengthBlock , 0, biguint64 , true , order )로 둡니다.agentRecord 를 주변 에이전트 의 Agent Record 로 둡니다.isLittleEndian 을 agentRecord .[[LittleEndian]] 으로 둡니다.ℝ (RawBytesToNumeric (biguint64 , rawLength , isLittleEndian ))을 반환합니다.단언 : IsDetachedBuffer (arrayBuffer )는 false 입니다.arrayBuffer .[[ArrayBufferByteLength]] 를 반환합니다.
25.1.3.3 ArrayBufferCopyAndDetach ( arrayBuffer , newLength , preserveResizability )
추상 연산 ArrayBufferCopyAndDetach. 인수 arrayBuffer (ECMAScript 언어 값 ), newLength (ECMAScript 언어 값 ) 및 preserveResizability ((preserve-resizability 또는 fixed-length )). 반환값: (정상 완료 (값: ArrayBuffer) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
? RequireInternalSlot (arrayBuffer , [[ArrayBufferData]] )를 수행합니다. IsSharedArrayBuffer (arrayBuffer )가 true 이면 TypeError 예외를 던집니다.newLength 가 undefined 이면, 다음을 수행합니다.newByteLength 를 arrayBuffer .[[ArrayBufferByteLength]] 로 둡니다.그렇지 않으면,newByteLength 를 ? ToIndex (newLength )로 둡니다. IsDetachedBuffer (arrayBuffer )가 true 이면 TypeError 예외를 던집니다.preserveResizability 가 preserve-resizability 이고 IsFixedLengthArrayBuffer (arrayBuffer )가 false 이면, 다음을 수행합니다.newMaxByteLength 를 arrayBuffer .[[ArrayBufferMaxByteLength]] 로 둡니다.그렇지 않으면,newMaxByteLength 를 empty 로 둡니다. arrayBuffer .[[ArrayBufferDetachKey]] 가 undefined 가 아니면 TypeError 예외를 던집니다.newBuffer 를 ? AllocateArrayBuffer (%ArrayBuffer% , newByteLength , newMaxByteLength )로 둡니다.copyLength 를 min (newByteLength , arrayBuffer .[[ArrayBufferByteLength]] )로 둡니다.fromBlock 을 arrayBuffer .[[ArrayBufferData]] 로 둡니다.toBlock 을 newBuffer .[[ArrayBufferData]] 로 둡니다.CopyDataBlockBytes (toBlock , 0, fromBlock , 0, copyLength )를 수행합니다.참고 : 새로운 Data Block 생성과 이전 Data Block 에서 복사하는 작업은 모두 관찰할 수 없습니다. 구현체는 이 메서드를 복사 없는 이동 또는 realloc로 구현할 수 있습니다.! DetachArrayBuffer (arrayBuffer )를 수행합니다. newBuffer 를 반환합니다.
25.1.3.4 IsDetachedBuffer ( arrayBuffer )
추상 연산 IsDetachedBuffer. 인수 arrayBuffer ((ArrayBuffer 또는 SharedArrayBuffer)). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
arrayBuffer .[[ArrayBufferData]] 가 null 이면 true 를 반환합니다.false 를 반환합니다.
25.1.3.5 DetachArrayBuffer ( arrayBuffer [ , key ] )
추상 연산 DetachArrayBuffer. 인수 arrayBuffer (ArrayBuffer) 및 선택적 인수 key (임의의 값). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
단언 : IsSharedArrayBuffer (arrayBuffer )는 false 입니다.key 가 존재하지 않으면 key 를 undefined 로 설정합니다.arrayBuffer .[[ArrayBufferDetachKey]] 가 key 가 아니면 TypeError 예외를 던집니다.arrayBuffer .[[ArrayBufferData]] 를 null 로 설정합니다.arrayBuffer .[[ArrayBufferByteLength]] 를 0으로 설정합니다.unused 를 반환합니다.
참고
ArrayBuffer 인스턴스를 분리하면 기반 저장소로 사용되는 Data Block 을 인스턴스와 분리하고 버퍼의 바이트 길이를 0으로 설정합니다.
25.1.3.6 CloneArrayBuffer ( sourceBuffer , sourceByteOffset , sourceLength )
추상 연산 CloneArrayBuffer. 인수 sourceBuffer ((ArrayBuffer 또는 SharedArrayBuffer)), sourceByteOffset (음이 아닌 정수) 및 sourceLength (음이 아닌 정수). 반환값: (정상 완료 (값: ArrayBuffer) 또는 throw 완료 ). sourceByteOffset 에서 시작하여 sourceLength 바이트 동안의 sourceBuffer 데이터를 복사한 데이터를 갖는 새로운 ArrayBuffer를 생성합니다. 호출되면 다음 단계를 수행한다.
단언 : IsDetachedBuffer (sourceBuffer )는 false 입니다.targetBuffer 를 ? AllocateArrayBuffer (%ArrayBuffer% , sourceLength )로 둡니다.sourceBlock 을 sourceBuffer .[[ArrayBufferData]] 로 둡니다.targetBlock 을 targetBuffer .[[ArrayBufferData]] 로 둡니다.CopyDataBlockBytes (targetBlock , 0, sourceBlock , sourceByteOffset , sourceLength )를 수행합니다.targetBuffer 를 반환합니다.
25.1.3.7 GetArrayBufferMaxByteLengthOption ( options )
추상 연산 GetArrayBufferMaxByteLengthOption. 인수 options (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: (음이 아닌 정수 또는 empty )) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
options 가 Object가 아니면 empty 를 반환합니다.maxByteLength 를 ? Get (options , "maxByteLength" )로 둡니다.maxByteLength 가 undefined 이면 empty 를 반환합니다.? ToIndex (maxByteLength )를 반환합니다.
25.1.3.8 HostResizeArrayBuffer ( buffer , newByteLength )
호스트 정의 추상 연산 HostResizeArrayBuffer. 인수 buffer (ArrayBuffer) 및 newByteLength (음이 아닌 정수). 반환값: (정상 완료 (값: (handled 또는 unhandled )) 또는 throw 완료 ). 호스트 가 buffer 의 구현체 정의 크기 조절을 수행할 기회를 제공합니다. 호스트 가 buffer 의 크기 조절을 처리하지 않기로 선택하면 기본 동작을 위해 unhandled 를 반환할 수 있습니다.
HostResizeArrayBuffer의 구현은 다음 요구 사항을 준수해야 합니다:
추상 연산 은 buffer 를 분리하지 않습니다.
추상 연산 이 handled 로 정상 완료 되면 buffer .[[ArrayBufferByteLength]] 는 newByteLength 입니다.
HostResizeArrayBuffer의 기본 구현은 NormalCompletion (unhandled )을 반환하는 것입니다.
25.1.3.9 IsFixedLengthArrayBuffer ( arrayBuffer )
추상 연산 IsFixedLengthArrayBuffer. 인수 arrayBuffer ((ArrayBuffer 또는 SharedArrayBuffer)). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
arrayBuffer 에 [[ArrayBufferMaxByteLength]] 내부 슬롯이 있으면 false 를 반환합니다.true 를 반환합니다.
25.1.3.10 IsUnsignedElementType ( type )
추상 연산 IsUnsignedElementType. 인수 type (TypedArray 요소 타입 ). 반환값: Boolean. 인수 type 이 부호 없는 TypedArray 요소 타입 인지 검증합니다. 호출되면 다음 단계를 수행한다.
type 이 uint8 , uint8clamped , uint16 , uint32 , biguint64 중 하나이면 true 를 반환합니다.false 를 반환합니다.
25.1.3.11 IsUnclampedIntegerElementType ( type )
추상 연산 IsUnclampedIntegerElementType. 인수 type (TypedArray 요소 타입 ). 반환값: Boolean. 인수 type 이 uint8clamped 를 제외한 Integer TypedArray 요소 타입 인지 검증합니다. 호출되면 다음 단계를 수행한다.
type 이 int8 , uint8 , int16 , uint16 , int32 , uint32 중 하나이면 true 를 반환합니다.false 를 반환합니다.
25.1.3.12 IsBigIntElementType ( type )
추상 연산 IsBigIntElementType. 인수 type (TypedArray 요소 타입 ). 반환값: Boolean. 인수 type 이 BigInt TypedArray 요소 타입 인지 검증합니다. 호출되면 다음 단계를 수행한다.
type 이 biguint64 또는 bigint64 이면 true 를 반환합니다.false 를 반환합니다.
25.1.3.13 IsNoTearConfiguration ( type , order )
추상 연산 IsNoTearConfiguration. 인수 type (TypedArray 요소 타입 ) 및 order ((seq-cst , unordered 또는 init )). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
IsUnclampedIntegerElementType (type )이 true 이면 true 를 반환합니다.IsBigIntElementType (type )이 true 이고 order 가 seq-cst 이면 true 를 반환합니다.false 를 반환합니다.
25.1.3.14 RawBytesToNumeric ( type , rawBytes , isLittleEndian )
추상 연산 RawBytesToNumeric. 인수 type (TypedArray 요소 타입 ), rawBytes (리스트 (요소: 바이트 값 )) 및 isLittleEndian (Boolean). 반환값: (Number 또는 BigInt). 호출되면 다음 단계를 수행한다.
elementSize 를 Element Type type 에 대해 표 71 에 지정된 Element Size 값으로 둡니다.isLittleEndian 이 false 이면 rawBytes 요소의 순서를 뒤집습니다.type 이 float16 이면, 다음을 수행합니다.value 를 rawBytes 의 바이트 요소를 연결하고 IEEE 754-2019 binary16 값의 리틀 엔디언 비트 문자열 인코딩으로 해석한 값으로 둡니다.value 가 NaN이면 NaN 을 반환합니다.value 에 대응하는 Number 값 을 반환합니다.type 이 float32 이면, 다음을 수행합니다.value 를 rawBytes 의 바이트 요소를 연결하고 IEEE 754-2019 binary32 값의 리틀 엔디언 비트 문자열 인코딩으로 해석한 값으로 둡니다.value 가 NaN이면 NaN 을 반환합니다.value 에 대응하는 Number 값 을 반환합니다.type 이 float64 이면, 다음을 수행합니다.value 를 rawBytes 의 바이트 요소를 연결하고 IEEE 754-2019 binary64 값의 리틀 엔디언 비트 문자열 인코딩으로 해석한 값으로 둡니다.value 가 NaN이면 NaN 을 반환합니다.value 에 대응하는 Number 값 을 반환합니다.IsUnsignedElementType (type )이 true 이면, 다음을 수행합니다.intValue 를 rawBytes 의 바이트 요소를 연결하고 부호 없는 리틀 엔디언 이진수의 비트 문자열 인코딩으로 해석한 값으로 둡니다.그렇지 않으면,intValue 를 rawBytes 의 바이트 요소를 연결하고 비트 길이가 elementSize × 8인 이진 리틀 엔디언 2의 보수 수의 비트 문자열 인코딩으로 해석한 값으로 둡니다. IsBigIntElementType (type )이 true 이면 intValue 에 대응하는 BigInt 값 을 반환합니다.intValue 에 대응하는 Number 값 을 반환합니다.
25.1.3.15 GetRawBytesFromSharedBlock ( block , byteIndex , type , isTypedArray , order )
추상 연산 GetRawBytesFromSharedBlock. 인수 block (공유 데이터 블록 ), byteIndex (음이 아닌 정수), type (TypedArray 요소 타입 ), isTypedArray (Boolean) 및 order ((seq-cst 또는 unordered )). 반환값: 리스트 (요소: 바이트 값 ). 호출되면 다음 단계를 수행한다.
elementSize 를 Element Type type 에 대해 표 71 에 지정된 Element Size 값으로 둡니다.agentRecord 를 주변 에이전트 의 Agent Record 로 둡니다.execution 을 agentRecord .[[CandidateExecution]] 으로 둡니다.eventsRecord 를 [[AgentSignifier]] 가 AgentSignifier ()인 execution .[[EventsRecords]] 의 Agent Events Record 로 둡니다.isTypedArray 가 true 이고 IsNoTearConfiguration (type , order )이 true 이면 noTear 를 true 로 둡니다. 그렇지 않으면 noTear 를 false 로 둡니다.rawValue 를 요소가 비결정적으로 선택된 바이트 값 인 길이 elementSize 의 List 로 둡니다.참고 : 구현체에서 rawValue 는 기반 하드웨어의 비원자적 또는 원자적 읽기 명령 결과입니다. 비결정성은 약한 일관성을 갖는 하드웨어의 관찰 가능한 동작을 설명하기 위한 메모리 모델 의 의미론적 규정입니다.readEvent 를 ReadSharedMemory { [[Order]] : order , [[NoTear]] : noTear , [[Block]] : block , [[ByteIndex]] : byteIndex , [[ElementSize]] : elementSize }로 둡니다.readEvent 를 eventsRecord .[[EventList]] 에 추가합니다.Chosen Value Record { [[Event]] : readEvent , [[ChosenValue]] : rawValue }를 execution .[[ChosenValues]] 에 추가합니다.rawValue 를 반환합니다.
25.1.3.16 GetValueFromBuffer ( arrayBuffer , byteIndex , type , isTypedArray , order [ , isLittleEndian ] )
추상 연산 GetValueFromBuffer. 인수 arrayBuffer ((ArrayBuffer 또는 SharedArrayBuffer)), byteIndex (음이 아닌 정수), type (TypedArray 요소 타입 ), isTypedArray (Boolean) 및 order ((seq-cst 또는 unordered )) 및 선택적 인수 isLittleEndian (Boolean). 반환값: (Number 또는 BigInt). 호출되면 다음 단계를 수행한다.
단언 : IsDetachedBuffer (arrayBuffer )는 false 입니다.단언 : arrayBuffer 에는 byteIndex 부터 시작하여 type 값을 표현하기에 충분한 바이트가 있습니다.block 을 arrayBuffer .[[ArrayBufferData]] 로 둡니다.elementSize 를 Element Type type 에 대해 표 71 에 지정된 Element Size 값으로 둡니다.IsSharedArrayBuffer (arrayBuffer )가 true 이면, 다음을 수행합니다.단언 : block 은 Shared Data Block 입니다.rawValue 를 GetRawBytesFromSharedBlock (block , byteIndex , type , isTypedArray , order )로 둡니다.그렇지 않으면,rawValue 를 byteIndex (포함)부터 byteIndex + elementSize (제외)까지 구간 의 인덱스에서 block 의 바이트를 요소로 갖는 List 로 둡니다. 단언 : rawValue 의 요소 수는 elementSize 입니다.isLittleEndian 이 존재하지 않으면, 다음을 수행합니다.agentRecord 를 주변 에이전트 의 Agent Record 로 둡니다.isLittleEndian 을 agentRecord .[[LittleEndian]] 으로 설정합니다.RawBytesToNumeric (type , rawValue , isLittleEndian )을 반환합니다.
25.1.3.17 NumericToRawBytes ( type , value , isLittleEndian )
추상 연산 NumericToRawBytes. 인수 type (TypedArray 요소 타입 ), value ((Number 또는 BigInt)) 및 isLittleEndian (Boolean). 반환값: 리스트 (요소: 바이트 값 ). 호출되면 다음 단계를 수행한다.
type 이 float16 이면, 다음을 수행합니다.rawBytes 를 roundTiesToEven 모드를 사용하여 value 를 IEEE 754-2019 binary16 형식으로 변환한 결과인 2바이트를 요소로 갖는 List 로 둡니다. 바이트는 리틀 엔디언 순서로 배열됩니다. value 가 NaN 이면 rawBytes 를 구현체가 선택한 임의의 IEEE 754-2019 binary16 형식 NaN 인코딩으로 설정할 수 있습니다. 구현체는 구현체에서 구별 가능한 각 NaN 값에 대해 항상 동일한 인코딩을 선택해야 합니다.그렇지 않고 type 이 float32 이면, 다음을 수행합니다.rawBytes 를 roundTiesToEven 모드를 사용하여 value 를 IEEE 754-2019 binary32 형식으로 변환한 결과인 4바이트를 요소로 갖는 List 로 둡니다. 바이트는 리틀 엔디언 순서로 배열됩니다. value 가 NaN 이면 rawBytes 를 구현체가 선택한 임의의 IEEE 754-2019 binary32 형식 NaN 인코딩으로 설정할 수 있습니다. 구현체는 구현체에서 구별 가능한 각 NaN 값에 대해 항상 동일한 인코딩을 선택해야 합니다. 그렇지 않고 type 이 float64 이면, 다음을 수행합니다.rawBytes 를 value 의 IEEE 754-2019 binary64 형식 인코딩인 8바이트를 요소로 갖는 List 로 둡니다. 바이트는 리틀 엔디언 순서로 배열됩니다. value 가 NaN 이면 rawBytes 를 구현체가 선택한 임의의 IEEE 754-2019 binary64 형식 NaN 인코딩으로 설정할 수 있습니다. 구현체는 구현체에서 구별 가능한 각 NaN 값에 대해 항상 동일한 인코딩을 선택해야 합니다. 그렇지 않으면,n 을 Element Type type 에 대해 표 71 에 지정된 Element Size 값으로 둡니다.conversionOperation 을 Element Type type 에 대해 표 71 의 “Conversion Operation” 열에 명명된 추상 연산 으로 둡니다.intValue 를 ℝ (! conversionOperation (value ))로 둡니다.intValue ≥ 0이면, 다음을 수행합니다.rawBytes 를 intValue 의 n 바이트 이진 인코딩을 요소로 갖는 List 로 둡니다. 바이트는 리틀 엔디언 순서로 배열됩니다.그렇지 않으면,rawBytes 를 intValue 의 n 바이트 이진 2의 보수 인코딩을 요소로 갖는 List 로 둡니다. 바이트는 리틀 엔디언 순서로 배열됩니다. isLittleEndian 이 false 이면 rawBytes 요소의 순서를 뒤집습니다.rawBytes 를 반환합니다.
25.1.3.18 SetValueInBuffer ( arrayBuffer , byteIndex , type , value , isTypedArray , order [ , isLittleEndian ] )
추상 연산 SetValueInBuffer. 인수 arrayBuffer ((ArrayBuffer 또는 SharedArrayBuffer)), byteIndex (음이 아닌 정수), type (TypedArray 요소 타입 ), value ((Number 또는 BigInt)), isTypedArray (Boolean) 및 order ((seq-cst , unordered 또는 init )) 및 선택적 인수 isLittleEndian (Boolean). 반환값: unused . 호출되면 다음 단계를 수행한다.
단언 : IsDetachedBuffer (arrayBuffer )는 false 입니다.단언 : arrayBuffer 에는 byteIndex 부터 시작하여 type 값을 표현하기에 충분한 바이트가 있습니다.단언 : IsBigIntElementType (type )이 true 이면 value 는 BigInt이고, 그렇지 않으면 value 는 Number입니다.block 을 arrayBuffer .[[ArrayBufferData]] 로 둡니다.elementSize 를 Element Type type 에 대해 표 71 에 지정된 Element Size 값으로 둡니다.agentRecord 를 주변 에이전트 의 Agent Record 로 둡니다.isLittleEndian 이 존재하지 않으면, 다음을 수행합니다.isLittleEndian 을 agentRecord .[[LittleEndian]] 으로 설정합니다.rawBytes 를 NumericToRawBytes (type , value , isLittleEndian )로 둡니다.IsSharedArrayBuffer (arrayBuffer )가 true 이면, 다음을 수행합니다.execution 을 agentRecord .[[CandidateExecution]] 으로 둡니다.eventsRecord 를 [[AgentSignifier]] 가 AgentSignifier ()인 execution .[[EventsRecords]] 의 Agent Events Record 로 둡니다.isTypedArray 가 true 이고 IsNoTearConfiguration (type , order )이 true 이면 noTear 를 true 로 둡니다. 그렇지 않으면 noTear 를 false 로 둡니다.WriteSharedMemory { [[Order]] : order , [[NoTear]] : noTear , [[Block]] : block , [[ByteIndex]] : byteIndex , [[ElementSize]] : elementSize , [[Payload]] : rawBytes }를 eventsRecord .[[EventList]] 에 추가합니다.그렇지 않으면,rawBytes 의 개별 바이트를 block [byteIndex ]에서 시작하여 block 에 저장합니다. unused 를 반환합니다.
25.1.3.19 GetModifySetValueInBuffer ( arrayBuffer , byteIndex , type , value , op )
추상 연산 GetModifySetValueInBuffer. 인수 arrayBuffer ((ArrayBuffer 또는 SharedArrayBuffer)), byteIndex (음이 아닌 정수), type (TypedArray 요소 타입 ), value ((Number 또는 BigInt)) 및 op (a read-modify-write modification function). 반환값: (Number 또는 BigInt). 호출되면 다음 단계를 수행한다.
단언 : IsDetachedBuffer (arrayBuffer )는 false 입니다.단언 : arrayBuffer 에는 byteIndex 부터 시작하여 type 값을 표현하기에 충분한 바이트가 있습니다.단언 : IsBigIntElementType (type )이 true 이면 value 는 BigInt이고, 그렇지 않으면 value 는 Number입니다.block 을 arrayBuffer .[[ArrayBufferData]] 로 둡니다.elementSize 를 Element Type type 에 대해 표 71 에 지정된 Element Size 값으로 둡니다.agentRecord 를 주변 에이전트 의 Agent Record 로 둡니다.isLittleEndian 을 agentRecord .[[LittleEndian]] 으로 둡니다.rawBytes 를 NumericToRawBytes (type , value , isLittleEndian )로 둡니다.IsSharedArrayBuffer (arrayBuffer )가 true 이면, 다음을 수행합니다.execution 을 agentRecord .[[CandidateExecution]] 으로 둡니다.eventsRecord 를 [[AgentSignifier]] 가 AgentSignifier ()인 execution .[[EventsRecords]] 의 Agent Events Record 로 둡니다.rawBytesRead 를 요소가 비결정적으로 선택된 바이트 값 인 길이 elementSize 의 List 로 둡니다.참고 : 구현체에서 rawBytesRead 는 기반 하드웨어의 load-link, load-exclusive 또는 read-modify-write 명령의 피연산자 결과입니다. 비결정성은 약한 일관성을 갖는 하드웨어의 관찰 가능한 동작을 설명하기 위한 메모리 모델 의 의미론적 규정입니다.rmwEvent 를 ReadModifyWriteSharedMemory { [[Order]] : seq-cst , [[NoTear]] : true , [[Block]] : block , [[ByteIndex]] : byteIndex , [[ElementSize]] : elementSize , [[Payload]] : rawBytes , [[ModifyOp]] : op }로 둡니다.rmwEvent 를 eventsRecord .[[EventList]] 에 추가합니다.Chosen Value Record { [[Event]] : rmwEvent , [[ChosenValue]] : rawBytesRead }를 execution .[[ChosenValues]] 에 추가합니다.그렇지 않으면,rawBytesRead 를 block [byteIndex ]부터 시작하는 elementSize 개의 바이트 시퀀스를 요소로 갖는 길이 elementSize 의 List 로 둡니다.rawBytesModified 를 op (rawBytesRead , rawBytes )로 둡니다.rawBytesModified 의 개별 바이트를 block [byteIndex ]에서 시작하여 block 에 저장합니다. RawBytesToNumeric (type , rawBytesRead , isLittleEndian )을 반환합니다.
25.1.4 ArrayBuffer 생성자
ArrayBuffer 생성자 는:
%ArrayBuffer% 입니다.
전역 객체 의 "ArrayBuffer" 프로퍼티의 초기 값입니다.
생성자 로 호출되면 새로운 ArrayBuffer를 생성하고 초기화합니다.
함수로 호출하도록 의도되지 않았으며 그러한 방식으로 호출되면 예외를 던집니다.
클래스 정의의 extends 절 값으로 사용할 수 있습니다. 지정된 ArrayBuffer 동작을 상속하려는 하위 클래스 생성자 는 ArrayBuffer.prototype의 내장 메서드를 지원하는 데 필요한 내부 상태를 갖도록 하위 클래스 인스턴스를 생성하고 초기화하기 위해 ArrayBuffer 생성자 에 대한 super 호출을 포함해야 합니다.
25.1.4.1 ArrayBuffer ( length [ , options ] )
이 함수는 호출되면 다음 단계를 수행합니다:
NewTarget이 undefined 이면 TypeError 예외를 던집니다. byteLength 를 ? ToIndex (length )로 둡니다.requestedMaxByteLength 를 ? GetArrayBufferMaxByteLengthOption (options )로 둡니다.? AllocateArrayBuffer (NewTarget, byteLength , requestedMaxByteLength )를 반환합니다.
25.1.5 ArrayBuffer 생성자의 프로퍼티
ArrayBuffer 생성자 는:
25.1.5.1 ArrayBuffer.isView ( arg )
이 함수는 호출되면 다음 단계를 수행합니다:
arg 가 Object가 아니면 false 를 반환합니다.arg 에 [[ViewedArrayBuffer]] 내부 슬롯이 있으면 true 를 반환합니다.false 를 반환합니다.
25.1.5.2 ArrayBuffer.prototype
ArrayBuffer.prototype의 초기 값은 ArrayBuffer 프로토타입 객체 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
25.1.5.3 get ArrayBuffer [ %Symbol.species% ]
ArrayBuffer[%Symbol.species%]는 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
this 값을 반환합니다.
이 함수의 "name" 프로퍼티 값은 "get [Symbol.species]" 입니다.
참고
25.1.6 ArrayBuffer 프로토타입 객체의 프로퍼티
ArrayBuffer 프로토타입 객체 는:
%ArrayBuffer.prototype% 입니다.
값이 %Object.prototype% 인 [[Prototype]] 내부 슬롯을 갖습니다.
일반 객체 입니다.
[[ArrayBufferData]] 또는 [[ArrayBufferByteLength]] 내부 슬롯을 갖지 않습니다.
25.1.6.1 get ArrayBuffer.prototype.byteLength
ArrayBuffer.prototype.byteLength는 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.? RequireInternalSlot (obj , [[ArrayBufferData]] )를 수행합니다. IsSharedArrayBuffer (obj )가 true 이면 TypeError 예외를 던집니다.IsDetachedBuffer (obj )가 true 이면 +0 𝔽 을 반환합니다.length 를 obj .[[ArrayBufferByteLength]] 로 둡니다.𝔽 (length )를 반환합니다.
25.1.6.2 ArrayBuffer.prototype.constructor
ArrayBuffer.prototype.constructor의 초기 값은 %ArrayBuffer% 입니다.
25.1.6.3 get ArrayBuffer.prototype.detached
ArrayBuffer.prototype.detached는 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.? RequireInternalSlot (obj , [[ArrayBufferData]] )를 수행합니다. IsSharedArrayBuffer (obj )가 true 이면 TypeError 예외를 던집니다.IsDetachedBuffer (obj )를 반환합니다.
25.1.6.4 get ArrayBuffer.prototype.maxByteLength
ArrayBuffer.prototype.maxByteLength는 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.? RequireInternalSlot (obj , [[ArrayBufferData]] )를 수행합니다. IsSharedArrayBuffer (obj )가 true 이면 TypeError 예외를 던집니다.IsDetachedBuffer (obj )가 true 이면 +0 𝔽 을 반환합니다.IsFixedLengthArrayBuffer (obj )가 true 이면, 다음을 수행합니다.length 를 obj .[[ArrayBufferByteLength]] 로 둡니다.그렇지 않으면,length 를 obj .[[ArrayBufferMaxByteLength]] 로 둡니다. 𝔽 (length )를 반환합니다.
25.1.6.5 get ArrayBuffer.prototype.resizable
ArrayBuffer.prototype.resizable은 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.? RequireInternalSlot (obj , [[ArrayBufferData]] )를 수행합니다. IsSharedArrayBuffer (obj )가 true 이면 TypeError 예외를 던집니다.IsFixedLengthArrayBuffer (obj )가 false 이면 true 를 반환합니다.false 를 반환합니다.
25.1.6.6 ArrayBuffer.prototype.resize ( newLength )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.? RequireInternalSlot (obj , [[ArrayBufferMaxByteLength]] )를 수행합니다. IsSharedArrayBuffer (obj )가 true 이면 TypeError 예외를 던집니다.newByteLength 를 ? ToIndex (newLength )로 둡니다.IsDetachedBuffer (obj )가 true 이면 TypeError 예외를 던집니다.newByteLength > obj .[[ArrayBufferMaxByteLength]] 이면 RangeError 예외를 던집니다.hostHandled 를 ? HostResizeArrayBuffer (obj , newByteLength )로 둡니다.hostHandled 가 handled 이면 undefined 를 반환합니다.oldBlock 을 obj .[[ArrayBufferData]] 로 둡니다.newBlock 을 ? CreateByteDataBlock (newByteLength )로 둡니다.copyLength 를 min (newByteLength , obj .[[ArrayBufferByteLength]] )로 둡니다.CopyDataBlockBytes (newBlock , 0, oldBlock , 0, copyLength )를 수행합니다.참고 : 새로운 Data Block 생성과 이전 Data Block 에서 복사하는 작업은 모두 관찰할 수 없습니다. 구현체는 이 메서드를 제자리 확장 또는 축소로 구현할 수 있습니다.obj .[[ArrayBufferData]] 를 newBlock 으로 설정합니다.obj .[[ArrayBufferByteLength]] 를 newByteLength 로 설정합니다.undefined 를 반환합니다.
25.1.6.7 ArrayBuffer.prototype.slice ( start , end )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.? RequireInternalSlot (obj , [[ArrayBufferData]] )를 수행합니다. IsSharedArrayBuffer (obj )가 true 이면 TypeError 예외를 던집니다.IsDetachedBuffer (obj )가 true 이면 TypeError 예외를 던집니다.length 를 obj .[[ArrayBufferByteLength]] 로 둡니다.first 를 ? ToClampedIndex (start , length )로 둡니다.end 가 undefined 이면 final 을 length 로 둡니다. 그렇지 않으면 final 을 ? ToClampedIndex (end , length )로 둡니다.newLength 를 max (final - first , 0)으로 둡니다.ctor 를 ? SpeciesConstructor (obj , %ArrayBuffer% )로 둡니다.new 를 ? Construct (ctor , « 𝔽 (newLength ) »)로 둡니다.? RequireInternalSlot (new , [[ArrayBufferData]] )를 수행합니다. IsSharedArrayBuffer (new )가 true 이면 TypeError 예외를 던집니다.IsDetachedBuffer (new )가 true 이면 TypeError 예외를 던집니다.SameValue (new , obj )가 true 이면 TypeError 예외를 던집니다.new .[[ArrayBufferByteLength]] < newLength 이면 TypeError 예외를 던집니다.참고 : 위 단계의 부수 효과로 obj 가 분리되거나 크기가 조절되었을 수 있습니다.IsDetachedBuffer (obj )가 true 이면 TypeError 예외를 던집니다.fromBlock 을 obj .[[ArrayBufferData]] 로 둡니다.toBlock 을 new .[[ArrayBufferData]] 로 둡니다.currentLength 를 obj .[[ArrayBufferByteLength]] 로 둡니다.maxCount 를 currentLength - first 로 둡니다.maxCount > 0이면, 다음을 수행합니다.count 를 min (newLength , maxCount )로 둡니다.CopyDataBlockBytes (toBlock , 0, fromBlock , first , count )를 수행합니다.new 를 반환합니다.
25.1.6.8 ArrayBuffer.prototype.transfer ( [ newLength ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.? ArrayBufferCopyAndDetach (obj , newLength , preserve-resizability )를 반환합니다.
25.1.6.9 ArrayBuffer.prototype.transferToFixedLength ( [ newLength ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.? ArrayBufferCopyAndDetach (obj , newLength , fixed-length )를 반환합니다.
25.1.6.10 ArrayBuffer.prototype [ %Symbol.toStringTag% ]
%Symbol.toStringTag% 프로퍼티의 초기 값은 String 값 "ArrayBuffer" 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
25.1.7 ArrayBuffer 인스턴스의 프로퍼티
ArrayBuffer 인스턴스는 ArrayBuffer 프로토타입 객체 에서 프로퍼티를 상속합니다. 각 ArrayBuffer 인스턴스에는 [[ArrayBufferData]] 내부 슬롯, [[ArrayBufferByteLength]] 내부 슬롯, [[ArrayBufferDetachKey]] 내부 슬롯이 있습니다. 크기 조절 가능한 각 ArrayBuffer 인스턴스에는 [[ArrayBufferMaxByteLength]] 내부 슬롯도 있습니다.
[[ArrayBufferData]] 가 null 인 ArrayBuffer 인스턴스는 분리된 것으로 간주되며, ArrayBuffer 인스턴스에 포함된 데이터에 접근하거나 수정하는 모든 연산자는 실패합니다.
[[ArrayBufferDetachKey]] 가 undefined 이외의 값으로 설정된 ArrayBuffer 인스턴스는 모든 DetachArrayBuffer 호출에서 동일한 “detach key”를 인수로 전달해야 하며, 그렇지 않으면 TypeError가 발생합니다. 이 내부 슬롯은 이 명세의 알고리즘이 아니라 특정 임베딩 환경에 의해서만 설정됩니다.
25.1.8 크기 조절 가능한 ArrayBuffer 지침
참고 1
다음은 크기 조절 가능한 ArrayBuffer 를 사용하는 ECMAScript 프로그래머를 위한 지침입니다.
가능한 경우 프로그램을 배포 환경에서 테스트할 것을 권장합니다. 사용 가능한 물리 메모리의 양은 하드웨어 장치마다 크게 다릅니다. 마찬가지로 가상 메모리 하위 시스템도 하드웨어 장치와 운영 체제에 따라 크게 다릅니다. 64비트 데스크톱 웹 브라우저에서 메모리 부족 오류 없이 실행되는 애플리케이션이 32비트 모바일 웹 브라우저에서는 메모리 부족이 발생할 수 있습니다.
크기 조절 가능한 ArrayBuffer 의 "maxByteLength" 옵션 값을 선택할 때는 애플리케이션에 가능한 가장 작은 크기를 선택할 것을 권장합니다. "maxByteLength" 가 1,073,741,824(230 바이트 또는 1GiB)를 초과하지 않을 것을 권장합니다.
특정 최대 크기로 크기 조절 가능한 ArrayBuffer 를 성공적으로 생성했다고 해서 이후의 크기 조절도 성공한다는 보장은 없다는 점에 유의하시기 바랍니다.
참고 2
다음은 크기 조절 가능한 ArrayBuffer 를 구현하는 ECMAScript 구현자를 위한 지침입니다.
크기 조절 가능한 ArrayBuffer 는 크기 조절 시 복사하는 방식, 가상 메모리를 미리 예약하여 제자리 확장하는 방식, 또는 생성자 의 "maxByteLength" 옵션 값에 따라 두 방식을 조합하여 구현할 수 있습니다.
웹 브라우저처럼 호스트 가 다중 테넌트인 경우(즉, 여러 ECMAScript 애플리케이션을 동시에 실행하는 경우), 구현체가 가상 메모리를 예약하여 제자리 확장을 구현하기로 선택한다면 32비트와 64비트 구현 모두 "maxByteLength" ≥ 1GiB~1.5GiB인 값에 대해 예외를 던질 것을 권장합니다. 이는 하나의 애플리케이션이 가상 메모리 주소 공간을 고갈시킬 가능성을 줄이고 상호 운용성 위험을 줄이기 위한 것입니다.
MMU가 없는 임베디드 장치에서 실행되는 경우처럼 호스트 에 가상 메모리가 없거나 호스트 가 복사 방식으로만 크기 조절을 구현하는 경우 "maxByteLength" 옵션에 대해 임의의 Number value for 값을 허용할 수 있습니다. 그러나 요청한 크기의 메모리 블록을 절대로 할당할 수 없는 경우 RangeError 를 던질 것을 권장합니다. 예를 들어 요청 크기가 장치에서 사용할 수 있는 최대 메모리 양보다 큰 경우입니다.
25.2 SharedArrayBuffer 객체
25.2.1 고정 길이 및 확장 가능한 SharedArrayBuffer 객체
고정 길이 SharedArrayBuffer 는 생성된 후 바이트 길이를 변경할 수 없는 SharedArrayBuffer입니다.
확장 가능한 SharedArrayBuffer 는 SharedArrayBuffer.prototype.grow ( newLength ) 호출을 통해 생성 후 바이트 길이를 늘릴 수 있는 SharedArrayBuffer입니다.
생성되는 SharedArrayBuffer 객체의 종류는 SharedArrayBuffer ( length [ , options ] ) 에 전달되는 인수에 따라 달라집니다.
25.2.2 SharedArrayBuffer 객체를 위한 추상 연산
25.2.2.1 AllocateSharedArrayBuffer ( ctor , byteLength [ , maxByteLength ] )
추상 연산 AllocateSharedArrayBuffer. 인수 ctor (생성자 ) 및 byteLength (음이 아닌 정수) 및 선택적 인수 maxByteLength ((음이 아닌 정수 또는 empty )). 반환값: (정상 완료 (값: SharedArrayBuffer) 또는 throw 완료 ). SharedArrayBuffer를 생성하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
slots 를 « [[ArrayBufferData]] »로 둡니다.maxByteLength 가 존재하고 maxByteLength 가 empty 가 아니면 allocatingGrowableBuffer 를 true 로 두고, 그렇지 않으면 allocatingGrowableBuffer 를 false 로 둡니다.allocatingGrowableBuffer 가 true 이면, 다음을 수행합니다.byteLength > maxByteLength 이면 RangeError 예외를 던집니다.slots 에 [[ArrayBufferByteLengthData]] 및 [[ArrayBufferMaxByteLength]] 를 추가합니다.그렇지 않으면,slots 에 [[ArrayBufferByteLength]] 를 추가합니다. obj 를 ? OrdinaryCreateFromConstructor (ctor , "%SharedArrayBuffer.prototype%" , slots )로 둡니다.allocatingGrowableBuffer 가 true 이면 allocationLength 를 maxByteLength 로 두고, 그렇지 않으면 allocationLength 를 byteLength 로 둡니다.block 을 ? CreateSharedByteDataBlock (allocationLength )으로 둡니다.obj .[[ArrayBufferData]] 를 block 으로 설정합니다.allocatingGrowableBuffer 가 true 이면, 다음을 수행합니다.단언 : byteLength ≤ maxByteLength 입니다.byteLengthBlock 을 ? CreateSharedByteDataBlock (8)로 둡니다.SetValueInBuffer (byteLengthBlock , 0, biguint64 , ℤ (byteLength ), true , seq-cst )를 수행합니다.obj .[[ArrayBufferByteLengthData]] 를 byteLengthBlock 으로 설정합니다.obj .[[ArrayBufferMaxByteLength]] 를 maxByteLength 로 설정합니다.그렇지 않으면,obj .[[ArrayBufferByteLength]] 를 byteLength 로 설정합니다. obj 를 반환합니다.
25.2.2.2 IsSharedArrayBuffer ( obj )
추상 연산 IsSharedArrayBuffer. 인수 obj ((ArrayBuffer 또는 SharedArrayBuffer)). 반환값: Boolean. 객체가 SharedArrayBuffer인지 검사합니다. 호출되면 다음 단계를 수행한다.
obj .[[ArrayBufferData]] 가 Shared Data Block 이면 true 를 반환합니다.false 를 반환합니다.
25.2.2.3 IsGrowableSharedArrayBuffer ( obj )
추상 연산 IsGrowableSharedArrayBuffer. 인수 obj ((ArrayBuffer 또는 SharedArrayBuffer)). 반환값: Boolean. 객체가 확장 가능한 SharedArrayBuffer 인지 검사합니다. 호출되면 다음 단계를 수행한다.
IsSharedArrayBuffer (obj )가 true 이고 obj 에 [[ArrayBufferByteLengthData]] 내부 슬롯이 있으면 true 를 반환합니다.false 를 반환합니다.
25.2.2.4 HostGrowSharedArrayBuffer ( buffer , newByteLength )
호스트 정의 추상 연산 HostGrowSharedArrayBuffer. 인수 buffer (SharedArrayBuffer) 및 newByteLength (음이 아닌 정수). 반환값: (정상 완료 (값: (handled 또는 unhandled )) 또는 throw 완료 ). 호스트 가 buffer 의 구현체 정의 확장을 수행할 기회를 제공합니다. 호스트 가 buffer 확장을 처리하지 않기로 선택하면 기본 동작을 위해 unhandled 를 반환할 수 있습니다.
HostGrowSharedArrayBuffer의 구현은 다음 요구 사항을 준수해야 합니다:
참고
위의 두 번째 요구 사항은 buffer 의 현재 바이트 길이를 언제 또는 어떻게 읽는지 의도적으로 모호하게 규정합니다. 바이트 길이는 기반 하드웨어의 원자적 read-modify-write 연산을 통해 업데이트해야 하므로 load-link/store-conditional 또는 load-exclusive/store-exclusive 명령 쌍을 사용하는 아키텍처에서는 쌍을 이루는 명령을 명령 스트림에서 가까이 유지하고자 할 수 있습니다. 따라서 SharedArrayBuffer.prototype.grow ( newLength ) 자체는 HostGrowSharedArrayBuffer를 호출하기 전에 newByteLength 에 대한 범위 검사를 수행하지 않으며 현재 바이트 길이를 언제 읽어야 하는지에 대한 요구 사항도 없습니다.
이는 0 ≤ newByteLength ≤ buffer .[[ArrayBufferMaxByteLength]] 가 보장되는 HostResizeArrayBuffer 와 대조적입니다.
HostGrowSharedArrayBuffer의 기본 구현은 NormalCompletion (unhandled )을 반환하는 것입니다.
25.2.3 SharedArrayBuffer 생성자
SharedArrayBuffer 생성자 는:
%SharedArrayBuffer% 입니다.
해당 프로퍼티가 존재하는 경우 전역 객체 의 "SharedArrayBuffer" 프로퍼티의 초기 값입니다(아래 참조).
생성자 로 호출되면 새로운 SharedArrayBuffer를 생성하고 초기화합니다.
함수로 호출하도록 의도되지 않았으며 그러한 방식으로 호출되면 예외를 던집니다.
클래스 정의의 extends 절 값으로 사용할 수 있습니다. 지정된 SharedArrayBuffer 동작을 상속하려는 하위 클래스 생성자 는 SharedArrayBuffer.prototype의 내장 메서드를 지원하는 데 필요한 내부 상태를 갖도록 하위 클래스 인스턴스를 생성하고 초기화하기 위해 SharedArrayBuffer 생성자 에 대한 super 호출을 포함해야 합니다.
호스트 가 SharedArrayBuffer에 대한 동시 접근을 제공하지 않는 경우 전역 객체 의 "SharedArrayBuffer" 프로퍼티를 생략할 수 있습니다.
참고
ArrayBuffer와 달리 SharedArrayBuffer는 분리될 수 없으며 내부 [[ArrayBufferData]] 슬롯은 절대 null 이 되지 않습니다.
25.2.3.1 SharedArrayBuffer ( length [ , options ] )
이 함수는 호출되면 다음 단계를 수행합니다:
NewTarget이 undefined 이면 TypeError 예외를 던집니다. byteLength 를 ? ToIndex (length )로 둡니다.requestedMaxByteLength 를 ? GetArrayBufferMaxByteLengthOption (options )로 둡니다.? AllocateSharedArrayBuffer (NewTarget, byteLength , requestedMaxByteLength )를 반환합니다.
25.2.4 SharedArrayBuffer 생성자의 프로퍼티
SharedArrayBuffer 생성자 는:
25.2.4.1 SharedArrayBuffer.prototype
SharedArrayBuffer.prototype의 초기 값은 SharedArrayBuffer 프로토타입 객체 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
25.2.4.2 get SharedArrayBuffer [ %Symbol.species% ]
SharedArrayBuffer[%Symbol.species%]는 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
this 값을 반환합니다.
이 함수의 "name" 프로퍼티 값은 "get [Symbol.species]" 입니다.
25.2.5 SharedArrayBuffer 프로토타입 객체의 프로퍼티
SharedArrayBuffer 프로토타입 객체 는:
%SharedArrayBuffer.prototype% 입니다.
값이 %Object.prototype% 인 [[Prototype]] 내부 슬롯을 갖습니다.
일반 객체 입니다.
[[ArrayBufferData]] 또는 [[ArrayBufferByteLength]] 내부 슬롯을 갖지 않습니다.
25.2.5.1 get SharedArrayBuffer.prototype.byteLength
SharedArrayBuffer.prototype.byteLength는 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.? RequireInternalSlot (obj , [[ArrayBufferData]] )를 수행합니다. IsSharedArrayBuffer (obj )가 false 이면 TypeError 예외를 던집니다.length 를 ArrayBufferByteLength (obj , seq-cst )로 둡니다.𝔽 (length )를 반환합니다.
25.2.5.2 SharedArrayBuffer.prototype.constructor
SharedArrayBuffer.prototype.constructor의 초기 값은 %SharedArrayBuffer% 입니다.
25.2.5.3 SharedArrayBuffer.prototype.grow ( newLength )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.? RequireInternalSlot (obj , [[ArrayBufferMaxByteLength]] )를 수행합니다. IsSharedArrayBuffer (obj )가 false 이면 TypeError 예외를 던집니다.newByteLength 를 ? ToIndex (newLength )로 둡니다.hostHandled 를 ? HostGrowSharedArrayBuffer (obj , newByteLength )로 둡니다.hostHandled 가 handled 이면 undefined 를 반환합니다.agentRecord 를 주변 에이전트 의 Agent Record 로 둡니다.isLittleEndian 을 agentRecord .[[LittleEndian]] 으로 둡니다.byteLengthBlock 을 obj .[[ArrayBufferByteLengthData]] 로 둡니다.currentByteLengthRawBytes 를 GetRawBytesFromSharedBlock (byteLengthBlock , 0, biguint64 , true , seq-cst )로 둡니다.newByteLengthRawBytes 를 NumericToRawBytes (biguint64 , ℤ (newByteLength ), isLittleEndian )로 둡니다.다음을 반복합니다.참고 : 이는 동일한 버퍼에 대한 병렬 경합 확장이 전순서화되고 유실되지 않으며 아무 일도 하지 않고 조용히 끝나지 않도록 보장하는 compare-and-exchange 루프입니다. 경합 없이 확장을 시도할 수 있으면 루프를 종료합니다.currentByteLength 를 ℝ (RawBytesToNumeric (biguint64 , currentByteLengthRawBytes , isLittleEndian ))로 둡니다.newByteLength = currentByteLength 이면 undefined 를 반환합니다.newByteLength < currentByteLength 이거나 newByteLength > obj .[[ArrayBufferMaxByteLength]] 이면 RangeError 예외를 던집니다.byteLengthDelta 를 newByteLength - currentByteLength 로 둡니다.byteLengthDelta 바이트로 구성된 새로운 Shared Data Block 값을 생성할 수 없으면 RangeError 예외를 던집니다.참고 : 여기서는 새로운 Shared Data Block 을 실제로 생성하여 사용하지 않습니다. 확장 가능한 SharedArrayBuffer 의 관찰 가능한 동작은 생성 시 최대 크기의 Shared Data Block 을 할당하는 방식으로 명시되며, 이 단계는 메모리가 부족한 구현체가 RangeError 를 던져야 한다는 요구 사항을 나타냅니다.readByteLengthRawBytes 를 AtomicCompareExchangeInSharedBlock (byteLengthBlock , 0, 8, currentByteLengthRawBytes , newByteLengthRawBytes )로 둡니다.ByteListEqual (readByteLengthRawBytes , currentByteLengthRawBytes )이 true 이면 undefined 를 반환합니다.currentByteLengthRawBytes 를 readByteLengthRawBytes 로 설정합니다.
참고
길이를 업데이트하는 compare-exchange의 허위 실패는 금지됩니다. 새 길이에 대한 범위 검사를 통과하고 구현체의 메모리가 부족하지 않으면 ReadModifyWriteSharedMemory 이벤트(즉, 성공한 compare-exchange)가 항상 후보 실행 에 추가됩니다.
SharedArrayBuffer.prototype.grow의 병렬 호출은 전순서화됩니다. 예를 들어 서로 경합 하는 두 호출 sab.grow(10)과 sab.grow(20)을 생각해 보십시오. 두 호출 중 하나가 반드시 경합 에서 이깁니다. sab.grow(20)이 먼저 발생한 경우에도 sab.grow(10) 호출은 절대 sab를 축소하지 않으며, 대신 RangeError를 던집니다.
25.2.5.4 get SharedArrayBuffer.prototype.growable
SharedArrayBuffer.prototype.growable은 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.? RequireInternalSlot (obj , [[ArrayBufferData]] )를 수행합니다. IsSharedArrayBuffer (obj )가 false 이면 TypeError 예외를 던집니다.IsFixedLengthArrayBuffer (obj )가 false 이면 true 를 반환합니다.false 를 반환합니다.
25.2.5.5 get SharedArrayBuffer.prototype.maxByteLength
SharedArrayBuffer.prototype.maxByteLength는 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.? RequireInternalSlot (obj , [[ArrayBufferData]] )를 수행합니다. IsSharedArrayBuffer (obj )가 false 이면 TypeError 예외를 던집니다.IsFixedLengthArrayBuffer (obj )가 true 이면, 다음을 수행합니다.length 를 obj .[[ArrayBufferByteLength]] 로 둡니다.그렇지 않으면,length 를 obj .[[ArrayBufferMaxByteLength]] 로 둡니다. 𝔽 (length )를 반환합니다.
25.2.5.6 SharedArrayBuffer.prototype.slice ( start , end )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.? RequireInternalSlot (obj , [[ArrayBufferData]] )를 수행합니다. IsSharedArrayBuffer (obj )가 false 이면 TypeError 예외를 던집니다.length 를 ArrayBufferByteLength (obj , seq-cst )로 둡니다.first 를 ? ToClampedIndex (start , length )로 둡니다.end 가 undefined 이면 final 을 length 로 둡니다. 그렇지 않으면 final 을 ? ToClampedIndex (end , length )로 둡니다.newLength 를 max (final - first , 0)으로 둡니다.ctor 를 ? SpeciesConstructor (obj , %SharedArrayBuffer% )로 둡니다.new 를 ? Construct (ctor , « 𝔽 (newLength ) »)로 둡니다.? RequireInternalSlot (new , [[ArrayBufferData]] )를 수행합니다. IsSharedArrayBuffer (new )가 false 이면 TypeError 예외를 던집니다.new .[[ArrayBufferData]] 가 obj .[[ArrayBufferData]] 이면 TypeError 예외를 던집니다.ArrayBufferByteLength (new , seq-cst ) < newLength 이면 TypeError 예외를 던집니다.fromBlock 을 obj .[[ArrayBufferData]] 로 둡니다.toBlock 을 new .[[ArrayBufferData]] 로 둡니다.CopyDataBlockBytes (toBlock , 0, fromBlock , first , newLength )를 수행합니다.new 를 반환합니다.
25.2.5.7 SharedArrayBuffer.prototype [ %Symbol.toStringTag% ]
%Symbol.toStringTag% 프로퍼티의 초기 값은 String 값 "SharedArrayBuffer" 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
25.2.6 SharedArrayBuffer 인스턴스의 프로퍼티
SharedArrayBuffer 인스턴스는 SharedArrayBuffer 프로토타입 객체 에서 프로퍼티를 상속합니다. 각 SharedArrayBuffer 인스턴스에는 [[ArrayBufferData]] 내부 슬롯이 있습니다. 확장 가능하지 않은 각 SharedArrayBuffer 인스턴스에는 [[ArrayBufferByteLength]] 내부 슬롯이 있습니다. 확장 가능한 각 SharedArrayBuffer 인스턴스에는 [[ArrayBufferByteLengthData]] 내부 슬롯과 [[ArrayBufferMaxByteLength]] 내부 슬롯이 있습니다.
참고
SharedArrayBuffer 인스턴스는 ArrayBuffer 인스턴스와 달리 절대 분리되지 않습니다.
25.2.7 확장 가능한 SharedArrayBuffer 지침
참고 1
다음은 확장 가능한 SharedArrayBuffer 를 사용하는 ECMAScript 프로그래머를 위한 지침입니다.
가능한 경우 프로그램을 배포 환경에서 테스트할 것을 권장합니다. 사용 가능한 물리 메모리의 양은 하드웨어 장치마다 크게 다릅니다. 마찬가지로 가상 메모리 하위 시스템도 하드웨어 장치와 운영 체제에 따라 크게 다릅니다. 64비트 데스크톱 웹 브라우저에서 메모리 부족 오류 없이 실행되는 애플리케이션이 32비트 모바일 웹 브라우저에서는 메모리 부족이 발생할 수 있습니다.
확장 가능한 SharedArrayBuffer 의 "maxByteLength" 옵션 값을 선택할 때는 애플리케이션에 가능한 가장 작은 크기를 선택할 것을 권장합니다. "maxByteLength" 가 1073741824, 즉 1GiB를 초과하지 않을 것을 권장합니다.
특정 최대 크기로 확장 가능한 SharedArrayBuffer 를 성공적으로 생성했다고 해서 이후의 확장도 성공한다는 보장은 없다는 점에 유의하시기 바랍니다.
확장 가능한 SharedArrayBuffer 의 길이를 읽는 모든 로드가 동기화 seq-cst 로드는 아닙니다. 예를 들어 u8[idx]와 같은 정수 인덱스 프로퍼티 접근의 범위 검사를 위한 길이 로드는 동기화되지 않습니다. 일반적으로 명시적 동기화가 없으면 한 프로퍼티 접근이 범위 안에 있다는 사실이 동일한 에이전트 의 이후 프로퍼티 접근도 범위 안에 있음을 의미하지 않습니다. 반대로 SharedArrayBuffer, %TypedArray% .prototype, DataView.prototype의 length 및 byteLength getter를 통한 명시적 길이 로드는 동기화됩니다. TypedArray 가 완전히 범위를 벗어났는지 검사하기 위해 내장 메서드가 수행하는 길이 로드도 동기화됩니다.
참고 2
다음은 확장 가능한 SharedArrayBuffer 를 구현하는 ECMAScript 구현자를 위한 지침입니다.
확장 가능한 SharedArrayBuffer 는 가상 메모리를 미리 예약하여 제자리 확장하는 방식으로 구현할 것을 권장합니다.
확장 연산은 확장 가능한 SharedArrayBuffer 에 대한 메모리 접근과 병렬로 발생할 수 있으므로 메모리 모델 의 제약 조건은 순서 없는 접근조차 “찢어짐”이 발생하지 않도록 요구합니다(값의 비트가 서로 섞이지 않아야 합니다). 실제로 이는 확장 가능한 SharedArrayBuffer 의 기반 데이터 블록을 전 세계를 중지하지 않고 복사하여 확장할 수 없음을 의미합니다. 구현 전략으로 전 세계를 중지하는 방식은 직렬화 지점을 도입하고 느리므로 권장하지 않습니다.
확장된 메모리는 병렬로 경합 하는 접근을 포함하여 생성되는 순간부터 0으로 채워진 것으로 보여야 합니다. 이는 필요 시 0으로 채워지는 가상 메모리 페이지를 사용하거나, 메모리를 수동으로 0으로 채우는 경우 주의 깊은 동기화를 사용하여 달성할 수 있습니다.
확장 가능한 SharedArrayBuffer 의 TypedArray 뷰에 대한 정수 인덱스 프로퍼티 접근은 확장 불가능한 SharedArrayBuffer의 TypedArray 뷰에 대한 접근과 유사하게 최적화할 수 있도록 의도됩니다. 이는 정수 인덱스 프로퍼티 로드가 기반 버퍼의 길이에 대해 동기화되지 않기 때문입니다(위의 프로그래머 지침 참조). 예를 들어 프로퍼티 접근의 범위 검사를 여전히 루프 밖으로 끌어올릴 수 있습니다.
MMU가 없는 임베디드 장치에서 실행되는 경우처럼 가상 메모리가 없는 호스트 에서는 확장 가능한 SharedArrayBuffer 를 복사 방식으로 구현하기가 실제로 어렵습니다. 이러한 호스트 에서 확장 가능한 SharedArrayBuffer 의 메모리 사용 동작은 가상 메모리를 갖는 호스트 와 크게 다를 수 있습니다. 이러한 호스트 는 사용자에게 메모리 사용 예상치를 명확히 전달해야 합니다.
25.3 DataView 객체
25.3.1 DataView 객체를 위한 추상 연산
25.3.1.1 DataView With Buffer Witness Records
DataView With Buffer Witness Record 는 DataView와 뷰가 참조하는 버퍼의 캐시된 바이트 길이를 함께 캡슐화하는 데 사용되는 Record 입니다. 뷰가 참조하는 버퍼가 확장 가능한 SharedArrayBuffer 일 때 바이트 길이 데이터 블록에 대한 ReadSharedMemory 이벤트가 하나만 존재하도록 보장하는 데 도움을 주기 위해 사용됩니다.
DataView With Buffer Witness Records에는 표 73 에 나열된 필드가 있습니다.
표 73: DataView With Buffer Witness Record 필드
필드 이름
값
의미
[[Object]]
a DataView
버퍼의 바이트 길이를 로드하는 DataView 객체입니다.
[[CachedBufferByteLength]]
a non-negative integer or detached
Record 가 생성될 때 객체의 [[ViewedArrayBuffer]] 의 바이트 길이입니다.
25.3.1.2 MakeDataViewWithBufferWitnessRecord ( obj , order )
추상 연산 MakeDataViewWithBufferWitnessRecord. 인수 obj (DataView) 및 order ((seq-cst 또는 unordered )). 반환값: DataView With Buffer Witness 레코드 . 호출되면 다음 단계를 수행한다.
buffer 를 obj .[[ViewedArrayBuffer]] 로 둡니다.IsDetachedBuffer (buffer )가 true 이면, 다음을 수행합니다.byteLength 를 detached 로 둡니다.그렇지 않으면,byteLength 를 ArrayBufferByteLength (buffer , order )로 둡니다. DataView With Buffer Witness Record { [[Object]] : obj , [[CachedBufferByteLength]] : byteLength }를 반환합니다.
25.3.1.3 GetViewByteLength ( viewRecord )
추상 연산 GetViewByteLength. 인수 viewRecord (DataView With Buffer Witness 레코드 ). 반환값: 음이 아닌 정수. 호출되면 다음 단계를 수행한다.
단언 : IsViewOutOfBounds (viewRecord )는 false 입니다.view 를 viewRecord .[[Object]] 로 둡니다.view .[[ByteLength]] 가 auto 가 아니면 view .[[ByteLength]] 를 반환합니다.단언 : IsFixedLengthArrayBuffer (view .[[ViewedArrayBuffer]] )는 false 입니다.byteOffset 을 view .[[ByteOffset]] 으로 둡니다.byteLength 를 viewRecord .[[CachedBufferByteLength]] 로 둡니다.단언 : byteLength 는 detached 가 아닙니다.byteLength - byteOffset 을 반환합니다.
25.3.1.4 IsViewOutOfBounds ( viewRecord )
추상 연산 IsViewOutOfBounds. 인수 viewRecord (DataView With Buffer Witness 레코드 ). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
view 를 viewRecord .[[Object]] 로 둡니다.bufferByteLength 를 viewRecord .[[CachedBufferByteLength]] 로 둡니다.IsDetachedBuffer (view .[[ViewedArrayBuffer]] )가 true 이면, 다음을 수행합니다.단언 : bufferByteLength 는 detached 입니다.true 를 반환합니다.단언 : bufferByteLength 는 음이 아닌 정수 입니다.byteOffsetStart 를 view .[[ByteOffset]] 으로 둡니다.view .[[ByteLength]] 가 auto 이면, 다음을 수행합니다.byteOffsetEnd 를 bufferByteLength 로 둡니다.그렇지 않으면,byteOffsetEnd 를 byteOffsetStart + view .[[ByteLength]] 로 둡니다. 참고 : [[ByteOffset]] 이 bufferByteLength 인 길이 0의 DataView는 범위를 벗어난 것으로 간주하지 않습니다.byteOffsetStart > bufferByteLength 이거나 byteOffsetEnd > bufferByteLength 이면 true 를 반환합니다.false 를 반환합니다.
25.3.1.5 GetViewValue ( view , requestIndex , isLittleEndian , type )
추상 연산 GetViewValue. 인수 view (ECMAScript 언어 값 ), requestIndex (ECMAScript 언어 값 ), isLittleEndian (ECMAScript 언어 값 ) 및 type (TypedArray 요소 타입 ). 반환값: (정상 완료 (값: (Number 또는 BigInt)) 또는 throw 완료 ). DataView 인스턴스의 함수가 뷰의 버퍼에서 값을 가져오는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
? RequireInternalSlot (view , [[DataView]] )를 수행합니다. 단언 : view 에는 [[ViewedArrayBuffer]] 내부 슬롯이 있습니다.getIndex 를 ? ToIndex (requestIndex )로 둡니다.isLittleEndian 을 ToBoolean (isLittleEndian )으로 설정합니다.viewOffset 을 view .[[ByteOffset]] 으로 둡니다.viewRecord 를 MakeDataViewWithBufferWitnessRecord (view , unordered )로 둡니다.참고 : view 의 기반 버퍼가 확장 가능한 SharedArrayBuffer 일 때 범위 검사는 동기화 연산이 아닙니다.IsViewOutOfBounds (viewRecord )가 true 이면 TypeError 예외를 던집니다.viewSize 를 GetViewByteLength (viewRecord )로 둡니다.elementSize 를 Element Type type 에 대해 표 71 에 지정된 Element Size 값으로 둡니다.getIndex + elementSize > viewSize 이면 RangeError 예외를 던집니다.bufferIndex 를 getIndex + viewOffset 으로 둡니다.GetValueFromBuffer (view .[[ViewedArrayBuffer]] , bufferIndex , type , false , unordered , isLittleEndian )을 반환합니다.
25.3.1.6 SetViewValue ( view , requestIndex , isLittleEndian , type , value )
추상 연산 SetViewValue. 인수 view (ECMAScript 언어 값 ), requestIndex (ECMAScript 언어 값 ), isLittleEndian (ECMAScript 언어 값 ), type (TypedArray 요소 타입 ) 및 value (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). DataView 인스턴스의 함수가 뷰의 버퍼에 값을 저장하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
? RequireInternalSlot (view , [[DataView]] )를 수행합니다. 단언 : view 에는 [[ViewedArrayBuffer]] 내부 슬롯이 있습니다.getIndex 를 ? ToIndex (requestIndex )로 둡니다.IsBigIntElementType (type )이 true 이면 number 를 ? ToBigInt (value )로 둡니다.그렇지 않으면 number 를 ? ToNumber (value )로 둡니다. isLittleEndian 을 ToBoolean (isLittleEndian )으로 설정합니다.viewOffset 을 view .[[ByteOffset]] 으로 둡니다.viewRecord 를 MakeDataViewWithBufferWitnessRecord (view , unordered )로 둡니다.참고 : view 의 기반 버퍼가 확장 가능한 SharedArrayBuffer 일 때 범위 검사는 동기화 연산이 아닙니다.IsViewOutOfBounds (viewRecord )가 true 이면 TypeError 예외를 던집니다.viewSize 를 GetViewByteLength (viewRecord )로 둡니다.elementSize 를 Element Type type 에 대해 표 71 에 지정된 Element Size 값으로 둡니다.getIndex + elementSize > viewSize 이면 RangeError 예외를 던집니다.bufferIndex 를 getIndex + viewOffset 으로 둡니다.SetValueInBuffer (view .[[ViewedArrayBuffer]] , bufferIndex , type , number , false , unordered , isLittleEndian )을 수행합니다.unused 를 반환합니다.
25.3.2 DataView 생성자
DataView 생성자 는:
%DataView% 입니다.
전역 객체 의 "DataView" 프로퍼티의 초기 값입니다.
생성자 로 호출되면 새로운 DataView를 생성하고 초기화합니다.
함수로 호출하도록 의도되지 않았으며 그러한 방식으로 호출되면 예외를 던집니다.
클래스 정의의 extends 절 값으로 사용할 수 있습니다. 지정된 DataView 동작을 상속하려는 하위 클래스 생성자 는 DataView.prototype의 내장 메서드를 지원하는 데 필요한 내부 상태를 갖도록 하위 클래스 인스턴스를 생성하고 초기화하기 위해 DataView 생성자 에 대한 super 호출을 포함해야 합니다.
25.3.2.1 DataView ( buffer [ , byteOffset [ , byteLength ] ] )
이 함수는 호출되면 다음 단계를 수행합니다:
NewTarget이 undefined 이면 TypeError 예외를 던집니다. ? RequireInternalSlot (buffer , [[ArrayBufferData]] )를 수행합니다. offset 을 ? ToIndex (byteOffset )로 둡니다.IsDetachedBuffer (buffer )가 true 이면 TypeError 예외를 던집니다.bufferByteLength 를 ArrayBufferByteLength (buffer , seq-cst )로 둡니다.offset > bufferByteLength 이면 RangeError 예외를 던집니다.bufferIsFixedLength 를 IsFixedLengthArrayBuffer (buffer )로 둡니다.byteLength 가 undefined 이면, 다음을 수행합니다.bufferIsFixedLength 가 true 이면, 다음을 수행합니다.viewByteLength 를 bufferByteLength - offset 으로 둡니다.그렇지 않으면,viewByteLength 를 auto 로 둡니다. 그렇지 않으면,viewByteLength 를 ? ToIndex (byteLength )로 둡니다.offset + viewByteLength > bufferByteLength 이면 RangeError 예외를 던집니다. obj 를 ? OrdinaryCreateFromConstructor (NewTarget, "%DataView.prototype%" , « [[DataView]] , [[ViewedArrayBuffer]] , [[ByteLength]] , [[ByteOffset]] »)로 둡니다.IsDetachedBuffer (buffer )가 true 이면 TypeError 예외를 던집니다.bufferByteLength 를 ArrayBufferByteLength (buffer , seq-cst )로 설정합니다.offset > bufferByteLength 이면 RangeError 예외를 던집니다.byteLength 가 undefined 가 아니면, 다음을 수행합니다.offset + viewByteLength > bufferByteLength 이면 RangeError 예외를 던집니다.obj .[[ViewedArrayBuffer]] 를 buffer 로 설정합니다.obj .[[ByteLength]] 를 viewByteLength 로 설정합니다.obj .[[ByteOffset]] 을 offset 으로 설정합니다.obj 를 반환합니다.
25.3.3 DataView 생성자의 프로퍼티
DataView 생성자 는:
25.3.3.1 DataView.prototype
DataView.prototype의 초기 값은 DataView 프로토타입 객체 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
25.3.4 DataView 프로토타입 객체의 프로퍼티
DataView 프로토타입 객체 는:
%DataView.prototype% 입니다.
값이 %Object.prototype% 인 [[Prototype]] 내부 슬롯을 갖습니다.
일반 객체 입니다.
[[DataView]] , [[ViewedArrayBuffer]] , [[ByteLength]] , [[ByteOffset]] 내부 슬롯을 갖지 않습니다.
25.3.4.1 get DataView.prototype.buffer
DataView.prototype.buffer는 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.? RequireInternalSlot (obj , [[DataView]] )를 수행합니다. 단언 : obj 에는 [[ViewedArrayBuffer]] 내부 슬롯이 있습니다.buffer 를 obj .[[ViewedArrayBuffer]] 로 둡니다.buffer 를 반환합니다.
25.3.4.2 get DataView.prototype.byteLength
DataView.prototype.byteLength는 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.? RequireInternalSlot (obj , [[DataView]] )를 수행합니다. 단언 : obj 에는 [[ViewedArrayBuffer]] 내부 슬롯이 있습니다.viewRecord 를 MakeDataViewWithBufferWitnessRecord (obj , seq-cst )로 둡니다.IsViewOutOfBounds (viewRecord )가 true 이면 TypeError 예외를 던집니다.size 를 GetViewByteLength (viewRecord )로 둡니다.𝔽 (size )를 반환합니다.
25.3.4.3 get DataView.prototype.byteOffset
DataView.prototype.byteOffset은 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.? RequireInternalSlot (obj , [[DataView]] )를 수행합니다. 단언 : obj 에는 [[ViewedArrayBuffer]] 내부 슬롯이 있습니다.viewRecord 를 MakeDataViewWithBufferWitnessRecord (obj , seq-cst )로 둡니다.IsViewOutOfBounds (viewRecord )가 true 이면 TypeError 예외를 던집니다.offset 을 obj .[[ByteOffset]] 으로 둡니다.𝔽 (offset )을 반환합니다.
25.3.4.4 DataView.prototype.constructor
DataView.prototype.constructor의 초기 값은 %DataView% 입니다.
25.3.4.5 DataView.prototype.getBigInt64 ( byteOffset [ , littleEndian ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
view 를 this 값으로 둡니다.? GetViewValue (view , byteOffset , littleEndian , bigint64 )를 반환합니다.
25.3.4.6 DataView.prototype.getBigUint64 ( byteOffset [ , littleEndian ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
view 를 this 값으로 둡니다.? GetViewValue (view , byteOffset , littleEndian , biguint64 )를 반환합니다.
25.3.4.7 DataView.prototype.getFloat16 ( byteOffset [ , littleEndian ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
view 를 this 값으로 둡니다.littleEndian 이 존재하지 않으면 littleEndian 을 false 로 설정합니다.? GetViewValue (view , byteOffset , littleEndian , float16 )를 반환합니다.
25.3.4.8 DataView.prototype.getFloat32 ( byteOffset [ , littleEndian ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
view 를 this 값으로 둡니다.littleEndian 이 존재하지 않으면 littleEndian 을 false 로 설정합니다.? GetViewValue (view , byteOffset , littleEndian , float32 )를 반환합니다.
25.3.4.9 DataView.prototype.getFloat64 ( byteOffset [ , littleEndian ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
view 를 this 값으로 둡니다.littleEndian 이 존재하지 않으면 littleEndian 을 false 로 설정합니다.? GetViewValue (view , byteOffset , littleEndian , float64 )를 반환합니다.
25.3.4.10 DataView.prototype.getInt8 ( byteOffset )
이 메서드는 호출되면 다음 단계를 수행합니다:
view 를 this 값으로 둡니다.? GetViewValue (view , byteOffset , true , int8 )를 반환합니다.
25.3.4.11 DataView.prototype.getInt16 ( byteOffset [ , littleEndian ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
view 를 this 값으로 둡니다.littleEndian 이 존재하지 않으면 littleEndian 을 false 로 설정합니다.? GetViewValue (view , byteOffset , littleEndian , int16 )를 반환합니다.
25.3.4.12 DataView.prototype.getInt32 ( byteOffset [ , littleEndian ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
view 를 this 값으로 둡니다.littleEndian 이 존재하지 않으면 littleEndian 을 false 로 설정합니다.? GetViewValue (view , byteOffset , littleEndian , int32 )를 반환합니다.
25.3.4.13 DataView.prototype.getUint8 ( byteOffset )
이 메서드는 호출되면 다음 단계를 수행합니다:
view 를 this 값으로 둡니다.? GetViewValue (view , byteOffset , true , uint8 )를 반환합니다.
25.3.4.14 DataView.prototype.getUint16 ( byteOffset [ , littleEndian ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
view 를 this 값으로 둡니다.littleEndian 이 존재하지 않으면 littleEndian 을 false 로 설정합니다.? GetViewValue (view , byteOffset , littleEndian , uint16 )를 반환합니다.
25.3.4.15 DataView.prototype.getUint32 ( byteOffset [ , littleEndian ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
view 를 this 값으로 둡니다.littleEndian 이 존재하지 않으면 littleEndian 을 false 로 설정합니다.? GetViewValue (view , byteOffset , littleEndian , uint32 )를 반환합니다.
25.3.4.16 DataView.prototype.setBigInt64 ( byteOffset , value [ , littleEndian ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
view 를 this 값으로 둡니다.? SetViewValue (view , byteOffset , littleEndian , bigint64 , value )를 수행합니다. undefined 를 반환합니다.
25.3.4.17 DataView.prototype.setBigUint64 ( byteOffset , value [ , littleEndian ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
view 를 this 값으로 둡니다.? SetViewValue (view , byteOffset , littleEndian , biguint64 , value )를 수행합니다. undefined 를 반환합니다.
25.3.4.18 DataView.prototype.setFloat16 ( byteOffset , value [ , littleEndian ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
view 를 this 값으로 둡니다.littleEndian 이 존재하지 않으면 littleEndian 을 false 로 설정합니다.? SetViewValue (view , byteOffset , littleEndian , float16 , value )를 수행합니다. undefined 를 반환합니다.
25.3.4.19 DataView.prototype.setFloat32 ( byteOffset , value [ , littleEndian ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
view 를 this 값으로 둡니다.littleEndian 이 존재하지 않으면 littleEndian 을 false 로 설정합니다.? SetViewValue (view , byteOffset , littleEndian , float32 , value )를 수행합니다. undefined 를 반환합니다.
25.3.4.20 DataView.prototype.setFloat64 ( byteOffset , value [ , littleEndian ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
view 를 this 값으로 둡니다.littleEndian 이 존재하지 않으면 littleEndian 을 false 로 설정합니다.? SetViewValue (view , byteOffset , littleEndian , float64 , value )를 수행합니다. undefined 를 반환합니다.
25.3.4.21 DataView.prototype.setInt8 ( byteOffset , value )
이 메서드는 호출되면 다음 단계를 수행합니다:
view 를 this 값으로 둡니다.? SetViewValue (view , byteOffset , true , int8 , value )를 수행합니다. undefined 를 반환합니다.
25.3.4.22 DataView.prototype.setInt16 ( byteOffset , value [ , littleEndian ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
view 를 this 값으로 둡니다.littleEndian 이 존재하지 않으면 littleEndian 을 false 로 설정합니다.? SetViewValue (view , byteOffset , littleEndian , int16 , value )를 수행합니다. undefined 를 반환합니다.
25.3.4.23 DataView.prototype.setInt32 ( byteOffset , value [ , littleEndian ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
view 를 this 값으로 둡니다.littleEndian 이 존재하지 않으면 littleEndian 을 false 로 설정합니다.? SetViewValue (view , byteOffset , littleEndian , int32 , value )를 수행합니다. undefined 를 반환합니다.
25.3.4.24 DataView.prototype.setUint8 ( byteOffset , value )
이 메서드는 호출되면 다음 단계를 수행합니다:
view 를 this 값으로 둡니다.? SetViewValue (view , byteOffset , true , uint8 , value )를 수행합니다. undefined 를 반환합니다.
25.3.4.25 DataView.prototype.setUint16 ( byteOffset , value [ , littleEndian ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
view 를 this 값으로 둡니다.littleEndian 이 존재하지 않으면 littleEndian 을 false 로 설정합니다.? SetViewValue (view , byteOffset , littleEndian , uint16 , value )를 수행합니다. undefined 를 반환합니다.
25.3.4.26 DataView.prototype.setUint32 ( byteOffset , value [ , littleEndian ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
view 를 this 값으로 둡니다.littleEndian 이 존재하지 않으면 littleEndian 을 false 로 설정합니다.? SetViewValue (view , byteOffset , littleEndian , uint32 , value )를 수행합니다. undefined 를 반환합니다.
25.3.4.27 DataView.prototype [ %Symbol.toStringTag% ]
%Symbol.toStringTag% 프로퍼티의 초기 값은 String 값 "DataView" 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
25.3.5 DataView 인스턴스의 프로퍼티
DataView 인스턴스는 DataView 프로토타입 객체 에서 프로퍼티를 상속하는 일반 객체 입니다. 각 DataView 인스턴스에는 [[DataView]] , [[ViewedArrayBuffer]] , [[ByteLength]] , [[ByteOffset]] 내부 슬롯이 있습니다.
참고
[[DataView]] 내부 슬롯의 값은 이 명세 안에서 사용되지 않습니다. 해당 내부 슬롯이 존재한다는 사실 자체가 명세에서 DataView 생성자 를 사용하여 생성된 객체를 식별하는 데 사용됩니다.
25.4 Atomics 객체
Atomics 객체는:
%Atomics% 입니다.
전역 객체 의 "Atomics" 프로퍼티의 초기 값입니다.
일반 객체 입니다.
값이 %Object.prototype% 인 [[Prototype]] 내부 슬롯을 갖습니다.
[[Construct]] 내부 메서드를 갖지 않으므로 new 연산자와 함께 생성자 로 사용할 수 없습니다.
[[Call]] 내부 메서드를 갖지 않으므로 함수로 호출할 수 없습니다.
Atomics 객체는 공유 메모리 배열 셀에 대해 분할 불가능하게(원자적으로) 동작하는 함수와 에이전트 가 기본 이벤트를 기다리고 디스패치하도록 하는 함수를 제공합니다. 규율 있게 사용하면 Atomics 함수는 공유 메모리를 통해 통신하는 다중 에이전트 프로그램이 병렬 CPU에서도 잘 정의된 순서로 실행되도록 합니다. 공유 메모리 통신을 지배하는 규칙은 아래에 정의된 메모리 모델 에서 제공합니다.
참고
ECMAScript에서 공유 메모리를 프로그래밍하고 구현하기 위한 정보 제공용 지침은 메모리 모델 절 끝의 참고 를 참조하시기 바랍니다.
25.4.1 Waiter Record
Waiter Record 는 Atomics.wait 또는 Atomics.waitAsync의 특정 호출을 나타내는 데 사용되는 Record 입니다.
Waiter Record에는 표 74 에 나열된 필드가 있습니다.
표 74: Waiter Record 필드
필드 이름
값
의미
[[AgentSignifier]]
an agent signifier
Atomics.wait 또는 Atomics.waitAsync를 호출한 에이전트 입니다.
[[PromiseCapability]]
a PromiseCapability Record or blocking
Atomics.waitAsync 호출을 나타내는 경우 결과 promise이며, 그렇지 않으면 blocking 입니다.
[[TimeoutTime]]
a non-negative extended mathematical value
타임아웃이 트리거될 수 있는 가장 이른 시간이며 시간 값 을 사용하여 계산합니다.
[[Result]]
"ok" or "timed-out"
호출의 반환 값입니다.
25.4.2 WaiterList Records
WaiterList Record 는 Atomics.wait, Atomics.waitAsync, Atomics.notify를 통한 에이전트 의 대기 및 알림을 설명하는 데 사용됩니다.
WaiterList Record에는 표 75 에 나열된 필드가 있습니다.
표 75: WaiterList Record 필드
필드 이름
값
의미
[[Waiters]]
a List of Waiter Records
이 WaiterList와 연결된 위치에서 대기 중인 Atomics.wait 또는 Atomics.waitAsync 호출입니다.
[[MostRecentLeaveEvent]]
a Synchronize event or empty
임계 구역 에서 가장 최근에 나간 이벤트이며, 임계 구역 에 한 번도 들어간 적이 없으면 empty 입니다.
동일한 agent signifier를 갖는 여러 Waiter Record 가 하나의 WaiterList에 있을 수 있습니다.
에이전트 클러스터 에는 WaiterList Records 저장소가 있습니다. 이 저장소는 (block , i )로 인덱싱되며, 여기서 block 은 Shared Data Block 이고 i 는 block 메모리 안의 바이트 오프셋입니다. WaiterList Records는 에이전트 와 독립적입니다. WaiterList Records 저장소에서 (block , i )로 조회하면 에이전트 클러스터 의 어떤 에이전트 에서도 동일한 WaiterList Record가 결과로 나옵니다.
각 WaiterList Record에는 평가 중 해당 WaiterList Record에 대한 배타적 접근을 제어하는 임계 구역 이 있습니다. 한 번에 하나의 에이전트 만 WaiterList Record의 임계 구역에 들어갈 수 있습니다. WaiterList Record의 임계 구역에 들어가고 나가는 것은 추상 연산 EnterCriticalSection 및 LeaveCriticalSection 이 제어합니다. WaiterList Record에 대한 연산—대기 중인 에이전트 추가 및 제거, 에이전트 목록 순회, 목록의 에이전트 일시 중단 및 알림, Synchronize 이벤트 설정 및 가져오기—은 WaiterList Record의 임계 구역에 들어간 에이전트 만 수행할 수 있습니다.
25.4.3 Atomics를 위한 추상 연산
25.4.3.1 ValidateIntegerTypedArray ( ta , waitable )
추상 연산 ValidateIntegerTypedArray. 인수 ta (ECMAScript 언어 값 ) 및 waitable (Boolean). 반환값: (정상 완료 (값: TypedArray With Buffer Witness 레코드 ) 또는 throw 완료 ). %Atomics% 함수와 함께 사용할 수 있는 TypedArray , 특히 공유 메모리와의 원자적 상호작용을 보장할 수 있는 TypedArray 를 제한하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
참고 : ta 의 기반 버퍼가 확장 가능한 SharedArrayBuffer 일 때 범위 검사는 동기화 연산이 아닙니다.taRecord 를 ? ValidateTypedArray (ta , unordered )로 둡니다.elementType 을 TypedArrayElementType (ta )로 둡니다.IsNoTearConfiguration (elementType , seq-cst )이 false 이면 TypeError 예외를 던집니다.waitable 이 true 이고 elementType 이 int32 도 bigint64 도 아니면 TypeError 예외를 던집니다.taRecord 를 반환합니다.
25.4.3.2 ValidateAtomicAccess ( taRecord , requestIndex )
추상 연산 ValidateAtomicAccess. 인수 taRecord (TypedArray With Buffer Witness 레코드 ) 및 requestIndex (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: 음이 아닌 정수) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
length 를 TypedArrayLength (taRecord )로 둡니다.accessIndex 를 ? ToIndex (requestIndex )로 둡니다.단언 : accessIndex ≥ 0입니다.accessIndex ≥ length 이면 RangeError 예외를 던집니다.ta 를 taRecord .[[Object]] 로 둡니다.elementSize 를 TypedArrayElementSize (ta )로 둡니다.offset 을 ta .[[ByteOffset]] 으로 둡니다.(accessIndex × elementSize ) + offset 을 반환합니다.
25.4.3.3 ValidateAtomicAccessOnIntegerTypedArray ( ta , requestIndex )
추상 연산 ValidateAtomicAccessOnIntegerTypedArray. 인수 ta (ECMAScript 언어 값 ) 및 requestIndex (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: 음이 아닌 정수) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
taRecord 를 ? ValidateIntegerTypedArray (ta , false )로 둡니다.? ValidateAtomicAccess (taRecord , requestIndex )를 반환합니다.
25.4.3.4 RevalidateAtomicAccess ( ta , byteIndexInBuffer )
추상 연산 RevalidateAtomicAccess. 인수 ta (TypedArray ) 및 byteIndexInBuffer (음이 아닌 정수). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). Atomics 메서드에서 모든 인수 강제 변환이 수행된 후 원자적 연산을 위해 기반 버퍼 안의 인덱스를 다시 검증합니다. 인수 강제 변환은 임의의 부수 효과를 가질 수 있어 버퍼가 범위를 벗어나게 할 수 있기 때문입니다. 이 연산은 ta 의 기반 버퍼가 SharedArrayBuffer인 경우 예외를 던지지 않습니다. 호출되면 다음 단계를 수행한다.
참고 : ta 의 기반 버퍼가 확장 가능한 SharedArrayBuffer 인 경우, 경계 검사는 동기화 작업이 아닙니다.taRecord 를 ? ValidateTypedArrayBounds (ta , unordered )로 설정합니다.단언 : byteIndexInBuffer ≥ ta .[[ByteOffset]] .elementSize 를 TypedArrayElementSize (ta )로 설정합니다.elementLastByteIndex 를 byteIndexInBuffer + elementSize - 1로 설정합니다.elementLastByteIndex ≥ taRecord .[[CachedBufferByteLength]] 이면 RangeError 예외를 던집니다.unused 를 반환합니다.
25.4.3.5 GetWaiterList ( block , i )
추상 연산 GetWaiterList. 인수 block (공유 데이터 블록 ) 및 i (a non-negative integer that is evenly divisible by 4). 반환값: WaiterList 레코드 . 호출되면 다음 단계를 수행한다.
단언 : i 와 i + 3은 block 메모리 안의 유효한 바이트 오프셋입니다.쌍 (block , i )가 참조하는 WaiterList Record 를 반환합니다.
25.4.3.6 EnterCriticalSection ( waiterList )
추상 연산 EnterCriticalSection. 인수 waiterList (WaiterList 레코드 ). 반환값: unused . 호출되면 다음 단계를 수행한다.
단언 : 주변 에이전트 는 어떤 WaiterList Record 의 임계 구역 에도 들어가 있지 않습니다.어떤 에이전트 도 waiterList 의 임계 구역 에 있지 않을 때까지 기다린 다음, 다른 에이전트 가 들어가는 것을 허용하지 않고 waiterList 의 임계 구역 에 들어갑니다. waiterList .[[MostRecentLeaveEvent]] 가 empty 가 아니면, 다음을 수행합니다.참고 : 임계 구역 에 한 번 이상 들어간 waiterList 에는 LeaveCriticalSection 이 설정한 Synchronize 이벤트 가 있습니다.agentRecord 를 주변 에이전트 의 Agent Record 로 둡니다.execution 을 agentRecord .[[CandidateExecution]] 으로 둡니다.eventsRecord 를 [[AgentSignifier]] 가 AgentSignifier ()인 execution .[[EventsRecords]] 의 Agent Events Record 로 둡니다.enterEvent 를 새로운 Synchronize 이벤트 로 둡니다.enterEvent 를 eventsRecord .[[EventList]] 에 추가합니다.(waiterList .[[MostRecentLeaveEvent]] , enterEvent )를 eventsRecord .[[AgentSynchronizesWith]] 에 추가합니다. unused 를 반환합니다.
EnterCriticalSection은 임계 구역 에 들어가려는 에이전트 가 다른 에이전트 가 나갈 때까지 기다려야 할 때 경합 이 발생합니다. 경합이 없으면 EnterCriticalSection 호출의 FIFO 순서를 관찰할 수 있습니다. 경합이 있는 경우 구현체는 임의의 순서를 선택할 수 있지만 에이전트 를 무기한 기다리게 해서는 안 됩니다.
25.4.3.7 LeaveCriticalSection ( waiterList )
추상 연산 LeaveCriticalSection. 인수 waiterList (WaiterList 레코드 ). 반환값: unused . 호출되면 다음 단계를 수행한다.
단언 : 주변 에이전트 는 waiterList 의 임계 구역 안에 있습니다.agentRecord 를 주변 에이전트 의 Agent Record 로 둡니다.execution 을 agentRecord .[[CandidateExecution]] 으로 둡니다.eventsRecord 를 [[AgentSignifier]] 가 AgentSignifier ()인 execution .[[EventsRecords]] 의 Agent Events Record 로 둡니다.leaveEvent 를 새로운 Synchronize 이벤트 로 둡니다.leaveEvent 를 eventsRecord .[[EventList]] 에 추가합니다.waiterList .[[MostRecentLeaveEvent]] 를 leaveEvent 로 설정합니다.waiterList 의 임계 구역 에서 나갑니다.unused 를 반환합니다.
25.4.3.8 AddWaiter ( waiterList , waiterRecord )
추상 연산 AddWaiter. 인수 waiterList (WaiterList 레코드 ) 및 waiterRecord (Waiter 레코드 ). 반환값: unused . 호출되면 다음 단계를 수행한다.
단언 : 주변 에이전트 는 waiterList 의 임계 구역 안에 있습니다.단언 : waiterList .[[Waiters]] 에는 [[PromiseCapability]] 필드가 waiterRecord .[[PromiseCapability]] 이고 [[AgentSignifier]] 필드가 waiterRecord .[[AgentSignifier]] 인 Waiter Record 가 없습니다.waiterRecord 를 waiterList .[[Waiters]] 에 추가합니다.unused 를 반환합니다.
25.4.3.9 RemoveWaiter ( waiterList , waiterRecord )
추상 연산 RemoveWaiter. 인수 waiterList (WaiterList 레코드 ) 및 waiterRecord (Waiter 레코드 ). 반환값: unused . 호출되면 다음 단계를 수행한다.
단언 : 주변 에이전트 는 waiterList 의 임계 구역 안에 있습니다.단언 : waiterList .[[Waiters]] 에는 waiterRecord 가 포함되어 있습니다.waiterRecord 를 waiterList .[[Waiters]] 에서 제거합니다.unused 를 반환합니다.
25.4.3.10 RemoveWaiters ( waiterList , count )
추상 연산 RemoveWaiters. 인수 waiterList (WaiterList 레코드 ) 및 count ((음이 아닌 정수 또는 +∞)). 반환값: 리스트 (요소: Waiter 레코드 ). 호출되면 다음 단계를 수행한다.
단언 : 주변 에이전트 는 waiterList 의 임계 구역 안에 있습니다.length 를 waiterList .[[Waiters]] 의 요소 수로 둡니다.count 를 min (count , length )로 설정합니다.waiters 를 waiterList .[[Waiters]] 의 처음 count 개 요소를 요소로 갖는 List 로 둡니다.waiterList .[[Waiters]] 의 처음 count 개 요소를 제거합니다.waiters 를 반환합니다.
25.4.3.11 SuspendThisAgent ( waiterList , waiterRecord )
추상 연산 SuspendThisAgent. 인수 waiterList (WaiterList 레코드 ) 및 waiterRecord (Waiter 레코드 ). 반환값: unused . 호출되면 다음 단계를 수행한다.
단언 : 주변 에이전트 는 waiterList 의 임계 구역 안에 있습니다.단언 : waiterList .[[Waiters]] 에는 waiterRecord 가 포함되어 있습니다.thisAgent 를 AgentSignifier ()로 둡니다.단언 : waiterRecord .[[AgentSignifier]] 는 thisAgent 입니다.단언 : waiterRecord .[[PromiseCapability]] 은 blocking 입니다.단언 : AgentCanSuspend ()는 true 입니다.LeaveCriticalSection (waiterList )을 수행하고 시간이 waiterRecord .[[TimeoutTime]] 이 될 때까지 주변 에이전트 를 일시 중단합니다. 이 두 연산은 임계 구역 을 나간 후 일시 중단이 실제로 적용되기 전에 도착한 알림이 유실되지 않는 방식으로 결합하여 수행합니다. 주변 에이전트 는 타임아웃 또는 다른 에이전트 가 waiterList 와 thisAgent 를 인수로 NotifyWaiter 를 호출하는 경우에만 일시 중단에서 깨어날 수 있습니다(즉, Atomics.notify 호출을 통해).EnterCriticalSection (waiterList )을 수행합니다.unused 를 반환합니다.
25.4.3.12 NotifyWaiter ( waiterList , waiterRecord )
추상 연산 NotifyWaiter. 인수 waiterList (WaiterList 레코드 ) 및 waiterRecord (Waiter 레코드 ). 반환값: unused . 호출되면 다음 단계를 수행한다.
단언 : 주변 에이전트 는 waiterList 의 임계 구역 안에 있습니다.waiterRecord .[[PromiseCapability]] 이 blocking 이면, 다음을 수행합니다.signifier가 waiterRecord .[[AgentSignifier]] 인 에이전트 를 일시 중단에서 깨웁니다. 참고 : 이로 인해 에이전트 는 SuspendThisAgent 에서 실행을 재개합니다.그렇지 않고 AgentSignifier ()가 waiterRecord .[[AgentSignifier]] 이면, 다음을 수행합니다.promiseCapability 을 waiterRecord .[[PromiseCapability]] 로 둡니다.! Call (promiseCapability .[[Resolve]] , undefined , « waiterRecord .[[Result]] »)를 수행합니다. 그렇지 않으면,EnqueueResolveInAgentJob (waiterRecord .[[AgentSignifier]] , waiterRecord .[[PromiseCapability]] , waiterRecord .[[Result]] )을 수행합니다. unused 를 반환합니다.
참고
에이전트 는 다른 에이전트 의 promise capability를 호스트 에 전달하는 것 이외의 어떠한 방식으로도 접근해서는 안 됩니다.
25.4.3.13 EnqueueResolveInAgentJob ( agentSignifier , promiseCapability , resolution )
추상 연산 EnqueueResolveInAgentJob. 인수 agentSignifier (an agent signifier), promiseCapability (PromiseCapability 레코드 ) 및 resolution (("ok" 또는 "timed-out" )). 반환값: unused . 호출되면 다음 단계를 수행한다.
resolveJob 을 매개변수가 없고 agentSignifier , promiseCapability , resolution 을 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Job Abstract Closure 로 둡니다:단언 : AgentSignifier ()는 agentSignifier 입니다.! Call (promiseCapability .[[Resolve]] , undefined , « resolution »)를 수행합니다. unused 를 반환합니다.realmInTargetAgent 를 ! GetFunctionRealm (promiseCapability .[[Resolve]] )로 둡니다.단언 : agentSignifier 는 realmInTargetAgent .[[AgentSignifier]] 입니다.HostEnqueueGenericJob (resolveJob , realmInTargetAgent )을 수행합니다.unused 를 반환합니다.
25.4.3.14 DoWait ( mode , ta , index , value , timeout )
추상 연산 DoWait. 인수 mode ((sync 또는 async )), ta (ECMAScript 언어 값 ), index (ECMAScript 언어 값 ), value (ECMAScript 언어 값 ) 및 timeout (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: (Object, "not-equal" , "timed-out" 또는 "ok" )) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
taRecord 를 ? ValidateIntegerTypedArray (ta , true )로 둡니다.buffer 를 taRecord .[[Object]] .[[ViewedArrayBuffer]] 로 둡니다.IsSharedArrayBuffer (buffer )가 false 이면 TypeError 예외를 던집니다.byteIndexInBuffer 를 ? ValidateAtomicAccess (taRecord , index )로 둡니다.elementType 을 TypedArrayElementType (ta )로 둡니다.단언 : elementType 은 bigint64 또는 int32 입니다.elementType 이 bigint64 이면 expected 를 ? ToBigInt64 (value )로 둡니다. 그렇지 않으면 expected 를 ? ToInt32 (value )로 둡니다.timeoutNumber 를 ? ToNumber (timeout )로 둡니다.timeoutNumber 가 NaN 또는 +∞ 𝔽 이면 realTimeout 을 +∞로 둡니다.그렇지 않고 timeoutNumber 가 -∞ 𝔽 이면 realTimeout 을 0으로 둡니다. 그렇지 않으면 realTimeout 을 max (ℝ (timeoutNumber ), 0)으로 둡니다. mode 가 sync 이고 AgentCanSuspend ()가 false 이면 TypeError 예외를 던집니다.block 을 buffer .[[ArrayBufferData]] 로 둡니다.waiterList 를 GetWaiterList (block , byteIndexInBuffer )로 둡니다.mode 가 sync 이면, 다음을 수행합니다.promiseCapability 을 blocking 으로 둡니다.resultObj 를 undefined 로 둡니다.그렇지 않으면,promiseCapability 을 ! NewPromiseCapability (%Promise% )로 둡니다.resultObj 를 OrdinaryObjectCreate (%Object.prototype% )로 둡니다. EnterCriticalSection (waiterList )을 수행합니다.witness 를 GetValueFromBuffer (buffer , byteIndexInBuffer , elementType , true , seq-cst )로 둡니다.expected ≠ witness 이면, 다음을 수행합니다.LeaveCriticalSection (waiterList )을 수행합니다.mode 가 sync 이면 "not-equal" 을 반환합니다.! CreateDataPropertyOrThrow (resultObj , "async" , false )를 수행합니다. ! CreateDataPropertyOrThrow (resultObj , "value" , "not-equal" )를 수행합니다. resultObj 를 반환합니다.realTimeout = 0이고 mode 가 async 이면, 다음을 수행합니다.참고 : 동기식 즉시 타임아웃에는 특별한 처리가 없습니다. 비동기식 즉시 타임아웃은 빠르게 실패하고 불필요한 Promise job을 피하기 위해 특별히 처리됩니다.LeaveCriticalSection (waiterList )을 수행합니다.! CreateDataPropertyOrThrow (resultObj , "async" , false )를 수행합니다. ! CreateDataPropertyOrThrow (resultObj , "value" , "timed-out" )를 수행합니다. resultObj 를 반환합니다.thisAgent 를 AgentSignifier ()로 둡니다.now 를 현재 시간을 식별하는 시간 값 (UTC)으로 둡니다.additionalTimeout 을 구현체 정의 음이 아닌 수학적 값 으로 둡니다.timeoutTime 을 ℝ (now ) + realTimeout + additionalTimeout 으로 둡니다.참고 : realTimeout 이 +∞이면 timeoutTime 도 +∞입니다.waiterRecord 를 새로운 Waiter Record { [[AgentSignifier]] : thisAgent , [[PromiseCapability]] : promiseCapability , [[TimeoutTime]] : timeoutTime , [[Result]] : "ok" }로 둡니다.AddWaiter (waiterList , waiterRecord )을 수행합니다.mode 가 sync 이면, 다음을 수행합니다.SuspendThisAgent (waiterList , waiterRecord )을 수행합니다.그렇지 않고 timeoutTime 이 유한하면, 다음을 수행합니다.EnqueueAtomicsWaitAsyncTimeoutJob (waiterList , waiterRecord )을 수행합니다. LeaveCriticalSection (waiterList )을 수행합니다.mode 가 sync 이면 waiterRecord .[[Result]] 를 반환합니다.! CreateDataPropertyOrThrow (resultObj , "async" , true )를 수행합니다. ! CreateDataPropertyOrThrow (resultObj , "value" , promiseCapability .[[Promise]] )를 수행합니다. resultObj 를 반환합니다.
참고
additionalTimeout 은 전력 소비를 줄이거나 타이밍 공격을 완화하기 위해 타이머 해상도를 낮추는 등 필요한 경우 구현체가 타임아웃을 늘릴 수 있게 합니다. 이 값은 DoWait 호출마다 달라질 수 있습니다.
25.4.3.15 EnqueueAtomicsWaitAsyncTimeoutJob ( waiterList , waiterRecord )
추상 연산 EnqueueAtomicsWaitAsyncTimeoutJob. 인수 waiterList (WaiterList 레코드 ) 및 waiterRecord (Waiter 레코드 ). 반환값: unused . 호출되면 다음 단계를 수행한다.
timeoutJob 을 매개변수가 없고 waiterList 와 waiterRecord 를 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Job Abstract Closure 로 둡니다:EnterCriticalSection (waiterList )을 수행합니다.waiterList .[[Waiters]] 에 waiterRecord 가 포함되어 있으면, 다음을 수행합니다.timeOfJobExecution 을 현재 시간을 식별하는 시간 값 (UTC)으로 둡니다.단언 : ℝ (timeOfJobExecution ) ≥ waiterRecord .[[TimeoutTime]] 입니다(시간 값 의 잠재적인 비단조성은 무시합니다).waiterRecord .[[Result]] 를 "timed-out" 으로 설정합니다.RemoveWaiter (waiterList , waiterRecord )을 수행합니다.NotifyWaiter (waiterList , waiterRecord )을 수행합니다.LeaveCriticalSection (waiterList )을 수행합니다.unused 를 반환합니다.now 를 현재 시간을 식별하는 시간 값 (UTC)으로 둡니다.currentRealm 을 현재 Realm Record 로 둡니다.HostEnqueueTimeoutJob (timeoutJob , currentRealm , 𝔽 (waiterRecord .[[TimeoutTime]] ) - now )을 수행합니다.unused 를 반환합니다.
25.4.3.16 AtomicCompareExchangeInSharedBlock ( block , byteIndexInBuffer , elementSize , expectedBytes , replacementBytes )
추상 연산 AtomicCompareExchangeInSharedBlock. 인수 block (공유 데이터 블록 ), byteIndexInBuffer (정수 ), elementSize (음이 아닌 정수), expectedBytes (리스트 (요소: 바이트 값 )) 및 replacementBytes (리스트 (요소: 바이트 값 )). 반환값: 리스트 (요소: 바이트 값 ). 호출되면 다음 단계를 수행한다.
agentRecord 를 주변 에이전트 의 Agent Record 로 둡니다.execution 을 agentRecord .[[CandidateExecution]] 으로 둡니다.eventsRecord 를 [[AgentSignifier]] 가 AgentSignifier ()인 execution .[[EventsRecords]] 의 Agent Events Record 로 둡니다.rawBytesRead 를 요소가 비결정적으로 선택된 바이트 값 인 길이 elementSize 의 List 로 둡니다.참고 : 구현체에서 rawBytesRead 는 기반 하드웨어의 load-link, load-exclusive 또는 read-modify-write 명령의 피연산자 결과입니다. 비결정성은 약한 일관성을 갖는 하드웨어의 관찰 가능한 동작을 설명하기 위한 메모리 모델 의 의미론적 규정입니다.참고 : 기대 값과 읽은 값의 비교는 기대 값이 읽은 값과 같지 않을 때 불필요하게 강한 동기화를 피하기 위해 read-modify-write 수정 함수 밖에서 수행됩니다.ByteListEqual (rawBytesRead , expectedBytes )이 true 이면, 다음을 수행합니다.second 를 아무것도 캡처하지 않고 매개변수 (oldBytes , newBytes )를 가지며 호출될 때 다음 단계를 원자적으로 수행하는 새로운 read-modify-write 수정 함수 로 둡니다:newBytes 를 반환합니다.event 를 ReadModifyWriteSharedMemory { [[Order]] : seq-cst , [[NoTear]] : true , [[Block]] : block , [[ByteIndex]] : byteIndexInBuffer , [[ElementSize]] : elementSize , [[Payload]] : replacementBytes , [[ModifyOp]] : second }로 둡니다.그렇지 않으면,event 를 ReadSharedMemory { [[Order]] : seq-cst , [[NoTear]] : true , [[Block]] : block , [[ByteIndex]] : byteIndexInBuffer , [[ElementSize]] : elementSize }로 둡니다. event 를 eventsRecord .[[EventList]] 에 추가합니다.Chosen Value Record { [[Event]] : event , [[ChosenValue]] : rawBytesRead }를 execution .[[ChosenValues]] 에 추가합니다.rawBytesRead 를 반환합니다.
25.4.3.17 AtomicReadModifyWrite ( ta , index , value , op )
추상 연산 AtomicReadModifyWrite. 인수 ta (ECMAScript 언어 값 ), index (ECMAScript 언어 값 ), value (ECMAScript 언어 값 ) 및 op (a read-modify-write modification function). 반환값: (정상 완료 (값: (Number 또는 BigInt)) 또는 throw 완료 ). op 는 바이트 값 의 두 List 인수를 받고 바이트 값 의 List 를 반환합니다. 이 연산은 값을 원자적으로 로드하고 다른 값과 결합한 다음 결합 결과를 저장합니다. 로드한 값을 반환합니다. 호출되면 다음 단계를 수행한다.
byteIndexInBuffer 를 ? ValidateAtomicAccessOnIntegerTypedArray (ta , index )로 둡니다.ta .[[ContentType]] 이 bigint 이면 coerced 를 ? ToBigInt (value )로 둡니다.그렇지 않으면 coerced 를 𝔽 (? ToIntegerOrInfinity (value ))로 둡니다. ? RevalidateAtomicAccess (ta , byteIndexInBuffer )를 수행합니다. buffer 를 ta .[[ViewedArrayBuffer]] 로 둡니다.elementType 을 TypedArrayElementType (ta )로 둡니다.GetModifySetValueInBuffer (buffer , byteIndexInBuffer , elementType , coerced , op )를 반환합니다.
25.4.3.18 ByteListBitwiseOp ( op , xBytes , yBytes )
추상 연산 ByteListBitwiseOp. 인수 op ((&, ^ 또는 |)), xBytes (리스트 (요소: 바이트 값 )) 및 yBytes (리스트 (요소: 바이트 값 )). 반환값: 리스트 (요소: 바이트 값 ). 이 연산은 인수의 모든 바이트 값 에 대해 비트 연산을 원자적으로 수행하고 바이트 값 의 List 를 반환합니다. 호출되면 다음 단계를 수행한다.
단언 : xBytes 와 yBytes 의 요소 수는 같습니다.result 를 새로운 빈 List 로 둡니다.i 를 0으로 둡니다.xBytes 의 각 요소 xByte 에 대해 다음을 수행합니다.yByte 를 yBytes [i ]로 둡니다.op 가 &이면,resultByte 를 xByte 와 yByte 에 비트 단위 AND 연산을 적용한 결과로 둡니다.그렇지 않고 op 가 ^이면,resultByte 를 xByte 와 yByte 에 비트 단위 XOR(배타적 OR) 연산을 적용한 결과로 둡니다. 그렇지 않으면,단언 : op 는 |입니다.resultByte 를 xByte 와 yByte 에 비트 단위 OR(포괄적 OR) 연산을 적용한 결과로 둡니다. i 를 i + 1로 설정합니다.result 에 resultByte 를 추가합니다.result 를 반환합니다.
25.4.3.19 ByteListEqual ( xBytes , yBytes )
추상 연산 ByteListEqual. 인수 xBytes (리스트 (요소: 바이트 값 )) 및 yBytes (리스트 (요소: 바이트 값 )). 반환값: Boolean. 호출되면 다음 단계를 수행한다.
xBytes 와 yBytes 의 요소 수가 같지 않으면 false 를 반환합니다.i 를 0으로 둡니다.xBytes 의 각 요소 xByte 에 대해 다음을 수행합니다.yByte 를 yBytes [i ]로 둡니다.xByte ≠ yByte 이면 false 를 반환합니다.i 를 i + 1로 설정합니다.true 를 반환합니다.
25.4.4 Atomics.add ( ta , index , value )
이 함수는 호출되면 다음 단계를 수행합니다:
add 를 ta 를 캡처하고 매개변수 (xBytes , yBytes )를 가지며 호출될 때 다음 단계를 원자적으로 수행하는 새로운 read-modify-write 수정 함수 로 둡니다:type 을 TypedArrayElementType (ta )로 둡니다.agentRecord 를 주변 에이전트 의 Agent Record 로 둡니다.isLittleEndian 을 agentRecord .[[LittleEndian]] 으로 둡니다.x 를 RawBytesToNumeric (type , xBytes , isLittleEndian )으로 둡니다.y 를 RawBytesToNumeric (type , yBytes , isLittleEndian )으로 둡니다.x 가 Number이면, 다음을 수행합니다.sum 을 Number::add (x , y )로 둡니다.그렇지 않으면,단언 : x 는 BigInt입니다.sum 을 BigInt::add (x , y )로 둡니다. sumBytes 를 NumericToRawBytes (type , sum , isLittleEndian )로 둡니다.단언 : sumBytes , xBytes , yBytes 의 요소 수는 같습니다.sumBytes 를 반환합니다.? AtomicReadModifyWrite (ta , index , value , add )를 반환합니다.
25.4.5 Atomics.and ( ta , index , value )
이 함수는 호출되면 다음 단계를 수행합니다:
and 를 아무것도 캡처하지 않고 매개변수 (xBytes , yBytes )를 가지며 호출될 때 다음 단계를 원자적으로 수행하는 새로운 read-modify-write 수정 함수 로 둡니다:ByteListBitwiseOp (&, xBytes , yBytes )를 반환합니다.? AtomicReadModifyWrite (ta , index , value , and )를 반환합니다.
25.4.6 Atomics.compareExchange ( ta , index , expectedValue , replacementValue )
이 함수는 호출되면 다음 단계를 수행합니다:
byteIndexInBuffer 를 ? ValidateAtomicAccessOnIntegerTypedArray (ta , index )로 둡니다.buffer 를 ta .[[ViewedArrayBuffer]] 로 둡니다.block 을 buffer .[[ArrayBufferData]] 로 둡니다.ta .[[ContentType]] 이 bigint 이면, 다음을 수행합니다.expected 를 ? ToBigInt (expectedValue )로 둡니다.replacement 를 ? ToBigInt (replacementValue )로 둡니다.그렇지 않으면,expected 를 𝔽 (? ToIntegerOrInfinity (expectedValue ))로 둡니다.replacement 를 𝔽 (? ToIntegerOrInfinity (replacementValue ))로 둡니다. ? RevalidateAtomicAccess (ta , byteIndexInBuffer )를 수행합니다. elementType 을 TypedArrayElementType (ta )로 둡니다.elementSize 를 TypedArrayElementSize (ta )로 둡니다.agentRecord 를 주변 에이전트 의 Agent Record 로 둡니다.isLittleEndian 을 agentRecord .[[LittleEndian]] 으로 둡니다.expectedBytes 를 NumericToRawBytes (elementType , expected , isLittleEndian )로 둡니다.replacementBytes 를 NumericToRawBytes (elementType , replacement , isLittleEndian )로 둡니다.IsSharedArrayBuffer (buffer )가 true 이면, 다음을 수행합니다.rawBytesRead 를 AtomicCompareExchangeInSharedBlock (block , byteIndexInBuffer , elementSize , expectedBytes , replacementBytes )로 둡니다.그렇지 않으면,rawBytesRead 를 block [byteIndexInBuffer ]부터 시작하는 elementSize 개의 바이트 시퀀스를 요소로 갖는 길이 elementSize 의 List 로 둡니다.ByteListEqual (rawBytesRead , expectedBytes )이 true 이면, 다음을 수행합니다.replacementBytes 의 개별 바이트를 block [byteIndexInBuffer ]에서 시작하여 block 에 저장합니다. RawBytesToNumeric (elementType , rawBytesRead , isLittleEndian )을 반환합니다.
25.4.7 Atomics.exchange ( ta , index , value )
이 함수는 호출되면 다음 단계를 수행합니다:
second 를 아무것도 캡처하지 않고 매개변수 (oldBytes , newBytes )를 가지며 호출될 때 다음 단계를 원자적으로 수행하는 새로운 read-modify-write 수정 함수 로 둡니다:newBytes 를 반환합니다.? AtomicReadModifyWrite (ta , index , value , second )를 반환합니다.
25.4.8 Atomics.isLockFree ( size )
이 함수는 호출되면 다음 단계를 수행합니다:
n 을 ? ToIntegerOrInfinity (size )로 둡니다.agentRecord 를 주변 에이전트 의 Agent Record 로 둡니다.n = 1이면 agentRecord .[[IsLockFree1]] 을 반환합니다.n = 2이면 agentRecord .[[IsLockFree2]] 를 반환합니다.n = 4이면 true 를 반환합니다.n = 8이면 agentRecord .[[IsLockFree8]] 을 반환합니다.false 를 반환합니다.
참고
이 함수는 최적화 프리미티브입니다. 직관적으로 크기 n 바이트인 데이터에 대한 원자적 프리미티브(compareExchange, load, store, add, sub, and, or, xor, exchange)의 원자적 단계가 데이터를 구성하는 n 바이트 밖에서 주변 에이전트 가 락을 획득하지 않고 수행된다면 Atomics.isLockFree(n )은 true 를 반환합니다. 고성능 알고리즘은 이 함수를 사용하여 임계 구역 에서 락을 사용할지 원자적 연산을 사용할지 결정합니다. 원자적 프리미티브가 lock-free가 아니면 알고리즘이 자체 락을 제공하는 것이 더 효율적인 경우가 많습니다.
Atomics.isLockFree(4)는 알려진 모든 관련 하드웨어에서 지원할 수 있으므로 항상 true 를 반환합니다. 이를 가정할 수 있으면 일반적으로 프로그램을 단순화할 수 있습니다.
이 함수가 반환하는 값과 관계없이 모든 원자적 연산은 원자성이 보장됩니다. 예를 들어 연산 중간에 관찰 가능한 동작이 발생하는 일(예: “tearing”)은 절대 없습니다.
25.4.9 Atomics.load ( ta , index )
이 함수는 호출되면 다음 단계를 수행합니다:
byteIndexInBuffer 를 ? ValidateAtomicAccessOnIntegerTypedArray (ta , index )로 둡니다.? RevalidateAtomicAccess (ta , byteIndexInBuffer )를 수행합니다. buffer 를 ta .[[ViewedArrayBuffer]] 로 둡니다.elementType 을 TypedArrayElementType (ta )로 둡니다.GetValueFromBuffer (buffer , byteIndexInBuffer , elementType , true , seq-cst )를 반환합니다.
25.4.10 Atomics.notify ( ta , index , count )
이 함수는 대기 큐에서 잠들어 있는 일부 에이전트 에 알립니다.
호출되면 다음 단계를 수행합니다:
taRecord 를 ? ValidateIntegerTypedArray (ta , true )로 설정합니다.byteIndexInBuffer 를 ? ValidateAtomicAccess (taRecord , index )로 설정합니다.count 가 undefined 이면,count 를 +∞로 설정합니다.그렇지 않으면,intCount 를 ? ToIntegerOrInfinity (count )로 설정합니다.count 를 max (intCount , 0)으로 설정합니다. buffer 를 ta .[[ViewedArrayBuffer]] 로 설정합니다.IsSharedArrayBuffer (buffer )가 false 이면, +0 𝔽 를 반환합니다.block 을 buffer .[[ArrayBufferData]] 로 설정합니다.waiterList 를 GetWaiterList (block , byteIndexInBuffer )로 설정합니다.EnterCriticalSection (waiterList )을 수행합니다.waiters 를 RemoveWaiters (waiterList , count )로 설정합니다.waiters 의 각 요소 waiterRecord 에 대해 다음을 수행합니다.NotifyWaiter (waiterList , waiterRecord )를 수행합니다.LeaveCriticalSection (waiterList )를 수행합니다.waitersCount 를 waiters 의 요소 수로 설정합니다.𝔽 (waitersCount )를 반환합니다.
25.4.11 Atomics.or ( ta , index , value )
이 함수는 호출되면 다음 단계를 수행합니다:
or 를 아무것도 캡처하지 않고 매개변수 (xBytes , yBytes )를 가지며 호출될 때 다음 단계를 원자적으로 수행하는 새로운 read-modify-write 수정 함수 로 둡니다:ByteListBitwiseOp (|, xBytes , yBytes )를 반환합니다.? AtomicReadModifyWrite (ta , index , value , or )를 반환합니다.
25.4.12 Atomics.pause ( )
이 함수는 프로그램이 값을 기다리며 스핀 루프 중이라는 힌트를 CPU에 제공합니다.
호출되면 다음 단계를 수행합니다:
ECMAScript 구현체의 실행 환경이 현재 실행 중인 코드가 스핀 대기 루프에 있다는 사실을 운영 체제나 CPU에 알리는 것을 지원하면 해당 신호를 보냅니다. undefined 를 반환합니다.
참고 1
이 메서드는 mutex 내부의 spinlock 빠른 경로와 같은 스핀 대기 루프를 구현하는 프로그램이 값을 기다리며 스핀 중이라는 힌트를 CPU에 제공하도록 설계되었습니다. 타이밍 외에는 관찰 가능한 동작이 없습니다.
기반 아키텍처의 모범 사례가 스핀 루프에서 pause 또는 yield 명령을 권장하는 경우 구현체가 그러한 명령을 구현할 것으로 예상됩니다. 예를 들어 Intel Optimization Manual 에서는 pause 명령을 권장합니다.
구현체는 일시 중단되는 최대 시간에 대해 수십~수백 나노초 정도의 내부 상한을 두는 것이 권장됩니다.
참고 2
함수 호출의 오버헤드 때문에 최적화 컴파일러에서 이 메서드에 대한 인라인 호출이 인라인되지 않은 호출과 다른 시간 동안 기다리는 것은 합리적입니다.
25.4.13 Atomics.store ( ta , index , value )
이 함수는 호출되면 다음 단계를 수행합니다:
byteIndexInBuffer 를 ? ValidateAtomicAccessOnIntegerTypedArray (ta , index )로 둡니다.ta .[[ContentType]] 이 bigint 이면 coerced 를 ? ToBigInt (value )로 둡니다.그렇지 않으면 coerced 를 𝔽 (? ToIntegerOrInfinity (value ))로 둡니다. ? RevalidateAtomicAccess (ta , byteIndexInBuffer )를 수행합니다. buffer 를 ta .[[ViewedArrayBuffer]] 로 둡니다.elementType 을 TypedArrayElementType (ta )로 둡니다.SetValueInBuffer (buffer , byteIndexInBuffer , elementType , coerced , true , seq-cst )를 수행합니다.coerced 를 반환합니다.
25.4.14 Atomics.sub ( ta , index , value )
이 함수는 호출되면 다음 단계를 수행합니다:
subtract 를 ta 를 캡처하고 매개변수 (xBytes , yBytes )를 가지며 호출될 때 다음 단계를 원자적으로 수행하는 새로운 read-modify-write 수정 함수 로 둡니다:type 을 TypedArrayElementType (ta )로 둡니다.agentRecord 를 주변 에이전트 의 Agent Record 로 둡니다.isLittleEndian 을 agentRecord .[[LittleEndian]] 으로 둡니다.x 를 RawBytesToNumeric (type , xBytes , isLittleEndian )으로 둡니다.y 를 RawBytesToNumeric (type , yBytes , isLittleEndian )으로 둡니다.x 가 Number이면, 다음을 수행합니다.difference 를 Number::subtract (x , y )로 둡니다.그렇지 않으면,단언 : x 는 BigInt입니다.difference 를 BigInt::subtract (x , y )로 둡니다. differenceBytes 를 NumericToRawBytes (type , difference , isLittleEndian )로 둡니다.단언 : differenceBytes , xBytes , yBytes 의 요소 수는 같습니다.differenceBytes 를 반환합니다.? AtomicReadModifyWrite (ta , index , value , subtract )를 반환합니다.
25.4.15 Atomics.wait ( ta , index , value , timeout )
이 함수는 주변 에이전트 를 대기 큐에 넣고 알림을 받거나 대기 시간이 초과될 때까지 일시 중단한 다음, 이러한 경우를 구별하는 String을 반환합니다.
호출되면 다음 단계를 수행합니다:
? DoWait (sync , ta , index , value , timeout )를 반환합니다.
25.4.16 Atomics.waitAsync ( ta , index , value , timeout )
이 함수는 호출 에이전트 가 알림을 받거나 타임아웃에 도달하면 이행되는 Promise를 반환합니다.
호출되면 다음 단계를 수행합니다:
? DoWait (async , ta , index , value , timeout )를 반환합니다.
25.4.17 Atomics.xor ( ta , index , value )
이 함수는 호출되면 다음 단계를 수행합니다:
xor 를 아무것도 캡처하지 않고 매개변수 (xBytes , yBytes )를 가지며 호출될 때 다음 단계를 원자적으로 수행하는 새로운 read-modify-write 수정 함수 로 둡니다:ByteListBitwiseOp (^, xBytes , yBytes )를 반환합니다.? AtomicReadModifyWrite (ta , index , value , xor )를 반환합니다.
25.4.18 Atomics [ %Symbol.toStringTag% ]
%Symbol.toStringTag% 프로퍼티의 초기 값은 String 값 "Atomics" 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
25.5 JSON 객체
JSON 객체는:
%JSON% 입니다.
전역 객체 의 "JSON" 프로퍼티의 초기 값입니다.
일반 객체 입니다.
JSON 텍스트를 파싱하고 구성하는 데 사용하는 두 함수 parse와 stringify를 포함합니다.
값이 %Object.prototype% 인 [[Prototype]] 내부 슬롯을 갖습니다.
[[Construct]] 내부 메서드를 갖지 않으므로 new 연산자와 함께 생성자 로 사용할 수 없습니다.
[[Call]] 내부 메서드를 갖지 않으므로 함수로 호출할 수 없습니다.
JSON 데이터 교환 형식은 ECMA-404에 정의되어 있습니다. 이 명세에서 사용하는 JSON 교환 형식은 ECMA-404에 설명된 것과 정확히 같습니다. JSON.parse 및 JSON.stringify의 적합한 구현체는 형식에서 삭제하거나 확장하지 않고 ECMA-404에 설명된 정확한 교환 형식을 지원해야 합니다.
25.5.1 JSON.isRawJSON ( obj )
이 함수는 호출되면 다음 단계를 수행합니다:
obj 가 Object이고 obj 에 [[IsRawJSON]] 내부 슬롯이 있으면 true 를 반환합니다.false 를 반환합니다.
25.5.2 JSON.parse ( text [ , reviver ] )
이 함수는 JSON 텍스트(JSON 형식의 String)를 파싱하고 ECMAScript language value를 생성합니다. JSON 형식은 ECMAScript 리터럴, Array Initializer, Object Initializer의 구문과 유사한 구문으로 리터럴, 배열, 객체를 나타냅니다. 파싱 후 JSON 객체는 ECMAScript 객체로 실체화됩니다. JSON 배열은 ECMAScript Array 인스턴스로 실체화됩니다. JSON 문자열, 숫자, 불리언, null은 ECMAScript String, Number, Boolean, null 로 실체화됩니다.
선택적 reviver 매개변수는 결과를 필터링하고 변환할 수 있는 함수입니다. 파싱으로 생성된 각 값에 대해 reviver 는 세 인수(연결된 프로퍼티 키 , 값, 컨텍스트 객체)로 호출됩니다. 프로퍼티가 수정되지 않았고 값이 프리미티브이면 제공된 컨텍스트 객체에는 대응하는 Parse Node의 소스 텍스트를 포함하는 "source" 프로퍼티가 있습니다. 호출이 undefined 를 반환하면 프로퍼티를 삭제합니다. 그렇지 않으면 반환 값을 사용하도록 프로퍼티를 다시 정의합니다.
jsonString 을 ? ToString (text )로 둡니다.parseResult 를 ? ParseJSON (jsonString )으로 둡니다.unfiltered 를 parseResult .[[Value]] 로 둡니다.IsCallable (reviver )가 false 이면 unfiltered 를 반환합니다.root 를 OrdinaryObjectCreate (%Object.prototype% )로 둡니다.rootName 을 빈 String으로 둡니다.! CreateDataPropertyOrThrow (root , rootName , unfiltered )를 수행합니다. snapshot 을 CreateJSONParseRecord (parseResult .[[ParseNode]] , rootName , unfiltered )로 둡니다.? InternalizeJSONProperty (root , rootName , reviver , snapshot )을 반환합니다.
이 함수의 "length" 프로퍼티는 2 𝔽 입니다.
25.5.2.1 ParseJSON ( text )
추상 연산 ParseJSON. 인수 text (String). 반환값: (정상 완료 (값: 레코드 (필드: [[ParseNode]] (구문 분석 노드), [[Value]] (ECMAScript 언어 값 ))) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
StringToCodePoints (text )가 ECMA-404에 지정된 유효한 JSON 텍스트가 아니면 SyntaxError 예외를 던집니다.scriptString 을 "(" , text , ");" 의 문자열 연결 로 둡니다.script 를 ParseText (scriptString , Script )로 둡니다.참고 : 13.2.5.1 에 정의된 early error 규칙은 위 ParseText 호출에 대해 특별하게 처리됩니다.단언 : script 는 Parse Node입니다.result 를 ! Evaluation of script 로 둡니다.참고 : 13.2.5.6 에 정의된 PropertyDefinitionEvaluation 의미론은 위 평가에 대해 특별하게 처리됩니다.단언 : result 는 String, Number, Boolean, ArrayLiteral 또는 ObjectLiteral 중 하나에 의해 정의된 Object, 또는 null 입니다.Record { [[ParseNode]] : script , [[Value]] : result }를 반환합니다.
적합한 JSON.parse 구현체가 JSON 문법을 확장하는 것은 허용되지 않습니다. 구현체가 수정되거나 확장된 JSON 교환 형식을 지원하려면 다른 parse 함수를 정의하여 수행해야 합니다.
참고 1
유효한 JSON 텍스트는 ECMAScript PrimaryExpression 구문의 부분집합입니다. 1 단계는 jsonString 이 해당 부분집합을 준수하는지 검증하고, 8 단계는 평가가 적절한 타입의 값을 반환하는지 단언 합니다.
그러나 13.2.5.6 이 ParseJSON 중에는 다르게 동작하므로 동일한 소스 텍스트를 JSON이 아니라 PrimaryExpression 으로 평가하면 다른 결과가 생성될 수 있습니다. 또한 객체 리터럴의 중복 "__proto__" 프로퍼티에 대한 Early Error 역시 ParseJSON 중에는 적용되지 않으므로, 문법과 일치하더라도 ParseJSON이 허용하는 모든 텍스트가 PrimaryExpression 으로 유효한 것은 아닙니다.
참고 2
객체 안에 중복된 이름의 String이 있는 경우 어휘적으로 앞선 동일 키의 값은 덮어써야 합니다.
25.5.2.2 JSON Parse Record
JSON Parse Record 는 JSON 텍스트에서 파싱된 값의 초기 상태를 설명하는 데 사용되는 Record 입니다.
JSON Parse Records에는 표 76 에 나열된 필드가 있습니다.
표 76: JSON Parse Record 필드
25.5.2.3 CreateJSONParseRecord ( parseNode , key , value )
추상 연산 CreateJSONParseRecord. 인수 parseNode (구문 분석 노드), key (프로퍼티 이름 ) 및 value (ECMAScript 언어 값 ). 반환값: JSON Parse 레코드 . JSON 텍스트에서 파싱한 parseNode 와 그 평가로 생성된 value 를 재귀적으로 결합합니다. 호출되면 다음 단계를 수행한다.
typedValueNode 를 ShallowestContainedJSONValue (parseNode )로 둡니다.단언 : typedValueNode 는 empty 가 아닙니다.elements 를 새로운 빈 List 로 둡니다.entries 를 새로운 빈 List 로 둡니다.value 가 Object이면, 다음을 수행합니다.isArray 를 ! IsArray (value )로 둡니다.isArray 가 true 이면, 다음을 수행합니다.단언 : typedValueNode 는 ArrayLiteral Parse Node입니다.contentNodes 를 typedValueNode 의 JSONArrayLiteralContentNodes 로 둡니다.length 를 contentNodes 의 요소 수로 둡니다.valueLength 를 ! LengthOfArrayLike (value )로 둡니다.단언 : valueLength 는 length 입니다.index 를 0으로 둡니다.index < length 인 동안 다음을 반복합니다.propertyName 을 ! ToString (𝔽 (index ))로 둡니다.elementParseRecord 를 CreateJSONParseRecord (contentNodes [index ], propertyName , ! Get (value , propertyName ))로 둡니다.elementParseRecord 를 elements 에 추가합니다.index 를 index + 1로 설정합니다.그렇지 않으면,단언 : typedValueNode 는 ObjectLiteral Parse Node입니다.propertyNodes 를 typedValueNode 의 PropertyDefinitionNodes 로 둡니다.참고 : value 는 JSON 텍스트에서 생성되었고 수정되지 않았으므로 모든 프로퍼티 키 는 String이며 빠짐없이 열거됩니다.keys 를 ! EnumerableOwnProperties (value , key )로 둡니다.keys 의 각 String propertyKey 에 대해 다음을 수행합니다.참고 : JSON 텍스트가 단일 객체에 같은 이름을 갖는 여러 이름/값 쌍을 지정하는 경우(예: {"a":"lost","a":"kept"}) 결과 ECMAScript 객체의 대응하는 프로퍼티 값은 해당 이름을 갖는 마지막 쌍으로 지정됩니다.propertyDefinition 을 empty 로 둡니다.propertyNodes 의 각 Parse Node propertyNode 에 대해 다음을 수행합니다.propertyName 을 propertyNode 의 PropName 으로 둡니다.propertyName 이 propertyKey 이면 propertyDefinition 을 propertyNode 로 설정합니다.단언 : propertyDefinition 은
PropertyDefinition :
PropertyName
:
AssignmentExpression
입니다.propertyValueNode 를 propertyDefinition 의 AssignmentExpression 로 둡니다.entryParseRecord 를 CreateJSONParseRecord (propertyValueNode , propertyKey , ! Get (value , propertyKey ))로 둡니다.entryParseRecord 를 entries 에 추가합니다. 그렇지 않으면,단언 : typedValueNode 는 ArrayLiteral Parse Node도 ObjectLiteral Parse Node도 아닙니다. JSON Parse Record { [[ParseNode]] : typedValueNode , [[Key]] : key , [[Value]] : value , [[Elements]] : elements , [[Entries]] : entries }를 반환합니다.
25.5.2.4 InternalizeJSONProperty ( holder , name , reviver , parseRecord )
추상 연산 InternalizeJSONProperty. 인수 holder (Object), name (String), reviver (함수 객체 ) 및 parseRecord ((JSON Parse 레코드 또는 empty )). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 throw 완료 ).
참고
이 알고리즘은 [[Delete]] 또는 CreateDataProperty 가 false 를 반환하더라도 의도적으로 예외를 던지지 않습니다.
호출되면 다음 단계를 수행합니다:
value 를 ? Get (holder , name )로 둡니다.context 를 OrdinaryObjectCreate (%Object.prototype% )로 둡니다.parseRecord 가 JSON Parse Record 이고 SameValue (parseRecord .[[Value]] , value )가 true 이면, 다음을 수행합니다.value 가 Object가 아니면, 다음을 수행합니다.parseNode 를 parseRecord .[[ParseNode]] 로 둡니다.단언 : parseNode 는 ArrayLiteral Parse Node도 ObjectLiteral Parse Node도 아닙니다.sourceText 를 parseNode 가 일치한 소스 텍스트로 둡니다.! CreateDataPropertyOrThrow (context , "source" , CodePointsToString (sourceText ))를 수행합니다. elementRecords 를 parseRecord .[[Elements]] 로 둡니다.entryRecords 를 parseRecord .[[Entries]] 로 둡니다.그렇지 않으면,elementRecords 를 새로운 빈 List 로 둡니다.entryRecords 를 새로운 빈 List 로 둡니다. value 가 Object이면, 다음을 수행합니다.isArray 를 ? IsArray (value )로 둡니다.isArray 가 true 이면, 다음을 수행합니다.elementRecordsLength 를 elementRecords 의 요소 수로 둡니다.length 를 ? LengthOfArrayLike (value )로 둡니다.index 를 0으로 둡니다.index < length 인 동안 다음을 반복합니다.propertyKey 를 ! ToString (𝔽 (index ))로 둡니다.index < elementRecordsLength 이면 elementRecord 를 elementRecords [index ]로 둡니다. 그렇지 않으면 elementRecord 를 empty 로 둡니다.newElement 를 ? InternalizeJSONProperty (value , propertyKey , reviver , elementRecord )로 둡니다.newElement 가 undefined 이면, 다음을 수행합니다.? value .[[Delete]] (propertyKey ) 를 수행합니다. 그렇지 않으면,? CreateDataProperty (value , propertyKey , newElement )를 수행합니다. index 를 index + 1로 설정합니다.그렇지 않으면,keys 를 ? EnumerableOwnProperties (value , key )로 둡니다.keys 의 각 String propertyKey 에 대해 다음을 수행합니다.entryRecords 에 [[Key]] 가 propertyKey 인 요소 entry 가 존재하면 entryRecord 를 entry 로 둡니다. 그렇지 않으면 entryRecord 를 empty 로 둡니다.newElement 를 ? InternalizeJSONProperty (value , propertyKey , reviver , entryRecord )로 둡니다.newElement 가 undefined 이면, 다음을 수행합니다.? value .[[Delete]] (propertyKey ) 를 수행합니다. 그렇지 않으면,? CreateDataProperty (value , propertyKey , newElement )를 수행합니다. ? Call (reviver , holder , « name , value , context »)를 반환합니다.
25.5.2.5 Static Semantics: ShallowestContainedJSONValue ( root )
추상 연산 ShallowestContainedJSONValue. 인수 root (구문 분석 노드). 반환값: (구문 분석 노드 또는 empty ). root 를 루트로 하는 파스 트리에 대해 너비 우선 탐색을 수행하고 JSON 값에 대응하는 비단말의 인스턴스인 첫 번째 노드를 반환하며, 그러한 노드가 없으면 empty 를 반환합니다. 호출되면 다음 단계를 수행한다.
activeFunc 를 활성 함수 객체 로 둡니다.단언 : activeFunc 는 JSON.parse 내장 함수 객체 입니다(JSON.parse 참조).types 를 « NullLiteral , BooleanLiteral , NumericLiteral , StringLiteral , ArrayLiteral , ObjectLiteral , UnaryExpression »로 둡니다.unaryExpr 를 empty 로 둡니다.queue 를 « root »로 둡니다.queue 가 비어 있지 않은 동안 다음을 반복합니다.candidate 를 queue 의 첫 번째 요소로 둡니다.queue 에서 첫 번째 요소를 제거합니다.queuedChildren 을 false 로 둡니다.types 의 각 비단말 type 에 대해 다음을 수행합니다.candidate 가 type 의 인스턴스이면, 다음을 수행합니다.참고 : JSON 문법에서 number 토큰은 음수 값을 나타낼 수 있습니다. ECMAScript에서 부정은 UnaryExpression 이 - 뒤에 파생된 UnaryExpression 이 오는 형태로 파싱되는 단항 연산으로 표현됩니다.type 이 UnaryExpression 이면, 다음을 수행합니다.candidate 의 부모가 UnaryExpression Parse Node가 아니면 unaryExpr 를 candidate 로 설정합니다.그렇지 않고 type 이 NumericLiteral 이면, 다음을 수행합니다.단언 : candidate 는 unaryExpr 안에 포함되어 있습니다.unaryExpr 를 반환합니다. 그렇지 않으면,candidate 를 반환합니다. queuedChildren 이 false 이고 candidate 가 비단말의 인스턴스이며 candidate Contains type 이 true 이면, 다음을 수행합니다.children 을 candidate 의 각 자식 노드를 순서대로 포함하는 List 로 둡니다.queue 를 queue 와 children 의 목록 연결 로 설정합니다.queuedChildren 을 true 로 설정합니다.empty 를 반환합니다.
25.5.2.6 Static Semantics: JSONArrayLiteralContentNodes
구문 지향 연산 JSONArrayLiteralContentNodes. 인수 없음. 반환값: 리스트 (요소: 구문 분석 노드 ). 다음 생성 규칙별로 정의된다.
ArrayLiteral :
[
Elision opt
]
[
ElementList
]
[
ElementList
,
Elision opt
]
단언 : Elision 은 존재하지 않습니다.ElementList 가 존재하지 않으면 새로운 빈 List 를 반환합니다.ElementList 의 JSONArrayLiteralContentNodes 를 반환합니다.
ElementList :
Elision opt
AssignmentExpression
단언 : Elision 은 존재하지 않습니다.« AssignmentExpression »을 반환합니다.
ElementList :
ElementList
,
Elision opt
AssignmentExpression
단언 : Elision 은 존재하지 않습니다.elements 를 파생된 ElementList 의 JSONArrayLiteralContentNodes 로 둡니다.elements 와 « AssignmentExpression »의 목록 연결 을 반환합니다.
ElementList :
Elision opt
SpreadElement
ElementList
,
Elision opt
SpreadElement
참고 : ECMA-404에 지정된 JSON 텍스트에는 SpreadElement 가 포함되지 않습니다.단언 : 이 단계에는 절대 도달하지 않습니다.
25.5.3 JSON.rawJSON ( text )
이 함수는 문자열, 숫자, 불리언 또는 null 값의 원시 JSON 텍스트를 나타내는 객체를 반환합니다.
jsonString 을 ? ToString (text )로 둡니다.jsonString 이 빈 String이면 SyntaxError 예외를 던집니다.jsonString 의 첫 번째 코드 단위가 ASCII 소문자 코드 단위(0x0061부터 0x007A까지 포함), ASCII 숫자 코드 단위(0x0030부터 0x0039까지 포함), 0x0022 (QUOTATION MARK), 0x002D (HYPHEN-MINUS) 중 하나가 아니면 SyntaxError 예외를 던집니다.jsonString 의 마지막 코드 단위가 ASCII 소문자 코드 단위(0x0061부터 0x007A까지 포함), ASCII 숫자 코드 단위(0x0030부터 0x0039까지 포함), 0x0022 (QUOTATION MARK) 중 하나가 아니면 SyntaxError 예외를 던집니다.parseResult 를 ? ParseJSON (jsonString )으로 둡니다.단언 : parseResult .[[Value]] 는 String, Number, Boolean 또는 null 입니다.internalSlotsList 를 « [[IsRawJSON]] »로 둡니다.obj 를 OrdinaryObjectCreate (null , internalSlotsList )로 둡니다.! CreateDataPropertyOrThrow (obj , "rawJSON" , jsonString )을 수행합니다. ! SetIntegrityLevel (obj , frozen )을 수행합니다. obj 를 반환합니다.
25.5.4 JSON.stringify ( value [ , replacer [ , space ] ] )
이 함수는 ECMAScript language value를 나타내는 UTF-16 인코딩 JSON 형식의 String 또는 undefined 를 반환합니다. 세 매개변수를 받을 수 있습니다. value 매개변수는 ECMAScript language value이며 일반적으로 객체 또는 배열이지만 String, Boolean, Number 또는 null 일 수도 있습니다. 선택적 replacer 매개변수는 객체와 배열을 문자열화하는 방식을 변경하는 함수이거나, 문자열화할 객체 프로퍼티를 선택하기 위한 포함 목록 역할을 하는 String 및 Number의 배열입니다. 선택적 space 매개변수는 사람이 읽기 쉽도록 결과에 공백을 삽입할 수 있게 하는 String 또는 Number입니다.
호출되면 다음 단계를 수행합니다:
stack 을 새로운 빈 List 로 둡니다.indent 를 빈 String으로 둡니다.propertyList 를 undefined 로 둡니다.replacerFunc 를 undefined 로 둡니다.replacer 가 Object이면, 다음을 수행합니다.IsCallable (replacer )가 true 이면, 다음을 수행합니다.replacerFunc 를 replacer 로 설정합니다.그렇지 않으면,isArray 를 ? IsArray (replacer )로 둡니다.isArray 가 true 이면, 다음을 수행합니다.propertyList 를 새로운 빈 List 로 설정합니다.length 를 ? LengthOfArrayLike (replacer )로 둡니다.k 를 0으로 둡니다.k < length 인 동안 다음을 반복합니다.propertyKey 를 ! ToString (𝔽 (k ))로 둡니다.propertyValue 를 ? Get (replacer , propertyKey )로 둡니다.item 을 undefined 로 둡니다.propertyValue 가 String이면, 다음을 수행합니다.item 을 propertyValue 로 설정합니다.그렇지 않고 propertyValue 가 Number이면, 다음을 수행합니다.item 을 ! ToString (propertyValue )로 설정합니다. 그렇지 않고 propertyValue 가 Object이면, 다음을 수행합니다.propertyValue 에 [[StringData]] 또는 [[NumberData]] 내부 슬롯이 있으면 item 을 ? ToString (propertyValue )로 설정합니다. item 이 undefined 가 아니고 propertyList 에 item 이 포함되어 있지 않으면, 다음을 수행합니다.item 을 propertyList 에 추가합니다.k 를 k + 1로 설정합니다. space 가 Object이면, 다음을 수행합니다.space 에 [[NumberData]] 내부 슬롯이 있으면, 다음을 수행합니다.space 를 ? ToNumber (space )로 설정합니다.그렇지 않고 space 에 [[StringData]] 내부 슬롯이 있으면, 다음을 수행합니다.space 를 ? ToString (space )로 설정합니다. space 가 Number이면, 다음을 수행합니다.spaceMV 를 ! ToIntegerOrInfinity (space )로 둡니다.spaceMV 를 min (10, spaceMV )로 설정합니다.spaceMV < 1이면 gap 을 빈 String으로 둡니다. 그렇지 않으면 gap 을 코드 단위 0x0020 (SPACE)이 spaceMV 번 나타나는 String 값으로 둡니다.그렇지 않고 space 가 String이면, 다음을 수행합니다.space 의 길이가 10 이하이면 gap 을 space 로 둡니다. 그렇지 않으면 gap 을 space 의 0부터 10까지의 부분 문자열 로 둡니다. 그렇지 않으면,gap 을 빈 String으로 둡니다. wrapper 를 OrdinaryObjectCreate (%Object.prototype% )로 둡니다.! CreateDataPropertyOrThrow (wrapper , 빈 String, value )을 수행합니다. state 를 JSON Serialization Record { [[ReplacerFunction]] : replacerFunc , [[Stack]] : stack , [[Indent]] : indent , [[Gap]] : gap , [[PropertyList]] : propertyList }로 둡니다.? SerializeJSONProperty (state , 빈 String, wrapper )을 반환합니다.
이 함수의 "length" 프로퍼티는 3 𝔽 입니다.
참고 1
JSON 구조는 임의의 깊이로 중첩될 수 있지만 순환해서는 안 됩니다. value 가 순환 구조이거나 순환 구조를 포함하면 이 함수는 TypeError 예외를 던져야 합니다. 다음은 문자열화할 수 없는 값의 예입니다:
a = [];
a[0 ] = a;
my_text = JSON .stringify (a);
참고 2
기호적 프리미티브 값은 다음과 같이 렌더링됩니다:
null 값은 JSON 텍스트에서 String 값 "null" 로 렌더링됩니다.
undefined 값은 렌더링되지 않습니다.
true 값은 JSON 텍스트에서 String 값 "true" 로 렌더링됩니다.
false 값은 JSON 텍스트에서 String 값 "false" 로 렌더링됩니다.
참고 3
String 값은 QUOTATION MARK (") 코드 단위로 감쌉니다. 코드 단위 " 및 \는 \ 접두사를 사용하여 이스케이프합니다. 제어 문자 코드 단위는 이스케이프 시퀀스 \uHHHH 또는 더 짧은 형식인 \b (BACKSPACE), \f (FORM FEED), \n (LINE FEED), \r (CARRIAGE RETURN), \t (CHARACTER TABULATION)로 대체합니다.
참고 4
각 유한 Number 는 ToString (number )을 호출한 것처럼 문자열로 변환됩니다. NaN , +∞ 𝔽 , -∞ 𝔽 는 String 값 "null" 로 나타냅니다.
참고 5
JSON 표현이 없는 값(예: undefined 및 함수)은 String을 생성하지 않습니다. 대신 undefined 값을 생성합니다. 배열에서 이러한 값은 String 값 "null" 로 나타냅니다. 객체에서 표현할 수 없는 값은 해당 프로퍼티가 문자열화에서 제외되도록 합니다.
참고 6
객체는 U+007B (LEFT CURLY BRACKET) 뒤에 0개 이상의 프로퍼티를 U+002C (COMMA)로 구분하여 배치하고 U+007D (RIGHT CURLY BRACKET)로 닫아 렌더링합니다. 프로퍼티는 프로퍼티 이름 을 나타내는 따옴표로 감싼 String, U+003A (COLON), 문자열화된 프로퍼티 값으로 구성됩니다. 배열은 여는 U+005B (LEFT SQUARE BRACKET) 뒤에 0개 이상의 값을 U+002C (COMMA)로 구분하여 배치하고 U+005D (RIGHT SQUARE BRACKET)로 닫아 렌더링합니다.
25.5.4.1 JSON Serialization Record
JSON Serialization Record 는 JSON 형식으로 직렬화할 수 있도록 하는 데 사용되는 Record 입니다.
JSON Serialization Records에는 표 77 에 나열된 필드가 있습니다.
표 77: JSON Serialization Record 필드
필드 이름
값
의미
[[ReplacerFunction]]
a function object or undefined
객체 프로퍼티에 대한 대체 값을 제공할 수 있는 함수입니다(JSON.stringify의 replacer 매개변수에서 가져옵니다).
[[PropertyList]]
either a List of Strings or undefined
배열이 아닌 객체를 직렬화할 때 포함할 프로퍼티 이름 입니다(JSON.stringify의 replacer 매개변수에서 가져옵니다).
[[Gap]]
a String
들여쓰기 단위입니다(JSON.stringify의 space 매개변수에서 가져옵니다).
[[Stack]]
a List of Objects
직렬화 중인 중첩 객체의 집합입니다. 순환 구조를 감지하는 데 사용합니다.
[[Indent]]
a String
현재 들여쓰기입니다.
25.5.4.2 SerializeJSONProperty ( state , key , holder )
추상 연산 SerializeJSONProperty. 인수 state (JSON Serialization 레코드 ), key (String) 및 holder (Object). 반환값: (정상 완료 (값: (String 또는 undefined )) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
value 를 ? Get (holder , key )로 둡니다.value 가 Object 또는 BigInt이면 다음을 수행합니다.toJSON 을 ? GetV (value , "toJSON" )으로 둡니다.IsCallable (toJSON )이 true 이면 다음을 수행합니다.value 를 ? Call (toJSON , value , « key »)로 설정합니다.state .[[ReplacerFunction]] 이 undefined 가 아니면 다음을 수행합니다.value 를 ? Call (state .[[ReplacerFunction]] , holder , « key , value »)로 설정합니다.value 가 Object이면 다음을 수행합니다.value 에 [[IsRawJSON]] 내부 슬롯이 있으면 다음을 수행합니다.rawJSON 을 ! Get (value , "rawJSON" )으로 둡니다.단언 : rawJSON 은 String입니다.rawJSON 을 반환합니다.value 에 [[NumberData]] 내부 슬롯이 있으면 다음을 수행합니다.value 를 ? ToNumber (value )로 설정합니다.그렇지 않고 value 에 [[StringData]] 내부 슬롯이 있으면 다음을 수행합니다.value 를 ? ToString (value )으로 설정합니다. 그렇지 않고 value 에 [[BooleanData]] 내부 슬롯이 있으면 다음을 수행합니다.value 를 value .[[BooleanData]] 로 설정합니다. 그렇지 않고 value 에 [[BigIntData]] 내부 슬롯이 있으면 다음을 수행합니다.value 를 value .[[BigIntData]] 로 설정합니다. value 가 null 이면 "null" 을 반환합니다.value 가 true 이면 "true" 를 반환합니다.value 가 false 이면 "false" 를 반환합니다.value 가 String이면 QuoteJSONString (value )을 반환합니다.value 가 Number이면 다음을 수행합니다.value 가 유한 Number 이면 ! ToString (value )을 반환합니다."null" 을 반환합니다.value 가 BigInt이면 TypeError 예외를 던집니다.value 가 Object이고 IsCallable (value )이 false 이면 다음을 수행합니다.isArray 를 ? IsArray (value )로 둡니다.isArray 가 true 이면 다음을 수행합니다.? SerializeJSONArray (state , value )을 반환합니다. ? SerializeJSONObject (state , value )을 반환합니다. undefined 를 반환합니다.
25.5.4.3 QuoteJSONString ( value )
추상 연산 QuoteJSONString. 인수 value (String). 반환값: String. value 를 0x0022 (QUOTATION MARK) 코드 단위로 감싸고 그 안의 특정 다른 코드 단위를 이스케이프합니다. 이 연산은 6.1.4 에 설명된 대로 value 를 UTF-16으로 인코딩된 코드 포인트 시퀀스로 해석합니다. 호출되면 다음 단계를 수행한다.
product 를 코드 단위 0x0022 (QUOTATION MARK) 하나로만 구성된 String 값으로 둡니다.StringToCodePoints (value )의 각 코드 포인트 codePoint 에 대해 다음을 수행합니다.codePoint 가 표 78 의 “Code Point” 열에 나열되어 있으면, 다음을 수행합니다.product 를 product 와 대응하는 행의 “Escape Sequence” 열에 지정된 codePoint 의 이스케이프 시퀀스의 문자열 연결 로 설정합니다.그렇지 않고 codePoint 의 숫자 값이 0x0020 (SPACE)보다 작거나 codePoint 가 leading surrogate 또는 trailing surrogate와 동일한 숫자 값을 가지면, 다음을 수행합니다.unit 을 숫자 값이 codePoint 의 숫자 값인 코드 단위로 둡니다.product 를 product 와 UnicodeEscape (unit )의 문자열 연결 로 설정합니다. 그렇지 않으면,product 를 product 와 UTF16EncodeCodePoint (codePoint )의 문자열 연결 로 설정합니다. product 를 product 와 코드 단위 0x0022 (QUOTATION MARK)의 문자열 연결 로 설정합니다.product 를 반환합니다.
표 78: JSON 단일 문자 이스케이프 시퀀스
코드 포인트
유니코드 문자 이름
이스케이프 시퀀스
U+0008
BACKSPACE
\b
U+0009
CHARACTER TABULATION
\t
U+000A
LINE FEED (LF)
\n
U+000C
FORM FEED (FF)
\f
U+000D
CARRIAGE RETURN (CR)
\r
U+0022
QUOTATION MARK
\"
U+005C
REVERSE SOLIDUS
\\
25.5.4.4 UnicodeEscape ( codeUnit )
추상 연산 UnicodeEscape. 인수 codeUnit (코드 단위). 반환값: String. codeUnit 을 유니코드 이스케이프 시퀀스로 나타냅니다. 호출되면 다음 단계를 수행한다.
n 을 codeUnit 의 숫자 값으로 둡니다.단언 : n ≤ 0xFFFF입니다.hex 를 n 을 소문자 16진수로 형식화한 String 표현으로 둡니다.코드 단위 0x005C (REVERSE SOLIDUS), "u" , StringPad (hex , 4, "0" , start )의 문자열 연결 을 반환합니다.
25.5.4.5 SerializeJSONObject ( state , value )
추상 연산 SerializeJSONObject. 인수 state (JSON Serialization 레코드 ) 및 value (Object). 반환값: (정상 완료 (값: String) 또는 throw 완료 ). 객체를 직렬화합니다. 호출되면 다음 단계를 수행한다.
state .[[Stack]] 에 value 가 포함되어 있으면 구조가 순환하므로 TypeError 예외를 던집니다.value 를 state .[[Stack]] 에 추가합니다.stepBack 을 state .[[Indent]] 로 둡니다.state .[[Indent]] 를 state .[[Indent]] 와 state .[[Gap]] 의 문자열 연결 로 설정합니다.state .[[PropertyList]] 가 undefined 가 아니면, 다음을 수행합니다.keys 를 state .[[PropertyList]] 로 둡니다.그렇지 않으면,keys 를 ? EnumerableOwnProperties (value , key )로 둡니다. partial 을 새로운 빈 List 로 둡니다.keys 의 각 요소 propertyKey 에 대해 다음을 수행합니다.stringP 를 ? SerializeJSONProperty (state , propertyKey , value )로 둡니다.stringP 가 undefined 가 아니면, 다음을 수행합니다.member 를 QuoteJSONString (propertyKey )로 둡니다.member 를 member 와 ":" 의 문자열 연결 로 설정합니다.state .[[Gap]] 이 빈 String이 아니면, 다음을 수행합니다.member 를 member 와 코드 단위 0x0020 (SPACE)의 문자열 연결 로 설정합니다.member 를 member 와 stringP 의 문자열 연결 로 설정합니다.member 를 partial 에 추가합니다.partial 이 비어 있으면, 다음을 수행합니다.final 을 "{}" 로 둡니다.그렇지 않으면,state .[[Gap]] 이 빈 String이면, 다음을 수행합니다.properties 를 partial 의 모든 요소 String을 연결하되 인접한 각 String 쌍 사이를 코드 단위 0x002C (COMMA)로 구분하여 만든 String 값으로 둡니다. 첫 번째 String 앞이나 마지막 String 뒤에는 쉼표를 삽입하지 않습니다.final 을 "{" , properties , "}" 의 문자열 연결 로 둡니다.그렇지 않으면,separator 를 코드 단위 0x002C (COMMA), 코드 단위 0x000A (LINE FEED), state .[[Indent]] 의 문자열 연결 로 둡니다.properties 를 partial 의 모든 요소 String을 연결하되 인접한 각 String 쌍 사이를 separator 로 구분하여 만든 String 값으로 둡니다. separator String은 첫 번째 String 앞이나 마지막 String 뒤에 삽입하지 않습니다.final 을 "{" , 코드 단위 0x000A (LINE FEED), state .[[Indent]] , properties , 코드 단위 0x000A (LINE FEED), stepBack , "}" 의 문자열 연결 로 둡니다. state .[[Stack]] 의 마지막 요소를 제거합니다.state .[[Indent]] 를 stepBack 으로 설정합니다.final 을 반환합니다.
25.5.4.6 SerializeJSONArray ( state , value )
추상 연산 SerializeJSONArray. 인수 state (JSON Serialization 레코드 ) 및 value (Object). 반환값: (정상 완료 (값: String) 또는 throw 완료 ). 배열을 직렬화합니다. 호출되면 다음 단계를 수행한다.
state .[[Stack]] 에 value 가 포함되어 있으면 구조가 순환하므로 TypeError 예외를 던집니다.value 를 state .[[Stack]] 에 추가합니다.stepBack 을 state .[[Indent]] 로 둡니다.state .[[Indent]] 를 state .[[Indent]] 와 state .[[Gap]] 의 문자열 연결 로 설정합니다.partial 을 새로운 빈 List 로 둡니다.length 를 ? LengthOfArrayLike (value )로 둡니다.index 를 0으로 둡니다.index < length 인 동안 다음을 반복합니다.stringP 를 ? SerializeJSONProperty (state , ! ToString (𝔽 (index )), value )로 둡니다.stringP 가 undefined 이면, 다음을 수행합니다."null" 을 partial 에 추가합니다.그렇지 않으면,stringP 를 partial 에 추가합니다. index 를 index + 1로 설정합니다.partial 이 비어 있으면, 다음을 수행합니다.final 을 "[]" 로 둡니다.그렇지 않으면,state .[[Gap]] 이 빈 String이면, 다음을 수행합니다.properties 를 partial 의 모든 요소 String을 연결하되 인접한 각 String 쌍 사이를 코드 단위 0x002C (COMMA)로 구분하여 만든 String 값으로 둡니다. 첫 번째 String 앞이나 마지막 String 뒤에는 쉼표를 삽입하지 않습니다.final 을 "[" , properties , "]" 의 문자열 연결 로 둡니다.그렇지 않으면,separator 를 코드 단위 0x002C (COMMA), 코드 단위 0x000A (LINE FEED), state .[[Indent]] 의 문자열 연결 로 둡니다.properties 를 partial 의 모든 요소 String을 연결하되 인접한 각 String 쌍 사이를 separator 로 구분하여 만든 String 값으로 둡니다. separator String은 첫 번째 String 앞이나 마지막 String 뒤에 삽입하지 않습니다.final 을 "[" , 코드 단위 0x000A (LINE FEED), state .[[Indent]] , properties , 코드 단위 0x000A (LINE FEED), stepBack , "]" 의 문자열 연결 로 둡니다. state .[[Stack]] 의 마지막 요소를 제거합니다.state .[[Indent]] 를 stepBack 으로 설정합니다.final 을 반환합니다.
참고
배열 표현에는 +0 𝔽 (포함)부터 array.length(제외)까지 구간 의 요소만 포함됩니다. 키가 배열 인덱스 가 아닌 프로퍼티는 문자열화에서 제외됩니다. 배열은 여는 LEFT SQUARE BRACKET, COMMA로 구분한 요소, 닫는 RIGHT SQUARE BRACKET으로 문자열화됩니다.
25.5.5 JSON [ %Symbol.toStringTag% ]
%Symbol.toStringTag% 프로퍼티의 초기 값은 String 값 "JSON" 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
26 메모리 관리
26.1 WeakRef 객체
WeakRef 는 대상 객체 또는 Symbol이 가비지 컬렉션되지 않도록 유지하지 않으면서 이를 참조하는 데 사용되는 객체입니다. 대상이 가비지 컬렉션에 의해 회수되지 않았다면 WeakRef 를 역참조하여 대상 값에 접근할 수 있습니다.
26.1.1 WeakRef 생성자
WeakRef 생성자 는:
%WeakRef% 입니다.
전역 객체 의 "WeakRef" 프로퍼티의 초기 값입니다.
생성자 로 호출되면 새로운 WeakRef를 생성하고 초기화합니다.
함수로 호출하도록 의도되지 않았으며 그러한 방식으로 호출되면 예외를 던집니다.
클래스 정의의 extends 절에서 값으로 사용할 수 있습니다. 지정된 WeakRef 동작을 상속하려는 하위 클래스 생성자 는 WeakRef.prototype의 내장 메서드를 지원하는 데 필요한 내부 상태로 하위 클래스 인스턴스를 생성하고 초기화하기 위해 WeakRef 생성자 에 대한 super 호출을 포함해야 합니다.
26.1.1.1 WeakRef ( target )
이 함수는 호출되면 다음 단계를 수행합니다:
NewTarget이 undefined 이면 TypeError 예외를 던집니다. CanBeHeldWeakly (target )이 false 이면 TypeError 예외를 던집니다.weakRef 를 ? OrdinaryCreateFromConstructor (NewTarget, "%WeakRef.prototype%" , « [[WeakRefTarget]] »)로 둡니다.AddToKeptObjects (target )를 수행합니다.weakRef .[[WeakRefTarget]] 을 target 으로 설정합니다.weakRef 를 반환합니다.
26.1.2 WeakRef 생성자의 프로퍼티
WeakRef 생성자 는:
26.1.2.1 WeakRef.prototype
WeakRef.prototype의 초기 값은 WeakRef 프로토타입 객체 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
26.1.3 WeakRef 프로토타입 객체의 프로퍼티
WeakRef 프로토타입 객체 는:
%WeakRef.prototype% 입니다.
값이 %Object.prototype% 인 [[Prototype]] 내부 슬롯을 갖습니다.
일반 객체 입니다.
[[WeakRefTarget]] 내부 슬롯을 갖지 않습니다.
규정 선택 사항
26.1.3.1 WeakRef.prototype.constructor
WeakRef.prototype.constructor의 초기 값은 %WeakRef% 입니다.
26.1.3.2 WeakRef.prototype.deref ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
weakRef 를 this 값으로 둡니다.? RequireInternalSlot (weakRef , [[WeakRefTarget]] )을 수행합니다. WeakRefDeref (weakRef )를 반환합니다.
참고
WeakRef 가 undefined 가 아닌 target 값을 반환하면 현재 ECMAScript 코드 실행이 완료될 때까지 이 target 값은 가비지 컬렉션되어서는 안 됩니다. AddToKeptObjects 연산은 읽기 일관성이 유지되도록 합니다.
let target = { foo ( ) {} };
let weakRef = new WeakRef (target);
if (weakRef.deref ()) {
weakRef.deref ().foo ();
}
위 예에서 첫 번째 deref가 undefined 로 평가되지 않으면 두 번째 deref도 undefined 로 평가될 수 없습니다.
26.1.3.3 WeakRef.prototype [ %Symbol.toStringTag% ]
%Symbol.toStringTag% 프로퍼티의 초기 값은 String 값 "WeakRef" 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
26.1.4 WeakRef 추상 연산
26.1.4.1 WeakRefDeref ( weakRef )
추상 연산 WeakRefDeref. 인수 weakRef (WeakRef ). 반환값: ECMAScript 언어 값 . 호출되면 다음 단계를 수행한다.
target 을 weakRef .[[WeakRefTarget]] 으로 둡니다.target 이 empty 가 아니면, 다음을 수행합니다.AddToKeptObjects (target )를 수행합니다.target 을 반환합니다.undefined 를 반환합니다.
참고
이 추상 연산 은 생존성을 간결하게 정의할 수 있도록 하기 위해서만 WeakRef.prototype.deref와 별도로 정의됩니다.
26.1.5 WeakRef 인스턴스의 프로퍼티
WeakRef 인스턴스는 WeakRef 프로토타입 객체 에서 프로퍼티를 상속하는 일반 객체 입니다. WeakRef 인스턴스는 [[WeakRefTarget]] 내부 슬롯도 갖습니다.
26.2 FinalizationRegistry 객체
FinalizationRegistry 는 대상 객체와 Symbol이 가비지 컬렉션될 때 수행되는 정리 연산의 등록 및 등록 해제를 관리하는 객체입니다.
26.2.1 FinalizationRegistry 생성자
FinalizationRegistry 생성자 는:
%FinalizationRegistry% 입니다.
전역 객체 의 "FinalizationRegistry" 프로퍼티의 초기 값입니다.
생성자 로 호출되면 새로운 FinalizationRegistry를 생성하고 초기화합니다.
함수로 호출하도록 의도되지 않았으며 그러한 방식으로 호출되면 예외를 던집니다.
클래스 정의의 extends 절에서 값으로 사용할 수 있습니다. 지정된 FinalizationRegistry 동작을 상속하려는 하위 클래스 생성자 는 FinalizationRegistry.prototype의 내장 메서드를 지원하는 데 필요한 내부 상태로 하위 클래스 인스턴스를 생성하고 초기화하기 위해 FinalizationRegistry 생성자 에 대한 super 호출을 포함해야 합니다.
26.2.1.1 FinalizationRegistry ( cleanupCallback )
이 함수는 호출되면 다음 단계를 수행합니다:
NewTarget이 undefined 이면 TypeError 예외를 던집니다. IsCallable (cleanupCallback )이 false 이면 TypeError 예외를 던집니다.finalizationRegistry 를 ? OrdinaryCreateFromConstructor (NewTarget, "%FinalizationRegistry.prototype%" , « [[Realm]] , [[CleanupCallback]] , [[Cells]] »)로 둡니다.activeFunc 를 활성 함수 객체 로 둡니다.finalizationRegistry .[[Realm]] 을 activeFunc .[[Realm]] 으로 설정합니다.finalizationRegistry .[[CleanupCallback]] 을 HostMakeJobCallback (cleanupCallback )으로 설정합니다.finalizationRegistry .[[Cells]] 를 새로운 빈 List 로 설정합니다.finalizationRegistry 를 반환합니다.
26.2.2 FinalizationRegistry 생성자의 프로퍼티
FinalizationRegistry 생성자 는:
26.2.2.1 FinalizationRegistry.prototype
FinalizationRegistry.prototype의 초기 값은 FinalizationRegistry 프로토타입 객체 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
26.2.3 FinalizationRegistry 프로토타입 객체의 프로퍼티
FinalizationRegistry 프로토타입 객체 는:
%FinalizationRegistry.prototype% 입니다.
값이 %Object.prototype% 인 [[Prototype]] 내부 슬롯을 갖습니다.
일반 객체 입니다.
[[Cells]] 및 [[CleanupCallback]] 내부 슬롯을 갖지 않습니다.
26.2.3.1 FinalizationRegistry.prototype.constructor
FinalizationRegistry.prototype.constructor의 초기 값은 %FinalizationRegistry% 입니다.
26.2.3.2 FinalizationRegistry.prototype.register ( target , heldValue [ , unregisterToken ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
finalizationRegistry 를 this 값으로 둡니다.? RequireInternalSlot (finalizationRegistry , [[Cells]] )를 수행합니다. CanBeHeldWeakly (target )이 false 이면 TypeError 예외를 던집니다.SameValue (target , heldValue )이 true 이면 TypeError 예외를 던집니다.CanBeHeldWeakly (unregisterToken )이 false 이면, 다음을 수행합니다.unregisterToken 이 undefined 가 아니면 TypeError 예외를 던집니다.unregisterToken 을 empty 로 설정합니다.cell 을 Record { [[WeakRefTarget]] : target , [[HeldValue]] : heldValue , [[UnregisterToken]] : unregisterToken }로 둡니다.cell 을 finalizationRegistry .[[Cells]] 에 추가합니다.undefined 를 반환합니다.
참고
이 명세의 알고리즘과 정의에 따르면 finalizationRegistry .[[Cells]] 에 cell 이 포함되어 있을 때 cell .[[HeldValue]] 는 생존합니다. 그러나 이것이 반드시 cell .[[UnregisterToken]] 또는 cell .[[Target]] 도 생존한다는 의미는 아닙니다. 예를 들어 객체 자체를 unregister token으로 사용하여 등록해도 그 객체가 영원히 생존하도록 유지되지는 않습니다.
26.2.3.3 FinalizationRegistry.prototype.unregister ( unregisterToken )
이 메서드는 호출되면 다음 단계를 수행합니다:
finalizationRegistry 를 this 값으로 둡니다.? RequireInternalSlot (finalizationRegistry , [[Cells]] )를 수행합니다. CanBeHeldWeakly (unregisterToken )이 false 이면 TypeError 예외를 던집니다.removed 를 false 로 둡니다.finalizationRegistry .[[Cells]] 의 각 Record { [[WeakRefTarget]] , [[HeldValue]] , [[UnregisterToken]] } cell 에 대해 다음을 수행합니다.cell .[[UnregisterToken]] 이 empty 가 아니고 SameValue (cell .[[UnregisterToken]] , unregisterToken )이 true 이면, 다음을 수행합니다.cell 을 finalizationRegistry .[[Cells]] 에서 제거합니다.removed 를 true 로 설정합니다.removed 를 반환합니다.
26.2.3.4 FinalizationRegistry.prototype [ %Symbol.toStringTag% ]
%Symbol.toStringTag% 프로퍼티의 초기 값은 String 값 "FinalizationRegistry" 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
26.2.4 FinalizationRegistry 인스턴스의 프로퍼티
FinalizationRegistry 인스턴스는 FinalizationRegistry 프로토타입 객체 에서 프로퍼티를 상속하는 일반 객체 입니다. FinalizationRegistry 인스턴스는 [[Cells]] 및 [[CleanupCallback]] 내부 슬롯도 갖습니다.
27 제어 추상화 객체
27.1 순회
27.1.1 공통 순회 인터페이스
인터페이스는 연결된 값이 특정 명세와 일치하는 프로퍼티 키 의 집합입니다. 인터페이스의 명세에 설명된 모든 프로퍼티를 제공하는 객체는 해당 인터페이스를 준수합니다 . 인터페이스는 별도의 객체로 표현되지 않습니다. 어떤 인터페이스든 이를 준수하는 여러 개별 구현 객체가 있을 수 있습니다. 하나의 객체가 여러 인터페이스를 준수할 수도 있습니다.
27.1.1.1 Iterable 인터페이스
iterable 인터페이스 에는 표 79 에 설명된 프로퍼티가 포함됩니다:
표 79: Iterable 인터페이스 필수 프로퍼티
27.1.1.2 Iterator 인터페이스
iterator 인터페이스 를 구현하는 객체는 표 80 의 프로퍼티를 포함해야 합니다. 이러한 객체는 표 81 의 프로퍼티도 구현할 수 있습니다.
표 80: Iterator 인터페이스 필수 프로퍼티
프로퍼티
값
요구 사항
"next"
a function that returns an IteratorResult object
반환된 객체는 IteratorResult 인터페이스 를 준수해야 합니다. iterator 의 next 메서드에 대한 이전 호출이 "done" 프로퍼티가 true 인 IteratorResult 객체를 반환했다면, 해당 객체의 next 메서드에 대한 이후의 모든 호출도 "done" 프로퍼티가 true 인 IteratorResult 객체를 반환해야 합니다. 그러나 이 요구 사항은 강제되지 않습니다.
참고 1
next 함수에 인수를 전달할 수 있지만 그 해석과 유효성은 대상 iterator에 따라 달라집니다. for-of 문과 iterator의 다른 일반적인 사용자는 인수를 전달하지 않으므로 그러한 방식으로 사용될 것으로 예상되는 iterator 객체는 인수 없이 호출되는 경우를 처리할 준비가 되어 있어야 합니다.
표 81: Iterator 인터페이스 선택적 프로퍼티
프로퍼티
값
요구 사항
"return"
a function that returns an IteratorResult object
반환된 객체는 IteratorResult 인터페이스 를 준수해야 합니다. 이 메서드를 호출하면 호출자가 해당 iterator 에 대해 더 이상 next 메서드를 호출하지 않을 것임을 iterator 객체에 알립니다. 반환되는 IteratorResult 객체는 일반적으로 값이 true 인 "done" 프로퍼티와 return 메서드의 인수로 전달된 값을 갖는 "value" 프로퍼티를 갖습니다. 그러나 이 요구 사항은 강제되지 않습니다.
"throw"
a function that returns an IteratorResult object
반환된 객체는 IteratorResult 인터페이스 를 준수해야 합니다. 이 메서드를 호출하면 호출자가 오류 조건을 감지했음을 iterator 객체에 알립니다. 인수는 오류 조건을 식별하는 데 사용할 수 있으며 일반적으로 예외 객체입니다. 일반적인 응답은 인수로 전달된 값을 throw하는 것입니다. 메서드가 throw하지 않으면 반환된 IteratorResult 객체는 일반적으로 값이 true 인 "done" 프로퍼티를 갖습니다.
참고 2
일반적으로 이러한 메서드의 호출자는 메서드를 호출하기 전에 존재 여부를 확인해야 합니다. for-of, yield*, 배열 구조 분해를 포함한 특정 ECMAScript 언어 기능은 존재 여부를 확인한 후 이러한 메서드를 호출합니다. iterable 객체를 인수로 받는 대부분의 ECMAScript 라이브러리 함수도 조건부로 이러한 메서드를 호출합니다.
27.1.1.3 Async Iterable 인터페이스
async iterable 인터페이스 에는 표 82 에 설명된 프로퍼티가 포함됩니다:
표 82: Async Iterable 인터페이스 필수 프로퍼티
27.1.1.4 Async Iterator 인터페이스
async iterator 인터페이스 를 구현하는 객체는 표 83 의 프로퍼티를 포함해야 합니다. 이러한 객체는 표 84 의 프로퍼티도 구현할 수 있습니다.
표 83: Async Iterator 인터페이스 필수 프로퍼티
프로퍼티
값
요구 사항
"next"
a function that returns a promise for an IteratorResult object
반환된 promise가 이행되면 IteratorResult 인터페이스 를 준수하는 객체로 이행되어야 합니다. async iterator 의 next 메서드에 대한 이전 호출이 "done" 프로퍼티가 true 인 IteratorResult 객체의 promise를 반환했다면, 해당 객체의 next 메서드에 대한 이후의 모든 호출도 "done" 프로퍼티가 true 인 IteratorResult 객체의 promise를 반환해야 합니다. 그러나 이 요구 사항은 강제되지 않습니다.
또한 이행 값으로 사용되는 IteratorResult 객체에는 값이 promise(또는 “thenable ”)가 아닌 "value" 프로퍼티가 있어야 합니다. 그러나 이 요구 사항 역시 강제되지 않습니다.
참고 1
next 함수에 인수를 전달할 수 있지만 그 해석과 유효성은 대상 async iterator에 따라 달라집니다. for-await-of 문과 async iterator의 다른 일반적인 사용자는 인수를 전달하지 않으므로 그러한 방식으로 사용될 것으로 예상되는 async iterator 객체는 인수 없이 호출되는 경우를 처리할 준비가 되어 있어야 합니다.
표 84: Async Iterator 인터페이스 선택적 프로퍼티
프로퍼티
값
요구 사항
"return"
a function that returns a promise for an IteratorResult object
반환된 promise가 이행되면 IteratorResult 인터페이스 를 준수하는 객체로 이행되어야 합니다. 이 메서드를 호출하면 호출자가 해당 async iterator 에 대해 더 이상 next 메서드를 호출하지 않을 것임을 async iterator 객체에 알립니다. 반환된 promise는 일반적으로 값이 true 인 "done" 프로퍼티와 return 메서드의 인수로 전달된 값을 갖는 "value" 프로퍼티가 있는 IteratorResult 객체로 이행됩니다. 그러나 이 요구 사항은 강제되지 않습니다.
또한 이행 값으로 사용되는 IteratorResult 객체에는 값이 promise(또는 “thenable ”)가 아닌 "value" 프로퍼티가 있어야 합니다. 인수 값이 일반적인 방식으로 사용되는 경우, 거부된 promise라면 같은 이유로 거부되는 promise가 반환되어야 하며, 이행된 promise라면 그 이행 값을 반환 promise의 IteratorResult 객체 이행 값의 "value" 프로퍼티로 사용해야 합니다. 그러나 이러한 요구 사항 역시 강제되지 않습니다.
"throw"
a function that returns a promise for an IteratorResult object
반환된 promise가 이행되면 IteratorResult 인터페이스 를 준수하는 객체로 이행되어야 합니다. 이 메서드를 호출하면 호출자가 오류 조건을 감지했음을 async iterator 객체에 알립니다. 인수는 오류 조건을 식별하는 데 사용할 수 있으며 일반적으로 예외 객체입니다. 일반적인 응답은 인수로 전달된 값을 이유로 거부되는 promise를 반환하는 것입니다.
반환된 promise가 이행되면 IteratorResult 객체 이행 값은 일반적으로 값이 true 인 "done" 프로퍼티를 갖습니다. 또한 값이 promise(또는 “thenable ”)가 아닌 "value" 프로퍼티를 가져야 하지만 이 요구 사항은 강제되지 않습니다.
참고 2
일반적으로 이러한 메서드의 호출자는 메서드를 호출하기 전에 존재 여부를 확인해야 합니다. for-await-of 및 yield*를 포함한 특정 ECMAScript 언어 기능은 존재 여부를 확인한 후 이러한 메서드를 호출합니다.
27.1.1.5 IteratorResult 인터페이스
IteratorResult 인터페이스 에는 표 85 에 나열된 프로퍼티가 포함됩니다:
표 85: IteratorResult 인터페이스 프로퍼티
프로퍼티
값
요구 사항
"done"
a Boolean
이는 iterator next 메서드 호출의 결과 상태입니다. iterator 의 끝에 도달하면 "done" 은 true 입니다. 끝에 도달하지 않았다면 "done" 은 false 이며 값을 사용할 수 있습니다. "done" 프로퍼티(자체 또는 상속된 프로퍼티)가 존재하지 않으면 값이 false 인 것으로 간주합니다.
"value"
an ECMAScript language value
done이 false 이면 현재 순회 요소 값입니다. done이 true 이면 iterator 가 반환 값을 제공한 경우 그 반환 값입니다. iterator 에 반환 값이 없으면 "value" 는 undefined 입니다. 이 경우 명시적인 "value" 프로퍼티를 상속하지 않는다면 준수 객체에 "value" 프로퍼티가 없을 수 있습니다.
27.1.2 Iterator Helper 객체
Iterator Helper 객체 는 특정 소스 iterator 객체의 지연 변환을 나타내는 일반 객체 입니다. Iterator Helper 객체에는 이름 있는 생성자 가 없습니다. 대신 Iterator Helper 객체는 Iterator 인스턴스 객체의 특정 메서드를 호출하여 생성됩니다.
27.1.2.1 %IteratorHelperPrototype% 객체
%IteratorHelperPrototype% 객체는:
27.1.2.1.1 %IteratorHelperPrototype%.next ( )
? GeneratorResume (this 값, undefined , "Iterator Helper" )를 반환합니다.
27.1.2.1.2 %IteratorHelperPrototype%.return ( )
obj 를 this 값으로 둡니다.? RequireInternalSlot (obj , [[UnderlyingIterators]] )를 수행합니다. 단언 : obj 에는 [[GeneratorState]] 내부 슬롯이 있습니다.obj .[[GeneratorState]] 가 suspended-start 이면, 다음을 수행합니다.obj .[[GeneratorState]] 를 completed 로 설정합니다.참고 : generator가 completed 상태에 들어가면 다시 벗어나지 않으며 연결된 실행 컨텍스트 는 다시 재개되지 않습니다. obj 와 연결된 모든 실행 상태는 이 시점에 폐기할 수 있습니다.? IteratorCloseAll (obj .[[UnderlyingIterators]] , NormalCompletion (unused ))을 수행합니다. CreateIteratorResultObject (undefined , true )를 반환합니다.completion 을 ReturnCompletion (undefined )로 둡니다.? GeneratorResumeAbrupt (obj , completion , "Iterator Helper" )를 반환합니다.
27.1.2.1.3 %IteratorHelperPrototype% [ %Symbol.toStringTag% ]
%Symbol.toStringTag% 프로퍼티의 초기 값은 String 값 "Iterator Helper" 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
27.1.3 Iterator 객체
27.1.3.1 Iterator 생성자
Iterator 생성자 는:
%Iterator% 입니다.
전역 객체 의 "Iterator" 프로퍼티의 초기 값입니다.
하위 클래스를 만들 수 있도록 설계되었습니다. 클래스 정의의 extends 절 값으로 사용할 수 있습니다.
27.1.3.1.1 Iterator ( )
이 함수는 호출되면 다음 단계를 수행합니다:
NewTarget이 undefined 이거나 활성 함수 객체 이면 TypeError 예외를 던집니다. ? OrdinaryCreateFromConstructor (NewTarget, "%Iterator.prototype%" )를 반환합니다.
27.1.3.2 Iterator 생성자의 프로퍼티
Iterator 생성자 는:
27.1.3.2.1 Iterator.concat ( ...items )
iterables 를 새로운 빈 List 로 둡니다.items 의 각 요소 item 에 대해 다음을 수행합니다.item 이 Object가 아니면 TypeError 예외를 던집니다.method 를 ? GetMethod (item , %Symbol.iterator% )로 둡니다.method 가 undefined 이면 TypeError 예외를 던집니다.Record { [[OpenMethod]] : method , [[Iterable]] : item }를 iterables 에 추가합니다.closure 를 매개변수가 없고 iterables 를 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:iterables 의 각 Record iterable 에 대해 다음을 수행합니다.iterator 를 ? Call (iterable .[[OpenMethod]] , iterable .[[Iterable]] )로 둡니다.iterator 가 Object가 아니면 TypeError 예외를 던집니다.iteratorRecord 를 ? GetIteratorDirect (iterator )로 둡니다.innerAlive 를 true 로 둡니다.innerAlive 가 true 인 동안 다음을 반복합니다.innerValue 를 ? IteratorStepValue (iteratorRecord )로 둡니다.innerValue 가 done 이면, 다음을 수행합니다.innerAlive 를 false 로 설정합니다.그렇지 않으면,completion 을 Completion (Yield (innerValue ))으로 둡니다.completion 이 abrupt completion이면, 다음을 수행합니다.? IteratorClose (iteratorRecord , completion )을 반환합니다. ReturnCompletion (undefined )을 반환합니다.gen 을 CreateIteratorFromClosure (closure , "Iterator Helper" , %IteratorHelperPrototype% , « [[UnderlyingIterators]] »)로 둡니다.gen .[[UnderlyingIterators]] 를 새로운 빈 List 로 설정합니다.gen 을 반환합니다.
27.1.3.2.2 Iterator.from ( obj )
iteratorRecord 를 ? GetIteratorFlattenable (obj , iterate-string-primitives )로 둡니다.hasInstance 를 ? OrdinaryHasInstance (%Iterator% , iteratorRecord .[[Iterator]] )로 둡니다.hasInstance 가 true 이면, 다음을 수행합니다.iteratorRecord .[[Iterator]] 를 반환합니다.wrapper 를 OrdinaryObjectCreate (%WrapForValidIteratorPrototype% , « [[Iterated]] »)로 둡니다.wrapper .[[Iterated]] 를 iteratorRecord 로 설정합니다.wrapper 를 반환합니다.
27.1.3.2.2.1 %WrapForValidIteratorPrototype% 객체
%WrapForValidIteratorPrototype% 객체는:
27.1.3.2.2.1.1 %WrapForValidIteratorPrototype%.next ( )
obj 를 this 값으로 둡니다.? RequireInternalSlot (obj , [[Iterated]] )를 수행합니다. iteratorRecord 를 obj .[[Iterated]] 로 둡니다.? Call (iteratorRecord .[[NextMethod]] , iteratorRecord .[[Iterator]] )를 반환합니다.
27.1.3.2.2.1.2 %WrapForValidIteratorPrototype%.return ( )
obj 를 this 값으로 둡니다.? RequireInternalSlot (obj , [[Iterated]] )를 수행합니다. iterator 를 obj .[[Iterated]] .[[Iterator]] 로 둡니다.단언 : iterator 는 Object입니다.returnMethod 를 ? GetMethod (iterator , "return" )으로 둡니다.returnMethod 가 undefined 이면, 다음을 수행합니다.CreateIteratorResultObject (undefined , true )를 반환합니다.? Call (returnMethod , iterator )를 반환합니다.
27.1.3.2.3 Iterator.prototype
Iterator.prototype의 초기 값은 Iterator 프로토타입 객체 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
27.1.3.2.4 Iterator.zip ( iterables [ , options ] )
이 함수는 호출되면 다음 단계를 수행합니다:
iterables 가 Object가 아니면 TypeError 예외를 던집니다.options 를 ? GetOptionsObject (options )로 설정합니다.mode 를 ? Get (options , "mode" )로 둡니다.mode 가 undefined 이면 mode 를 "shortest" 로 설정합니다.mode 가 "shortest" , "longest" , "strict" 중 하나가 아니면 TypeError 예외를 던집니다.paddingOption 을 undefined 로 둡니다.mode 가 "longest" 이면, 다음을 수행합니다.paddingOption 을 ? Get (options , "padding" )으로 설정합니다.paddingOption 이 undefined 가 아니고 Object도 아니면 TypeError 예외를 던집니다.iters 를 새로운 빈 List 로 둡니다.padding 을 새로운 빈 List 로 둡니다.inputIter 를 ? GetIterator (iterables , sync )로 둡니다.next 를 not-started 로 둡니다.next 가 done 이 아닌 동안 다음을 반복합니다.next 를 Completion (IteratorStepValue (inputIter ))으로 설정합니다.IfAbruptCloseIterators (next , iters ).next 가 done 이 아니면, 다음을 수행합니다.iter 를 Completion (GetIteratorFlattenable (next , reject-primitives ))으로 둡니다.needClosing 을 « inputIter »와 iters 의 목록 연결 로 둡니다.IfAbruptCloseIterators (iter , needClosing ).iter 를 iters 에 추가합니다.iterCount 를 iters 의 요소 수로 둡니다.mode 가 "longest" 이면, 다음을 수행합니다.paddingOption 이 undefined 이면, 다음을 수행합니다.iterCount 번 반복합니다:undefined 를 padding 에 추가합니다.그렇지 않으면,paddingIter 를 Completion (GetIterator (paddingOption , sync ))으로 둡니다.IfAbruptCloseIterators (paddingIter , iters ).usingIterator 를 true 로 둡니다.iterCount 번 반복합니다:usingIterator 가 true 이면, 다음을 수행합니다.next 를 Completion (IteratorStepValue (paddingIter ))으로 설정합니다.IfAbruptCloseIterators (next , iters ).next 가 done 이면, 다음을 수행합니다.usingIterator 를 false 로 설정합니다.그렇지 않으면,next 를 padding 에 추가합니다. usingIterator 가 false 이면 undefined 를 padding 에 추가합니다.usingIterator 가 true 이면, 다음을 수행합니다.completion 을 Completion (IteratorClose (paddingIter , NormalCompletion (unused )))으로 둡니다.IfAbruptCloseIterators (completion , iters ). finishResults 를 매개변수 (results )를 가지며 아무것도 캡처하지 않고 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:CreateArrayFromList (results )를 반환합니다.IteratorZip (iters , mode , padding , finishResults )를 반환합니다.
27.1.3.2.5 Iterator.zipKeyed ( iterables [ , options ] )
이 함수는 호출되면 다음 단계를 수행합니다:
iterables 가 Object가 아니면 TypeError 예외를 던집니다.options 를 ? GetOptionsObject (options )로 설정합니다.mode 를 ? Get (options , "mode" )로 둡니다.mode 가 undefined 이면 mode 를 "shortest" 로 설정합니다.mode 가 "shortest" , "longest" , "strict" 중 하나가 아니면 TypeError 예외를 던집니다.paddingOption 을 undefined 로 둡니다.mode 가 "longest" 이면, 다음을 수행합니다.paddingOption 을 ? Get (options , "padding" )으로 설정합니다.paddingOption 이 undefined 가 아니고 Object도 아니면 TypeError 예외를 던집니다.iters 를 새로운 빈 List 로 둡니다.padding 을 새로운 빈 List 로 둡니다.allKeys 를 ? iterables .[[OwnPropertyKeys]] ()로 둡니다.keys 를 새로운 빈 List 로 둡니다.allKeys 의 각 요소 key 에 대해 다음을 수행합니다.propertyDesc 를 Completion (iterables .[[GetOwnProperty]] (key ))으로 둡니다.IfAbruptCloseIterators (propertyDesc , iters ).propertyDesc 가 undefined 가 아니고 propertyDesc .[[Enumerable]] 이 true 이면, 다음을 수행합니다.value 를 Completion (Get (iterables , key ))으로 둡니다.IfAbruptCloseIterators (value , iters ).value 가 undefined 가 아니면, 다음을 수행합니다.key 를 keys 에 추가합니다.iter 를 Completion (GetIteratorFlattenable (value , reject-primitives ))으로 둡니다.IfAbruptCloseIterators (iter , iters ).iter 를 iters 에 추가합니다.iterCount 를 iters 의 요소 수로 둡니다.mode 가 "longest" 이면, 다음을 수행합니다.paddingOption 이 undefined 이면, 다음을 수행합니다.iterCount 번 반복합니다:undefined 를 padding 에 추가합니다.그렇지 않으면,keys 의 각 요소 key 에 대해 다음을 수행합니다.value 를 Completion (Get (paddingOption , key ))으로 둡니다.IfAbruptCloseIterators (value , iters ).value 를 padding 에 추가합니다. finishResults 를 매개변수 (results )를 가지며 keys 와 iterCount 를 캡처하고 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:obj 를 OrdinaryObjectCreate (null )로 둡니다.0 ≤ i < iterCount 를 만족하는 각 정수 i 에 대해 오름차순으로 다음을 수행합니다.! CreateDataPropertyOrThrow (obj , keys [i ], results [i ])를 수행합니다. obj 를 반환합니다.IteratorZip (iters , mode , padding , finishResults )를 반환합니다.
27.1.3.3 Iterator 프로토타입 객체의 프로퍼티
Iterator 프로토타입 객체 는:
참고
이 명세에서 정의되고 iterator 인터페이스 를 구현하는 모든 객체는 %Iterator.prototype%에서도 상속합니다. ECMAScript 코드도 %Iterator.prototype%에서 상속하는 객체를 정의할 수 있습니다. %Iterator.prototype%은 모든 iterator 객체에 적용할 수 있는 추가 메서드를 추가할 수 있는 위치를 제공합니다.
다음 표현식은 ECMAScript 코드가 %Iterator.prototype% 객체에 접근할 수 있는 한 가지 방법입니다:
Object .getPrototypeOf (Object .getPrototypeOf ([][Symbol .iterator ]()))
27.1.3.3.1 Iterator.prototype.chunks ( chunkSize )
이 메서드는 호출될 때 다음 단계를 수행합니다.
obj 를 this 값으로 둡니다.obj 가 Object가 아니면 TypeError 예외를 던집니다.iterated 를 Iterator 레코드 { [[Iterator]] : obj , [[NextMethod]] : undefined , [[Done]] : false }로 둡니다.chunkSize 가 정수인 Number 가 아니면 다음을 수행합니다.error 를 ThrowCompletion (새로 생성된 TypeError 객체)로 둡니다.? IteratorClose (iterated , error )를 반환합니다. chunkSize 가 1 𝔽 부터 𝔽 (232 - 1)까지 양 끝을 포함하는 구간 에 있지 않으면 다음을 수행합니다.error 를 ThrowCompletion (새로 생성된 RangeError 객체)로 둡니다.? IteratorClose (iterated , error )를 반환합니다. iterated 를 ? GetIteratorDirect (obj )로 설정합니다.closure 를 iterated 와 chunkSize 를 캡처하고 매개변수가 없으며 호출될 때 다음 단계를 수행하는 새로운 추상 클로저로 둡니다.buffer 를 새로운 빈 List 로 둡니다.다음 단계를 반복합니다.value 를 ? IteratorStepValue (iterated )로 둡니다.value 가 done 이면 다음을 수행합니다.buffer 가 비어 있지 않으면 다음을 수행합니다.Completion (Yield (CreateArrayFromList (buffer )))을 수행합니다.ReturnCompletion (undefined )를 반환합니다.value 를 buffer 에 추가합니다.buffer 의 요소 수가 ℝ (chunkSize )이면 다음을 수행합니다.completion 을 Completion (Yield (CreateArrayFromList (buffer )))으로 둡니다.IfAbruptCloseIterator (completion , iterated )를 수행합니다.buffer 를 새로운 빈 List 로 설정합니다. result 를 CreateIteratorFromClosure (closure , "Iterator Helper" , %IteratorHelperPrototype% , « [[UnderlyingIterators]] »)로 둡니다.result .[[UnderlyingIterators]] 를 « iterated »로 설정합니다.result 를 반환합니다.
27.1.3.3.2 Iterator.prototype.constructor
Iterator.prototype.constructor는 { [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖는 접근자 프로퍼티 입니다. [[Getter]] 및 [[Setter]] 속성은 다음과 같이 정의됩니다:
27.1.3.3.2.1 get Iterator.prototype.constructor
[[Getter]] 속성의 값은 인수를 요구하지 않는 내장 함수입니다. 호출되면 다음 단계를 수행합니다:
%Iterator% 를 반환합니다.
27.1.3.3.2.2 set Iterator.prototype.constructor
[[Setter]] 속성의 값은 인수 v 를 받는 내장 함수입니다. 호출되면 다음 단계를 수행합니다:
? SetterThatIgnoresPrototypeProperties (this 값, %Iterator.prototype% , "constructor" , v )를 수행합니다. undefined 를 반환합니다.
참고
대부분의 내장 프로토타입의 "constructor" 프로퍼티와 달리 웹 호환성을 위해 이 프로퍼티는 접근자여야 합니다.
27.1.3.3.3 Iterator.prototype.drop ( limit )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.obj 가 Object가 아니면 TypeError 예외를 던집니다.iterated 를 Iterator Record { [[Iterator]] : obj , [[NextMethod]] : undefined , [[Done]] : false }로 둡니다.numberLimit 을 Completion (ToNumber (limit ))으로 둡니다.IfAbruptCloseIterator (numberLimit , iterated ).numberLimit 이 NaN 이면, 다음을 수행합니다.error 를 ThrowCompletion (새로 생성된 RangeError 객체)로 둡니다.? IteratorClose (iterated , error )를 반환합니다. numberLimit 이 유한하고 numberLimit > 𝔽 (253 - 1)이면, 다음을 수행합니다.error 를 ThrowCompletion (새로 생성된 RangeError 객체)로 둡니다.? IteratorClose (iterated , error )를 반환합니다. intLimit 을 ! ToIntegerOrInfinity (numberLimit )로 둡니다.intLimit < 0이면, 다음을 수행합니다.error 를 ThrowCompletion (새로 생성된 RangeError 객체)로 둡니다.? IteratorClose (iterated , error )를 반환합니다. iterated 를 ? GetIteratorDirect (obj )로 설정합니다.closure 를 매개변수가 없고 iterated 와 intLimit 을 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:remaining 을 𝔽 (intLimit )로 둡니다.remaining > +0 𝔽 인 동안 다음을 반복합니다.remaining 을 remaining - 1 𝔽 로 설정합니다.next 를 ? IteratorStep (iterated )로 둡니다.next 가 done 이면 ReturnCompletion (undefined )을 반환합니다.다음을 반복합니다.value 를 ? IteratorStepValue (iterated )로 둡니다.value 가 done 이면 ReturnCompletion (undefined )을 반환합니다.completion 을 Completion (Yield (value ))으로 둡니다.IfAbruptCloseIterator (completion , iterated ). result 를 CreateIteratorFromClosure (closure , "Iterator Helper" , %IteratorHelperPrototype% , « [[UnderlyingIterators]] »)로 둡니다.result .[[UnderlyingIterators]] 를 « iterated »로 설정합니다.result 를 반환합니다.
27.1.3.3.4 Iterator.prototype.every ( predicate )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.obj 가 Object가 아니면 TypeError 예외를 던집니다.iterated 를 Iterator Record { [[Iterator]] : obj , [[NextMethod]] : undefined , [[Done]] : false }로 둡니다.IsCallable (predicate )이 false 이면, 다음을 수행합니다.error 를 ThrowCompletion (새로 생성된 TypeError 객체)로 둡니다.? IteratorClose (iterated , error )를 반환합니다. iterated 를 ? GetIteratorDirect (obj )로 설정합니다.counter 를 +0 𝔽 으로 둡니다.다음을 반복합니다.value 를 ? IteratorStepValue (iterated )로 둡니다.value 가 done 이면 true 를 반환합니다.result 를 Completion (Call (predicate , undefined , « value , counter »))으로 둡니다.IfAbruptCloseIterator (result , iterated ).ToBoolean (result )이 false 이면 ? IteratorClose (iterated , NormalCompletion (false ))를 반환합니다.참고 : 다음 단계는 counter 가 253 𝔽 에 도달하면 더 이상 counter 를 변경하지 않습니다.counter 를 counter + 1 𝔽 로 설정합니다.
27.1.3.3.5 Iterator.prototype.filter ( predicate )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.obj 가 Object가 아니면 TypeError 예외를 던집니다.iterated 를 Iterator Record { [[Iterator]] : obj , [[NextMethod]] : undefined , [[Done]] : false }로 둡니다.IsCallable (predicate )이 false 이면, 다음을 수행합니다.error 를 ThrowCompletion (새로 생성된 TypeError 객체)로 둡니다.? IteratorClose (iterated , error )를 반환합니다. iterated 를 ? GetIteratorDirect (obj )로 설정합니다.closure 를 매개변수가 없고 iterated 와 predicate 를 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:counter 를 +0 𝔽 으로 둡니다.다음을 반복합니다.value 를 ? IteratorStepValue (iterated )로 둡니다.value 가 done 이면 ReturnCompletion (undefined )을 반환합니다.selected 를 Completion (Call (predicate , undefined , « value , counter »))으로 둡니다.IfAbruptCloseIterator (selected , iterated ).ToBoolean (selected )이 true 이면, 다음을 수행합니다.completion 을 Completion (Yield (value ))으로 둡니다.IfAbruptCloseIterator (completion , iterated ).참고 : 다음 단계는 counter 가 253 𝔽 에 도달하면 더 이상 counter 를 변경하지 않습니다.counter 를 counter + 1 𝔽 로 설정합니다. result 를 CreateIteratorFromClosure (closure , "Iterator Helper" , %IteratorHelperPrototype% , « [[UnderlyingIterators]] »)로 둡니다.result .[[UnderlyingIterators]] 를 « iterated »로 설정합니다.result 를 반환합니다.
27.1.3.3.6 Iterator.prototype.find ( predicate )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.obj 가 Object가 아니면 TypeError 예외를 던집니다.iterated 를 Iterator Record { [[Iterator]] : obj , [[NextMethod]] : undefined , [[Done]] : false }로 둡니다.IsCallable (predicate )이 false 이면, 다음을 수행합니다.error 를 ThrowCompletion (새로 생성된 TypeError 객체)로 둡니다.? IteratorClose (iterated , error )를 반환합니다. iterated 를 ? GetIteratorDirect (obj )로 설정합니다.counter 를 +0 𝔽 으로 둡니다.다음을 반복합니다.value 를 ? IteratorStepValue (iterated )로 둡니다.value 가 done 이면 undefined 를 반환합니다.result 를 Completion (Call (predicate , undefined , « value , counter »))으로 둡니다.IfAbruptCloseIterator (result , iterated ).ToBoolean (result )이 true 이면 ? IteratorClose (iterated , NormalCompletion (value ))를 반환합니다.참고 : 다음 단계는 counter 가 253 𝔽 에 도달하면 더 이상 counter 를 변경하지 않습니다.counter 를 counter + 1 𝔽 로 설정합니다.
27.1.3.3.7 Iterator.prototype.flatMap ( mapper )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.obj 가 Object가 아니면 TypeError 예외를 던집니다.iterated 를 Iterator Record { [[Iterator]] : obj , [[NextMethod]] : undefined , [[Done]] : false }로 둡니다.IsCallable (mapper )가 false 이면, 다음을 수행합니다.error 를 ThrowCompletion (새로 생성된 TypeError 객체)로 둡니다.? IteratorClose (iterated , error )를 반환합니다. iterated 를 ? GetIteratorDirect (obj )로 설정합니다.closure 를 매개변수가 없고 iterated 와 mapper 를 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:counter 를 +0 𝔽 으로 둡니다.다음을 반복합니다.value 를 ? IteratorStepValue (iterated )로 둡니다.value 가 done 이면 ReturnCompletion (undefined )을 반환합니다.mapped 를 Completion (Call (mapper , undefined , « value , counter »))으로 둡니다.IfAbruptCloseIterator (mapped , iterated ).innerIterator 를 Completion (GetIteratorFlattenable (mapped , reject-primitives ))으로 둡니다.IfAbruptCloseIterator (innerIterator , iterated ).innerAlive 를 true 로 둡니다.innerAlive 가 true 인 동안 다음을 반복합니다.innerValue 를 Completion (IteratorStepValue (innerIterator ))으로 둡니다.IfAbruptCloseIterator (innerValue , iterated ).innerValue 가 done 이면, 다음을 수행합니다.innerAlive 를 false 로 설정합니다.그렇지 않으면,completion 을 Completion (Yield (innerValue ))으로 둡니다.completion 이 abrupt completion이면, 다음을 수행합니다.backupCompletion 을 Completion (IteratorClose (innerIterator , completion ))으로 둡니다.IfAbruptCloseIterator (backupCompletion , iterated ).? IteratorClose (iterated , completion )을 반환합니다. 참고 : 다음 단계는 counter 가 253 𝔽 에 도달하면 더 이상 counter 를 변경하지 않습니다.counter 를 counter + 1 𝔽 로 설정합니다. result 를 CreateIteratorFromClosure (closure , "Iterator Helper" , %IteratorHelperPrototype% , « [[UnderlyingIterators]] »)로 둡니다.result .[[UnderlyingIterators]] 를 « iterated »로 설정합니다.result 를 반환합니다.
27.1.3.3.8 Iterator.prototype.forEach ( procedure )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.obj 가 Object가 아니면 TypeError 예외를 던집니다.iterated 를 Iterator Record { [[Iterator]] : obj , [[NextMethod]] : undefined , [[Done]] : false }로 둡니다.IsCallable (procedure )이 false 이면, 다음을 수행합니다.error 를 ThrowCompletion (새로 생성된 TypeError 객체)로 둡니다.? IteratorClose (iterated , error )를 반환합니다. iterated 를 ? GetIteratorDirect (obj )로 설정합니다.counter 를 +0 𝔽 으로 둡니다.다음을 반복합니다.value 를 ? IteratorStepValue (iterated )로 둡니다.value 가 done 이면 undefined 를 반환합니다.result 를 Completion (Call (procedure , undefined , « value , counter »))으로 둡니다.IfAbruptCloseIterator (result , iterated ).참고 : 다음 단계는 counter 가 253 𝔽 에 도달하면 더 이상 counter 를 변경하지 않습니다.counter 를 counter + 1 𝔽 로 설정합니다.
27.1.3.3.9 Iterator.prototype.join ( separator )
이 메서드는 반복자의 값을 String으로 변환한 다음, separator 가 나타나는 부분으로 구분하여 이 String들을 연결합니다. 구분자가 제공되지 않으면 단일 쉼표가 구분자로 사용됩니다.
호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둔다.obj 가 Object가 아니면 TypeError 예외를 던진다.iterated 를 Iterator Record { [[Iterator]] : obj , [[NextMethod]] : undefined , [[Done]] : false }로 둔다.separator 가 undefined 이면,separatorString 을 "," 로 둔다.그렇지 않으면,separatorString 을 Completion (ToString (separator ))으로 둔다.IfAbruptCloseIterator (separatorString , iterated ). iterated 를 ? GetIteratorDirect (obj )로 설정한다.result 를 빈 String으로 둔다.first 를 true 로 둔다.반복한다,value 를 ? IteratorStepValue (iterated )로 둔다.value 가 done 이면 result 를 반환한다.first 가 true 이면,first 를 false 로 설정한다.그렇지 않으면,result 를 result 와 separatorString 의 string-concatenation으로 설정한다. value 가 undefined 도 null 도 아니면,valueString 을 Completion (ToString (value ))으로 둔다.IfAbruptCloseIterator (valueString , iterated ).result 를 result 와 valueString 의 string-concatenation으로 설정한다.
27.1.3.3.10 Iterator.prototype.map ( mapper )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.obj 가 Object가 아니면 TypeError 예외를 던집니다.iterated 를 Iterator Record { [[Iterator]] : obj , [[NextMethod]] : undefined , [[Done]] : false }로 둡니다.IsCallable (mapper )가 false 이면, 다음을 수행합니다.error 를 ThrowCompletion (새로 생성된 TypeError 객체)로 둡니다.? IteratorClose (iterated , error )를 반환합니다. iterated 를 ? GetIteratorDirect (obj )로 설정합니다.closure 를 매개변수가 없고 iterated 와 mapper 를 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:counter 를 +0 𝔽 으로 둡니다.다음을 반복합니다.value 를 ? IteratorStepValue (iterated )로 둡니다.value 가 done 이면 ReturnCompletion (undefined )을 반환합니다.mapped 를 Completion (Call (mapper , undefined , « value , counter »))으로 둡니다.IfAbruptCloseIterator (mapped , iterated ).completion 을 Completion (Yield (mapped ))으로 둡니다.IfAbruptCloseIterator (completion , iterated ).참고 : 다음 단계는 counter 가 253 𝔽 에 도달하면 더 이상 counter 를 변경하지 않습니다.counter 를 counter + 1 𝔽 로 설정합니다. result 를 CreateIteratorFromClosure (closure , "Iterator Helper" , %IteratorHelperPrototype% , « [[UnderlyingIterators]] »)로 둡니다.result .[[UnderlyingIterators]] 를 « iterated »로 설정합니다.result 를 반환합니다.
27.1.3.3.11 Iterator.prototype.reduce ( reducer [ , initialValue ] )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.obj 가 Object가 아니면 TypeError 예외를 던집니다.iterated 를 Iterator Record { [[Iterator]] : obj , [[NextMethod]] : undefined , [[Done]] : false }로 둡니다.IsCallable (reducer )가 false 이면, 다음을 수행합니다.error 를 ThrowCompletion (새로 생성된 TypeError 객체)로 둡니다.? IteratorClose (iterated , error )를 반환합니다. iterated 를 ? GetIteratorDirect (obj )로 설정합니다.initialValue 가 존재하지 않으면, 다음을 수행합니다.accumulator 를 ? IteratorStepValue (iterated )로 둡니다.accumulator 가 done 이면 TypeError 예외를 던집니다.counter 를 1 𝔽 로 둡니다.그렇지 않으면,accumulator 를 initialValue 로 둡니다.counter 를 +0 𝔽 으로 둡니다. 다음을 반복합니다.value 를 ? IteratorStepValue (iterated )로 둡니다.value 가 done 이면 accumulator 를 반환합니다.result 를 Completion (Call (reducer , undefined , « accumulator , value , counter »))으로 둡니다.IfAbruptCloseIterator (result , iterated ).accumulator 를 result 로 설정합니다.참고 : 다음 단계는 counter 가 253 𝔽 에 도달하면 더 이상 counter 를 변경하지 않습니다.counter 를 counter + 1 𝔽 로 설정합니다.
27.1.3.3.12 Iterator.prototype.some ( predicate )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.obj 가 Object가 아니면 TypeError 예외를 던집니다.iterated 를 Iterator Record { [[Iterator]] : obj , [[NextMethod]] : undefined , [[Done]] : false }로 둡니다.IsCallable (predicate )이 false 이면, 다음을 수행합니다.error 를 ThrowCompletion (새로 생성된 TypeError 객체)로 둡니다.? IteratorClose (iterated , error )를 반환합니다. iterated 를 ? GetIteratorDirect (obj )로 설정합니다.counter 를 +0 𝔽 으로 둡니다.다음을 반복합니다.value 를 ? IteratorStepValue (iterated )로 둡니다.value 가 done 이면 false 를 반환합니다.result 를 Completion (Call (predicate , undefined , « value , counter »))으로 둡니다.IfAbruptCloseIterator (result , iterated ).ToBoolean (result )이 true 이면 ? IteratorClose (iterated , NormalCompletion (true ))를 반환합니다.참고 : 다음 단계는 counter 가 253 𝔽 에 도달하면 더 이상 counter 를 변경하지 않습니다.counter 를 counter + 1 𝔽 로 설정합니다.
27.1.3.3.13 Iterator.prototype.take ( limit )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.obj 가 Object가 아니면 TypeError 예외를 던집니다.iterated 를 Iterator Record { [[Iterator]] : obj , [[NextMethod]] : undefined , [[Done]] : false }로 둡니다.numberLimit 을 Completion (ToNumber (limit ))으로 둡니다.IfAbruptCloseIterator (numberLimit , iterated ).numberLimit 이 NaN 이면, 다음을 수행합니다.error 를 ThrowCompletion (새로 생성된 RangeError 객체)로 둡니다.? IteratorClose (iterated , error )를 반환합니다. numberLimit 이 유한하고 numberLimit > 𝔽 (253 - 1)이면, 다음을 수행합니다.error 를 ThrowCompletion (새로 생성된 RangeError 객체)로 둡니다.? IteratorClose (iterated , error )를 반환합니다. intLimit 을 ! ToIntegerOrInfinity (numberLimit )로 둡니다.intLimit < 0이면, 다음을 수행합니다.error 를 ThrowCompletion (새로 생성된 RangeError 객체)로 둡니다.? IteratorClose (iterated , error )를 반환합니다. iterated 를 ? GetIteratorDirect (obj )로 설정합니다.closure 를 매개변수가 없고 iterated 와 intLimit 을 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:remaining 을 𝔽 (intLimit )로 둡니다.다음을 반복합니다.remaining 이 +0 𝔽 이면, 다음을 수행합니다.? IteratorClose (iterated , ReturnCompletion (undefined ))를 반환합니다. remaining 을 remaining - 1 𝔽 로 설정합니다.value 를 ? IteratorStepValue (iterated )로 둡니다.value 가 done 이면 ReturnCompletion (undefined )을 반환합니다.completion 을 Completion (Yield (value ))으로 둡니다.IfAbruptCloseIterator (completion , iterated ). result 를 CreateIteratorFromClosure (closure , "Iterator Helper" , %IteratorHelperPrototype% , « [[UnderlyingIterators]] »)로 둡니다.result .[[UnderlyingIterators]] 를 « iterated »로 설정합니다.result 를 반환합니다.
27.1.3.3.14 Iterator.prototype.toArray ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.obj 가 Object가 아니면 TypeError 예외를 던집니다.iterated 를 ? GetIteratorDirect (obj )로 둡니다.items 를 새로운 빈 List 로 둡니다.다음을 반복합니다.value 를 ? IteratorStepValue (iterated )로 둡니다.value 가 done 이면 CreateArrayFromList (items )를 반환합니다.value 를 items 에 추가합니다.
27.1.3.3.15 Iterator.prototype.windows ( windowSize [ , undersized ] )
이 메서드는 호출될 때 다음 단계를 수행합니다.
obj 를 this 값으로 둡니다.obj 가 Object가 아니면 TypeError 예외를 던집니다.iterated 를 Iterator 레코드 { [[Iterator]] : obj , [[NextMethod]] : undefined , [[Done]] : false }로 둡니다.windowSize 가 정수인 Number 가 아니면 다음을 수행합니다.error 를 ThrowCompletion (새로 생성된 TypeError 객체)로 둡니다.? IteratorClose (iterated , error )를 반환합니다. windowSize 가 1 𝔽 부터 𝔽 (232 - 1)까지 양 끝을 포함하는 구간 에 있지 않으면 다음을 수행합니다.error 를 ThrowCompletion (새로 생성된 RangeError 객체)로 둡니다.? IteratorClose (iterated , error )를 반환합니다. undersized 가 undefined 이면 undersized 를 "only-full" 로 설정합니다.undersized 가 "only-full" 도 "allow-partial" 도 아니면 다음을 수행합니다.error 를 ThrowCompletion (새로 생성된 TypeError 객체)로 둡니다.? IteratorClose (iterated , error )를 반환합니다. iterated 를 ? GetIteratorDirect (obj )로 설정합니다.closure 를 iterated , windowSize , undersized 를 캡처하고 매개변수가 없으며 호출될 때 다음 단계를 수행하는 새로운 추상 클로저로 둡니다.buffer 를 새로운 빈 List 로 둡니다.다음 단계를 반복합니다.value 를 ? IteratorStepValue (iterated )로 둡니다.value 가 done 이면 다음을 수행합니다.undersized 가 "allow-partial" 이고 buffer 가 비어 있지 않으며 buffer 의 요소 수가 < ℝ (windowSize )이면 다음을 수행합니다.Completion (Yield (CreateArrayFromList (buffer )))을 수행합니다.ReturnCompletion (undefined )를 반환합니다.buffer 의 요소 수가 ℝ (windowSize )이면 다음을 수행합니다.buffer 에서 첫 번째 요소를 제거합니다.value 를 buffer 에 추가합니다.buffer 의 요소 수가 ℝ (windowSize )이면 다음을 수행합니다.completion 을 Completion (Yield (CreateArrayFromList (buffer )))으로 둡니다.IfAbruptCloseIterator (completion , iterated )를 수행합니다. result 를 CreateIteratorFromClosure (closure , "Iterator Helper" , %IteratorHelperPrototype% , « [[UnderlyingIterators]] »)로 둡니다.result .[[UnderlyingIterators]] 를 « iterated »로 설정합니다.result 를 반환합니다.
27.1.3.3.16 Iterator.prototype [ %Symbol.dispose% ] ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.return 을 ? GetMethod (obj , "return" )으로 둡니다.return 이 undefined 가 아니면, 다음을 수행합니다.? Call (return , obj )를 수행합니다. undefined 를 반환합니다.
이 메서드의 "name" 프로퍼티 값은 "[Symbol.dispose]" 입니다.
27.1.3.3.17 Iterator.prototype [ %Symbol.iterator% ] ( )
이 함수는 호출되면 다음 단계를 수행합니다:
this 값을 반환합니다.
이 함수의 "name" 프로퍼티 값은 "[Symbol.iterator]" 입니다.
27.1.3.3.18 Iterator.prototype [ %Symbol.toStringTag% ]
Iterator.prototype[%Symbol.toStringTag%]는 { [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖는 접근자 프로퍼티 입니다. [[Getter]] 및 [[Setter]] 속성은 다음과 같이 정의됩니다:
27.1.3.3.18.1 get Iterator.prototype [ %Symbol.toStringTag% ]
[[Getter]] 속성의 값은 인수를 요구하지 않는 내장 함수입니다. 호출되면 다음 단계를 수행합니다:
"Iterator" 를 반환합니다.
27.1.3.3.18.2 set Iterator.prototype [ %Symbol.toStringTag% ]
[[Setter]] 속성의 값은 인수 v 를 받는 내장 함수입니다. 호출되면 다음 단계를 수행합니다:
? SetterThatIgnoresPrototypeProperties (this 값, %Iterator.prototype% , %Symbol.toStringTag% , v )를 수행합니다. undefined 를 반환합니다.
참고
대부분의 내장 프로토타입의 %Symbol.toStringTag% 프로퍼티와 달리 웹 호환성을 위해 이 프로퍼티는 접근자여야 합니다.
27.1.3.4 Iterator를 위한 추상 연산
27.1.3.4.1 IteratorZip ( iters , mode , padding , finishResults )
추상 연산 IteratorZip. 인수 iters (리스트 (요소: Iterator 레코드 )), mode (("shortest" , "longest" 또는 "strict" )), padding (리스트 (요소: ECMAScript 언어 값 )) 및 finishResults (an Abstract Closure that takes a List of ECMAScript language values and returns an ECMAScript language value). 반환값: Generator. 호출되면 다음 단계를 수행한다.
iterCount 를 iters 의 요소 수로 둡니다.openIters 를 iters 의 복사본으로 둡니다.closure 를 매개변수가 없고 iters , iterCount , openIters , mode , padding , finishResults 를 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:iterCount = 0이면 ReturnCompletion (undefined )을 반환합니다.다음을 반복합니다.results 를 새로운 빈 List 로 둡니다.단언 : openIters 는 비어 있지 않습니다.0 ≤ i < iterCount 를 만족하는 각 정수 i 에 대해 오름차순으로 다음을 수행합니다.iter 를 iters [i ]로 둡니다.iter 가 null 이면, 다음을 수행합니다.단언 : mode 는 "longest" 입니다.result 를 padding [i ]로 둡니다.그렇지 않으면,result 를 Completion (IteratorStepValue (iter ))으로 둡니다.result 가 abrupt completion이면, 다음을 수행합니다.iter 를 openIters 에서 제거합니다.? IteratorCloseAll (openIters , result )을 반환합니다. result 를 ! result 로 설정합니다.result 가 done 이면, 다음을 수행합니다.iter 를 openIters 에서 제거합니다.mode 가 "shortest" 이면, 다음을 수행합니다.? IteratorCloseAll (openIters , ReturnCompletion (undefined ))을 반환합니다. 그렇지 않고 mode 가 "strict" 이면, 다음을 수행합니다.i ≠ 0이면, 다음을 수행합니다.? IteratorCloseAll (openIters , ThrowCompletion (새로 생성된 TypeError 객체))를 반환합니다. 1 ≤ k < iterCount 를 만족하는 각 정수 k 에 대해 오름차순으로 다음을 수행합니다.단언 : iters [k ]는 null 이 아닙니다.open 을 Completion (IteratorStep (iters [k ]))으로 둡니다.open 이 abrupt completion이면, 다음을 수행합니다.iters [k ]를 openIters 에서 제거합니다.? IteratorCloseAll (openIters , open )을 반환합니다. open 을 ! open 으로 설정합니다.open 이 done 이면, 다음을 수행합니다.iters [k ]를 openIters 에서 제거합니다.그렇지 않으면,? IteratorCloseAll (openIters , ThrowCompletion (새로 생성된 TypeError 객체))를 반환합니다. ReturnCompletion (undefined )을 반환합니다. 그렇지 않으면,단언 : mode 는 "longest" 입니다.openIters 가 비어 있으면 ReturnCompletion (undefined )을 반환합니다.iters [i ]를 null 로 설정합니다.result 를 padding [i ]로 설정합니다. result 를 results 에 추가합니다. results 를 finishResults (results )로 설정합니다.completion 을 Completion (Yield (results ))으로 둡니다.IfAbruptCloseIterators (completion , openIters ). gen 을 CreateIteratorFromClosure (closure , "Iterator Helper" , %IteratorHelperPrototype% , « [[UnderlyingIterators]] »)로 둡니다.gen .[[UnderlyingIterators]] 를 openIters 로 설정합니다.gen 을 반환합니다.
27.1.4 %AsyncIteratorPrototype% 객체
%AsyncIteratorPrototype% 객체는:
참고
이 명세에서 정의되고 async iterator 인터페이스 를 구현하는 모든 객체는 %AsyncIteratorPrototype%에서도 상속합니다. ECMAScript 코드도 %AsyncIteratorPrototype%에서 상속하는 객체를 정의할 수 있습니다. %AsyncIteratorPrototype% 객체는 모든 async iterator 객체에 적용할 수 있는 추가 메서드를 추가할 수 있는 위치를 제공합니다.
27.1.4.1 %AsyncIteratorPrototype% [ %Symbol.asyncDispose% ] ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.promiseCapability 을 ! NewPromiseCapability (%Promise% )로 둡니다.return 을 Completion (GetMethod (obj , "return" ))으로 둡니다.IfAbruptRejectPromise (return , promiseCapability ).return 이 undefined 이면, 다음을 수행합니다.! Call (promiseCapability .[[Resolve]] , undefined , « undefined »)를 수행합니다. 그렇지 않으면,result 를 Completion (Call (return , obj , « »))으로 둡니다.IfAbruptRejectPromise (result , promiseCapability ).resultWrapper 를 Completion (PromiseResolve (%Promise% , result ))으로 둡니다.IfAbruptRejectPromise (resultWrapper , promiseCapability ).unwrap 을 매개변수가 없고 아무것도 캡처하지 않으며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:undefined 를 반환합니다.onFulfilled 를 CreateBuiltinFunction (unwrap , 1, "" , « »)로 둡니다.PerformPromiseThen (resultWrapper , onFulfilled , undefined , promiseCapability )을 수행합니다. promiseCapability .[[Promise]] 를 반환합니다.
이 메서드의 "name" 프로퍼티 값은 "[Symbol.asyncDispose]" 입니다.
27.1.4.2 %AsyncIteratorPrototype% [ %Symbol.asyncIterator% ] ( )
이 함수는 호출되면 다음 단계를 수행합니다:
this 값을 반환합니다.
이 함수의 "name" 프로퍼티 값은 "[Symbol.asyncIterator]" 입니다.
27.1.5 Async-from-Sync Iterator 객체
Async-from-Sync Iterator 객체 는 특정 동기 iterator 를 적응시키는 async iterator 입니다. Async-from-Sync Iterator 객체는 ECMAScript 코드에서 직접 접근할 수 없습니다. Async-from-Sync Iterator 객체에는 이름 있는 생성자 가 없습니다. 대신 필요할 때 CreateAsyncFromSyncIterator 추상 연산 이 Async-from-Sync Iterator 객체를 생성합니다.
27.1.5.1 CreateAsyncFromSyncIterator ( syncIteratorRecord )
추상 연산 CreateAsyncFromSyncIterator. 인수 syncIteratorRecord (Iterator 레코드 ). 반환값: Iterator 레코드 . 동기 Iterator Record 에서 async Iterator Record 를 생성하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
asyncIterator 를 OrdinaryObjectCreate (%AsyncFromSyncIteratorPrototype% , « [[SyncIteratorRecord]] »)로 둡니다.asyncIterator .[[SyncIteratorRecord]] 를 syncIteratorRecord 로 설정합니다.nextMethod 를 ! Get (asyncIterator , "next" )로 둡니다.iteratorRecord 를 Iterator Record { [[Iterator]] : asyncIterator , [[NextMethod]] : nextMethod , [[Done]] : false }로 둡니다.iteratorRecord 를 반환합니다.
27.1.5.2 %AsyncFromSyncIteratorPrototype% 객체
%AsyncFromSyncIteratorPrototype% 객체는:
27.1.5.2.1 %AsyncFromSyncIteratorPrototype%.next ( [ value ] )
obj 를 this 값으로 둡니다.단언 : obj 는 [[SyncIteratorRecord]] 내부 슬롯을 갖는 Object입니다.promiseCapability 을 ! NewPromiseCapability (%Promise% )로 둡니다.syncIteratorRecord 를 obj .[[SyncIteratorRecord]] 로 둡니다.value 가 존재하면, 다음을 수행합니다.result 를 Completion (IteratorNext (syncIteratorRecord , value ))으로 둡니다.그렇지 않으면,result 를 Completion (IteratorNext (syncIteratorRecord ))으로 둡니다. IfAbruptRejectPromise (result , promiseCapability ).AsyncFromSyncIteratorContinuation (result , promiseCapability , syncIteratorRecord , true )를 반환합니다.
27.1.5.2.2 %AsyncFromSyncIteratorPrototype%.return ( [ value ] )
obj 를 this 값으로 둡니다.단언 : obj 는 [[SyncIteratorRecord]] 내부 슬롯을 갖는 Object입니다.promiseCapability 을 ! NewPromiseCapability (%Promise% )로 둡니다.syncIteratorRecord 를 obj .[[SyncIteratorRecord]] 로 둡니다.syncIterator 를 syncIteratorRecord .[[Iterator]] 로 둡니다.return 을 Completion (GetMethod (syncIterator , "return" ))으로 둡니다.IfAbruptRejectPromise (return , promiseCapability ).return 이 undefined 이면, 다음을 수행합니다.iteratorResult 를 CreateIteratorResultObject (value , true )로 둡니다.! Call (promiseCapability .[[Resolve]] , undefined , « iteratorResult »)를 수행합니다. promiseCapability .[[Promise]] 를 반환합니다.value 가 존재하면, 다음을 수행합니다.result 를 Completion (Call (return , syncIterator , « value »))으로 둡니다.그렇지 않으면,result 를 Completion (Call (return , syncIterator ))으로 둡니다. IfAbruptRejectPromise (result , promiseCapability ).result 가 Object가 아니면, 다음을 수행합니다.! Call (promiseCapability .[[Reject]] , undefined , « 새로 생성된 TypeError 객체 »)를 수행합니다. promiseCapability .[[Promise]] 를 반환합니다.AsyncFromSyncIteratorContinuation (result , promiseCapability , syncIteratorRecord , false )를 반환합니다.
27.1.5.2.3 %AsyncFromSyncIteratorPrototype%.throw ( [ value ] )
참고
obj 를 this 값으로 둡니다.단언 : obj 는 [[SyncIteratorRecord]] 내부 슬롯을 갖는 Object입니다.promiseCapability 을 ! NewPromiseCapability (%Promise% )로 둡니다.syncIteratorRecord 를 obj .[[SyncIteratorRecord]] 로 둡니다.syncIterator 를 syncIteratorRecord .[[Iterator]] 로 둡니다.throw 를 Completion (GetMethod (syncIterator , "throw" ))으로 둡니다.IfAbruptRejectPromise (throw , promiseCapability ).throw 가 undefined 이면, 다음을 수행합니다.참고 : syncIterator 에 throw 메서드가 없으면 capability를 거부하기 전에 정리할 기회를 주기 위해 이를 닫습니다.closeCompletion 을 NormalCompletion (empty )으로 둡니다.result 를 Completion (IteratorClose (syncIteratorRecord , closeCompletion ))으로 둡니다.IfAbruptRejectPromise (result , promiseCapability ).참고 : 다음 단계에서는 프로토콜 위반, 즉 syncIterator 에 throw 메서드가 없음을 나타내기 위해 TypeError 를 던집니다.참고 : syncIterator 를 닫는 과정에서 예외가 발생하지 않으면, 거부된 promise를 산출하더라도 해당 연산의 결과는 무시됩니다.! Call (promiseCapability .[[Reject]] , undefined , « 새로 생성된 TypeError 객체 »)를 수행합니다. promiseCapability .[[Promise]] 를 반환합니다.value 가 존재하면, 다음을 수행합니다.result 를 Completion (Call (throw , syncIterator , « value »))으로 둡니다.그렇지 않으면,result 를 Completion (Call (throw , syncIterator ))으로 둡니다. IfAbruptRejectPromise (result , promiseCapability ).result 가 Object가 아니면, 다음을 수행합니다.! Call (promiseCapability .[[Reject]] , undefined , « 새로 생성된 TypeError 객체 »)를 수행합니다. promiseCapability .[[Promise]] 를 반환합니다.AsyncFromSyncIteratorContinuation (result , promiseCapability , syncIteratorRecord , true )를 반환합니다.
27.1.5.3 Async-from-Sync Iterator 인스턴스의 프로퍼티
Async-from-Sync Iterator 인스턴스는 %AsyncFromSyncIteratorPrototype% 내재 객체에서 프로퍼티를 상속하는 일반 객체 입니다. Async-from-Sync Iterator 인스턴스는 처음에 표 86 에 나열된 내부 슬롯과 함께 생성됩니다.
표 86: Async-from-Sync Iterator 인스턴스의 내부 슬롯
27.1.5.4 AsyncFromSyncIteratorContinuation ( result , promiseCapability , syncIteratorRecord , closeOnRejection )
추상 연산 AsyncFromSyncIteratorContinuation. 인수 result (Object), promiseCapability (a PromiseCapability Record for an intrinsic %Promise% ), syncIteratorRecord (Iterator 레코드 ) 및 closeOnRejection (Boolean). 반환값: Promise. 호출되면 다음 단계를 수행한다.
참고 : promiseCapability 은 내재 %Promise% 에서 파생되므로 아래에서 IfAbruptRejectPromise 를 사용함으로써 발생하는 promiseCapability .[[Reject]] 호출은 예외를 던지지 않는 것이 보장됩니다.done 을 Completion (IteratorComplete (result ))으로 둡니다.IfAbruptRejectPromise (done , promiseCapability ).value 를 Completion (IteratorValue (result ))으로 둡니다.IfAbruptRejectPromise (value , promiseCapability ).valueWrapper 를 Completion (PromiseResolve (%Promise% , value ))으로 둡니다.valueWrapper 가 abrupt completion이고 done 이 false 이며 closeOnRejection 이 true 이면, 다음을 수행합니다.valueWrapper 를 Completion (IteratorClose (syncIteratorRecord , valueWrapper ))으로 설정합니다.IfAbruptRejectPromise (valueWrapper , promiseCapability ).unwrap 을 매개변수 (value )를 가지며 done 을 캡처하고 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:CreateIteratorResultObject (value , done )를 반환합니다.onFulfilled 를 CreateBuiltinFunction (unwrap , 1, "" , « »)로 둡니다.참고 : onFulfilled 는 IteratorResult 객체의 "value" 프로퍼티를 처리할 때 그 값이 promise인 경우 기다린 뒤 결과를 새로운 “unwrapped” IteratorResult 객체로 다시 패키징하는 데 사용됩니다.done 이 true 이거나 closeOnRejection 이 false 이면, 다음을 수행합니다.onRejected 를 undefined 로 둡니다.그렇지 않으면,closeIterator 를 매개변수 (error )를 가지며 syncIteratorRecord 를 캡처하고 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:? IteratorClose (syncIteratorRecord , ThrowCompletion (error ))를 반환합니다. onRejected 를 CreateBuiltinFunction (closeIterator , 1, "" , « »)로 둡니다.참고 : onRejected 는 iterator 가 산출한 IteratorResult 객체의 "value" 프로퍼티가 거부된 promise인 경우 Iterator 를 닫는 데 사용됩니다. PerformPromiseThen (valueWrapper , onFulfilled , onRejected , promiseCapability )을 수행합니다.promiseCapability .[[Promise]] 를 반환합니다.
27.2 리소스 관리
27.2.1 공통 리소스 관리 인터페이스
27.2.1.1 Disposable 인터페이스
Disposable 인터페이스에는 표 87 에 설명된 프로퍼티가 포함됩니다:
표 87: Disposable 인터페이스 필수 프로퍼티
프로퍼티
값
요구 사항
%Symbol.dispose%
a function object
이 메서드를 호출하면 호출자가 이 객체를 계속 사용할 의도가 없음을 Disposable 객체에 알립니다. 이 메서드는 파일 시스템 핸들, 스트림, 호스트 객체 등을 포함하되 이에 국한되지 않는 리소스의 명시적 정리에 필요한 모든 로직을 수행해야 합니다. 이 메서드에서 예외가 던져지면 일반적으로 리소스를 명시적으로 해제할 수 없었음을 의미합니다.
같은 객체에서 이 메서드를 두 번 이상 호출하는 경우 이미 폐기된 리소스에 대한 정리 로직을 반복하지 않아야 하며, 첫 번째 호출에서 예외가 던져졌더라도 예외를 던져서는 안 됩니다. 그러나 이 요구 사항은 강제되지 않습니다.
Disposable 객체를 using 또는 await using 선언과 함께 사용하는 경우 선언을 직접 포함하는 Block 또는 Module 의 평가가 완료되면 리소스가 자동으로 폐기됩니다.
27.2.1.2 AsyncDisposable 인터페이스
AsyncDisposable 인터페이스에는 표 88 에 설명된 프로퍼티가 포함됩니다:
표 88: AsyncDisposable 인터페이스 필수 프로퍼티
프로퍼티
값
요구 사항
%Symbol.asyncDispose%
a function object that returns a promise
이 메서드를 호출하면 호출자가 이 객체를 계속 사용할 의도가 없음을 AsyncDisposable 객체에 알립니다. 이 메서드는 파일 시스템 핸들, 스트림, 호스트 객체 등을 포함하되 이에 국한되지 않는 리소스의 명시적 정리에 필요한 모든 로직을 수행해야 합니다. 이 메서드가 반환한 promise가 거부되면 일반적으로 리소스를 명시적으로 해제할 수 없었음을 의미합니다. 결과 Promise가 이행될 때까지 AsyncDisposable 객체는 “폐기된” 것으로 간주되지 않습니다.
같은 객체에서 이 메서드를 두 번 이상 호출하는 경우 이미 폐기된 리소스에 대한 정리 로직을 반복하지 않아야 하며, 첫 번째 호출에서 예외가 던져지거나 거부된 promise가 반환되었더라도 예외를 던지거나 거부된 promise를 반환해서는 안 됩니다. 그러나 이 요구 사항은 강제되지 않습니다.
AsyncDisposable 객체를 await using 선언과 함께 사용하는 경우 선언을 직접 포함하는 Block 또는 Module 의 평가가 완료되면 리소스가 자동으로 폐기됩니다.
27.3 DisposableStack 객체
DisposableStack은 함께 폐기해야 하는 하나 이상의 리소스를 포함하는 데 사용할 수 있는 객체입니다.
모든 DisposableStack 객체는 서로 배타적인 두 상태 중 하나에 있습니다: disposed 또는 pending . disposable stack d에 대해 d.dispose()와 d.move() 어느 것도 호출되지 않은 경우에만 d는 pending입니다.
27.3.1 DisposableStack 생성자
DisposableStack 생성자 는:
%DisposableStack% 입니다.
전역 객체 의 "DisposableStack" 프로퍼티의 초기 값입니다.
생성자 로 호출되면 새로운 DisposableStack을 생성하고 초기화합니다.
함수로 호출하도록 의도되지 않았으며 그러한 방식으로 호출되면 예외를 던집니다.
클래스 정의의 extends 절에서 값으로 사용할 수 있습니다. 지정된 DisposableStack 동작을 상속하려는 하위 클래스 생성자 는 DisposableStack.prototype의 내장 메서드를 지원하는 데 필요한 내부 상태로 하위 클래스 인스턴스를 생성하고 초기화하기 위해 DisposableStack 생성자 에 대한 super 호출을 포함해야 합니다.
27.3.1.1 DisposableStack ( )
이 함수는 호출되면 다음 단계를 수행합니다:
NewTarget이 undefined 이면 TypeError 예외를 던집니다. disposableStack 을 ? OrdinaryCreateFromConstructor (NewTarget, "%DisposableStack.prototype%" , « [[DisposableState]] , [[DisposableResourceStack]] »)로 둡니다.disposableStack .[[DisposableState]] 를 pending 으로 설정합니다.disposableStack .[[DisposableResourceStack]] 을 새로운 빈 List 로 설정합니다.disposableStack 을 반환합니다.
27.3.2 DisposableStack 생성자의 프로퍼티
DisposableStack 생성자 는:
27.3.2.1 DisposableStack.prototype
DisposableStack.prototype의 초기 값은 DisposableStack 프로토타입 객체 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
27.3.3 DisposableStack 프로토타입 객체의 프로퍼티
DisposableStack 프로토타입 객체 는:
%DisposableStack.prototype% 입니다.
값이 %Object.prototype% 인 [[Prototype]] 내부 슬롯을 갖습니다.
일반 객체 입니다.
[[DisposableState]] 내부 슬롯 또는 DisposableStack 인스턴스의 다른 내부 슬롯을 갖지 않습니다.
27.3.3.1 DisposableStack.prototype.adopt ( value , onDispose )
이 메서드는 호출되면 다음 단계를 수행합니다:
disposableStack 을 this 값으로 둡니다.? RequireInternalSlot (disposableStack , [[DisposableState]] )를 수행합니다. disposableStack .[[DisposableState]] 가 disposed 이면 ReferenceError 예외를 던집니다.IsCallable (onDispose )이 false 이면 TypeError 예외를 던집니다.closure 를 매개변수가 없고 value 와 onDispose 를 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:? Call (onDispose , undefined , « value »)를 반환합니다. func 를 CreateBuiltinFunction (closure , 0, "" , « »)로 둡니다.? AddDisposableResource (disposableStack .[[DisposableResourceStack]] , undefined , sync-dispose , func )를 수행합니다. value 를 반환합니다.
27.3.3.2 DisposableStack.prototype.constructor
DisposableStack.prototype.constructor의 초기 값은 %DisposableStack% 입니다.
27.3.3.3 DisposableStack.prototype.defer ( onDispose )
이 메서드는 호출되면 다음 단계를 수행합니다:
disposableStack 을 this 값으로 둡니다.? RequireInternalSlot (disposableStack , [[DisposableState]] )를 수행합니다. disposableStack .[[DisposableState]] 가 disposed 이면 ReferenceError 예외를 던집니다.IsCallable (onDispose )이 false 이면 TypeError 예외를 던집니다.? AddDisposableResource (disposableStack .[[DisposableResourceStack]] , undefined , sync-dispose , onDispose )를 수행합니다. undefined 를 반환합니다.
27.3.3.4 DisposableStack.prototype.dispose ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
disposableStack 을 this 값으로 둡니다.? RequireInternalSlot (disposableStack , [[DisposableState]] )를 수행합니다. disposableStack .[[DisposableState]] 가 disposed 이면 undefined 를 반환합니다.disposableStack .[[DisposableState]] 를 disposed 로 설정합니다.? DisposeResources (disposableStack .[[DisposableResourceStack]] , NormalCompletion (undefined ))를 반환합니다.
27.3.3.5 get DisposableStack.prototype.disposed
DisposableStack.prototype.disposed는 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
disposableStack 을 this 값으로 둡니다.? RequireInternalSlot (disposableStack , [[DisposableState]] )를 수행합니다. disposableStack .[[DisposableState]] 가 disposed 이면 true 를 반환합니다.false 를 반환합니다.
27.3.3.6 DisposableStack.prototype.move ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
disposableStack 을 this 값으로 둡니다.? RequireInternalSlot (disposableStack , [[DisposableState]] )를 수행합니다. disposableStack .[[DisposableState]] 가 disposed 이면 ReferenceError 예외를 던집니다.newDisposableStack 을 ? OrdinaryCreateFromConstructor (%DisposableStack% , "%DisposableStack.prototype%" , « [[DisposableState]] , [[DisposableResourceStack]] »)로 둡니다.newDisposableStack .[[DisposableState]] 를 pending 으로 설정합니다.newDisposableStack .[[DisposableResourceStack]] 을 disposableStack .[[DisposableResourceStack]] 으로 설정합니다.disposableStack .[[DisposableResourceStack]] 을 새로운 빈 List 로 설정합니다.disposableStack .[[DisposableState]] 를 disposed 로 설정합니다.newDisposableStack 을 반환합니다.
27.3.3.7 DisposableStack.prototype.use ( value )
이 메서드는 호출되면 다음 단계를 수행합니다:
disposableStack 을 this 값으로 둡니다.? RequireInternalSlot (disposableStack , [[DisposableState]] )를 수행합니다. disposableStack .[[DisposableState]] 가 disposed 이면 ReferenceError 예외를 던집니다.? AddDisposableResource (disposableStack .[[DisposableResourceStack]] , value , sync-dispose )를 수행합니다. value 를 반환합니다.
27.3.3.8 DisposableStack.prototype [ %Symbol.dispose% ] ( )
%Symbol.dispose% 프로퍼티의 초기 값은 27.3.3.4 에 정의된 %DisposableStack.prototype.dispose%입니다.
27.3.3.9 DisposableStack.prototype [ %Symbol.toStringTag% ]
%Symbol.toStringTag% 프로퍼티의 초기 값은 String 값 "DisposableStack" 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
27.3.4 DisposableStack 인스턴스의 프로퍼티
DisposableStack 인스턴스는 DisposableStack 프로토타입 객체 (내재 %DisposableStack.prototype% )에서 프로퍼티를 상속하는 일반 객체 입니다. DisposableStack 인스턴스는 처음에 표 89 에 설명된 내부 슬롯과 함께 생성됩니다.
표 89: DisposableStack 인스턴스의 내부 슬롯
내부 슬롯
타입
설명
[[DisposableState]]
pending or disposed
disposable stack이 %Symbol.dispose% 메서드에 대한 들어오는 호출에 어떻게 반응할지를 제어합니다.
[[DisposableResourceStack]]
a List of DisposableResource Records
disposable stack이 폐기될 때 폐기해야 하는 리소스입니다. 리소스는 초기화되는 순서로 추가되며 역순으로 폐기됩니다.
27.4 AsyncDisposableStack 객체
AsyncDisposableStack은 함께 비동기적으로 폐기해야 하는 하나 이상의 리소스를 포함하는 데 사용할 수 있는 객체입니다.
모든 AsyncDisposableStack 객체는 서로 배타적인 두 상태 중 하나에 있습니다: disposed 또는 pending . async-disposable stack d에 대해 d.disposeAsync()와 d.move() 어느 것도 호출되지 않은 경우에만 d는 pending입니다.
27.4.1 AsyncDisposableStack 생성자
AsyncDisposableStack 생성자 는:
%AsyncDisposableStack% 입니다.
전역 객체 의 "AsyncDisposableStack" 프로퍼티의 초기 값입니다.
생성자 로 호출되면 새로운 AsyncDisposableStack을 생성하고 초기화합니다.
함수로 호출하도록 의도되지 않았으며 그러한 방식으로 호출되면 예외를 던집니다.
클래스 정의의 extends 절에서 값으로 사용할 수 있습니다. 지정된 AsyncDisposableStack 동작을 상속하려는 하위 클래스 생성자 는 AsyncDisposableStack.prototype의 내장 메서드를 지원하는 데 필요한 내부 상태로 하위 클래스 인스턴스를 생성하고 초기화하기 위해 AsyncDisposableStack 생성자 에 대한 super 호출을 포함해야 합니다.
27.4.1.1 AsyncDisposableStack ( )
이 함수는 호출되면 다음 단계를 수행합니다:
NewTarget이 undefined 이면 TypeError 예외를 던집니다. asyncDisposableStack 을 ? OrdinaryCreateFromConstructor (NewTarget, "%AsyncDisposableStack.prototype%" , « [[AsyncDisposableState]] , [[DisposableResourceStack]] »)로 둡니다.asyncDisposableStack .[[AsyncDisposableState]] 를 pending 으로 설정합니다.asyncDisposableStack .[[DisposableResourceStack]] 을 새로운 빈 List 로 설정합니다.asyncDisposableStack 을 반환합니다.
27.4.2 AsyncDisposableStack 생성자의 프로퍼티
AsyncDisposableStack 생성자 는:
27.4.2.1 AsyncDisposableStack.prototype
AsyncDisposableStack.prototype의 초기 값은 AsyncDisposableStack 프로토타입 객체 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
27.4.3 AsyncDisposableStack 프로토타입 객체의 프로퍼티
AsyncDisposableStack 프로토타입 객체 는:
%AsyncDisposableStack.prototype% 입니다.
값이 %Object.prototype% 인 [[Prototype]] 내부 슬롯을 갖습니다.
일반 객체 입니다.
[[AsyncDisposableState]] 내부 슬롯 또는 AsyncDisposableStack 인스턴스의 다른 내부 슬롯을 갖지 않습니다.
27.4.3.1 AsyncDisposableStack.prototype.adopt ( value , onDisposeAsync )
이 메서드는 호출되면 다음 단계를 수행합니다:
asyncDisposableStack 을 this 값으로 둡니다.? RequireInternalSlot (asyncDisposableStack , [[AsyncDisposableState]] )를 수행합니다. asyncDisposableStack .[[AsyncDisposableState]] 가 disposed 이면 ReferenceError 예외를 던집니다.IsCallable (onDisposeAsync )가 false 이면 TypeError 예외를 던집니다.closure 를 매개변수가 없고 value 와 onDisposeAsync 를 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:? Call (onDisposeAsync , undefined , « value »)를 반환합니다. func 를 CreateBuiltinFunction (closure , 0, "" , « »)로 둡니다.? AddDisposableResource (asyncDisposableStack .[[DisposableResourceStack]] , undefined , async-dispose , func )를 수행합니다. value 를 반환합니다.
27.4.3.2 AsyncDisposableStack.prototype.constructor
AsyncDisposableStack.prototype.constructor의 초기 값은 %AsyncDisposableStack% 입니다.
27.4.3.3 AsyncDisposableStack.prototype.defer ( onDisposeAsync )
이 메서드는 호출되면 다음 단계를 수행합니다:
asyncDisposableStack 을 this 값으로 둡니다.? RequireInternalSlot (asyncDisposableStack , [[AsyncDisposableState]] )를 수행합니다. asyncDisposableStack .[[AsyncDisposableState]] 가 disposed 이면 ReferenceError 예외를 던집니다.IsCallable (onDisposeAsync )가 false 이면 TypeError 예외를 던집니다.? AddDisposableResource (asyncDisposableStack .[[DisposableResourceStack]] , undefined , async-dispose , onDisposeAsync )를 수행합니다. undefined 를 반환합니다.
27.4.3.4 AsyncDisposableStack.prototype.disposeAsync ( )
이 async 메서드는 호출되면 다음 단계를 수행합니다:
asyncDisposableStack 을 this 값으로 둡니다.? RequireInternalSlot (asyncDisposableStack , [[AsyncDisposableState]] )를 수행합니다. asyncDisposableStack .[[AsyncDisposableState]] 가 disposed 이면 undefined 를 반환합니다.asyncDisposableStack .[[AsyncDisposableState]] 를 disposed 로 설정합니다.? DisposeResources (asyncDisposableStack .[[DisposableResourceStack]] , NormalCompletion (undefined ))를 반환합니다.
27.4.3.5 get AsyncDisposableStack.prototype.disposed
AsyncDisposableStack.prototype.disposed는 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
asyncDisposableStack 을 this 값으로 둡니다.? RequireInternalSlot (asyncDisposableStack , [[AsyncDisposableState]] )를 수행합니다. asyncDisposableStack .[[AsyncDisposableState]] 가 disposed 이면 true 를 반환합니다.false 를 반환합니다.
27.4.3.6 AsyncDisposableStack.prototype.move ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
asyncDisposableStack 을 this 값으로 둡니다.? RequireInternalSlot (asyncDisposableStack , [[AsyncDisposableState]] )를 수행합니다. asyncDisposableStack .[[AsyncDisposableState]] 가 disposed 이면 ReferenceError 예외를 던집니다.newAsyncDisposableStack 을 ? OrdinaryCreateFromConstructor (%AsyncDisposableStack% , "%AsyncDisposableStack.prototype%" , « [[AsyncDisposableState]] , [[DisposableResourceStack]] »)로 둡니다.newAsyncDisposableStack .[[AsyncDisposableState]] 를 pending 으로 설정합니다.newAsyncDisposableStack .[[DisposableResourceStack]] 을 asyncDisposableStack .[[DisposableResourceStack]] 으로 설정합니다.asyncDisposableStack .[[DisposableResourceStack]] 을 새로운 빈 List 로 설정합니다.asyncDisposableStack .[[AsyncDisposableState]] 를 disposed 로 설정합니다.newAsyncDisposableStack 을 반환합니다.
27.4.3.7 AsyncDisposableStack.prototype.use ( value )
이 메서드는 호출되면 다음 단계를 수행합니다:
asyncDisposableStack 을 this 값으로 둡니다.? RequireInternalSlot (asyncDisposableStack , [[AsyncDisposableState]] )를 수행합니다. asyncDisposableStack .[[AsyncDisposableState]] 가 disposed 이면 ReferenceError 예외를 던집니다.? AddDisposableResource (asyncDisposableStack .[[DisposableResourceStack]] , value , async-dispose )를 수행합니다. value 를 반환합니다.
27.4.3.8 AsyncDisposableStack.prototype [ %Symbol.asyncDispose% ] ( )
%Symbol.asyncDispose% 프로퍼티의 초기 값은 27.4.3.4 에 정의된 %AsyncDisposableStack.prototype.disposeAsync%입니다.
27.4.3.9 AsyncDisposableStack.prototype [ %Symbol.toStringTag% ]
%Symbol.toStringTag% 프로퍼티의 초기 값은 String 값 "AsyncDisposableStack" 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
27.4.4 AsyncDisposableStack 인스턴스의 프로퍼티
AsyncDisposableStack 인스턴스는 AsyncDisposableStack 프로토타입 객체 (내재 %AsyncDisposableStack.prototype% )에서 프로퍼티를 상속하는 일반 객체 입니다. AsyncDisposableStack 인스턴스는 처음에 표 90 에 설명된 내부 슬롯과 함께 생성됩니다.
표 90: AsyncDisposableStack 인스턴스의 내부 슬롯
내부 슬롯
타입
설명
[[AsyncDisposableState]]
pending or disposed
disposable stack이 %Symbol.asyncDispose% 메서드에 대한 들어오는 호출에 어떻게 반응할지를 제어합니다.
[[DisposableResourceStack]]
a List of DisposableResource Records
disposable stack이 폐기될 때 폐기해야 하는 리소스입니다. 리소스는 초기화되는 순서로 추가되며 역순으로 폐기됩니다.
27.5 Promise 객체
Promise는 지연된(그리고 비동기일 수 있는) 계산의 최종 결과를 위한 자리 표시자로 사용되는 객체입니다.
모든 Promise는 서로 배타적인 세 상태 중 하나에 있습니다: fulfilled , rejected , pending :
promise p에 대해 p.then(f, r)이 함수 f를 호출하는 Job 을 즉시 큐에 넣는다면 p는 fulfilled입니다.
promise p에 대해 p.then(f, r)이 함수 r을 호출하는 Job 을 즉시 큐에 넣는다면 p는 rejected입니다.
promise가 fulfilled도 rejected도 아니면 pending입니다.
promise가 pending이 아니면, 즉 fulfilled 또는 rejected이면 settled 되었다고 합니다.
promise가 settled되었거나 다른 promise의 상태와 일치하도록 “고정”된 경우 resolved 되었다고 합니다. resolved promise를 다시 resolve하거나 reject하려고 해도 아무 효과가 없습니다. promise가 resolved되지 않았다면 unresolved 입니다. unresolved promise는 항상 pending 상태입니다. resolved promise는 pending, fulfilled 또는 rejected일 수 있습니다.
thenable 은 Get (obj , "then" )이 function object를 반환하는 객체 obj 입니다.
27.5.1 Promise 추상 연산
27.5.1.1 PromiseCapability Records
PromiseCapability Record 는 Promise 또는 promise와 유사한 객체와 함께 해당 promise를 resolve하거나 reject할 수 있는 함수를 캡슐화하는 데 사용되는 Record 입니다. PromiseCapability Records는 NewPromiseCapability 추상 연산 에 의해 생성됩니다.
PromiseCapability Records에는 표 91 에 나열된 필드가 있습니다.
표 91: PromiseCapability Record 필드
필드 이름
값
의미
[[Promise]]
an Object
promise로 사용할 수 있는 객체입니다.
[[Resolve]]
a function object
주어진 promise를 resolve하는 데 사용되는 함수입니다.
[[Reject]]
a function object
주어진 promise를 reject하는 데 사용되는 함수입니다.
27.5.1.1.1 IfAbruptRejectPromise ( value , capability )
IfAbruptRejectPromise는 PromiseCapability Record 를 사용하는 일련의 알고리즘 단계에 대한 축약 표현입니다. 다음 형식의 알고리즘 단계:
IfAbruptRejectPromise (value , capability ).
는 다음과 같은 의미입니다:
단언 : value 는 Completion Record 입니다.value 가 abrupt completion이면, 다음을 수행합니다.? Call (capability .[[Reject]] , undefined , « value .[[Value]] »)를 수행합니다. capability .[[Promise]] 를 반환합니다.value 를 ! value 로 설정합니다.
27.5.1.2 PromiseReaction Records
PromiseReaction Record 는 promise가 주어진 값으로 resolve되거나 reject될 때 어떻게 반응해야 하는지에 대한 정보를 저장하는 데 사용되는 Record 입니다. PromiseReaction Records는 PerformPromiseThen 추상 연산 에 의해 생성되며 NewPromiseReactionJob 이 반환하는 Abstract Closure 에서 사용됩니다.
PromiseReaction Records에는 표 92 에 나열된 필드가 있습니다.
표 92: PromiseReaction Record 필드
필드 이름
값
의미
[[Capability]]
a PromiseCapability Record or undefined
이 Record 가 reaction handler를 제공하는 promise의 capability입니다.
[[Type]]
fulfill or reject
[[Handler]] 가 empty 일 때 settlement type에 특화된 동작을 허용하기 위해 [[Type]] 을 사용합니다.
[[Handler]]
a JobCallback Record or empty
들어오는 값에 적용해야 하는 함수이며 그 반환 값에 따라 파생 promise에 어떤 일이 발생할지가 결정됩니다. [[Handler]] 가 empty 이면 대신 [[Type]] 값에 따라 달라지는 함수를 사용합니다.
27.5.1.3 CreateResolvingFunctions ( toResolve )
추상 연산 CreateResolvingFunctions. 인수 toResolve (Promise). 반환값: 레코드 (필드: [[Resolve]] (함수 객체 ), [[Reject]] (함수 객체 )). 호출되면 다음 단계를 수행한다.
promiseOrEmpty 를 Record { [[Value]] : toResolve }로 둡니다.resolveSteps 를 매개변수 (resolution )을 가지며 promiseOrEmpty 를 캡처하고 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:promiseOrEmpty .[[Value]] 가 empty 이면 undefined 를 반환합니다.promise 를 promiseOrEmpty .[[Value]] 로 둡니다.promiseOrEmpty .[[Value]] 를 empty 로 설정합니다.SameValue (resolution , promise )가 true 이면, 다음을 수행합니다.selfResolutionError 를 새로 생성된 TypeError 객체로 둡니다.RejectPromise (promise , selfResolutionError )를 수행합니다.undefined 를 반환합니다.resolution 이 Object가 아니면, 다음을 수행합니다.FulfillPromise (promise , resolution )을 수행합니다.undefined 를 반환합니다.then 을 Completion (Get (resolution , "then" ))으로 둡니다.then 이 abrupt completion이면, 다음을 수행합니다.RejectPromise (promise , then .[[Value]] )를 수행합니다.undefined 를 반환합니다.thenAction 을 then .[[Value]] 로 둡니다.IsCallable (thenAction )이 false 이면, 다음을 수행합니다.FulfillPromise (promise , resolution )을 수행합니다.undefined 를 반환합니다.thenJobCallback 을 HostMakeJobCallback (thenAction )으로 둡니다.job 을 NewPromiseResolveThenableJob (promise , resolution , thenJobCallback )으로 둡니다.HostEnqueuePromiseJob (job .[[Job]] , job .[[Realm]] )을 수행합니다.undefined 를 반환합니다.resolve 를 CreateBuiltinFunction (resolveSteps , 1, "" , « »)로 둡니다.rejectSteps 를 매개변수 (reason )을 가지며 promiseOrEmpty 를 캡처하고 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:promiseOrEmpty .[[Value]] 가 empty 이면 undefined 를 반환합니다.promise 를 promiseOrEmpty .[[Value]] 로 둡니다.promiseOrEmpty .[[Value]] 를 empty 로 설정합니다.RejectPromise (promise , reason )을 수행합니다.undefined 를 반환합니다.reject 를 CreateBuiltinFunction (rejectSteps , 1, "" , « »)로 둡니다.Record { [[Resolve]] : resolve , [[Reject]] : reject }를 반환합니다.
27.5.1.4 FulfillPromise ( promise , value )
추상 연산 FulfillPromise. 인수 promise (Promise) 및 value (ECMAScript 언어 값 ). 반환값: unused . 호출되면 다음 단계를 수행한다.
단언 : promise .[[PromiseState]] 는 pending 입니다.reactions 를 promise .[[PromiseFulfillReactions]] 로 둡니다.promise .[[PromiseResult]] 를 value 로 설정합니다.promise .[[PromiseFulfillReactions]] 를 undefined 로 설정합니다.promise .[[PromiseRejectReactions]] 를 undefined 로 설정합니다.promise .[[PromiseState]] 를 fulfilled 로 설정합니다.TriggerPromiseReactions (reactions , value )를 수행합니다.unused 를 반환합니다.
27.5.1.5 NewPromiseCapability ( ctor )
추상 연산 NewPromiseCapability. 인수 ctor (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: PromiseCapability 레코드 ) 또는 throw 완료 ). 내장 Promise 생성자 와 같은 방식으로 ctor 를 생성자 로 사용하여 promise를 생성하고 그 resolve 및 reject 함수를 추출하려고 시도합니다. promise와 resolve, reject 함수는 새로운 PromiseCapability Record 를 초기화하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.
IsConstructor (ctor )가 false 이면 TypeError 예외를 던집니다.참고 : ctor 는 Promise 생성자 의 매개변수 규약을 지원하는 생성자 함수라고 가정합니다(27.5.3.1 참조).resolvingFuncs 를 Record { [[Resolve]] : undefined , [[Reject]] : undefined }로 둡니다.executorClosure 를 매개변수 (resolve , reject )를 가지며 resolvingFuncs 를 캡처하고 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:resolvingFuncs .[[Resolve]] 가 undefined 가 아니면 TypeError 예외를 던집니다.resolvingFuncs .[[Reject]] 가 undefined 가 아니면 TypeError 예외를 던집니다.resolvingFuncs .[[Resolve]] 를 resolve 로 설정합니다.resolvingFuncs .[[Reject]] 를 reject 로 설정합니다.NormalCompletion (undefined )을 반환합니다.executor 를 CreateBuiltinFunction (executorClosure , 2, "" , « »)로 둡니다.promise 를 ? Construct (ctor , « executor »)로 둡니다.IsCallable (resolvingFuncs .[[Resolve]] )가 false 이면 TypeError 예외를 던집니다.IsCallable (resolvingFuncs .[[Reject]] )가 false 이면 TypeError 예외를 던집니다.PromiseCapability Record { [[Promise]] : promise , [[Resolve]] : resolvingFuncs .[[Resolve]] , [[Reject]] : resolvingFuncs .[[Reject]] }를 반환합니다.
참고
이 추상 연산 은 전달된 executor 함수 인수를 Promise 생성자 와 같은 방식으로 호출하는 모든 생성자 에 대해 일반적으로 동작하므로 Promise 하위 클래싱을 지원합니다. Promise 생성자 의 정적 메서드를 모든 하위 클래스로 일반화하는 데 사용됩니다.
27.5.1.6 IsPromise ( arg )
추상 연산 IsPromise. 인수 arg (ECMAScript 언어 값 ). 반환값: Boolean. 객체에 promise 브랜드가 있는지 검사합니다. 호출되면 다음 단계를 수행한다.
arg 가 Object가 아니면 false 를 반환합니다.arg 에 [[PromiseState]] 내부 슬롯이 없으면 false 를 반환합니다.true 를 반환합니다.
27.5.1.7 RejectPromise ( promise , reason )
추상 연산 RejectPromise. 인수 promise (Promise) 및 reason (ECMAScript 언어 값 ). 반환값: unused . 호출되면 다음 단계를 수행한다.
단언 : promise .[[PromiseState]] 는 pending 입니다.reactions 를 promise .[[PromiseRejectReactions]] 로 둡니다.promise .[[PromiseResult]] 를 reason 으로 설정합니다.promise .[[PromiseFulfillReactions]] 를 undefined 로 설정합니다.promise .[[PromiseRejectReactions]] 를 undefined 로 설정합니다.promise .[[PromiseState]] 를 rejected 로 설정합니다.promise .[[PromiseIsHandled]] 가 false 이면 HostPromiseRejectionTracker (promise , "reject" )를 수행합니다.TriggerPromiseReactions (reactions , reason )을 수행합니다.unused 를 반환합니다.
27.5.1.8 TriggerPromiseReactions ( reactions , arg )
추상 연산 TriggerPromiseReactions. 인수 reactions (리스트 (요소: PromiseReaction 레코드 )) 및 arg (ECMAScript 언어 값 ). 반환값: unused . reactions 의 각 Record 에 대해 새로운 Job 을 큐에 넣습니다. 각 Job 은 PromiseReaction Record 의 [[Type]] 및 [[Handler]] 를 처리하고, [[Handler]] 가 empty 가 아니면 주어진 인수를 전달하여 호출합니다. [[Handler]] 가 empty 이면 동작은 [[Type]] 에 의해 결정됩니다. 호출되면 다음 단계를 수행한다.
reactions 의 각 요소 reaction 에 대해 다음을 수행합니다.job 을 NewPromiseReactionJob (reaction , arg )으로 둡니다.HostEnqueuePromiseJob (job .[[Job]] , job .[[Realm]] )을 수행합니다.unused 를 반환합니다.
27.5.1.9 HostPromiseRejectionTracker ( promise , operation )
호스트 정의 추상 연산 HostPromiseRejectionTracker. 인수 promise (Promise) 및 operation (("reject" 또는 "handle" )). 반환값: unused . 호스트 환경 이 promise rejection을 추적할 수 있도록 합니다.
HostPromiseRejectionTracker의 기본 구현은 unused 를 반환하는 것입니다.
참고 1
HostPromiseRejectionTracker는 두 가지 상황에서 호출됩니다:
promise가 handler 없이 reject되면 operation 인수를 "reject" 로 설정하여 호출합니다.
reject된 promise에 처음으로 handler가 추가되면 operation 인수를 "handle" 로 설정하여 호출합니다.
일반적인 HostPromiseRejectionTracker 구현은 처리되지 않은 rejection을 개발자에게 알리려고 하면서도, 나중에 새로운 handler가 연결되어 이전 알림이 더 이상 유효하지 않게 된 경우에도 이를 알리도록 주의할 수 있습니다.
참고 2
operation 이 "handle" 이면 구현체는 가비지 컬렉션을 방해하는 방식으로 promise 에 대한 참조를 유지해서는 안 됩니다. operation 이 "reject" 이면 rejection은 드물고 핫 코드 경로에 있지 않을 것으로 예상되므로 구현체는 promise 에 대한 참조를 유지할 수 있습니다.
27.5.2 Promise 작업
27.5.2.1 NewPromiseReactionJob ( reaction , arg )
추상 연산 NewPromiseReactionJob. 인수 reaction (PromiseReaction 레코드 ) 및 arg (ECMAScript 언어 값 ). 반환값: 레코드 (필드: [[Job]] (a Job Abstract Closure ), [[Realm]] ((Realm 레코드 또는 null ))). 들어오는 값에 적절한 handler를 적용하고 handler의 반환 값을 사용하여 해당 handler와 연결된 파생 promise를 resolve하거나 reject하는 새로운 Job Abstract Closure 를 반환합니다. 호출되면 다음 단계를 수행한다.
job 을 매개변수가 없고 reaction 과 arg 를 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Job Abstract Closure 로 둡니다:promiseCapability 을 reaction .[[Capability]] 로 둡니다.type 을 reaction .[[Type]] 으로 둡니다.handler 를 reaction .[[Handler]] 로 둡니다.handler 가 empty 이면, 다음을 수행합니다.type 이 fulfill 이면, 다음을 수행합니다.handlerResult 를 NormalCompletion (arg )으로 둡니다.그렇지 않으면,단언 : type 은 reject 입니다.handlerResult 를 ThrowCompletion (arg )으로 둡니다. 그렇지 않으면,handlerResult 를 Completion (HostCallJobCallback (handler , undefined , « arg »))으로 둡니다. promiseCapability 이 undefined 이면, 다음을 수행합니다.단언 : handlerResult 는 abrupt completion이 아닙니다.empty 를 반환합니다.단언 : promiseCapability 은 PromiseCapability Record 입니다.handlerResult 가 abrupt completion이면, 다음을 수행합니다.? Call (promiseCapability .[[Reject]] , undefined , « handlerResult .[[Value]] »)를 반환합니다. ? Call (promiseCapability .[[Resolve]] , undefined , « handlerResult .[[Value]] »)를 반환합니다. handlerRealm 을 null 로 둡니다.reaction .[[Handler]] 가 empty 가 아니면, 다음을 수행합니다.getHandlerRealmResult 를 Completion (GetFunctionRealm (reaction .[[Handler]] .[[Callback]] ))으로 둡니다.getHandlerRealmResult 가 normal completion이면 handlerRealm 을 getHandlerRealmResult .[[Value]] 로 설정합니다.그렇지 않으면 handlerRealm 을 현재 Realm Record 로 설정합니다. 참고 : handler가 undefined 인 경우를 제외하면 handlerRealm 은 절대 null 이 아닙니다. handler가 폐기된 Proxy이고 ECMAScript 코드가 실행되지 않는 경우 handlerRealm 은 오류 객체를 생성하는 데 사용됩니다.Record { [[Job]] : job , [[Realm]] : handlerRealm }를 반환합니다.
27.5.2.2 NewPromiseResolveThenableJob ( promiseToResolve , thenable , then )
추상 연산 NewPromiseResolveThenableJob. 인수 promiseToResolve (Promise), thenable (Object) 및 then (JobCallback 레코드 ). 반환값: 레코드 (필드: [[Job]] (a Job Abstract Closure ), [[Realm]] (Realm 레코드 )). 호출되면 다음 단계를 수행한다.
job 을 매개변수가 없고 promiseToResolve , thenable , then 을 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Job Abstract Closure 로 둡니다:resolvingFuncs 를 CreateResolvingFunctions (promiseToResolve )로 둡니다.thenCallResult 를 Completion (HostCallJobCallback (then , thenable , « resolvingFuncs .[[Resolve]] , resolvingFuncs .[[Reject]] »))으로 둡니다.thenCallResult 가 abrupt completion이면, 다음을 수행합니다.? Call (resolvingFuncs .[[Reject]] , undefined , « thenCallResult .[[Value]] »)를 반환합니다. ! thenCallResult 를 반환합니다. getThenRealmResult 를 Completion (GetFunctionRealm (then .[[Callback]] ))으로 둡니다.getThenRealmResult 가 normal completion이면 thenRealm 을 getThenRealmResult .[[Value]] 로 둡니다.그렇지 않으면 thenRealm 을 현재 Realm Record 로 둡니다. 참고 : thenRealm 은 절대 null 이 아닙니다. then .[[Callback]] 이 폐기된 Proxy이고 코드가 실행되지 않는 경우 thenRealm 은 오류 객체를 생성하는 데 사용됩니다.Record { [[Job]] : job , [[Realm]] : thenRealm }를 반환합니다.
참고
이 Job 은 제공된 thenable 과 그 then 메서드를 사용하여 주어진 promise를 resolve합니다. then 메서드의 평가가 주변 코드의 평가가 완료된 후에 발생하도록 보장하기 위해 이 과정은 Job 으로 수행되어야 합니다.
27.5.3 Promise 생성자
Promise 생성자 는:
%Promise% 입니다.
전역 객체 의 "Promise" 프로퍼티의 초기 값입니다.
생성자 로 호출되면 새로운 Promise를 생성하고 초기화합니다.
함수로 호출하도록 의도되지 않았으며 그러한 방식으로 호출되면 예외를 던집니다.
클래스 정의의 extends 절에서 값으로 사용할 수 있습니다. 지정된 Promise 동작을 상속하려는 하위 클래스 생성자 는 Promise 및 Promise.prototype의 내장 메서드를 지원하는 데 필요한 내부 상태로 하위 클래스 인스턴스를 생성하고 초기화하기 위해 Promise 생성자 에 대한 super 호출을 포함해야 합니다.
27.5.3.1 Promise ( executor )
이 함수는 호출되면 다음 단계를 수행합니다:
NewTarget이 undefined 이면 TypeError 예외를 던집니다. IsCallable (executor )이 false 이면 TypeError 예외를 던집니다.promise 를 ? OrdinaryCreateFromConstructor (NewTarget, "%Promise.prototype%" , « [[PromiseState]] , [[PromiseResult]] , [[PromiseFulfillReactions]] , [[PromiseRejectReactions]] , [[PromiseIsHandled]] »)로 둡니다.promise .[[PromiseState]] 를 pending 으로 설정합니다.promise .[[PromiseResult]] 를 empty 로 설정합니다.promise .[[PromiseFulfillReactions]] 를 새로운 빈 List 로 설정합니다.promise .[[PromiseRejectReactions]] 를 새로운 빈 List 로 설정합니다.promise .[[PromiseIsHandled]] 를 false 로 설정합니다.resolvingFuncs 를 CreateResolvingFunctions (promise )로 둡니다.completion 을 Completion (Call (executor , undefined , « resolvingFuncs .[[Resolve]] , resolvingFuncs .[[Reject]] »))으로 둡니다.completion 이 abrupt completion이면, 다음을 수행합니다.? Call (resolvingFuncs .[[Reject]] , undefined , « completion .[[Value]] »)를 수행합니다. promise 를 반환합니다.
참고
executor 인수는 function object여야 합니다. 이 Promise가 나타내는 지연될 수 있는 동작의 시작과 완료를 보고하기 위해 호출됩니다. executor는 두 인수 resolve 와 reject 로 호출됩니다. 이 함수들은 executor 함수가 지연된 계산의 최종 완료 또는 실패를 보고하는 데 사용할 수 있습니다. executor 함수에서 반환한다고 해서 지연된 동작이 완료되었다는 의미는 아니며, 단지 지연된 동작을 최종적으로 수행하라는 요청이 수락되었다는 의미입니다.
executor 함수에 전달되는 resolve 함수는 하나의 인수를 받습니다. executor 코드는 연결된 Promise를 resolve하려 함을 나타내기 위해 최종적으로 resolve 함수를 호출할 수 있습니다. resolve 함수에 전달되는 인수는 지연된 동작의 최종 값을 나타내며 실제 이행 값이거나, 이행되면 값을 제공할 다른 promise일 수 있습니다.
executor 함수에 전달되는 reject 함수는 하나의 인수를 받습니다. executor 코드는 연결된 Promise가 reject되었고 절대 fulfilled되지 않을 것임을 나타내기 위해 최종적으로 reject 함수를 호출할 수 있습니다. reject 함수에 전달되는 인수는 promise의 rejection 값으로 사용됩니다. 일반적으로 Error 객체입니다.
Promise 생성자 가 executor 함수에 전달하는 resolve 및 reject 함수는 연결된 promise를 실제로 resolve하고 reject할 수 있습니다. 하위 클래스는 resolve 및 reject에 사용자 정의 값을 전달하는 다른 생성자 동작을 가질 수 있습니다.
27.5.4 Promise 생성자의 프로퍼티
Promise 생성자 는:
27.5.4.1 Promise.all ( iterable )
이 함수는 전달된 promise들의 이행 값 배열로 fulfilled되는 새로운 promise를 반환하거나, 처음 reject된 전달 promise의 이유로 reject됩니다. 이 알고리즘을 실행하면서 전달된 iterable 의 모든 요소를 promise로 resolve합니다.
ctor 를 this 값으로 둡니다.promiseCapability 을 ? NewPromiseCapability (ctor )로 둡니다.promiseResolve 를 Completion (GetPromiseResolve (ctor ))으로 둡니다.IfAbruptRejectPromise (promiseResolve , promiseCapability ).iteratorRecord 를 Completion (GetIterator (iterable , sync ))으로 둡니다.IfAbruptRejectPromise (iteratorRecord , promiseCapability ).result 를 Completion (PerformPromiseAll (iteratorRecord , ctor , promiseCapability , promiseResolve ))으로 둡니다.result 가 abrupt completion이면, 다음을 수행합니다.iteratorRecord .[[Done]] 이 false 이면 result 를 Completion (IteratorClose (iteratorRecord , result ))으로 설정합니다.IfAbruptRejectPromise (result , promiseCapability ).! result 를 반환합니다.
참고
이 함수의 this 값은 Promise 생성자 의 매개변수 규약을 지원하는 생성자 함수여야 합니다.
27.5.4.1.1 GetPromiseResolve ( promiseCtor )
추상 연산 GetPromiseResolve. 인수 promiseCtor (생성자 ). 반환값: (정상 완료 (값: 함수 객체 ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
promiseResolve 를 ? Get (promiseCtor , "resolve" )로 둡니다.IsCallable (promiseResolve )가 false 이면 TypeError 예외를 던집니다.promiseResolve 를 반환합니다.
27.5.4.1.2 PerformPromiseAll ( iteratorRecord , ctor , resultCapability , promiseResolve )
추상 연산 PerformPromiseAll. 인수 iteratorRecord (Iterator 레코드 ), ctor (생성자 ), resultCapability (PromiseCapability 레코드 ) 및 promiseResolve (함수 객체 ). 반환값: (정상 완료 (값: Object) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
values 를 새로운 빈 List 로 둡니다.참고 : 입력 iterator 가 소진되기 전에 전달된 콜백을 호출하는 잘못 동작하는 "then" 이 존재하더라도 resultCapability .[[Resolve]] 가 한 번만 호출되도록 remainingElementsCount 는 0이 아니라 1에서 시작합니다.remainingElementsCount 를 Record { [[Value]] : 1 }로 둡니다.index 를 0으로 둡니다.다음을 반복합니다.next 를 ? IteratorStepValue (iteratorRecord )로 둡니다.next 가 done 이면, 다음을 수행합니다.remainingElementsCount .[[Value]] 를 remainingElementsCount .[[Value]] - 1로 설정합니다.remainingElementsCount .[[Value]] = 0이면, 다음을 수행합니다.valuesArray 를 CreateArrayFromList (values )로 둡니다.? Call (resultCapability .[[Resolve]] , undefined , « valuesArray »)를 수행합니다. resultCapability .[[Promise]] 를 반환합니다.undefined 를 values 에 추가합니다.nextPromise 를 ? Call (promiseResolve , ctor , « next »)로 둡니다.fulfilledSteps 를 매개변수 (value )를 가지며 values , resultCapability , remainingElementsCount 를 캡처하고 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:activeFunc 를 활성 함수 객체 로 둡니다.activeFunc .[[AlreadyCalled]] 가 true 이면 undefined 를 반환합니다.activeFunc .[[AlreadyCalled]] 를 true 로 설정합니다.thisIndex 를 activeFunc .[[Index]] 로 둡니다.values [thisIndex ]를 value 로 설정합니다.remainingElementsCount .[[Value]] 를 remainingElementsCount .[[Value]] - 1로 설정합니다.remainingElementsCount .[[Value]] = 0이면, 다음을 수행합니다.valuesArray 를 CreateArrayFromList (values )로 둡니다.? Call (resultCapability .[[Resolve]] , undefined , « valuesArray »)를 반환합니다. undefined 를 반환합니다.onFulfilled 를 CreateBuiltinFunction (fulfilledSteps , 1, "" , « [[AlreadyCalled]] , [[Index]] »)로 둡니다.onFulfilled .[[AlreadyCalled]] 를 false 로 설정합니다.onFulfilled .[[Index]] 를 index 로 설정합니다.index 를 index + 1로 설정합니다.remainingElementsCount .[[Value]] 를 remainingElementsCount .[[Value]] + 1로 설정합니다.? Invoke (nextPromise , "then" , « onFulfilled , resultCapability .[[Reject]] »)를 수행합니다.
27.5.4.2 Promise.allSettled ( iterable )
이 함수는 원래의 모든 promise가 settled된 후, 즉 fulfilled 또는 rejected가 된 후에만 promise 상태 스냅샷의 배열로 fulfilled되는 promise를 반환합니다. 이 알고리즘을 실행하면서 전달된 iterable 의 모든 요소를 promise로 resolve합니다.
ctor 를 this 값으로 둡니다.promiseCapability 을 ? NewPromiseCapability (ctor )로 둡니다.promiseResolve 를 Completion (GetPromiseResolve (ctor ))으로 둡니다.IfAbruptRejectPromise (promiseResolve , promiseCapability ).iteratorRecord 를 Completion (GetIterator (iterable , sync ))으로 둡니다.IfAbruptRejectPromise (iteratorRecord , promiseCapability ).result 를 Completion (PerformPromiseAllSettled (iteratorRecord , ctor , promiseCapability , promiseResolve ))으로 둡니다.result 가 abrupt completion이면, 다음을 수행합니다.iteratorRecord .[[Done]] 이 false 이면 result 를 Completion (IteratorClose (iteratorRecord , result ))으로 설정합니다.IfAbruptRejectPromise (result , promiseCapability ).! result 를 반환합니다.
참고
이 함수의 this 값은 Promise 생성자 의 매개변수 규약을 지원하는 생성자 함수여야 합니다.
27.5.4.2.1 PerformPromiseAllSettled ( iteratorRecord , ctor , resultCapability , promiseResolve )
추상 연산 PerformPromiseAllSettled. 인수 iteratorRecord (Iterator 레코드 ), ctor (생성자 ), resultCapability (PromiseCapability 레코드 ) 및 promiseResolve (함수 객체 ). 반환값: (정상 완료 (값: Object) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
values 를 새로운 빈 List 로 둡니다.참고 : 입력 iterator 가 소진되기 전에 전달된 콜백 중 하나를 호출하는 잘못 동작하는 "then" 이 존재하더라도 resultCapability .[[Resolve]] 가 한 번만 호출되도록 remainingElementsCount 는 0이 아니라 1에서 시작합니다.remainingElementsCount 를 Record { [[Value]] : 1 }로 둡니다.index 를 0으로 둡니다.다음을 반복합니다.next 를 ? IteratorStepValue (iteratorRecord )로 둡니다.next 가 done 이면, 다음을 수행합니다.remainingElementsCount .[[Value]] 를 remainingElementsCount .[[Value]] - 1로 설정합니다.remainingElementsCount .[[Value]] = 0이면, 다음을 수행합니다.valuesArray 를 CreateArrayFromList (values )로 둡니다.? Call (resultCapability .[[Resolve]] , undefined , « valuesArray »)를 수행합니다. resultCapability .[[Promise]] 를 반환합니다.undefined 를 values 에 추가합니다.nextPromise 를 ? Call (promiseResolve , ctor , « next »)로 둡니다.alreadyCalled 를 Record { [[Value]] : false }로 둡니다.fulfilledSteps 를 매개변수 (value )를 가지며 values , resultCapability , remainingElementsCount 를 캡처하고 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:activeFunc 를 활성 함수 객체 로 둡니다.activeFunc .[[AlreadyCalled]] .[[Value]] 가 true 이면 undefined 를 반환합니다.activeFunc .[[AlreadyCalled]] .[[Value]] 를 true 로 설정합니다.obj 를 OrdinaryObjectCreate (%Object.prototype% )로 둡니다.! CreateDataPropertyOrThrow (obj , "status" , "fulfilled" )를 수행합니다. ! CreateDataPropertyOrThrow (obj , "value" , value )를 수행합니다. thisIndex 를 activeFunc .[[Index]] 로 둡니다.values [thisIndex ]를 obj 로 설정합니다.remainingElementsCount .[[Value]] 를 remainingElementsCount .[[Value]] - 1로 설정합니다.remainingElementsCount .[[Value]] = 0이면, 다음을 수행합니다.valuesArray 를 CreateArrayFromList (values )로 둡니다.? Call (resultCapability .[[Resolve]] , undefined , « valuesArray »)를 반환합니다. undefined 를 반환합니다.onFulfilled 를 CreateBuiltinFunction (fulfilledSteps , 1, "" , « [[AlreadyCalled]] , [[Index]] »)로 둡니다.onFulfilled .[[AlreadyCalled]] 를 alreadyCalled 로 설정합니다.onFulfilled .[[Index]] 를 index 로 설정합니다.rejectedSteps 를 매개변수 (error )를 가지며 values , resultCapability , remainingElementsCount 를 캡처하고 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:activeFunc 를 활성 함수 객체 로 둡니다.activeFunc .[[AlreadyCalled]] .[[Value]] 가 true 이면 undefined 를 반환합니다.activeFunc .[[AlreadyCalled]] .[[Value]] 를 true 로 설정합니다.obj 를 OrdinaryObjectCreate (%Object.prototype% )로 둡니다.! CreateDataPropertyOrThrow (obj , "status" , "rejected" )를 수행합니다. ! CreateDataPropertyOrThrow (obj , "reason" , error )를 수행합니다. thisIndex 를 activeFunc .[[Index]] 로 둡니다.values [thisIndex ]를 obj 로 설정합니다.remainingElementsCount .[[Value]] 를 remainingElementsCount .[[Value]] - 1로 설정합니다.remainingElementsCount .[[Value]] = 0이면, 다음을 수행합니다.valuesArray 를 CreateArrayFromList (values )로 둡니다.? Call (resultCapability .[[Resolve]] , undefined , « valuesArray »)를 반환합니다. undefined 를 반환합니다.onRejected 를 CreateBuiltinFunction (rejectedSteps , 1, "" , « [[AlreadyCalled]] , [[Index]] »)로 둡니다.onRejected .[[AlreadyCalled]] 를 alreadyCalled 로 설정합니다.onRejected .[[Index]] 를 index 로 설정합니다.index 를 index + 1로 설정합니다.remainingElementsCount .[[Value]] 를 remainingElementsCount .[[Value]] + 1로 설정합니다.? Invoke (nextPromise , "then" , « onFulfilled , onRejected »)를 수행합니다.
27.5.4.3 Promise.any ( iterable )
이 함수는 주어진 promise 중 처음으로 fulfilled되는 promise에 의해 fulfilled되는 promise를 반환하거나, 주어진 모든 promise가 rejected되면 rejection 이유를 보유하는 AggregateError로 rejected됩니다. 이 알고리즘을 실행하면서 전달된 iterable 의 모든 요소를 promise로 resolve합니다.
ctor 를 this 값으로 둡니다.promiseCapability 을 ? NewPromiseCapability (ctor )로 둡니다.promiseResolve 를 Completion (GetPromiseResolve (ctor ))으로 둡니다.IfAbruptRejectPromise (promiseResolve , promiseCapability ).iteratorRecord 를 Completion (GetIterator (iterable , sync ))으로 둡니다.IfAbruptRejectPromise (iteratorRecord , promiseCapability ).result 를 Completion (PerformPromiseAny (iteratorRecord , ctor , promiseCapability , promiseResolve ))으로 둡니다.result 가 abrupt completion이면, 다음을 수행합니다.iteratorRecord .[[Done]] 이 false 이면 result 를 Completion (IteratorClose (iteratorRecord , result ))으로 설정합니다.IfAbruptRejectPromise (result , promiseCapability ).! result 를 반환합니다.
참고
이 함수의 this 값은 Promise 생성자 의 매개변수 규약을 지원하는 생성자 함수여야 합니다.
27.5.4.3.1 PerformPromiseAny ( iteratorRecord , ctor , resultCapability , promiseResolve )
추상 연산 PerformPromiseAny. 인수 iteratorRecord (Iterator 레코드 ), ctor (생성자 ), resultCapability (PromiseCapability 레코드 ) 및 promiseResolve (함수 객체 ). 반환값: (정상 완료 (값: Object) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
errors 를 새로운 빈 List 로 둡니다.참고 : 입력 iterator 가 소진되기 전에 전달된 콜백을 호출하는 잘못 동작하는 "then" 이 존재하더라도 resultCapability .[[Reject]] 가 한 번만 호출되도록 remainingElementsCount 는 0이 아니라 1에서 시작합니다.remainingElementsCount 를 Record { [[Value]] : 1 }로 둡니다.index 를 0으로 둡니다.다음을 반복합니다.next 를 ? IteratorStepValue (iteratorRecord )로 둡니다.next 가 done 이면, 다음을 수행합니다.remainingElementsCount .[[Value]] 를 remainingElementsCount .[[Value]] - 1로 설정합니다.remainingElementsCount .[[Value]] = 0이면, 다음을 수행합니다.aggregateError 를 새로 생성된 AggregateError 객체로 둡니다.! DefinePropertyOrThrow (aggregateError , "errors" , PropertyDescriptor { [[Configurable]] : true , [[Enumerable]] : false , [[Writable]] : true , [[Value]] : CreateArrayFromList (errors ) })를 수행합니다. ? Call (resultCapability .[[Reject]] , undefined , « aggregateError »)를 수행합니다. resultCapability .[[Promise]] 를 반환합니다.undefined 를 errors 에 추가합니다.nextPromise 를 ? Call (promiseResolve , ctor , « next »)로 둡니다.rejectedSteps 를 매개변수 (error )를 가지며 errors , resultCapability , remainingElementsCount 를 캡처하고 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:activeFunc 를 활성 함수 객체 로 둡니다.activeFunc .[[AlreadyCalled]] 가 true 이면 undefined 를 반환합니다.activeFunc .[[AlreadyCalled]] 를 true 로 설정합니다.thisIndex 를 activeFunc .[[Index]] 로 둡니다.errors [thisIndex ]를 error 로 설정합니다.remainingElementsCount .[[Value]] 를 remainingElementsCount .[[Value]] - 1로 설정합니다.remainingElementsCount .[[Value]] = 0이면, 다음을 수행합니다.aggregateError 를 새로 생성된 AggregateError 객체로 둡니다.! DefinePropertyOrThrow (aggregateError , "errors" , PropertyDescriptor { [[Configurable]] : true , [[Enumerable]] : false , [[Writable]] : true , [[Value]] : CreateArrayFromList (errors ) })를 수행합니다. ? Call (resultCapability .[[Reject]] , undefined , « aggregateError »)를 반환합니다. undefined 를 반환합니다.onRejected 를 CreateBuiltinFunction (rejectedSteps , 1, "" , « [[AlreadyCalled]] , [[Index]] »)로 둡니다.onRejected .[[AlreadyCalled]] 를 false 로 설정합니다.onRejected .[[Index]] 를 index 로 설정합니다.index 를 index + 1로 설정합니다.remainingElementsCount .[[Value]] 를 remainingElementsCount .[[Value]] + 1로 설정합니다.? Invoke (nextPromise , "then" , « resultCapability .[[Resolve]] , onRejected »)를 수행합니다.
27.5.4.4 Promise.prototype
Promise.prototype의 초기 값은 Promise 프로토타입 객체 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
27.5.4.5 Promise.race ( iterable )
이 함수는 전달된 promise 중 처음 settled되는 promise와 같은 방식으로 settled되는 새로운 promise를 반환합니다. 이 알고리즘을 실행하면서 전달된 iterable 의 모든 요소를 promise로 resolve합니다.
ctor 를 this 값으로 둡니다.promiseCapability 을 ? NewPromiseCapability (ctor )로 둡니다.promiseResolve 를 Completion (GetPromiseResolve (ctor ))으로 둡니다.IfAbruptRejectPromise (promiseResolve , promiseCapability ).iteratorRecord 를 Completion (GetIterator (iterable , sync ))으로 둡니다.IfAbruptRejectPromise (iteratorRecord , promiseCapability ).result 를 Completion (PerformPromiseRace (iteratorRecord , ctor , promiseCapability , promiseResolve ))으로 둡니다.result 가 abrupt completion이면, 다음을 수행합니다.iteratorRecord .[[Done]] 이 false 이면 result 를 Completion (IteratorClose (iteratorRecord , result ))으로 설정합니다.IfAbruptRejectPromise (result , promiseCapability ).! result 를 반환합니다.
참고 1
iterable 인수가 값을 산출하지 않거나 iterable 이 산출한 promise 중 어느 것도 절대 settled되지 않으면 이 메서드가 반환한 pending promise도 절대 settled되지 않습니다.
참고 2
이 함수는 this 값이 Promise 생성자 의 매개변수 규약을 지원하는 생성자 함수일 것으로 기대합니다. 또한 this 값이 resolve 메서드를 제공할 것으로 기대합니다.
27.5.4.5.1 PerformPromiseRace ( iteratorRecord , ctor , resultCapability , promiseResolve )
추상 연산 PerformPromiseRace. 인수 iteratorRecord (Iterator 레코드 ), ctor (생성자 ), resultCapability (PromiseCapability 레코드 ) 및 promiseResolve (함수 객체 ). 반환값: (정상 완료 (값: Object) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
다음을 반복합니다.next 를 ? IteratorStepValue (iteratorRecord )로 둡니다.next 가 done 이면, 다음을 수행합니다.resultCapability .[[Promise]] 를 반환합니다.nextPromise 를 ? Call (promiseResolve , ctor , « next »)로 둡니다.? Invoke (nextPromise , "then" , « resultCapability .[[Resolve]] , resultCapability .[[Reject]] »)를 수행합니다.
27.5.4.6 Promise.reject ( reason )
이 함수는 전달된 인수로 rejected된 새로운 promise를 반환합니다.
ctor 를 this 값으로 둡니다.promiseCapability 을 ? NewPromiseCapability (ctor )로 둡니다.? Call (promiseCapability .[[Reject]] , undefined , « reason »)를 수행합니다. promiseCapability .[[Promise]] 를 반환합니다.
참고
이 함수는 this 값이 Promise 생성자 의 매개변수 규약을 지원하는 생성자 함수일 것으로 기대합니다.
27.5.4.7 Promise.resolve ( resolution )
이 함수는 전달된 인수로 resolve된 새로운 promise를 반환하거나, 인수가 이 생성자 가 생성한 promise라면 인수 자체를 반환합니다.
ctor 를 this 값으로 둡니다.ctor 가 Object가 아니면 TypeError 예외를 던집니다.? PromiseResolve (ctor , resolution )을 반환합니다.
참고
이 함수는 this 값이 Promise 생성자 의 매개변수 규약을 지원하는 생성자 함수일 것으로 기대합니다.
27.5.4.7.1 PromiseResolve ( ctor , resolution )
추상 연산 PromiseResolve. 인수 ctor (Object) 및 resolution (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: Object) 또는 throw 완료 ). resolution 으로 resolve된 새로운 promise를 반환합니다. 호출되면 다음 단계를 수행한다.
IsPromise (resolution )이 true 이면, 다음을 수행합니다.resolutionCtor 를 ? Get (resolution , "constructor" )로 둡니다.SameValue (resolutionCtor , ctor )가 true 이면 resolution 을 반환합니다.promiseCapability 을 ? NewPromiseCapability (ctor )로 둡니다.? Call (promiseCapability .[[Resolve]] , undefined , « resolution »)를 수행합니다. promiseCapability .[[Promise]] 를 반환합니다.
27.5.4.8 Promise.try ( callback , ...args )
이 함수는 호출되면 다음 단계를 수행합니다:
ctor 를 this 값으로 둡니다.ctor 가 Object가 아니면 TypeError 예외를 던집니다.status 를 Completion (Call (callback , undefined , args ))으로 둡니다.status 가 abrupt completion이면, 다음을 수행합니다.promiseCapability 을 ? NewPromiseCapability (ctor )로 둡니다.? Call (promiseCapability .[[Reject]] , undefined , « status .[[Value]] »)를 수행합니다. promiseCapability .[[Promise]] 를 반환합니다.그렇지 않으면,? PromiseResolve (ctor , ! status )를 반환합니다.
참고
이 함수는 this 값이 Promise 생성자 의 매개변수 규약을 지원하는 생성자 함수일 것으로 기대합니다.
27.5.4.9 Promise.withResolvers ( )
이 함수는 세 프로퍼티, 즉 새로운 promise와 그에 연결된 resolve 및 reject 함수를 갖는 객체를 반환합니다.
ctor 를 this 값으로 둡니다.promiseCapability 을 ? NewPromiseCapability (ctor )로 둡니다.obj 를 OrdinaryObjectCreate (%Object.prototype% )로 둡니다.! CreateDataPropertyOrThrow (obj , "promise" , promiseCapability .[[Promise]] )를 수행합니다. ! CreateDataPropertyOrThrow (obj , "resolve" , promiseCapability .[[Resolve]] )를 수행합니다. ! CreateDataPropertyOrThrow (obj , "reject" , promiseCapability .[[Reject]] )를 수행합니다. obj 를 반환합니다.
27.5.4.10 get Promise [ %Symbol.species% ]
Promise[%Symbol.species%]는 set 접근자 함수가 undefined 인 접근자 프로퍼티 입니다. get 접근자 함수는 호출되면 다음 단계를 수행합니다:
this 값을 반환합니다.
이 함수의 "name" 프로퍼티 값은 "get [Symbol.species]" 입니다.
참고
Promise 프로토타입 메서드는 일반적으로 this 값의 생성자 를 사용하여 파생 객체를 생성합니다. 그러나 하위 클래스 생성자 는 자신의 %Symbol.species% 프로퍼티를 재정의하여 기본 동작을 재정의할 수 있습니다.
27.5.5 Promise 프로토타입 객체의 프로퍼티
Promise 프로토타입 객체 는:
%Promise.prototype% 입니다.
값이 %Object.prototype% 인 [[Prototype]] 내부 슬롯을 갖습니다.
일반 객체 입니다.
[[PromiseState]] 내부 슬롯 또는 Promise 인스턴스의 다른 내부 슬롯을 갖지 않습니다.
27.5.5.1 Promise.prototype.catch ( onRejected )
이 메서드는 호출되면 다음 단계를 수행합니다:
promise 를 this 값으로 둡니다.? Invoke (promise , "then" , « undefined , onRejected »)를 반환합니다.
27.5.5.2 Promise.prototype.constructor
Promise.prototype.constructor의 초기 값은 %Promise% 입니다.
27.5.5.3 Promise.prototype.finally ( onFinally )
이 메서드는 호출되면 다음 단계를 수행합니다:
promise 를 this 값으로 둡니다.promise 가 Object가 아니면 TypeError 예외를 던집니다.ctor 를 ? SpeciesConstructor (promise , %Promise% )로 둡니다.단언 : IsConstructor (ctor )는 true 입니다.IsCallable (onFinally )가 false 이면, 다음을 수행합니다.thenFinally 를 onFinally 로 둡니다.catchFinally 를 onFinally 로 둡니다.그렇지 않으면,thenFinallyClosure 를 매개변수 (value )를 가지며 onFinally 와 ctor 를 캡처하고 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:result 를 ? Call (onFinally , undefined )로 둡니다.p 를 ? PromiseResolve (ctor , result )로 둡니다.returnValue 를 매개변수가 없고 value 를 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:NormalCompletion (value )을 반환합니다.valueThunk 를 CreateBuiltinFunction (returnValue , 0, "" , « »)로 둡니다.? Invoke (p , "then" , « valueThunk »)를 반환합니다. thenFinally 를 CreateBuiltinFunction (thenFinallyClosure , 1, "" , « »)로 둡니다.catchFinallyClosure 를 매개변수 (reason )을 가지며 onFinally 와 ctor 를 캡처하고 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:result 를 ? Call (onFinally , undefined )로 둡니다.p 를 ? PromiseResolve (ctor , result )로 둡니다.throwReason 을 매개변수가 없고 reason 을 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:reason 을 던집니다.thrower 를 CreateBuiltinFunction (throwReason , 0, "" , « »)로 둡니다.? Invoke (p , "then" , « thrower »)를 반환합니다. catchFinally 를 CreateBuiltinFunction (catchFinallyClosure , 1, "" , « »)로 둡니다. ? Invoke (promise , "then" , « thenFinally , catchFinally »)를 반환합니다.
27.5.5.4 Promise.prototype.then ( onFulfilled , onRejected )
이 메서드는 호출되면 다음 단계를 수행합니다:
promise 를 this 값으로 둡니다.IsPromise (promise )가 false 이면 TypeError 예외를 던집니다.ctor 를 ? SpeciesConstructor (promise , %Promise% )로 둡니다.resultCapability 을 ? NewPromiseCapability (ctor )로 둡니다.PerformPromiseThen (promise , onFulfilled , onRejected , resultCapability )을 반환합니다.
27.5.5.4.1 PerformPromiseThen ( promise , onFulfilled , onRejected [ , resultCapability ] )
추상 연산 PerformPromiseThen. 인수 promise (Promise), onFulfilled (ECMAScript 언어 값 ) 및 onRejected (ECMAScript 언어 값 ) 및 선택적 인수 resultCapability (PromiseCapability 레코드 ). 반환값: (Object 또는 undefined ). onFulfilled 와 onRejected 를 settlement 동작으로 사용하여 promise 에 “then” 연산을 수행합니다. resultCapability 이 전달되면 resultCapability 의 promise를 업데이트하여 결과를 저장합니다. 전달되지 않으면 결과가 중요하지 않은 명세 내부 연산에서 PerformPromiseThen이 호출된 것입니다. 호출되면 다음 단계를 수행한다.
단언 : IsPromise (promise )는 true 입니다.resultCapability 이 존재하지 않으면, 다음을 수행합니다.resultCapability 을 undefined 로 설정합니다.IsCallable (onFulfilled )가 false 이면, 다음을 수행합니다.onFulfilledJobCallback 을 empty 로 둡니다.그렇지 않으면,onFulfilledJobCallback 을 HostMakeJobCallback (onFulfilled )으로 둡니다. IsCallable (onRejected )가 false 이면, 다음을 수행합니다.onRejectedJobCallback 을 empty 로 둡니다.그렇지 않으면,onRejectedJobCallback 을 HostMakeJobCallback (onRejected )으로 둡니다. fulfillReaction 을 PromiseReaction Record { [[Capability]] : resultCapability , [[Type]] : fulfill , [[Handler]] : onFulfilledJobCallback }로 둡니다.rejectReaction 을 PromiseReaction Record { [[Capability]] : resultCapability , [[Type]] : reject , [[Handler]] : onRejectedJobCallback }로 둡니다.promise .[[PromiseState]] 가 pending 이면, 다음을 수행합니다.fulfillReaction 을 promise .[[PromiseFulfillReactions]] 에 추가합니다.rejectReaction 을 promise .[[PromiseRejectReactions]] 에 추가합니다.그렇지 않고 promise .[[PromiseState]] 가 fulfilled 이면, 다음을 수행합니다.value 를 promise .[[PromiseResult]] 로 둡니다.fulfillJob 을 NewPromiseReactionJob (fulfillReaction , value )로 둡니다.HostEnqueuePromiseJob (fulfillJob .[[Job]] , fulfillJob .[[Realm]] )을 수행합니다. 그렇지 않으면,단언 : promise .[[PromiseState]] 는 rejected 입니다.reason 을 promise .[[PromiseResult]] 로 둡니다.promise .[[PromiseIsHandled]] 가 false 이면 HostPromiseRejectionTracker (promise , "handle" )를 수행합니다.rejectJob 을 NewPromiseReactionJob (rejectReaction , reason )으로 둡니다.HostEnqueuePromiseJob (rejectJob .[[Job]] , rejectJob .[[Realm]] )을 수행합니다. promise .[[PromiseIsHandled]] 를 true 로 설정합니다.resultCapability 이 undefined 이면 undefined 를 반환합니다.resultCapability .[[Promise]] 를 반환합니다.
27.5.5.5 Promise.prototype [ %Symbol.toStringTag% ]
%Symbol.toStringTag% 프로퍼티의 초기 값은 String 값 "Promise" 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
27.5.6 Promise 인스턴스의 프로퍼티
Promise 인스턴스는 Promise 프로토타입 객체 (내재 %Promise.prototype% )에서 프로퍼티를 상속하는 일반 객체 입니다. Promise 인스턴스는 처음에 표 93 에 설명된 내부 슬롯과 함께 생성됩니다.
표 93: Promise 인스턴스의 내부 슬롯
내부 슬롯
타입
설명
[[PromiseState]]
pending , fulfilled , or rejected
promise가 then 메서드에 대한 들어오는 호출에 어떻게 반응할지를 제어합니다.
[[PromiseResult]]
an ECMAScript language value or empty
promise가 fulfilled 또는 rejected된 값입니다. 값이 있을 경우에 해당합니다. [[PromiseState]] 가 pending 인 경우에만 empty 입니다.
[[PromiseFulfillReactions]]
a List of PromiseReaction Records
promise가 pending 상태에서 fulfilled 상태로 전환될 때 처리할 Record 입니다.
[[PromiseRejectReactions]]
a List of PromiseReaction Records
promise가 pending 상태에서 rejected 상태로 전환될 때 처리할 Record 입니다.
[[PromiseIsHandled]]
a Boolean
promise에 fulfillment 또는 rejection handler가 한 번이라도 있었는지를 나타냅니다. 처리되지 않은 rejection 추적에 사용됩니다.
27.6 GeneratorFunction 객체
GeneratorFunction은 일반적으로 GeneratorDeclaration , GeneratorExpression , GeneratorMethod 를 평가하여 생성되는 함수입니다. %GeneratorFunction% 내재 객체를 호출하여 생성할 수도 있습니다.
그림 6 (참고 ): Generator 객체 관계
27.6.1 GeneratorFunction 생성자
GeneratorFunction 생성자 는:
%GeneratorFunction% 입니다.
Function의 하위 클래스입니다.
생성자 가 아니라 함수로 호출되면 새로운 GeneratorFunction을 생성하고 초기화합니다. 따라서 함수 호출 GeneratorFunction (…)은 같은 인수를 사용하는 객체 생성 표현식 new GeneratorFunction (…)과 동등합니다.
클래스 정의의 extends 절 값으로 사용할 수 있습니다. 지정된 GeneratorFunction 동작을 상속하려는 하위 클래스 생성자 는 내장 GeneratorFunction 동작에 필요한 내부 슬롯을 갖도록 하위 클래스 인스턴스를 생성하고 초기화하기 위해 GeneratorFunction 생성자 에 대한 super 호출을 포함해야 합니다. generator 함수 객체 를 정의하는 모든 ECMAScript 구문 형식은 GeneratorFunction의 직접 인스턴스를 생성합니다. GeneratorFunction 하위 클래스의 인스턴스를 생성하는 구문적 방법은 없습니다.
27.6.1.1 GeneratorFunction ( ...paramArgs , bodyArg )
마지막 인수(있는 경우)는 generator 함수의 본문(실행 가능한 코드)을 지정하며, 그 앞의 모든 인수는 형식 매개변수를 지정합니다.
이 함수는 호출되면 다음 단계를 수행합니다:
activeFunc 를 활성 함수 객체 로 둡니다.bodyArg 가 존재하지 않으면 bodyArg 를 빈 String으로 설정합니다.? CreateDynamicFunction (activeFunc , NewTarget, generator , paramArgs , bodyArg )를 반환합니다.
참고
20.2.1.1 의 참고 를 참조하시기 바랍니다.
27.6.2 GeneratorFunction 생성자의 프로퍼티
GeneratorFunction 생성자 는:
Function 생성자 에서 상속하는 표준 내장 함수 객체 입니다.
값이 %Function% 인 [[Prototype]] 내부 슬롯을 갖습니다.
값이 1 𝔽 인 "length" 프로퍼티를 갖습니다.
값이 "GeneratorFunction" 인 "name" 프로퍼티를 갖습니다.
다음 프로퍼티를 갖습니다:
27.6.2.1 GeneratorFunction.prototype
GeneratorFunction.prototype의 초기 값은 GeneratorFunction 프로토타입 객체 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
27.6.3 GeneratorFunction 프로토타입 객체의 프로퍼티
GeneratorFunction 프로토타입 객체 는:
27.6.3.1 GeneratorFunction.prototype.constructor
GeneratorFunction.prototype.constructor의 초기 값은 %GeneratorFunction% 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
27.6.3.2 GeneratorFunction.prototype.prototype
GeneratorFunction.prototype.prototype의 초기 값은 %GeneratorPrototype% 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
27.6.3.3 GeneratorFunction.prototype [ %Symbol.toStringTag% ]
%Symbol.toStringTag% 프로퍼티의 초기 값은 String 값 "GeneratorFunction" 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
27.6.4 GeneratorFunction 인스턴스
모든 GeneratorFunction 인스턴스는 ECMAScript 함수 객체 이며 표 26 에 나열된 내부 슬롯을 갖습니다. 이러한 모든 인스턴스의 [[IsClassConstructor]] 내부 슬롯 값은 false 입니다.
각 GeneratorFunction 인스턴스에는 다음 자체 프로퍼티가 있습니다:
27.6.4.1 length
20.2.4.1 에 제시된 Function 인스턴스의 "length" 프로퍼티 명세는 GeneratorFunction 인스턴스에도 적용됩니다.
27.6.4.2 name
20.2.4.2 에 제시된 Function 인스턴스의 "name" 프로퍼티 명세는 GeneratorFunction 인스턴스에도 적용됩니다.
27.6.4.3 prototype
GeneratorFunction 인스턴스가 생성될 때마다 또 다른 일반 객체 도 생성되며 generator 함수의 "prototype" 프로퍼티의 초기 값이 됩니다. prototype 프로퍼티 값은 generator 함수 객체 가 [[Call]] 을 사용하여 호출될 때 새로 생성되는 Generator의 [[Prototype]] 내부 슬롯을 초기화하는 데 사용됩니다.
이 프로퍼티는 { [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
참고
Function 인스턴스와 달리 GeneratorFunction의 "prototype" 프로퍼티 값인 객체에는 값이 GeneratorFunction 인스턴스인 "constructor" 프로퍼티가 없습니다.
27.7 AsyncGeneratorFunction 객체
AsyncGeneratorFunction은 일반적으로 AsyncGeneratorDeclaration , AsyncGeneratorExpression , AsyncGeneratorMethod 구문 생성물을 평가하여 생성되는 함수입니다. %AsyncGeneratorFunction% 내재 객체를 호출하여 생성할 수도 있습니다.
27.7.1 AsyncGeneratorFunction 생성자
AsyncGeneratorFunction 생성자 는:
%AsyncGeneratorFunction% 입니다.
Function의 하위 클래스입니다.
생성자 가 아니라 함수로 호출되면 새로운 AsyncGeneratorFunction을 생성하고 초기화합니다. 따라서 함수 호출 AsyncGeneratorFunction (...)은 같은 인수를 사용하는 객체 생성 표현식 new AsyncGeneratorFunction (...)과 동등합니다.
클래스 정의의 extends 절 값으로 사용할 수 있습니다. 지정된 AsyncGeneratorFunction 동작을 상속하려는 하위 클래스 생성자 는 내장 AsyncGeneratorFunction 동작에 필요한 내부 슬롯을 갖도록 하위 클래스 인스턴스를 생성하고 초기화하기 위해 AsyncGeneratorFunction 생성자 에 대한 super 호출을 포함해야 합니다. async generator 함수 객체 를 정의하는 모든 ECMAScript 구문 형식은 AsyncGeneratorFunction의 직접 인스턴스를 생성합니다. AsyncGeneratorFunction 하위 클래스의 인스턴스를 생성하는 구문적 방법은 없습니다.
27.7.1.1 AsyncGeneratorFunction ( ...paramArgs , bodyArg )
마지막 인수(있는 경우)는 async generator 함수의 본문(실행 가능한 코드)을 지정하며, 그 앞의 모든 인수는 형식 매개변수를 지정합니다.
이 함수는 호출되면 다음 단계를 수행합니다:
activeFunc 를 활성 함수 객체 로 둡니다.bodyArg 가 존재하지 않으면 bodyArg 를 빈 String으로 설정합니다.? CreateDynamicFunction (activeFunc , NewTarget, async-generator , paramArgs , bodyArg )를 반환합니다.
참고
20.2.1.1 의 참고 를 참조하시기 바랍니다.
27.7.2 AsyncGeneratorFunction 생성자의 프로퍼티
AsyncGeneratorFunction 생성자 는:
Function 생성자 에서 상속하는 표준 내장 함수 객체 입니다.
값이 %Function% 인 [[Prototype]] 내부 슬롯을 갖습니다.
값이 1 𝔽 인 "length" 프로퍼티를 갖습니다.
값이 "AsyncGeneratorFunction" 인 "name" 프로퍼티를 갖습니다.
다음 프로퍼티를 갖습니다:
27.7.2.1 AsyncGeneratorFunction.prototype
AsyncGeneratorFunction.prototype의 초기 값은 AsyncGeneratorFunction 프로토타입 객체 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
27.7.3 AsyncGeneratorFunction 프로토타입 객체의 프로퍼티
AsyncGeneratorFunction 프로토타입 객체 는:
27.7.3.1 AsyncGeneratorFunction.prototype.constructor
AsyncGeneratorFunction.prototype.constructor의 초기 값은 %AsyncGeneratorFunction% 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
27.7.3.2 AsyncGeneratorFunction.prototype.prototype
AsyncGeneratorFunction.prototype.prototype의 초기 값은 %AsyncGeneratorPrototype% 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
27.7.3.3 AsyncGeneratorFunction.prototype [ %Symbol.toStringTag% ]
%Symbol.toStringTag% 프로퍼티의 초기 값은 String 값 "AsyncGeneratorFunction" 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
27.7.4 AsyncGeneratorFunction 인스턴스
모든 AsyncGeneratorFunction 인스턴스는 ECMAScript 함수 객체 이며 표 26 에 나열된 내부 슬롯을 갖습니다. 이러한 모든 인스턴스의 [[IsClassConstructor]] 내부 슬롯 값은 false 입니다.
각 AsyncGeneratorFunction 인스턴스에는 다음 자체 프로퍼티가 있습니다:
27.7.4.1 length
"length" 프로퍼티 값은 AsyncGeneratorFunction이 일반적으로 받을 것으로 예상되는 인수 수를 나타내는 정수 Number입니다. 그러나 언어는 다른 수의 인수로 함수를 호출하는 것도 허용합니다. "length" 프로퍼티에 지정된 수와 다른 수의 인수로 AsyncGeneratorFunction을 호출했을 때의 동작은 함수에 따라 달라집니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
27.7.4.2 name
20.2.4.2 에 제시된 Function 인스턴스의 "name" 프로퍼티 명세는 AsyncGeneratorFunction 인스턴스에도 적용됩니다.
27.7.4.3 prototype
AsyncGeneratorFunction 인스턴스가 생성될 때마다 또 다른 일반 객체 도 생성되며 async generator 함수의 "prototype" 프로퍼티의 초기 값이 됩니다. prototype 프로퍼티 값은 generator 함수 객체 가 [[Call]] 을 사용하여 호출될 때 새로 생성되는 AsyncGenerator의 [[Prototype]] 내부 슬롯을 초기화하는 데 사용됩니다.
이 프로퍼티는 { [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
참고
함수 인스턴스와 달리 AsyncGeneratorFunction의 "prototype" 프로퍼티 값인 객체에는 값이 AsyncGeneratorFunction 인스턴스인 "constructor" 프로퍼티가 없습니다.
27.8 Generator 객체
Generator는 generator 함수를 호출하여 생성되며 iterator 인터페이스 와 iterable 인터페이스 를 모두 준수합니다.
Generator 인스턴스는 해당 인스턴스를 생성한 generator 함수의 "prototype" 프로퍼티 초기 값에서 직접 프로퍼티를 상속합니다. Generator 인스턴스는 %GeneratorPrototype% 에서 간접적으로 프로퍼티를 상속합니다.
27.8.1 %GeneratorPrototype% 객체
%GeneratorPrototype% 객체는:
%GeneratorFunction.prototype.prototype% 입니다.
일반 객체 입니다.
Generator 인스턴스가 아니며 [[GeneratorState]] 내부 슬롯을 갖지 않습니다.
값이 %Iterator.prototype% 인 [[Prototype]] 내부 슬롯을 갖습니다.
모든 Generator 인스턴스가 간접적으로 상속하는 프로퍼티를 갖습니다.
27.8.1.1 %GeneratorPrototype%.constructor
%GeneratorPrototype% .constructor의 초기 값은 %GeneratorFunction.prototype% 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
27.8.1.2 %GeneratorPrototype%.next ( value )
? GeneratorResume (this 값, value , empty )를 반환합니다.
27.8.1.3 %GeneratorPrototype%.return ( value )
이 메서드는 호출되면 다음 단계를 수행합니다:
gen 을 this 값으로 둡니다.completion 을 ReturnCompletion (value )으로 둡니다.? GeneratorResumeAbrupt (gen , completion , empty )를 반환합니다.
27.8.1.4 %GeneratorPrototype%.throw ( exception )
이 메서드는 호출되면 다음 단계를 수행합니다:
gen 을 this 값으로 둡니다.completion 을 ThrowCompletion (exception )으로 둡니다.? GeneratorResumeAbrupt (gen , completion , empty )를 반환합니다.
27.8.1.5 %GeneratorPrototype% [ %Symbol.toStringTag% ]
%Symbol.toStringTag% 프로퍼티의 초기 값은 String 값 "Generator" 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
27.8.2 Generator 인스턴스의 프로퍼티
Generator 인스턴스는 처음에 표 94 에 설명된 내부 슬롯과 함께 생성됩니다.
표 94: Generator 인스턴스의 내부 슬롯
내부 슬롯
타입
설명
[[GeneratorState]]
suspended-start , suspended-yield , executing , or completed
generator의 현재 실행 상태입니다.
[[GeneratorContext]]
an execution context
이 generator의 코드를 실행할 때 사용하는 실행 컨텍스트 입니다.
[[GeneratorBrand]]
a String or empty
서로 다른 종류의 generator를 구별하는 데 사용되는 브랜드입니다. ECMAScript 소스 텍스트 로 선언된 generator의 [[GeneratorBrand]] 는 항상 empty 입니다.
27.8.3 Generator 추상 연산
27.8.3.1 GeneratorStart ( gen , genBody )
추상 연산 GeneratorStart. 인수 gen (Generator) 및 genBody ((a FunctionBody Parse Node 또는 매개변수가 없는 추상 클로저 )). 반환값: unused . 호출되면 다음 단계를 수행한다.
단언 : gen .[[GeneratorState]] 는 suspended-start 입니다.genContext 를 실행 중인 실행 컨텍스트 로 둡니다.genContext 의 Generator 구성 요소를 gen 으로 설정합니다.closure 를 매개변수가 없고 genBody 를 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:acGenContext 를 실행 중인 실행 컨텍스트 로 둡니다.acGen 을 acGenContext 의 Generator 구성 요소로 둡니다.genBody 가 Parse Node이면, 다음을 수행합니다.result 를 Completion (genBody 의 Evaluation )으로 둡니다.그렇지 않으면,단언 : genBody 는 매개변수가 없는 Abstract Closure 입니다.result 를 Completion (genBody ())로 둡니다. 단언 : 여기서 반환한다면 generator는 예외를 던졌거나 암시적 또는 명시적 return을 수행했습니다.acGenContext 를 실행 컨텍스트 스택 에서 제거하고 실행 컨텍스트 스택 맨 위의 실행 컨텍스트 를 실행 중인 실행 컨텍스트 로 복원합니다.acGen .[[GeneratorState]] 를 completed 로 설정합니다.참고 : generator가 completed 상태에 들어가면 다시 벗어나지 않으며 연결된 실행 컨텍스트 는 다시 재개되지 않습니다. acGen 과 연결된 모든 실행 상태는 이 시점에 폐기할 수 있습니다.result 가 throw completion이면, 다음을 수행합니다.resumption 을 result 로 둡니다.그렇지 않으면,result 가 normal completion이면, 다음을 수행합니다.resultValue 를 undefined 로 둡니다.그렇지 않고 result 가 return completion이면, 다음을 수행합니다.resultValue 를 result .[[Value]] 로 둡니다. resumption 을 NormalCompletion (CreateIteratorResultObject (resultValue , true ))으로 둡니다. callerContext 를 실행 중인 실행 컨텍스트 로 둡니다.resumption 을 전달하여 callerContext 를 재개합니다.단언 : 이 단계에는 절대 도달하지 않습니다.해당 실행 컨텍스트 의 평가가 재개될 때 closure 가 인수 없이 호출되도록 genContext 의 코드 평가 상태를 설정합니다. gen .[[GeneratorContext]] 를 genContext 로 설정합니다.unused 를 반환합니다.
27.8.3.2 GeneratorValidate ( gen , genBrand )
추상 연산 GeneratorValidate. 인수 gen (ECMAScript 언어 값 ) 및 genBrand ((String 또는 empty )). 반환값: (정상 완료 (값: (suspended-start , suspended-yield 또는 completed )) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
? RequireInternalSlot (gen , [[GeneratorState]] )를 수행합니다. ? RequireInternalSlot (gen , [[GeneratorBrand]] )를 수행합니다. gen .[[GeneratorBrand]] 가 genBrand 가 아니면 TypeError 예외를 던집니다.단언 : gen 에는 [[GeneratorContext]] 내부 슬롯이 있습니다.state 를 gen .[[GeneratorState]] 로 둡니다.state 가 executing 이면 TypeError 예외를 던집니다.state 를 반환합니다.
27.8.3.3 GeneratorResume ( gen , value , genBrand )
추상 연산 GeneratorResume. 인수 gen (ECMAScript 언어 값 ), value ((ECMAScript 언어 값 또는 empty )) 및 genBrand ((String 또는 empty )). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
state 를 ? GeneratorValidate (gen , genBrand )로 둡니다.state 가 completed 이면 CreateIteratorResultObject (undefined , true )를 반환합니다.단언 : state 는 suspended-start 또는 suspended-yield 입니다.genContext 를 gen .[[GeneratorContext]] 로 둡니다.gen .[[GeneratorState]] 를 executing 으로 설정합니다.? RunSuspendedContext (genContext , NormalCompletion (value ))을 반환합니다.
27.8.3.4 GeneratorResumeAbrupt ( gen , abruptCompletion , genBrand )
추상 연산 GeneratorResumeAbrupt. 인수 gen (ECMAScript 언어 값 ), abruptCompletion ((return 완료 또는 throw 완료 )) 및 genBrand ((String 또는 empty )). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
state 를 ? GeneratorValidate (gen , genBrand )로 둡니다.state 가 suspended-start 이면, 다음을 수행합니다.gen .[[GeneratorState]] 를 completed 로 설정합니다.참고 : generator가 completed 상태에 들어가면 다시 벗어나지 않으며 연결된 실행 컨텍스트 는 다시 재개되지 않습니다. gen 과 연결된 모든 실행 상태는 이 시점에 폐기할 수 있습니다.state 를 completed 로 설정합니다.state 가 completed 이면, 다음을 수행합니다.abruptCompletion 이 return completion이면, 다음을 수행합니다.CreateIteratorResultObject (abruptCompletion .[[Value]] , true )를 반환합니다.? abruptCompletion 을 반환합니다. 단언 : state 는 suspended-yield 입니다.genContext 를 gen .[[GeneratorContext]] 로 둡니다.gen .[[GeneratorState]] 를 executing 으로 설정합니다.? RunSuspendedContext (genContext , abruptCompletion )을 반환합니다.
27.8.3.5 GetGeneratorKind ( )
추상 연산 GetGeneratorKind. 인수 없음. 반환값: (non-generator , sync 또는 async ). 호출되면 다음 단계를 수행한다.
genContext 를 실행 중인 실행 컨텍스트 로 둡니다.genContext 에 Generator 구성 요소가 없으면 non-generator 를 반환합니다.gen 을 genContext 의 Generator 구성 요소로 둡니다.gen 에 [[AsyncGeneratorState]] 내부 슬롯이 있으면 async 를 반환합니다.sync 를 반환합니다.
27.8.3.6 GeneratorYield ( iteratorResult )
추상 연산 GeneratorYield. 인수 iteratorResult (an Object that conforms to the IteratorResult interface). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 중도 완료). 호출되면 다음 단계를 수행한다.
genContext 를 실행 중인 실행 컨텍스트 로 둡니다.단언 : genContext 는 generator의 실행 컨텍스트 입니다.gen 을 genContext 의 Generator 구성 요소 값으로 둡니다.단언 : GetGeneratorKind ()는 sync 입니다.gen .[[GeneratorState]] 를 suspended-yield 로 설정합니다.? RunCallerContext (iteratorResult )를 반환합니다.
27.8.3.7 Yield ( arg )
추상 연산 Yield. 인수 arg (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 중도 완료). 호출되면 다음 단계를 수행한다.
genKind 를 GetGeneratorKind ()로 둡니다.genKind 가 async 이면 ? AsyncGeneratorYield (? Await (arg ))를 반환합니다.? GeneratorYield (CreateIteratorResultObject (arg , false ))를 반환합니다.
27.8.3.8 CreateIteratorFromClosure ( closure , genBrand , genProto [ , extraSlots ] )
추상 연산 CreateIteratorFromClosure. 인수 closure (매개변수가 없는 추상 클로저 ), genBrand ((String 또는 empty )) 및 genProto (Object) 및 선택적 인수 extraSlots (리스트 (요소: 내부 슬롯 이름)). 반환값: Generator. 호출되면 다음 단계를 수행한다.
참고 : closure 는 IteratorResult 객체를 산출하기 위한 Yield 연산 사용을 포함할 수 있습니다.extraSlots 가 존재하지 않으면 extraSlots 를 새로운 빈 List 로 설정합니다.internalSlotsList 를 extraSlots 와 « [[GeneratorState]] , [[GeneratorContext]] , [[GeneratorBrand]] »의 목록 연결 로 둡니다.gen 을 OrdinaryObjectCreate (genProto , internalSlotsList )로 둡니다.gen .[[GeneratorBrand]] 를 genBrand 로 설정합니다.gen .[[GeneratorState]] 를 suspended-start 로 설정합니다.callerContext 를 실행 중인 실행 컨텍스트 로 둡니다.calleeContext 를 새로운 실행 컨텍스트 로 둡니다.calleeContext 의 Function을 null 로 설정합니다.calleeContext 의 Realm 을 현재 Realm Record 로 설정합니다.calleeContext 의 ScriptOrModule을 callerContext 의 ScriptOrModule로 설정합니다.callerContext 가 아직 일시 중단되지 않았다면 callerContext 를 일시 중단합니다.calleeContext 를 실행 컨텍스트 스택 에 push합니다. 이제 calleeContext 가 실행 중인 실행 컨텍스트 입니다.GeneratorStart (gen , closure )를 수행합니다.calleeContext 를 실행 컨텍스트 스택 에서 제거하고 callerContext 를 실행 중인 실행 컨텍스트 로 복원합니다.gen 을 반환합니다.
27.9 AsyncGenerator 객체
AsyncGenerator는 async generator 함수를 호출하여 생성되며 async iterator 인터페이스 와 async iterable 인터페이스 를 모두 준수합니다.
AsyncGenerator 인스턴스는 해당 인스턴스를 생성한 async generator 함수의 "prototype" 프로퍼티 초기 값에서 직접 프로퍼티를 상속합니다. AsyncGenerator 인스턴스는 %AsyncGeneratorPrototype% 에서 간접적으로 프로퍼티를 상속합니다.
27.9.1 %AsyncGeneratorPrototype% 객체
%AsyncGeneratorPrototype% 객체는:
%AsyncGeneratorFunction.prototype.prototype% 입니다.
일반 객체 입니다.
AsyncGenerator 인스턴스가 아니며 [[AsyncGeneratorState]] 내부 슬롯을 갖지 않습니다.
값이 %AsyncIteratorPrototype% 인 [[Prototype]] 내부 슬롯을 갖습니다.
모든 AsyncGenerator 인스턴스가 간접적으로 상속하는 프로퍼티를 갖습니다.
27.9.1.1 %AsyncGeneratorPrototype%.constructor
%AsyncGeneratorPrototype% .constructor의 초기 값은 %AsyncGeneratorFunction.prototype% 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
27.9.1.2 %AsyncGeneratorPrototype%.next ( value )
gen 을 this 값으로 둡니다.promiseCapability 을 ! NewPromiseCapability (%Promise% )로 둡니다.result 를 Completion (AsyncGeneratorValidate (gen , empty ))으로 둡니다.IfAbruptRejectPromise (result , promiseCapability ).state 를 gen .[[AsyncGeneratorState]] 로 둡니다.state 가 completed 이면, 다음을 수행합니다.iteratorResult 를 CreateIteratorResultObject (undefined , true )로 둡니다.! Call (promiseCapability .[[Resolve]] , undefined , « iteratorResult »)를 수행합니다. promiseCapability .[[Promise]] 를 반환합니다.completion 을 NormalCompletion (value )으로 둡니다.AsyncGeneratorEnqueue (gen , completion , promiseCapability )을 수행합니다.state 가 suspended-start 또는 suspended-yield 이면, 다음을 수행합니다.AsyncGeneratorResume (gen , completion )을 수행합니다.그렇지 않으면,단언 : state 는 executing 또는 draining-queue 입니다. promiseCapability .[[Promise]] 를 반환합니다.
27.9.1.3 %AsyncGeneratorPrototype%.return ( value )
gen 을 this 값으로 둡니다.promiseCapability 을 ! NewPromiseCapability (%Promise% )로 둡니다.result 를 Completion (AsyncGeneratorValidate (gen , empty ))으로 둡니다.IfAbruptRejectPromise (result , promiseCapability ).completion 을 ReturnCompletion (value )으로 둡니다.AsyncGeneratorEnqueue (gen , completion , promiseCapability )을 수행합니다.state 를 gen .[[AsyncGeneratorState]] 로 둡니다.state 가 suspended-start 또는 completed 이면, 다음을 수행합니다.gen .[[AsyncGeneratorState]] 를 draining-queue 로 설정합니다.AsyncGeneratorAwaitReturn (gen )을 수행합니다.그렇지 않고 state 가 suspended-yield 이면, 다음을 수행합니다.AsyncGeneratorResume (gen , completion )을 수행합니다. 그렇지 않으면,단언 : state 는 executing 또는 draining-queue 입니다. promiseCapability .[[Promise]] 를 반환합니다.
27.9.1.4 %AsyncGeneratorPrototype%.throw ( exception )
gen 을 this 값으로 둡니다.promiseCapability 을 ! NewPromiseCapability (%Promise% )로 둡니다.result 를 Completion (AsyncGeneratorValidate (gen , empty ))으로 둡니다.IfAbruptRejectPromise (result , promiseCapability ).state 를 gen .[[AsyncGeneratorState]] 로 둡니다.state 가 suspended-start 이면, 다음을 수행합니다.gen .[[AsyncGeneratorState]] 를 completed 로 설정합니다.state 를 completed 로 설정합니다.state 가 completed 이면, 다음을 수행합니다.! Call (promiseCapability .[[Reject]] , undefined , « exception »)를 수행합니다. promiseCapability .[[Promise]] 를 반환합니다.completion 을 ThrowCompletion (exception )으로 둡니다.AsyncGeneratorEnqueue (gen , completion , promiseCapability )을 수행합니다.state 가 suspended-yield 이면, 다음을 수행합니다.AsyncGeneratorResume (gen , completion )을 수행합니다.그렇지 않으면,단언 : state 는 executing 또는 draining-queue 입니다. promiseCapability .[[Promise]] 를 반환합니다.
27.9.1.5 %AsyncGeneratorPrototype% [ %Symbol.toStringTag% ]
%Symbol.toStringTag% 프로퍼티의 초기 값은 String 값 "AsyncGenerator" 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
27.9.2 AsyncGenerator 인스턴스의 프로퍼티
AsyncGenerator 인스턴스는 처음에 아래에 설명된 내부 슬롯과 함께 생성됩니다:
표 95: AsyncGenerator 인스턴스의 내부 슬롯
내부 슬롯
타입
설명
[[AsyncGeneratorState]]
suspended-start , suspended-yield , executing , draining-queue , or completed
async generator의 현재 실행 상태입니다.
[[AsyncGeneratorContext]]
an execution context
이 async generator의 코드를 실행할 때 사용하는 실행 컨텍스트 입니다.
[[AsyncGeneratorQueue]]
a List of AsyncGeneratorRequest Records
async generator를 재개하라는 요청을 나타내는 Record 입니다. 상태 전환 중을 제외하면 [[AsyncGeneratorState]] 가 executing 또는 draining-queue 인 경우에만 비어 있지 않습니다.
[[GeneratorBrand]]
a String or empty
서로 다른 종류의 async generator를 구별하는 데 사용되는 브랜드입니다. ECMAScript 소스 텍스트 로 선언된 async generator의 [[GeneratorBrand]] 는 항상 empty 입니다.
27.9.3 AsyncGenerator 추상 연산
27.9.3.1 AsyncGeneratorRequest Records
AsyncGeneratorRequest 는 async generator를 어떻게 재개해야 하는지에 대한 정보를 저장하는 데 사용되는 Record 이며 대응하는 promise를 fulfill하거나 reject하기 위한 capability를 포함합니다.
다음 필드를 갖습니다:
표 96: AsyncGeneratorRequest Record 필드
27.9.3.2 AsyncGeneratorStart ( gen , genBody )
추상 연산 AsyncGeneratorStart. 인수 gen (AsyncGenerator) 및 genBody ((a FunctionBody Parse Node 또는 매개변수가 없는 추상 클로저 )). 반환값: unused . 호출되면 다음 단계를 수행한다.
단언 : gen .[[AsyncGeneratorState]] 는 suspended-start 입니다.genContext 를 실행 중인 실행 컨텍스트 로 둡니다.genContext 의 Generator 구성 요소를 gen 으로 설정합니다.closure 를 매개변수가 없고 genBody 를 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:acGenContext 를 실행 중인 실행 컨텍스트 로 둡니다.acGen 을 acGenContext 의 Generator 구성 요소로 둡니다.genBody 가 Parse Node이면, 다음을 수행합니다.result 를 Completion (genBody 의 Evaluation )으로 둡니다.그렇지 않으면,단언 : genBody 는 매개변수가 없는 Abstract Closure 입니다.result 를 Completion (genBody ())로 둡니다. 단언 : 여기서 반환한다면 async generator는 예외를 던졌거나 암시적 또는 명시적 return을 수행했습니다.acGenContext 를 실행 컨텍스트 스택 에서 제거하고 실행 컨텍스트 스택 맨 위의 실행 컨텍스트 를 실행 중인 실행 컨텍스트 로 복원합니다.acGen .[[AsyncGeneratorState]] 를 draining-queue 로 설정합니다.result 가 normal completion이면 result 를 NormalCompletion (undefined )으로 설정합니다.result 가 return completion이면 result 를 NormalCompletion (result .[[Value]] )으로 설정합니다.AsyncGeneratorCompleteStep (acGen , result , true )를 수행합니다.AsyncGeneratorDrainQueue (acGen )를 수행합니다.callerContext 를 실행 중인 실행 컨텍스트 로 둡니다.NormalCompletion (undefined )을 전달하여 callerContext 를 재개합니다.단언 : 이 단계에는 절대 도달하지 않습니다.해당 실행 컨텍스트 의 평가가 재개될 때 closure 가 인수 없이 호출되도록 genContext 의 코드 평가 상태를 설정합니다. gen .[[AsyncGeneratorContext]] 를 genContext 로 설정합니다.gen .[[AsyncGeneratorQueue]] 를 새로운 빈 List 로 설정합니다.unused 를 반환합니다.
27.9.3.3 AsyncGeneratorValidate ( gen , genBrand )
추상 연산 AsyncGeneratorValidate. 인수 gen (ECMAScript 언어 값 ) 및 genBrand ((String 또는 empty )). 반환값: (정상 완료 (값: unused ) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
? RequireInternalSlot (gen , [[AsyncGeneratorContext]] )를 수행합니다. ? RequireInternalSlot (gen , [[AsyncGeneratorState]] )를 수행합니다. ? RequireInternalSlot (gen , [[AsyncGeneratorQueue]] )를 수행합니다. gen .[[GeneratorBrand]] 가 genBrand 가 아니면 TypeError 예외를 던집니다.unused 를 반환합니다.
27.9.3.4 AsyncGeneratorEnqueue ( gen , completion , promiseCapability )
추상 연산 AsyncGeneratorEnqueue. 인수 gen (AsyncGenerator), completion (완료 레코드 ) 및 promiseCapability (PromiseCapability 레코드 ). 반환값: unused . 호출되면 다음 단계를 수행한다.
request 를 AsyncGeneratorRequest { [[Completion]] : completion , [[Capability]] : promiseCapability }로 둡니다.request 를 gen .[[AsyncGeneratorQueue]] 에 추가합니다.unused 를 반환합니다.
27.9.3.5 AsyncGeneratorCompleteStep ( gen , completion , done [ , realm ] )
추상 연산 AsyncGeneratorCompleteStep. 인수 gen (AsyncGenerator), completion (완료 레코드 ) 및 done (Boolean) 및 선택적 인수 realm (Realm 레코드 ). 반환값: unused . 호출되면 다음 단계를 수행한다.
단언 : gen .[[AsyncGeneratorQueue]] 는 비어 있지 않습니다.next 를 gen .[[AsyncGeneratorQueue]] 의 첫 번째 요소로 둡니다.gen .[[AsyncGeneratorQueue]] 에서 첫 번째 요소를 제거합니다.promiseCapability 을 next .[[Capability]] 로 둡니다.value 를 completion .[[Value]] 로 둡니다.completion 이 throw completion이면, 다음을 수행합니다.! Call (promiseCapability .[[Reject]] , undefined , « value »)를 수행합니다. 그렇지 않으면,단언 : completion 은 normal completion입니다.realm 이 존재하면, 다음을 수행합니다.oldRealm 을 실행 중인 실행 컨텍스트 의 Realm 으로 둡니다.실행 중인 실행 컨텍스트 의 Realm 을 realm 으로 설정합니다.iteratorResult 를 CreateIteratorResultObject (value , done )로 둡니다.실행 중인 실행 컨텍스트 의 Realm 을 oldRealm 으로 설정합니다.그렇지 않으면,iteratorResult 를 CreateIteratorResultObject (value , done )로 둡니다. ! Call (promiseCapability .[[Resolve]] , undefined , « iteratorResult »)를 수행합니다. unused 를 반환합니다.
27.9.3.6 AsyncGeneratorResume ( gen , completion )
추상 연산 AsyncGeneratorResume. 인수 gen (AsyncGenerator) 및 completion (완료 레코드 ). 반환값: unused . 호출되면 다음 단계를 수행한다.
단언 : gen .[[AsyncGeneratorState]] 는 suspended-start 또는 suspended-yield 입니다.genContext 를 gen .[[AsyncGeneratorContext]] 로 둡니다.gen .[[AsyncGeneratorState]] 를 executing 으로 설정합니다.! RunSuspendedContext (genContext , completion )을 수행합니다. unused 를 반환합니다.
27.9.3.7 AsyncGeneratorUnwrapYieldResumption ( resumptionValue )
추상 연산 AsyncGeneratorUnwrapYieldResumption. 인수 resumptionValue (완료 레코드 ). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 중도 완료). 호출되면 다음 단계를 수행한다.
resumptionValue 가 return completion이 아니면 ? resumptionValue 를 반환합니다.awaited 를 Completion (Await (resumptionValue .[[Value]] ))으로 둡니다.awaited 가 throw completion이면 ? awaited 를 반환합니다.단언 : awaited 는 normal completion입니다.ReturnCompletion (awaited .[[Value]] )을 반환합니다.
27.9.3.8 AsyncGeneratorYield ( arg )
추상 연산 AsyncGeneratorYield. 인수 arg (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: ECMAScript 언어 값 ) 또는 중도 완료). 호출되면 다음 단계를 수행한다.
genContext 를 실행 중인 실행 컨텍스트 로 둡니다.단언 : genContext 는 generator의 실행 컨텍스트 입니다.gen 을 genContext 의 Generator 구성 요소 값으로 둡니다.단언 : GetGeneratorKind ()는 async 입니다.completion 을 NormalCompletion (arg )으로 둡니다.단언 : 실행 컨텍스트 스택 에는 최소 두 개의 요소가 있습니다.previousContext 를 실행 컨텍스트 스택 에서 위에서 두 번째 요소로 둡니다.previousRealm 을 previousContext 의 Realm 으로 둡니다.AsyncGeneratorCompleteStep (gen , completion , false , previousRealm )을 수행합니다.queue 를 gen .[[AsyncGeneratorQueue]] 로 둡니다.queue 가 비어 있지 않으면, 다음을 수행합니다.참고 : generator를 일시 중단하지 않고 실행이 계속됩니다.toYield 를 queue 의 첫 번째 요소로 둡니다.resumptionValue 를 Completion (toYield .[[Completion]] )으로 둡니다.? AsyncGeneratorUnwrapYieldResumption (resumptionValue )을 반환합니다. gen .[[AsyncGeneratorState]] 를 suspended-yield 로 설정합니다.resumptionValue 를 Completion (RunCallerContext (undefined ))으로 둡니다.? AsyncGeneratorUnwrapYieldResumption (resumptionValue )을 반환합니다.
27.9.3.9 AsyncGeneratorAwaitReturn ( gen )
추상 연산 AsyncGeneratorAwaitReturn. 인수 gen (AsyncGenerator). 반환값: unused . 호출되면 다음 단계를 수행한다.
단언 : gen .[[AsyncGeneratorState]] 는 draining-queue 입니다.queue 를 gen .[[AsyncGeneratorQueue]] 로 둡니다.단언 : queue 는 비어 있지 않습니다.next 를 queue 의 첫 번째 요소로 둡니다.completion 을 Completion (next .[[Completion]] )으로 둡니다.단언 : completion 은 return completion입니다.promiseCompletion 을 Completion (PromiseResolve (%Promise% , completion .[[Value]] ))으로 둡니다.promiseCompletion 이 abrupt completion이면, 다음을 수행합니다.AsyncGeneratorCompleteStep (gen , promiseCompletion , true )를 수행합니다.AsyncGeneratorDrainQueue (gen )를 수행합니다.unused 를 반환합니다.단언 : promiseCompletion 은 normal completion입니다.promise 를 promiseCompletion .[[Value]] 로 둡니다.fulfilledClosure 를 매개변수 (value )를 가지며 gen 을 캡처하고 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:단언 : gen .[[AsyncGeneratorState]] 는 draining-queue 입니다.result 를 NormalCompletion (value )으로 둡니다.AsyncGeneratorCompleteStep (gen , result , true )를 수행합니다.AsyncGeneratorDrainQueue (gen )를 수행합니다.NormalCompletion (undefined )을 반환합니다.onFulfilled 를 CreateBuiltinFunction (fulfilledClosure , 1, "" , « »)로 둡니다.rejectedClosure 를 매개변수 (reason )을 가지며 gen 을 캡처하고 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:단언 : gen .[[AsyncGeneratorState]] 는 draining-queue 입니다.result 를 ThrowCompletion (reason )으로 둡니다.AsyncGeneratorCompleteStep (gen , result , true )를 수행합니다.AsyncGeneratorDrainQueue (gen )를 수행합니다.NormalCompletion (undefined )을 반환합니다.onRejected 를 CreateBuiltinFunction (rejectedClosure , 1, "" , « »)로 둡니다.PerformPromiseThen (promise , onFulfilled , onRejected )을 수행합니다.unused 를 반환합니다.
27.9.3.10 AsyncGeneratorDrainQueue ( gen )
추상 연산 AsyncGeneratorDrainQueue. 인수 gen (AsyncGenerator). 반환값: unused . return completion을 보유하는 AsyncGeneratorRequest 를 만날 때까지 generator의 AsyncGeneratorQueue를 비웁니다. 호출되면 다음 단계를 수행한다.
단언 : gen .[[AsyncGeneratorState]] 는 draining-queue 입니다.queue 를 gen .[[AsyncGeneratorQueue]] 로 둡니다.queue 가 비어 있지 않은 동안 다음을 반복합니다.next 를 queue 의 첫 번째 요소로 둡니다.completion 을 Completion (next .[[Completion]] )으로 둡니다.completion 이 return completion이면, 다음을 수행합니다.AsyncGeneratorAwaitReturn (gen )을 수행합니다.unused 를 반환합니다.completion 이 normal completion이면, 다음을 수행합니다.completion 을 NormalCompletion (undefined )으로 설정합니다.AsyncGeneratorCompleteStep (gen , completion , true )를 수행합니다.gen .[[AsyncGeneratorState]] 를 completed 로 설정합니다.unused 를 반환합니다.
27.10 AsyncFunction 객체
AsyncFunction은 일반적으로 AsyncFunctionDeclaration , AsyncFunctionExpression , AsyncMethod , AsyncArrowFunction 을 평가하여 생성되는 함수입니다. %AsyncFunction% 내재 객체를 호출하여 생성할 수도 있습니다.
27.10.1 AsyncFunction 생성자
AsyncFunction 생성자 는:
%AsyncFunction% 입니다.
Function의 하위 클래스입니다.
생성자 가 아니라 함수로 호출되면 새로운 AsyncFunction을 생성하고 초기화합니다. 따라서 함수 호출 AsyncFunction(…)은 같은 인수를 사용하는 객체 생성 표현식 new AsyncFunction(…)과 동등합니다.
클래스 정의의 extends 절 값으로 사용할 수 있습니다. 지정된 AsyncFunction 동작을 상속하려는 하위 클래스 생성자 는 내장 async 함수 동작에 필요한 내부 슬롯을 갖도록 하위 클래스 인스턴스를 생성하고 초기화하기 위해 AsyncFunction 생성자 에 대한 super 호출을 포함해야 합니다. async 함수 객체 를 정의하는 모든 ECMAScript 구문 형식은 AsyncFunction의 직접 인스턴스를 생성합니다. AsyncFunction 하위 클래스의 인스턴스를 생성하는 구문적 방법은 없습니다.
27.10.1.1 AsyncFunction ( ...paramArgs , bodyArg )
마지막 인수(있는 경우)는 async 함수의 본문(실행 가능한 코드)을 지정합니다. 그 앞의 모든 인수는 형식 매개변수를 지정합니다.
이 함수는 호출되면 다음 단계를 수행합니다:
activeFunc 를 활성 함수 객체 로 둡니다.bodyArg 가 존재하지 않으면 bodyArg 를 빈 String으로 설정합니다.? CreateDynamicFunction (activeFunc , NewTarget, async , paramArgs , bodyArg )를 반환합니다.
참고 20.2.1.1 의
참고 를 참조하시기 바랍니다.
27.10.2 AsyncFunction 생성자의 프로퍼티
AsyncFunction 생성자 는:
Function 생성자 에서 상속하는 표준 내장 함수 객체 입니다.
값이 %Function% 인 [[Prototype]] 내부 슬롯을 갖습니다.
값이 1 𝔽 인 "length" 프로퍼티를 갖습니다.
값이 "AsyncFunction" 인 "name" 프로퍼티를 갖습니다.
다음 프로퍼티를 갖습니다:
27.10.2.1 AsyncFunction.prototype
AsyncFunction.prototype의 초기 값은 AsyncFunction 프로토타입 객체 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
27.10.3 AsyncFunction 프로토타입 객체의 프로퍼티
AsyncFunction 프로토타입 객체 는:
27.10.3.1 AsyncFunction.prototype.constructor
AsyncFunction.prototype.constructor의 초기 값은 %AsyncFunction% 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
27.10.3.2 AsyncFunction.prototype [ %Symbol.toStringTag% ]
%Symbol.toStringTag% 프로퍼티의 초기 값은 String 값 "AsyncFunction" 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
27.10.4 AsyncFunction 인스턴스
모든 AsyncFunction 인스턴스는 ECMAScript 함수 객체 이며 표 26 에 나열된 내부 슬롯을 갖습니다. 이러한 모든 인스턴스의 [[IsClassConstructor]] 내부 슬롯 값은 false 입니다. AsyncFunction 인스턴스는 생성자 가 아니며 [[Construct]] 내부 메서드를 갖지 않습니다. AsyncFunction 인스턴스는 생성할 수 없으므로 prototype 프로퍼티를 갖지 않습니다.
각 AsyncFunction 인스턴스에는 다음 자체 프로퍼티가 있습니다:
27.10.4.1 length
20.2.4.1 에 제시된 Function 인스턴스의 "length" 프로퍼티 명세는 AsyncFunction 인스턴스에도 적용됩니다.
27.10.4.2 name
20.2.4.2 에 제시된 Function 인스턴스의 "name" 프로퍼티 명세는 AsyncFunction 인스턴스에도 적용됩니다.
27.10.5 Async 함수 추상 연산
27.10.5.1 AsyncFunctionStart ( promiseCapability , asyncFuncBody )
추상 연산 AsyncFunctionStart. 인수 promiseCapability (PromiseCapability 레코드 ) 및 asyncFuncBody ((a FunctionBody Parse Node, an ExpressionBody Parse Node 또는 매개변수가 없는 추상 클로저 )). 반환값: unused . 호출되면 다음 단계를 수행한다.
runningContext 를 실행 중인 실행 컨텍스트 로 둡니다.asyncContext 를 runningContext 의 복사본으로 둡니다.참고 : AsyncBlockStart 가 실행을 재개하려면 실행 상태를 복사해야 합니다. 현재 실행 중인 컨텍스트를 재개하는 것은 정의되지 않습니다.AsyncBlockStart (promiseCapability , asyncFuncBody , asyncContext )를 수행합니다.unused 를 반환합니다.
27.10.5.2 AsyncBlockStart ( promiseCapability , asyncBody , asyncContext )
추상 연산 AsyncBlockStart. 인수 promiseCapability (PromiseCapability 레코드 ), asyncBody ((구문 분석 노드 또는 매개변수가 없는 추상 클로저 )) 및 asyncContext (실행 컨텍스트 ). 반환값: unused . 호출되면 다음 단계를 수행한다.
closure 를 매개변수가 없고 promiseCapability 과 asyncBody 를 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:acAsyncContext 를 실행 중인 실행 컨텍스트 로 둡니다.asyncBody 가 Parse Node이면, 다음을 수행합니다.result 를 Completion (asyncBody 의 Evaluation )으로 둡니다.그렇지 않으면,단언 : asyncBody 는 매개변수가 없는 Abstract Closure 입니다.result 를 Completion (asyncBody ())로 둡니다. 단언 : 여기서 반환한다면 async 함수는 예외를 던졌거나 암시적 또는 명시적 return을 수행했으며 모든 await가 완료되었습니다.acAsyncContext 를 실행 컨텍스트 스택 에서 제거하고 실행 컨텍스트 스택 맨 위의 실행 컨텍스트 를 실행 중인 실행 컨텍스트 로 복원합니다.result 가 normal completion이면, 다음을 수행합니다.! Call (promiseCapability .[[Resolve]] , undefined , « undefined »)를 수행합니다. 그렇지 않고 result 가 return completion이면, 다음을 수행합니다.! Call (promiseCapability .[[Resolve]] , undefined , « result .[[Value]] »)를 수행합니다. 그렇지 않으면,단언 : result 는 throw completion입니다.! Call (promiseCapability .[[Reject]] , undefined , « result .[[Value]] »)를 수행합니다. callerContext 를 실행 중인 실행 컨텍스트 로 둡니다.NormalCompletion (unused )을 전달하여 callerContext 를 재개합니다.단언 : 이 단계에는 절대 도달하지 않습니다.해당 실행 컨텍스트 의 평가가 재개될 때 closure 가 인수 없이 호출되도록 asyncContext 의 코드 평가 상태를 설정합니다. result 를 ! RunSuspendedContext (asyncContext , NormalCompletion (empty ))로 둡니다.단언 : result 는 unused 입니다.참고 : result 값의 가능한 출처는 Await 또는 async 함수가 아무것도 await하지 않는 경우 위의 1.j 단계입니다.unused 를 반환합니다.
27.10.5.3 Await ( arg )
추상 연산 Await. 인수 arg (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: (ECMAScript 언어 값 또는 empty )) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
asyncContext 를 실행 중인 실행 컨텍스트 로 둡니다.promise 를 ? PromiseResolve (%Promise% , arg )로 둡니다.fulfilledClosure 를 매개변수 (value )를 가지며 asyncContext 를 캡처하고 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:Completion (RunSuspendedContext (asyncContext , NormalCompletion (value )))을 수행합니다.참고 : RunSuspendedContext 가 반환하는 Completion Record 는 의도적으로 무시됩니다.NormalCompletion (undefined )을 반환합니다.onFulfilled 를 CreateBuiltinFunction (fulfilledClosure , 1, "" , « »)로 둡니다.rejectedClosure 를 매개변수 (reason )을 가지며 asyncContext 를 캡처하고 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:Completion (RunSuspendedContext (asyncContext , ThrowCompletion (reason )))을 수행합니다.참고 : RunSuspendedContext 가 반환하는 Completion Record 는 의도적으로 무시됩니다.NormalCompletion (undefined )을 반환합니다.onRejected 를 CreateBuiltinFunction (rejectedClosure , 1, "" , « »)로 둡니다.PerformPromiseThen (promise , onFulfilled , onRejected )을 수행합니다.? RunCallerContext (empty )를 반환합니다.
28 리플렉션
28.1 Reflect 객체
Reflect 객체는:
%Reflect% 입니다.
전역 객체 의 "Reflect" 프로퍼티의 초기 값입니다.
일반 객체 입니다.
값이 %Object.prototype% 인 [[Prototype]] 내부 슬롯을 갖습니다.
함수 객체 가 아닙니다.
[[Construct]] 내부 메서드를 갖지 않으므로 new 연산자와 함께 생성자 로 사용할 수 없습니다.
[[Call]] 내부 메서드를 갖지 않으므로 함수로 호출할 수 없습니다.
28.1.1 Reflect.apply ( target , thisArg , args )
이 함수는 호출되면 다음 단계를 수행합니다:
IsCallable (target )이 false 이면 TypeError 예외를 던집니다.argList 를 ? CreateListFromArrayLike (args )로 둡니다.PrepareForTailCall ()을 수행합니다.? Call (target , thisArg , argList )를 반환합니다.
28.1.2 Reflect.construct ( target , args [ , newTarget ] )
이 함수는 호출되면 다음 단계를 수행합니다:
IsConstructor (target )가 false 이면 TypeError 예외를 던집니다.newTarget 이 존재하지 않으면 newTarget 을 target 으로 설정합니다.그렇지 않고 IsConstructor (newTarget )가 false 이면 TypeError 예외를 던집니다. argList 를 ? CreateListFromArrayLike (args )로 둡니다.? Construct (target , argList , newTarget )을 반환합니다.
28.1.3 Reflect.defineProperty ( target , key , attrs )
이 함수는 호출되면 다음 단계를 수행합니다:
target 이 Object가 아니면 TypeError 예외를 던집니다.propertyKey 를 ? ToPropertyKey (key )로 둡니다.propertyDesc 를 ? ToPropertyDescriptor (attrs )로 둡니다.? target .[[DefineOwnProperty]] (propertyKey , propertyDesc ) 를 반환합니다.
28.1.4 Reflect.deleteProperty ( target , key )
이 함수는 호출되면 다음 단계를 수행합니다:
target 이 Object가 아니면 TypeError 예외를 던집니다.propertyKey 를 ? ToPropertyKey (key )로 둡니다.? target .[[Delete]] (propertyKey ) 를 반환합니다.
28.1.5 Reflect.get ( target , key [ , receiver ] )
이 함수는 호출되면 다음 단계를 수행합니다:
target 이 Object가 아니면 TypeError 예외를 던집니다.propertyKey 를 ? ToPropertyKey (key )로 둡니다.receiver 가 존재하지 않으면, 다음을 수행합니다.receiver 를 target 으로 설정합니다.? target .[[Get]] (propertyKey , receiver ) 를 반환합니다.
28.1.6 Reflect.getOwnPropertyDescriptor ( target , key )
이 함수는 호출되면 다음 단계를 수행합니다:
target 이 Object가 아니면 TypeError 예외를 던집니다.propertyKey 를 ? ToPropertyKey (key )로 둡니다.propertyDesc 를 ? target .[[GetOwnProperty]] (propertyKey ) 로 둡니다.FromPropertyDescriptor (propertyDesc )를 반환합니다.
28.1.7 Reflect.getPrototypeOf ( target )
이 함수는 호출되면 다음 단계를 수행합니다:
target 이 Object가 아니면 TypeError 예외를 던집니다.? target .[[GetPrototypeOf]] () 를 반환합니다.
28.1.8 Reflect.has ( target , key )
이 함수는 호출되면 다음 단계를 수행합니다:
target 이 Object가 아니면 TypeError 예외를 던집니다.propertyKey 를 ? ToPropertyKey (key )로 둡니다.? target .[[HasProperty]] (propertyKey ) 를 반환합니다.
28.1.9 Reflect.isExtensible ( target )
이 함수는 호출되면 다음 단계를 수행합니다:
target 이 Object가 아니면 TypeError 예외를 던집니다.? target .[[IsExtensible]] () 를 반환합니다.
28.1.10 Reflect.ownKeys ( target )
이 함수는 호출되면 다음 단계를 수행합니다:
target 이 Object가 아니면 TypeError 예외를 던집니다.keys 를 ? target .[[OwnPropertyKeys]] () 로 둡니다.CreateArrayFromList (keys )를 반환합니다.
28.1.11 Reflect.preventExtensions ( target )
이 함수는 호출되면 다음 단계를 수행합니다:
target 이 Object가 아니면 TypeError 예외를 던집니다.? target .[[PreventExtensions]] () 를 반환합니다.
28.1.12 Reflect.set ( target , key , value [ , receiver ] )
이 함수는 호출되면 다음 단계를 수행합니다:
target 이 Object가 아니면 TypeError 예외를 던집니다.propertyKey 를 ? ToPropertyKey (key )로 둡니다.receiver 가 존재하지 않으면, 다음을 수행합니다.receiver 를 target 으로 설정합니다.? target .[[Set]] (propertyKey , value , receiver ) 를 반환합니다.
28.1.13 Reflect.setPrototypeOf ( target , proto )
이 함수는 호출되면 다음 단계를 수행합니다:
target 이 Object가 아니면 TypeError 예외를 던집니다.proto 가 Object가 아니고 proto 가 null 도 아니면 TypeError 예외를 던집니다.? target .[[SetPrototypeOf]] (proto ) 를 반환합니다.
28.1.14 Reflect [ %Symbol.toStringTag% ]
%Symbol.toStringTag% 프로퍼티의 초기 값은 String 값 "Reflect" 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } 속성을 갖습니다.
28.2 Proxy 객체
28.2.1 Proxy 생성자
Proxy 생성자 는:
%Proxy% 입니다.
전역 객체 의 "Proxy" 프로퍼티의 초기 값입니다.
생성자 로 호출되면 새로운 Proxy 객체를 생성하고 초기화합니다.
함수로 호출하도록 의도되지 않았으며 그러한 방식으로 호출되면 예외를 던집니다.
28.2.1.1 Proxy ( target , handler )
이 함수는 호출되면 다음 단계를 수행합니다:
NewTarget이 undefined 이면 TypeError 예외를 던집니다. ? ProxyCreate (target , handler )를 반환합니다.
28.2.2 Proxy 생성자의 프로퍼티
Proxy 생성자 는:
값이 %Function.prototype% 인 [[Prototype]] 내부 슬롯을 갖습니다.
Proxy 객체에는 초기화가 필요한 [[Prototype]] 내부 슬롯이 없으므로 "prototype" 프로퍼티를 갖지 않습니다.
다음 프로퍼티를 갖습니다:
28.2.2.1 Proxy.revocable ( target , handler )
이 함수는 취소 가능한 Proxy 객체를 생성합니다.
호출되면 다음 단계를 수행합니다:
proxy 를 ? ProxyCreate (target , handler )로 둡니다.revokerClosure 를 매개변수가 없고 아무것도 캡처하지 않으며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure 로 둡니다:activeFunc 를 활성 함수 객체 로 둡니다.revocableProxy 를 activeFunc .[[RevocableProxy]] 로 둡니다.revocableProxy 가 null 이면 NormalCompletion (undefined )을 반환합니다.activeFunc .[[RevocableProxy]] 를 null 로 설정합니다.단언 : revocableProxy 는 Proxy 특수 객체 입니다.revocableProxy .[[ProxyTarget]] 을 null 로 설정합니다.revocableProxy .[[ProxyHandler]] 를 null 로 설정합니다.NormalCompletion (undefined )을 반환합니다.revoker 를 CreateBuiltinFunction (revokerClosure , 0, "" , « [[RevocableProxy]] »)로 둡니다.revoker .[[RevocableProxy]] 를 proxy 로 설정합니다.result 를 OrdinaryObjectCreate (%Object.prototype% )로 둡니다.! CreateDataPropertyOrThrow (result , "proxy" , proxy )를 수행합니다. ! CreateDataPropertyOrThrow (result , "revoke" , revoker )를 수행합니다. result 를 반환합니다.
28.3 모듈 네임스페이스 객체
모듈 네임스페이스 객체는 모듈의 내보낸 바인딩에 런타임 프로퍼티 기반 접근을 제공하는 모듈 네임스페이스 특수 객체 입니다. 모듈 네임스페이스 객체에는 생성자 함수가 없습니다. 대신 NameSpaceImport 를 포함하는 ImportDeclaration 에 의해 가져온 각 모듈에 대해 그러한 객체가 생성됩니다.
10.4.6 에 지정된 프로퍼티에 더하여 각 모듈 네임스페이스 객체에는 다음 자체 프로퍼티가 있습니다:
28.3.1 %Symbol.toStringTag%
%Symbol.toStringTag% 프로퍼티의 초기 값은 String 값 "Module" 입니다.
이 프로퍼티는 { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false } 속성을 갖습니다.
29 메모리 모델
메모리 일관성 모델, 즉 메모리 모델 은 SharedArrayBuffer를 기반으로 하는 TypedArray 인스턴스에 접근하거나 Atomics 객체의 메서드를 통해 발생하는 Shared Data Block 이벤트 의 가능한 순서를 지정합니다. 프로그램에 데이터 경합 (아래 정의)이 없으면 이벤트 순서는 순차적 일관성을 갖는 것처럼, 즉 각 에이전트 의 동작이 서로 교차하여 실행되는 것처럼 보입니다. 프로그램에 데이터 경합 이 있으면 공유 메모리 연산은 순차적으로 일관되지 않게 보일 수 있습니다. 예를 들어 프로그램은 인과성을 위반하는 동작과 그 밖의 놀라운 동작을 보일 수 있습니다. 이러한 놀라운 동작은 컴파일러 변환과 CPU 설계(예: 비순차 실행 및 추측 실행)에서 발생합니다. 메모리 모델은 프로그램이 순차적으로 일관된 동작을 보이는 정확한 조건과 데이터 경합 에서 읽을 수 있는 가능한 값을 모두 정의합니다. 즉, 정의되지 않은 동작은 없습니다.
메모리 모델은 평가 중 SharedArrayBuffer에 대한 추상 연산 또는 Atomics 객체의 메서드가 도입하는 Memory 이벤트 에 대한 관계적 제약으로 정의됩니다.
참고
이 절은 SharedArrayBuffer에 대한 추상 연산 이 도입하는 Memory 이벤트 에 대한 공리적 모델을 제공합니다. 이 명세의 나머지 부분과 달리 이 모델은 알고리즘으로 표현할 수 없다는 점을 강조합니다. 추상 연산 에 의한 이벤트의 비결정적 도입은 ECMAScript 평가의 연산 의미론과 메모리 모델의 공리적 의미론 사이의 인터페이스입니다. 이러한 이벤트의 의미론은 평가의 모든 이벤트 그래프를 고려하여 정의됩니다. 이는 정적 의미론 도 런타임 의미론 도 아닙니다. 입증된 알고리즘 구현은 없으며, 대신 특정 이벤트 그래프가 허용되는지 허용되지 않는지를 결정하는 제약 조건 집합이 있습니다.
29.1 메모리 모델의 기본 사항
공유 메모리 접근(읽기 및 쓰기)은 아래에 정의된 원자적 접근과 데이터 접근이라는 두 그룹으로 나뉩니다. 원자적 접근은 순차적으로 일관됩니다. 즉, 에이전트 클러스터 의 모든 에이전트 가 동의하는 이벤트의 엄격한 전순서가 있습니다. 비원자적 접근에는 모든 에이전트 가 동의하는 엄격한 전순서가 없습니다. 즉, 순서가 지정되지 않습니다.
참고 1
순차적 일관성보다 약하고 순서 없음보다 강한 release-acquire와 같은 순서는 지원되지 않습니다.
Shared Data Block 이벤트 는 ReadSharedMemory , WriteSharedMemory , ReadModifyWriteSharedMemory Record 중 하나입니다. 읽기 이벤트 는 ReadSharedMemory 또는 ReadModifyWriteSharedMemory입니다. 쓰기 이벤트 는 WriteSharedMemory 또는 ReadModifyWriteSharedMemory입니다.
표 97: ReadSharedMemory 이벤트 필드
필드 이름
값
의미
[[Order]]
seq-cst or unordered
메모리 모델 이 이 이벤트에 대해 보장하는 가장 약한 순서입니다.
[[NoTear]]
a Boolean
이 이벤트가 자신과 동일한 메모리 범위 를 갖는 여러 쓰기 이벤트 에서 읽는 것이 허용되는지 여부입니다.
[[Block]]
a Shared Data Block
이벤트가 동작하는 블록입니다.
[[ByteIndex]]
a non-negative integer
[[Block]] 에서 읽기의 바이트 주소입니다.
[[ElementSize]]
a non-negative integer
읽기의 크기입니다.
표 98: WriteSharedMemory 이벤트 필드
필드 이름
값
의미
[[Order]]
seq-cst , unordered , or init
메모리 모델 이 이 이벤트에 대해 보장하는 가장 약한 순서입니다.
[[NoTear]]
a Boolean
이 이벤트를 자신과 동일한 메모리 범위 를 갖는 여러 읽기 이벤트 가 읽는 것이 허용되는지 여부입니다.
[[Block]]
a Shared Data Block
이벤트가 동작하는 블록입니다.
[[ByteIndex]]
a non-negative integer
[[Block]] 에서 쓰기의 바이트 주소입니다.
[[ElementSize]]
a non-negative integer
쓰기의 크기입니다.
[[Payload]]
a List of byte values
다른 이벤트가 읽을 바이트 값 의 List 입니다.
표 99: ReadModifyWriteSharedMemory 이벤트 필드
필드 이름
값
의미
[[Order]]
seq-cst
Read-modify-write 이벤트는 항상 순차적으로 일관됩니다.
[[NoTear]]
true
Read-modify-write 이벤트는 찢어질 수 없습니다.
[[Block]]
a Shared Data Block
이벤트가 동작하는 블록입니다.
[[ByteIndex]]
a non-negative integer
[[Block]] 에서 read-modify-write의 바이트 주소입니다.
[[ElementSize]]
a non-negative integer
read-modify-write의 크기입니다.
[[Payload]]
a List of byte values
[[ModifyOp]] 에 전달할 바이트 값 의 List 입니다.
[[ModifyOp]]
a read-modify-write modification function
읽은 바이트 값 의 List 와 [[Payload]] 에서 수정된 바이트 값 의 List 를 반환하는 Abstract Closure 입니다.
Shared Data Block 이벤트는 추상 연산 또는 Atomics 객체의 메서드에 의해 후보 실행 의 Agent Events Records 에 도입됩니다. 일부 연산은 필드가 없으며 순전히 다른 이벤트의 허용 가능한 순서를 직접 제한하기 위해 존재하는 Synchronize 이벤트 도 도입합니다. 마지막으로 호스트 별 이벤트가 있습니다. Memory 이벤트 는 Shared Data Block 이벤트, Synchronize 이벤트 또는 그러한 호스트 별 이벤트 중 하나입니다.
Shared Data Block 이벤트 e 의 메모리 범위 를 e .[[ByteIndex]] (포함)부터 e .[[ByteIndex]] + e .[[ElementSize]] (제외)까지 구간 에 있는 모든 정수 의 Set으로 둡니다. 두 이벤트가 같은 [[Block]] , [[ByteIndex]] , [[ElementSize]] 를 가지면 두 이벤트의 메모리 범위는 같습니다. 두 이벤트가 같은 [[Block]] 을 가지고 범위가 같지 않으며 교집합이 비어 있지 않으면 두 이벤트의 메모리 범위는 겹칩니다. 두 이벤트가 같은 [[Block]] 을 갖지 않거나 그 범위가 같지도 겹치지도 않으면 두 이벤트의 메모리 범위는 서로 분리되어 있습니다.
참고 2
고려해야 하는 호스트 별 동기화 이벤트의 예로는 한 에이전트 에서 다른 에이전트 로 SharedArrayBuffer를 보내는 것(예: 브라우저의 postMessage), 에이전트 를 시작하고 중지하는 것, 공유 메모리 이외의 채널을 통해 에이전트 클러스터 내에서 통신하는 것이 있습니다. 특정 실행 execution 에 대해 이러한 이벤트는 host-synchronizes-with 엄격 부분 순서 를 통해 호스트 가 제공합니다. 또한 호스트 는 is-agent-order-before Relation 에 참여하도록 호스트 별 동기화 이벤트를 execution .[[EventList]] 에 추가할 수 있습니다.
이벤트는 아래에 정의된 관계에 따라 후보 실행 내에서 순서가 정해집니다.
29.2 Agent Events Records
Agent Events Record 는 다음 필드를 갖는 Record 입니다.
표 100: Agent Events Record 필드
29.3 Chosen Value Records
Chosen Value Record 는 다음 필드를 갖는 Record 입니다.
표 101: Chosen Value Record 필드
29.4 후보 실행
에이전트 클러스터 평가의 후보 실행 은 다음 필드를 갖는 Record 입니다.
표 102: 후보 실행 Record 필드
빈 후보 실행 은 필드가 빈 List 인 후보 실행 Record 입니다.
29.5 메모리 모델을 위한 추상 연산
29.5.1 EventSet ( execution )
추상 연산 EventSet. 인수 execution (a candidate execution). 반환값: a Set of Memory events . 호출되면 다음 단계를 수행한다.
events 를 빈 Set으로 둡니다.execution .[[EventsRecords]] 의 각 Agent Events Record eventsRecord 에 대해 다음을 수행합니다.eventsRecord .[[EventList]] 의 각 Memory 이벤트 event 에 대해 다음을 수행합니다.event 를 events 에 추가합니다.events 를 반환합니다.
29.5.2 SharedDataBlockEventSet ( execution )
추상 연산 SharedDataBlockEventSet. 인수 execution (a candidate execution). 반환값: a Set of Shared Data Block events . 호출되면 다음 단계를 수행한다.
events 를 빈 Set으로 둡니다.EventSet (execution )의 각 Memory 이벤트 event 에 대해 다음을 수행합니다.event 가 Shared Data Block 이벤트 이면 event 를 events 에 추가합니다.events 를 반환합니다.
29.5.3 HostEventSet ( execution )
추상 연산 HostEventSet. 인수 execution (a candidate execution). 반환값: a Set of Memory events . 호출되면 다음 단계를 수행한다.
SharedDataBlockEventSet (execution )에 포함되지 않은 EventSet (execution )의 모든 요소를 포함하는 새로운 Set을 반환합니다.
29.5.4 ComposeWriteEventBytes ( execution , byteIndex , writes )
추상 연산 ComposeWriteEventBytes. 인수 execution (a candidate execution), byteIndex (음이 아닌 정수) 및 writes (리스트 (요소: (WriteSharedMemory 또는 ReadModifyWriteSharedMemory events))). 반환값: 리스트 (요소: 바이트 값 ). 호출되면 다음 단계를 수행한다.
byteLocation 을 byteIndex 로 둡니다.bytesRead 를 새로운 빈 List 로 둡니다.writes 의 각 요소 writeEvent 에 대해 다음을 수행합니다.단언 : writeEvent 는 자신의 메모리 범위 에 byteLocation 을 포함합니다.payloadIndex 를 byteLocation - writeEvent .[[ByteIndex]] 로 둡니다.writeEvent 가 WriteSharedMemory 이벤트이면, 다음을 수행합니다.byte 를 writeEvent .[[Payload]] [payloadIndex ]로 둡니다.그렇지 않으면,단언 : writeEvent 는 ReadModifyWriteSharedMemory 이벤트입니다.bytes 를 ValueOfReadEvent (execution , writeEvent )로 둡니다.bytesModified 를 writeEvent .[[ModifyOp]] (bytes , writeEvent .[[Payload]] )로 둡니다.byte 를 bytesModified [payloadIndex ]로 둡니다. byte 를 bytesRead 에 추가합니다.byteLocation 을 byteLocation + 1로 설정합니다.bytesRead 를 반환합니다.
참고 1
read-modify-write 수정 [[ModifyOp]] 는 ReadModifyWriteSharedMemory 이벤트를 도입하는 Atomics 객체의 함수 프로퍼티에 의해 제공됩니다.
참고 2
29.5.5 ValueOfReadEvent ( execution , readEvent )
추상 연산 ValueOfReadEvent. 인수 execution (a candidate execution) 및 readEvent ((a ReadSharedMemory 또는 ReadModifyWriteSharedMemory event)). 반환값: 리스트 (요소: 바이트 값 ). 호출되면 다음 단계를 수행한다.
writes 를 execution 에서 reads-bytes-from (readEvent )으로 둡니다.단언 : writes 는 길이가 readEvent .[[ElementSize]] 와 같은 WriteSharedMemory 또는 ReadModifyWriteSharedMemory 이벤트의 List 입니다.ComposeWriteEventBytes (execution , readEvent .[[ByteIndex]] , writes )를 반환합니다.
29.6 후보 실행의 관계
다음 관계와 수학적 함수는 특정 후보 실행 에 대해 매개변수화되며 그 Memory 이벤트 의 순서를 정합니다.
29.6.1 is-agent-order-before
후보 실행 execution 에 대해 해당 is-agent-order-before Relation 은 다음을 만족하는 Memory 이벤트 에 대한 최소 Relation 입니다.
이벤트 eventA 와 eventB 에 대해, execution .[[EventsRecords]] 에 eventA 와 eventB 를 모두 포함하는 [[EventList]] 를 가진 Agent Events Record eventsRecord 가 있고 eventsRecord .[[EventList]] 의 List 순서에서 eventA 가 eventB 보다 앞서면 execution 에서 eventA is-agent-order-before eventB 입니다.
참고
각 에이전트 는 평가 중 에이전트 별 엄격 전순서 로 이벤트를 도입합니다. 이는 그러한 엄격 전순서 들의 합집합입니다.
29.6.2 reads-bytes-from
후보 실행 execution 에 대해 해당 reads-bytes-from 함수는 SharedDataBlockEventSet (execution )의 Memory 이벤트 를 SharedDataBlockEventSet (execution )의 이벤트 List 에 매핑하며 다음 조건을 만족하는 수학적 함수입니다.
후보 실행 에는 항상 reads-bytes-from 함수가 존재합니다.
29.6.3 reads-from
후보 실행 execution 에 대해 해당 reads-from Relation 은 다음을 만족하는 Memory 이벤트 에 대한 최소 Relation 입니다.
이벤트 readEvent 와 writeEvent 에 대해 SharedDataBlockEventSet (execution )이 readEvent 와 writeEvent 를 모두 포함하고 execution 에서 reads-bytes-from (readEvent )이 writeEvent 를 포함하면 execution 에서 readEvent reads-from writeEvent 입니다.
29.6.4 host-synchronizes-with
후보 실행 execution 에 대해 해당 host-synchronizes-with Relation 은 적어도 다음을 만족하는 호스트 별 Memory 이벤트 에 대한 호스트 제공 엄격 부분 순서 입니다.
execution 에서 eventA host-synchronizes-with eventB 이면 HostEventSet (execution )은 eventA 와 eventB 를 포함합니다.
execution 에서 host-synchronizes-with와 is-agent-order-before 의 합집합에는 순환이 없습니다.
참고 1
후보 실행 execution 의 두 호스트 별 이벤트 eventA 와 eventB 에 대해 execution 에서 eventA host-synchronizes-with eventB 이면 execution 에서 eventA happens-before eventB 입니다.
참고 2
이 Relation 을 통해 호스트 는 HTML worker 사이의 postMessage와 같은 추가 동기화 메커니즘을 제공할 수 있습니다.
29.6.5 synchronizes-with
후보 실행 execution 에 대해 해당 synchronizes-with Relation 은 다음을 만족하는 Memory 이벤트 에 대한 최소 Relation 입니다.
이벤트 readEvent 와 writeEvent 에 대해 execution 에서 readEvent reads-from writeEvent 이고, readEvent .[[Order]] 가 seq-cst 이고, writeEvent .[[Order]] 가 seq-cst 이며, readEvent 와 writeEvent 의 메모리 범위 가 같으면 execution 에서 writeEvent synchronizes-with readEvent 입니다.
execution .[[EventsRecords]] 의 각 요소 eventsRecord 에 대해 다음이 참입니다.
이벤트 eventA 와 eventB 에 대해 eventsRecord .[[AgentSynchronizesWith]] 가 (eventA , eventB )를 포함하면 execution 에서 eventA synchronizes-with eventB 입니다.
이벤트 eventA 와 eventB 에 대해 execution 에서 eventA host-synchronizes-with eventB 이면 execution 에서 eventA synchronizes-with eventB 입니다.
참고 1
메모리 모델 문헌의 관례에 따라 후보 실행 execution 에서는 읽기 이벤트 가 쓰기 이벤트 와 synchronizes-with하는 것이 아니라 쓰기 이벤트 가 읽기 이벤트 와 synchronizes-with합니다.
참고 2
후보 실행 execution 에서 init 이벤트는 이 Relation 에 참여하지 않으며 대신 happens-before 에 의해 직접 제약됩니다.
참고 3
후보 실행 execution 에서 reads-from 으로 관련된 모든 seq-cst 이벤트가 synchronizes-with로 관련되는 것은 아닙니다. 메모리 범위 도 같은 이벤트만 synchronizes-with로 관련됩니다.
참고 4
후보 실행 execution 에서 writeEvent synchronizes-with readEvent 인 Shared Data Block 이벤트 readEvent 와 writeEvent 에 대해 readEvent 는 writeEvent 이외의 다른 쓰기에서도 reads-from 할 수 있습니다.
29.6.6 happens-before
후보 실행 execution 에 대해 해당 happens-before Relation 은 다음을 만족하는 Memory 이벤트 에 대한 최소 Relation 입니다.
참고
happens-before는 agent-order의 상위 집합이므로 후보 실행 은 ECMAScript의 단일 스레드 평가 의미론과 일관됩니다.
29.7 유효한 실행의 프로퍼티
29.7.1 유효한 선택 읽기
다음 알고리즘이 true 를 반환하면 후보 실행 execution 은 유효한 선택 읽기를 갖습니다.
SharedDataBlockEventSet (execution )의 각 ReadSharedMemory 또는 ReadModifyWriteSharedMemory 이벤트 readEvent 에 대해 다음을 수행합니다.chosenValueRecord 를 [[Event]] 필드가 readEvent 인 execution .[[ChosenValues]] 의 요소로 둡니다.chosenValue 를 chosenValueRecord .[[ChosenValue]] 로 둡니다.readValue 를 ValueOfReadEvent (execution , readEvent )로 둡니다.chosenLength 를 chosenValue 의 요소 수로 둡니다.readLength 를 readValue 의 요소 수로 둡니다.chosenLength ≠ readLength 이면, 다음을 수행합니다.false 를 반환합니다.0(포함)부터 chosenLength (제외)까지의 구간 에 있는 어떤 정수 i 에 대해 chosenValue [i ] ≠ readValue [i ]이면, 다음을 수행합니다.false 를 반환합니다. true 를 반환합니다.
29.7.2 일관된 읽기
다음 알고리즘이 true 를 반환하면 후보 실행 execution 은 일관된 읽기를 갖습니다.
SharedDataBlockEventSet (execution )의 각 ReadSharedMemory 또는 ReadModifyWriteSharedMemory 이벤트 readEvent 에 대해 다음을 수행합니다.writes 를 execution 에서 reads-bytes-from (readEvent )으로 둡니다.byteLocation 을 readEvent .[[ByteIndex]] 로 둡니다.writes 의 각 요소 writeEvent 에 대해 다음을 수행합니다.execution 에서 readEvent happens-before writeEvent 이면, 다음을 수행합니다.false 를 반환합니다.자신의 메모리 범위 에 byteLocation 을 포함하는 WriteSharedMemory 또는 ReadModifyWriteSharedMemory 이벤트 value 가 존재하여 execution 에서 writeEvent happens-before value 이고 value happens-before readEvent 이면, 다음을 수행합니다.false 를 반환합니다. byteLocation 을 byteLocation + 1로 설정합니다.true 를 반환합니다.
29.7.3 찢어짐 없는 읽기
다음 알고리즘이 true 를 반환하면 후보 실행 execution 은 찢어짐 없는 읽기를 갖습니다.
SharedDataBlockEventSet (execution )의 각 ReadSharedMemory 또는 ReadModifyWriteSharedMemory 이벤트 readEvent 에 대해 다음을 수행합니다.readEvent .[[NoTear]] 가 true 이면, 다음을 수행합니다.단언 : readEvent .[[ByteIndex]] 를 readEvent .[[ElementSize]] 로 나눈 나머지는 0입니다.execution 에서 readEvent reads-from writeEvent 이고 writeEvent .[[NoTear]] 가 true 인 각 Memory 이벤트 writeEvent 에 대해 다음을 수행합니다.readEvent 와 writeEvent 의 메모리 범위 가 같고, value 와 writeEvent 의 메모리 범위 가 같고 value .[[NoTear]] 가 true 이며 writeEvent 와 value 가 동일한 Shared Data Block 이벤트 가 아니고 execution 에서 readEvent reads-from value 인 Memory 이벤트 value 가 존재하면, 다음을 수행합니다.false 를 반환합니다.true 를 반환합니다.
참고
Shared Data Block 이벤트 의 [[NoTear]] 필드는 해당 이벤트가 정수 TypedArray 에 접근하여 도입되었으면 true 이고, 부동 소수점 TypedArray 또는 DataView에 접근하여 도입되었으면 false 입니다.
직관적으로 이 요구 사항은 정수 TypedArray 를 통해 정렬된 방식으로 메모리 범위 에 접근할 때 동일한 범위를 가진 다른 쓰기 이벤트 와 데이터 경합 이 발생하면 해당 범위에 대한 하나의 쓰기 이벤트 가 “승리”해야 한다는 의미입니다. 더 정확하게는 정렬된 읽기 이벤트 가 모두 동일한 범위를 갖는 서로 다른 여러 쓰기 이벤트 의 바이트로 구성된 값을 읽을 수 없다는 의미입니다. 그러나 정렬된 읽기 이벤트 가 범위가 겹치는 여러 쓰기 이벤트 에서 읽는 것은 가능합니다.
29.7.4 순차적으로 일관된 원자적 연산
후보 실행 execution 에 대해 is-memory-order-before 는 EventSet (execution )의 모든 Memory 이벤트 에 대한 엄격 전순서 이며 다음을 만족합니다.
후보 실행 에 is-memory-order-before Relation 이 존재하면 순차적으로 일관된 원자적 연산을 갖습니다.
참고 3
is-memory-order-before는 EventSet (execution )의 모든 이벤트를 포함하지만, execution 에서 happens-before 또는 synchronizes-with 에 의해 제약되지 않는 이벤트는 순서의 어느 위치에서든 발생할 수 있습니다.
29.7.5 유효한 실행
다음이 모두 참이면 후보 실행 execution 은 유효한 실행(또는 간단히 실행)입니다.
모든 프로그램에는 적어도 하나의 유효한 실행이 있습니다.
29.8 경합
실행 execution 과 SharedDataBlockEventSet (execution )에 포함된 이벤트 eventA 및 eventB 에 대해 다음 알고리즘이 true 를 반환하면 eventA 와 eventB 는 경합 상태입니다.
eventA 와 eventB 가 동일한 Shared Data Block 이벤트 가 아니면, 다음을 수행합니다.execution 에서 eventA happens-before eventB 이고 eventB happens-before eventA 인 것이 모두 참인 경우가 아니면, 다음을 수행합니다.eventA 가 WriteSharedMemory 또는 ReadModifyWriteSharedMemory 이벤트이고, eventB 가 WriteSharedMemory 또는 ReadModifyWriteSharedMemory 이벤트이며, eventA 와 eventB 의 메모리 범위 가 서로 분리되어 있지 않으면, 다음을 수행합니다.true 를 반환합니다.execution 에서 eventA reads-from eventB 이거나 eventB reads-from eventA 이면, 다음을 수행합니다.true 를 반환합니다.false 를 반환합니다.
29.9 데이터 경합
실행 execution 과 SharedDataBlockEventSet (execution )에 포함된 이벤트 eventA 및 eventB 에 대해 다음 알고리즘이 true 를 반환하면 eventA 와 eventB 는 데이터 경합 상태입니다.
execution 에서 eventA 와 eventB 가 경합 상태이면, 다음을 수행합니다.eventA .[[Order]] 가 seq-cst 가 아니거나 eventB .[[Order]] 가 seq-cst 가 아니면, 다음을 수행합니다.true 를 반환합니다.eventA 와 eventB 의 메모리 범위 가 겹치면, 다음을 수행합니다.true 를 반환합니다.false 를 반환합니다.
29.10 데이터 경합 없음
SharedDataBlockEventSet (execution )에 데이터 경합 상태인 두 이벤트가 없으면 실행 execution 은 데이터 경합이 없습니다 .
프로그램의 모든 실행에 데이터 경합 이 없으면 프로그램에는 데이터 경합이 없습니다.
메모리 모델 은 데이터 경합 이 없는 프로그램의 모든 이벤트에 대해 순차적 일관성을 보장합니다.
29.11 공유 메모리 지침
참고 1
다음은 공유 메모리를 사용하는 ECMAScript 프로그래머를 위한 지침입니다.
프로그램에 데이터 경합 이 없도록 유지할 것을 권장합니다. 즉, 동일한 메모리 위치에서 동시 비원자적 연산이 발생하는 것이 불가능하도록 해야 합니다. 데이터 경합 이 없는 프로그램은 각 에이전트 의 평가 의미론의 각 단계가 서로 교차하여 실행되는 의미론을 갖습니다. 데이터 경합 이 없는 프로그램에서는 메모리 모델 의 세부 사항을 이해할 필요가 없습니다. 세부 사항은 더 나은 ECMAScript 코드를 작성하는 데 도움이 되는 직관을 형성할 가능성이 낮습니다.
더 일반적으로 프로그램에 데이터 경합 이 있더라도 원자적 연산이 어떤 데이터 경합 에도 관여하지 않고 경합 하는 연산이 모두 같은 접근 크기를 갖는다면 예측 가능한 동작을 가질 수 있습니다. 원자적 연산이 경합 에 관여하지 않게 하는 가장 간단한 방법은 원자적 연산과 비원자적 연산이 서로 다른 메모리 셀을 사용하도록 하고 서로 다른 크기의 원자적 접근이 동일한 셀에 동시에 접근하지 않도록 하는 것입니다. 사실상 프로그램은 공유 메모리를 가능한 한 강한 타입이 지정된 것처럼 취급해야 합니다. 경합 하는 비원자적 접근의 순서와 타이밍에 의존할 수는 없지만, 메모리를 강한 타입이 지정된 것처럼 취급하면 경합 하는 접근이 “찢어지지” 않습니다(값의 비트가 서로 섞이지 않습니다).
참고 2
다음은 공유 메모리를 사용하는 프로그램에 대해 컴파일러 변환을 작성하는 ECMAScript 구현자를 위한 지침입니다.
다중 에이전트 프로그램에서 각 에이전트 의 성능이 단일 에이전트 환경에서만큼 좋도록 하기 위해, 단일 에이전트 환경에서 유효한 대부분의 프로그램 변환을 다중 에이전트 환경에서도 허용하는 것이 바람직합니다. 이러한 변환은 판단하기 어려운 경우가 많습니다. 여기서는 규범적으로 받아들여지도록 의도된(메모리 모델 에 의해 암시되거나 메모리 모델 이 암시하는 것보다 더 강한) 프로그램 변환에 관한 몇 가지 규칙을 개략적으로 설명하지만, 완전한 목록은 아닐 가능성이 높습니다. 이러한 규칙은 is-agent-order-before Relation 을 구성하는 Memory 이벤트 가 도입되기 전에 이루어지는 프로그램 변환에 적용하도록 의도됩니다.
단일 에이전트 와 관련된 is-agent-order-before Relation 의 부분집합을 agent-order slice 라고 합니다.
읽기 이벤트 의 가능한 읽기 값 을 모든 유효한 실행에 걸쳐 해당 이벤트의 ValueOfReadEvent 가 가질 수 있는 모든 값의 집합이라고 합니다.
공유 메모리가 없을 때 유효한 agent-order slice의 모든 변환은 다음 예외를 제외하고 공유 메모리가 있을 때도 유효합니다.
Atomics는 변경할 수 없습니다 : 프로그램 변환은 [[Order]] 가 seq-cst 인 Shared Data Block 이벤트 를 is-agent-order-before Relation 에서 제거하거나, 서로의 순서를 바꾸거나, [[Order]] 가 unordered 인 이벤트와 관련하여 agent-order slice 안에서 순서를 바꾸어서는 안 됩니다.
(실제로 순서 변경 금지는 컴파일러가 모든 seq-cst 연산을 동기화로 간주하고 최종 is-memory-order-before Relation 에 포함된다고 가정하도록 강제합니다. 에이전트 간 프로그램 분석이 없다면 어차피 일반적으로 그렇게 가정해야 합니다. 또한 호출 대상의 memory-order에 대한 효과를 알 수 없는 모든 호출이 seq-cst 연산을 포함할 수 있다고 컴파일러가 가정하도록 강제합니다.)
읽기는 안정적이어야 합니다 : 주어진 공유 메모리 읽기는 한 실행에서 하나의 값만 관찰해야 합니다.
(예를 들어 프로그램에서 의미상 하나의 읽기가 여러 번 실행되면 프로그램은 그 뒤 읽힌 값 중 하나만 관찰할 수 있습니다. rematerialization으로 알려진 변환은 이 규칙을 위반할 수 있습니다.)
쓰기는 안정적이어야 합니다 : 공유 메모리에 대한 모든 관찰 가능한 쓰기는 실행의 프로그램 의미론에서 비롯되어야 합니다.
(예를 들어 더 작은 데이터를 쓰기 위해 더 큰 위치에 read-modify-write 연산을 사용하거나, 프로그램이 쓸 수 없는 값을 메모리에 쓰거나, 읽은 위치가 읽기 후 다른 에이전트 에 의해 덮어쓰였을 수 있는데도 방금 읽은 값을 같은 위치에 다시 쓰는 것처럼 특정 관찰 가능한 쓰기를 변환이 도입해서는 안 됩니다.)
가능한 읽기 값은 비어 있지 않아야 합니다 : 프로그램 변환으로 인해 공유 메모리 읽기의 가능한 읽기 값이 빈 집합이 되어서는 안 됩니다.
(직관과 달리 이 규칙은 사실상 쓰기에 대한 변환을 제한합니다. 메모리 모델 에서 쓰기는 읽기 이벤트 가 읽을 수 있다는 점에서 효력을 갖기 때문입니다. 예를 들어 두 seq-cst 연산 사이에서 쓰기를 이동하고 병합하며 때로는 순서를 바꿀 수 있지만, 변환은 위치를 업데이트하는 모든 쓰기를 제거해서는 안 됩니다. 일부 쓰기는 보존해야 합니다.)
계속 유효한 변환의 예로는 동일한 위치에서 여러 비원자적 읽기를 병합하는 것, 비원자적 읽기의 순서를 바꾸는 것, 추측적 비원자적 읽기를 도입하는 것, 동일한 위치에 대한 여러 비원자적 쓰기를 병합하는 것, 서로 다른 위치에 대한 비원자적 쓰기의 순서를 바꾸는 것, 종료 여부에 영향을 미치더라도 비원자적 읽기를 루프 밖으로 끌어올리는 것이 있습니다. 일반적으로 별칭이 있는 TypedArray 는 위치가 서로 다름을 증명하기 어렵게 한다는 점에 유의하시기 바랍니다.
참고 3
다음은 공유 메모리 접근을 위한 기계어 코드를 생성하는 ECMAScript 구현자를 위한 지침입니다.
메모리 모델 이 ARM 또는 Power보다 약하지 않은 아키텍처에서는 비원자적 store와 load를 대상 아키텍처의 단순 store 및 load로 컴파일할 수 있습니다. 원자적 store와 load는 순차적 일관성을 보장하는 명령으로 컴파일할 수 있습니다. 그러한 명령이 없으면 단순 store 또는 load의 양쪽에 배리어를 배치하는 것과 같은 메모리 배리어를 사용해야 합니다. read-modify-write 연산은 x86의 LOCK 접두사가 붙은 명령, ARM의 load-exclusive/store-exclusive 명령, Power의 load-link/store-conditional 명령과 같은 대상 아키텍처의 read-modify-write 명령으로 컴파일할 수 있습니다.
구체적으로 메모리 모델 은 다음과 같은 코드 생성을 허용하도록 의도됩니다.
프로그램의 모든 원자적 연산은 필요하다고 가정합니다.
원자적 연산은 서로 또는 비원자적 연산과 절대 순서를 바꾸지 않습니다.
함수는 항상 원자적 연산을 수행한다고 가정합니다.
원자적 연산은 더 큰 데이터에 대한 read-modify-write 연산으로 구현하지 않으며, 플랫폼에 적절한 크기의 원자적 연산이 없으면 non-lock-free 원자적 연산으로 구현합니다. (우리는 이미 모든 플랫폼이 관심 있는 모든 크기의 일반 메모리 접근 연산을 갖는다고 가정합니다.)
단순한 코드 생성은 다음 패턴을 사용합니다:
일반 load 및 store는 단일 load 및 store 명령으로 컴파일합니다.
lock-free 원자적 load 및 store는 전체(순차적 일관성) fence, 일반 load 또는 store, 전체 fence로 컴파일합니다.
lock-free 원자적 read-modify-write 접근은 전체 fence, 원자적 read-modify-write 명령 시퀀스, 전체 fence로 컴파일합니다.
non-lock-free 원자적 연산은 spinlock 획득, 전체 fence, 일련의 비원자적 load 및 store 명령, 전체 fence, spinlock 해제로 컴파일합니다.
메모리 범위 에 대한 원자적 연산이 비원자적 쓰기 또는 다른 크기의 원자적 연산과 경합 하지 않는 한 이 매핑은 올바릅니다. 그러나 이것이면 충분합니다. 메모리 모델 은 경합 에 관여하는 원자적 연산을 사실상 비원자적 상태로 강등합니다. 반면 단순 매핑은 상당히 강합니다. 원자적 연산을 순차적으로 일관된 fence로 사용할 수 있게 하는데, 이는 메모리 모델 이 실제로 보장하지는 않습니다.
메모리 모델 의 제약을 따르는 한 이러한 기본 패턴에 대한 로컬 개선도 허용됩니다. 예를 들면:
중복 fence를 제거하는 명백한 플랫폼 의존적 개선이 있습니다. 예를 들어 x86에서는 lock-free 원자적 load 및 store 주변의 fence를 항상 생략할 수 있으며 store 뒤의 fence만 예외입니다. lock-free read-modify-write 명령은 모두 LOCK 접두사가 붙은 명령을 사용하므로 fence가 필요하지 않습니다. 많은 플랫폼에는 여러 강도의 fence가 있으며 특정 컨텍스트에서는 순차적 일관성을 깨뜨리지 않고 더 약한 fence를 사용할 수 있습니다.
대부분의 현대 플랫폼은 ECMAScript 원자적 연산에 필요한 모든 데이터 크기에 대해 lock-free 원자적 연산을 지원합니다. non-lock-free 원자적 연산이 필요한 경우 원자적 연산 본문 주변의 fence를 보통 lock과 unlock 단계에 통합할 수 있습니다. non-lock-free 원자적 연산의 가장 간단한 해결책은 SharedArrayBuffer마다 하나의 lock word를 두는 것입니다.
일부 코드 분석이 필요한 더 복잡한 플랫폼 의존적 로컬 개선도 있습니다. 예를 들어 연속된 두 fence는 하나의 fence와 같은 효과를 갖는 경우가 많으므로 두 원자적 연산이 연속되는 코드를 생성한다면 하나의 fence만으로 분리할 수 있습니다. x86에서는 store 뒤의 fence가 store를 이후 load와 분리하기 위해서만 필요하므로 원자적 store를 분리하는 단일 fence조차 생략할 수 있습니다.
부속서 A (참고) 문법 요약
A.1 어휘 문법
SourceCharacter ::
any Unicode code point
InputElementDiv ::
WhiteSpace
LineTerminator
Comment
CommonToken
DivPunctuator
RightBracePunctuator
InputElementRegExp ::
WhiteSpace
LineTerminator
Comment
CommonToken
RightBracePunctuator
RegularExpressionLiteral
InputElementRegExpOrTemplateTail ::
WhiteSpace
LineTerminator
Comment
CommonToken
RegularExpressionLiteral
TemplateSubstitutionTail
InputElementTemplateTail ::
WhiteSpace
LineTerminator
Comment
CommonToken
DivPunctuator
TemplateSubstitutionTail
InputElementHashbangOrRegExp ::
WhiteSpace
LineTerminator
Comment
CommonToken
HashbangComment
RegularExpressionLiteral
WhiteSpace ::
<TAB>
<VT>
<FF>
<ZWNBSP>
<USP>
LineTerminator ::
<LF>
<CR>
<LS>
<PS>
LineTerminatorSequence ::
<LF>
<CR>
[lookahead ≠ <LF> ]
<LS>
<PS>
<CR>
<LF>
Comment ::
MultiLineComment
SingleLineComment
MultiLineComment ::
/*
MultiLineCommentChars opt
*/
MultiLineCommentChars ::
MultiLineNotAsteriskChar
MultiLineCommentChars opt
*
PostAsteriskCommentChars opt
PostAsteriskCommentChars ::
MultiLineNotForwardSlashOrAsteriskChar
MultiLineCommentChars opt
*
PostAsteriskCommentChars opt
MultiLineNotAsteriskChar ::
SourceCharacter but not *
MultiLineNotForwardSlashOrAsteriskChar ::
SourceCharacter but not one of / or *
SingleLineComment ::
//
SingleLineCommentChars opt
SingleLineCommentChars ::
SingleLineCommentChar
SingleLineCommentChars opt
SingleLineCommentChar ::
SourceCharacter but not LineTerminator
HashbangComment ::
#!
SingleLineCommentChars opt
CommonToken ::
IdentifierName
PrivateIdentifier
Punctuator
NumericLiteral
StringLiteral
Template
PrivateIdentifier ::
#
IdentifierName
IdentifierName ::
IdentifierStart
IdentifierName
IdentifierPart
IdentifierStart ::
IdentifierStartChar
\
UnicodeEscapeSequence
IdentifierPart ::
IdentifierPartChar
\
UnicodeEscapeSequence
IdentifierStartChar ::
UnicodeIDStart
$
_
IdentifierPartChar ::
UnicodeIDContinue
$
AsciiLetter :: one of a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
UnicodeIDStart ::
any Unicode code point with the Unicode property “ID_Start”
UnicodeIDContinue ::
any Unicode code point with the Unicode property “ID_Continue”
ReservedWord :: one of await break case catch class const continue debugger default delete do else enum export extends false finally for function if import in instanceof new null return super switch this throw true try typeof var void while with yield
Punctuator ::
OptionalChainingPunctuator
OtherPunctuator
OptionalChainingPunctuator ::
?.
[lookahead ∉ DecimalDigit ]
OtherPunctuator :: one of { ( ) [ ] . ... ; , < > <= >= == != === !== + - * % ** ++ -- << >> >>> & | ^ ! ~ && || ?? ? : = += -= *= %= **= <<= >>= >>>= &= |= ^= &&= ||= ??= =>
DivPunctuator ::
/
/=
RightBracePunctuator ::
}
NullLiteral ::
null
BooleanLiteral ::
true
false
NumericLiteralSeparator ::
_
NumericLiteral ::
DecimalLiteral
DecimalBigIntegerLiteral
NonDecimalIntegerLiteral [+Sep]
NonDecimalIntegerLiteral [+Sep]
BigIntLiteralSuffix
LegacyOctalIntegerLiteral
DecimalBigIntegerLiteral ::
0
BigIntLiteralSuffix
NonZeroDigit
DecimalDigits [+Sep] opt
BigIntLiteralSuffix
NonZeroDigit
NumericLiteralSeparator
DecimalDigits [+Sep]
BigIntLiteralSuffix
NonDecimalIntegerLiteral [Sep] ::
BinaryIntegerLiteral [?Sep]
OctalIntegerLiteral [?Sep]
HexIntegerLiteral [?Sep]
BigIntLiteralSuffix ::
n
DecimalLiteral ::
DecimalIntegerLiteral
.
DecimalDigits [+Sep] opt
ExponentPart [+Sep] opt
.
DecimalDigits [+Sep]
ExponentPart [+Sep] opt
DecimalIntegerLiteral
ExponentPart [+Sep] opt
DecimalIntegerLiteral ::
DecimalDigit
NonZeroDigit
NumericLiteralSeparator opt
DecimalDigits [+Sep]
NonOctalDecimalIntegerLiteral
DecimalDigits [Sep] ::
DecimalDigit
DecimalDigits [?Sep]
DecimalDigit
[+Sep]
DecimalDigits [+Sep]
NumericLiteralSeparator
DecimalDigit
DecimalDigit :: one of 0 1 2 3 4 5 6 7 8 9
NonZeroDigit :: one of 1 2 3 4 5 6 7 8 9
ExponentPart [Sep] ::
ExponentIndicator
SignedInteger [?Sep]
ExponentIndicator :: one of e E
SignedInteger [Sep] ::
DecimalDigits [?Sep]
+
DecimalDigits [?Sep]
-
DecimalDigits [?Sep]
BinaryIntegerLiteral [Sep] ::
0b
BinaryDigits [?Sep]
0B
BinaryDigits [?Sep]
BinaryDigits [Sep] ::
BinaryDigit
BinaryDigits [?Sep]
BinaryDigit
[+Sep]
BinaryDigits [+Sep]
NumericLiteralSeparator
BinaryDigit
BinaryDigit :: one of 0 1
OctalIntegerLiteral [Sep] ::
0o
OctalDigits [?Sep]
0O
OctalDigits [?Sep]
OctalDigits [Sep] ::
OctalDigit
OctalDigits [?Sep]
OctalDigit
[+Sep]
OctalDigits [+Sep]
NumericLiteralSeparator
OctalDigit
LegacyOctalIntegerLiteral ::
0
OctalDigit
LegacyOctalIntegerLiteral
OctalDigit
NonOctalDecimalIntegerLiteral ::
0
LegacyOctalLikeDecimalDigits opt
NonOctalDigit
NonOctalDecimalIntegerLiteral
DecimalDigit
LegacyOctalLikeDecimalDigits ::
OctalDigit
LegacyOctalLikeDecimalDigits
OctalDigit
OctalDigit :: one of 0 1 2 3 4 5 6 7
NonOctalDigit :: one of 8 9
HexIntegerLiteral [Sep] ::
0x
HexDigits [?Sep]
0X
HexDigits [?Sep]
HexDigits [Sep] ::
HexDigit
HexDigits [?Sep]
HexDigit
[+Sep]
HexDigits [+Sep]
NumericLiteralSeparator
HexDigit
HexDigit :: one of 0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F
StringLiteral ::
"
DoubleStringCharacters opt
"
'
SingleStringCharacters opt
'
DoubleStringCharacters ::
DoubleStringCharacter
DoubleStringCharacters opt
SingleStringCharacters ::
SingleStringCharacter
SingleStringCharacters opt
DoubleStringCharacter ::
SourceCharacter but not one of " or \ or LineTerminator
<LS>
<PS>
\
EscapeSequence
LineContinuation
SingleStringCharacter ::
SourceCharacter but not one of ' or \ or LineTerminator
<LS>
<PS>
\
EscapeSequence
LineContinuation
LineContinuation ::
\
LineTerminatorSequence
EscapeSequence ::
CharacterEscapeSequence
0
[lookahead ∉ DecimalDigit ]
LegacyOctalEscapeSequence
NonOctalDecimalEscapeSequence
HexEscapeSequence
UnicodeEscapeSequence
CharacterEscapeSequence ::
SingleEscapeCharacter
NonEscapeCharacter
SingleEscapeCharacter :: one of ' " \ b f n r t v
NonEscapeCharacter ::
SourceCharacter but not one of EscapeCharacter or LineTerminator
EscapeCharacter ::
SingleEscapeCharacter
DecimalDigit
x
u
LegacyOctalEscapeSequence ::
0
[lookahead ∈ { 8 , 9 }]
NonZeroOctalDigit
[lookahead ∉ OctalDigit ]
ZeroToThree
OctalDigit
[lookahead ∉ OctalDigit ]
FourToSeven
OctalDigit
ZeroToThree
OctalDigit
OctalDigit
NonZeroOctalDigit ::
OctalDigit but not 0
ZeroToThree :: one of 0 1 2 3
FourToSeven :: one of 4 5 6 7
NonOctalDecimalEscapeSequence :: one of 8 9
HexEscapeSequence ::
x
HexDigit
HexDigit
UnicodeEscapeSequence ::
u
Hex4Digits
u{
CodePoint
}
Hex4Digits ::
HexDigit
HexDigit
HexDigit
HexDigit
RegularExpressionLiteral ::
/
RegularExpressionBody
/
RegularExpressionFlags
RegularExpressionBody ::
RegularExpressionFirstChar
RegularExpressionChars
RegularExpressionChars ::
[empty]
RegularExpressionChars
RegularExpressionChar
RegularExpressionFirstChar ::
RegularExpressionNonTerminator but not one of * or \ or / or [
RegularExpressionBackslashSequence
RegularExpressionClass
RegularExpressionChar ::
RegularExpressionNonTerminator but not one of \ or / or [
RegularExpressionBackslashSequence
RegularExpressionClass
RegularExpressionBackslashSequence ::
\
RegularExpressionNonTerminator
RegularExpressionNonTerminator ::
SourceCharacter but not LineTerminator
RegularExpressionClass ::
[
RegularExpressionClassChars
]
RegularExpressionClassChars ::
[empty]
RegularExpressionClassChars
RegularExpressionClassChar
RegularExpressionClassChar ::
RegularExpressionNonTerminator but not one of ] or \
RegularExpressionBackslashSequence
RegularExpressionFlags ::
[empty]
RegularExpressionFlags
IdentifierPartChar
Template ::
NoSubstitutionTemplate
TemplateHead
NoSubstitutionTemplate ::
`
TemplateCharacters opt
`
TemplateHead ::
`
TemplateCharacters opt
${
TemplateSubstitutionTail ::
TemplateMiddle
TemplateTail
TemplateMiddle ::
}
TemplateCharacters opt
${
TemplateTail ::
}
TemplateCharacters opt
`
TemplateCharacters ::
TemplateCharacter
TemplateCharacters opt
TemplateCharacter ::
$
[lookahead ≠ { ]
\
TemplateEscapeSequence
\
NotEscapeSequence
LineContinuation
LineTerminatorSequence
SourceCharacter but not one of ` or \ or $ or LineTerminator
TemplateEscapeSequence ::
CharacterEscapeSequence
0
[lookahead ∉ DecimalDigit ]
HexEscapeSequence
UnicodeEscapeSequence
NotEscapeSequence ::
0
DecimalDigit
DecimalDigit but not 0
x
[lookahead ∉ HexDigit ]
x
HexDigit
[lookahead ∉ HexDigit ]
u
[lookahead ∉ HexDigit ]
[lookahead ≠ { ]
u
HexDigit
[lookahead ∉ HexDigit ]
u
HexDigit
HexDigit
[lookahead ∉ HexDigit ]
u
HexDigit
HexDigit
HexDigit
[lookahead ∉ HexDigit ]
u
{
[lookahead ∉ HexDigit ]
u
{
NotCodePoint
[lookahead ∉ HexDigit ]
u
{
CodePoint
[lookahead ∉ HexDigit ]
[lookahead ≠ } ]
NotCodePoint ::
HexDigits [~Sep]
but only if the MV of HexDigits > 0x10FFFF
CodePoint ::
HexDigits [~Sep]
but only if the MV of HexDigits ≤ 0x10FFFF
A.2 표현식
IdentifierReference [Yield, Await] :
Identifier
[~Yield]
yield
[~Await]
await
BindingIdentifier [Yield, Await] :
Identifier
yield
await
LabelIdentifier [Yield, Await] :
Identifier
[~Yield]
yield
[~Await]
await
Identifier :
IdentifierName but not ReservedWord
PrimaryExpression [Yield, Await] :
this
IdentifierReference [?Yield, ?Await]
Literal
ArrayLiteral [?Yield, ?Await]
ObjectLiteral [?Yield, ?Await]
FunctionExpression
ClassExpression [?Yield, ?Await]
GeneratorExpression
AsyncFunctionExpression
AsyncGeneratorExpression
RegularExpressionLiteral
TemplateLiteral [?Yield, ?Await, ~Tagged]
CoverParenthesizedExpressionAndArrowParameterList [?Yield, ?Await]
CoverParenthesizedExpressionAndArrowParameterList [Yield, Await] :
(
)
(
Expression [+In, ?Yield, ?Await]
,opt
)
(
...
BindingIdentifier [?Yield, ?Await]
)
(
...
BindingPattern [?Yield, ?Await]
)
(
Expression [+In, ?Yield, ?Await]
,
...
BindingIdentifier [?Yield, ?Await]
)
(
Expression [+In, ?Yield, ?Await]
,
...
BindingPattern [?Yield, ?Await]
)
다음 생성물의 인스턴스를 처리할 때
PrimaryExpression [Yield, Await] :
CoverParenthesizedExpressionAndArrowParameterList [?Yield, ?Await]
CoverParenthesizedExpressionAndArrowParameterList 의 해석은 다음 문법을 사용하여 정제됩니다:
ParenthesizedExpression [Yield, Await] :
(
Expression [+In, ?Yield, ?Await]
)
Literal :
NullLiteral
BooleanLiteral
NumericLiteral
StringLiteral
ArrayLiteral [Yield, Await] :
[
Elision opt
]
[
ElementList [?Yield, ?Await]
]
[
ElementList [?Yield, ?Await]
,
Elision opt
]
ElementList [Yield, Await] :
Elision opt
AssignmentExpression [+In, ?Yield, ?Await]
Elision opt
SpreadElement [?Yield, ?Await]
ElementList [?Yield, ?Await]
,
Elision opt
AssignmentExpression [+In, ?Yield, ?Await]
ElementList [?Yield, ?Await]
,
Elision opt
SpreadElement [?Yield, ?Await]
Elision :
,
Elision
,
SpreadElement [Yield, Await] :
...
AssignmentExpression [+In, ?Yield, ?Await]
ObjectLiteral [Yield, Await] :
{
}
{
PropertyDefinitionList [?Yield, ?Await]
,opt
}
PropertyDefinitionList [Yield, Await] :
PropertyDefinition [?Yield, ?Await]
PropertyDefinitionList [?Yield, ?Await]
,
PropertyDefinition [?Yield, ?Await]
PropertyDefinition [Yield, Await] :
IdentifierReference [?Yield, ?Await]
CoverInitializedName [?Yield, ?Await]
PropertyName [?Yield, ?Await]
:
AssignmentExpression [+In, ?Yield, ?Await]
MethodDefinition [?Yield, ?Await]
...
AssignmentExpression [+In, ?Yield, ?Await]
PropertyName [Yield, Await] :
LiteralPropertyName
ComputedPropertyName [?Yield, ?Await]
LiteralPropertyName :
IdentifierName
StringLiteral
NumericLiteral
ComputedPropertyName [Yield, Await] :
[
AssignmentExpression [+In, ?Yield, ?Await]
]
CoverInitializedName [Yield, Await] :
IdentifierReference [?Yield, ?Await]
Initializer [+In, ?Yield, ?Await]
Initializer [In, Yield, Await] :
=
AssignmentExpression [?In, ?Yield, ?Await]
TemplateLiteral [Yield, Await, Tagged] :
NoSubstitutionTemplate
SubstitutionTemplate [?Yield, ?Await]
SubstitutionTemplate [Yield, Await] :
TemplateHead
Expression [+In, ?Yield, ?Await]
TemplateSpans [?Yield, ?Await]
TemplateSpans [Yield, Await] :
TemplateTail
TemplateMiddleList [?Yield, ?Await]
TemplateTail
TemplateMiddleList [Yield, Await] :
TemplateMiddle
Expression [+In, ?Yield, ?Await]
TemplateMiddleList [?Yield, ?Await]
TemplateMiddle
Expression [+In, ?Yield, ?Await]
MemberExpression [Yield, Await] :
PrimaryExpression [?Yield, ?Await]
MemberExpression [?Yield, ?Await]
[
Expression [+In, ?Yield, ?Await]
]
MemberExpression [?Yield, ?Await]
.
IdentifierName
MemberExpression [?Yield, ?Await]
TemplateLiteral [?Yield, ?Await, +Tagged]
SuperProperty [?Yield, ?Await]
MetaProperty
new
MemberExpression [?Yield, ?Await]
Arguments [?Yield, ?Await]
MemberExpression [?Yield, ?Await]
.
PrivateIdentifier
SuperProperty [Yield, Await] :
super
[
Expression [+In, ?Yield, ?Await]
]
super
.
IdentifierName
MetaProperty :
NewTarget
ImportMeta
NewTarget :
new
.
target
ImportMeta :
import
.
meta
NewExpression [Yield, Await] :
MemberExpression [?Yield, ?Await]
new
NewExpression [?Yield, ?Await]
CallExpression [Yield, Await] :
CoverCallExpressionAndAsyncArrowHead [?Yield, ?Await]
SuperCall [?Yield, ?Await]
ImportCall [?Yield, ?Await]
CallExpression [?Yield, ?Await]
Arguments [?Yield, ?Await]
CallExpression [?Yield, ?Await]
[
Expression [+In, ?Yield, ?Await]
]
CallExpression [?Yield, ?Await]
.
IdentifierName
CallExpression [?Yield, ?Await]
TemplateLiteral [?Yield, ?Await, +Tagged]
CallExpression [?Yield, ?Await]
.
PrivateIdentifier
다음 생성물의 인스턴스를 처리할 때
CallExpression [Yield, Await] :
CoverCallExpressionAndAsyncArrowHead [?Yield, ?Await]
CoverCallExpressionAndAsyncArrowHead 의 해석은 다음 문법을 사용하여 정제됩니다:
CallMemberExpression [Yield, Await] :
MemberExpression [?Yield, ?Await]
Arguments [?Yield, ?Await]
SuperCall [Yield, Await] :
super
Arguments [?Yield, ?Await]
ImportCall [Yield, Await] :
import
(
AssignmentExpression [+In, ?Yield, ?Await]
,opt
)
import
(
AssignmentExpression [+In, ?Yield, ?Await]
,
AssignmentExpression [+In, ?Yield, ?Await]
,opt
)
Arguments [Yield, Await] :
(
)
(
ArgumentList [?Yield, ?Await]
,opt
)
ArgumentList [Yield, Await] :
AssignmentExpression [+In, ?Yield, ?Await]
...
AssignmentExpression [+In, ?Yield, ?Await]
ArgumentList [?Yield, ?Await]
,
AssignmentExpression [+In, ?Yield, ?Await]
ArgumentList [?Yield, ?Await]
,
...
AssignmentExpression [+In, ?Yield, ?Await]
OptionalExpression [Yield, Await] :
MemberExpression [?Yield, ?Await]
OptionalChain [?Yield, ?Await]
CallExpression [?Yield, ?Await]
OptionalChain [?Yield, ?Await]
OptionalExpression [?Yield, ?Await]
OptionalChain [?Yield, ?Await]
OptionalChain [Yield, Await] :
?.
Arguments [?Yield, ?Await]
?.
[
Expression [+In, ?Yield, ?Await]
]
?.
IdentifierName
?.
TemplateLiteral [?Yield, ?Await, +Tagged]
?.
PrivateIdentifier
OptionalChain [?Yield, ?Await]
Arguments [?Yield, ?Await]
OptionalChain [?Yield, ?Await]
[
Expression [+In, ?Yield, ?Await]
]
OptionalChain [?Yield, ?Await]
.
IdentifierName
OptionalChain [?Yield, ?Await]
TemplateLiteral [?Yield, ?Await, +Tagged]
OptionalChain [?Yield, ?Await]
.
PrivateIdentifier
LeftHandSideExpression [Yield, Await] :
NewExpression [?Yield, ?Await]
CallExpression [?Yield, ?Await]
OptionalExpression [?Yield, ?Await]
UpdateExpression [Yield, Await] :
LeftHandSideExpression [?Yield, ?Await]
LeftHandSideExpression [?Yield, ?Await]
[no LineTerminator here]
++
LeftHandSideExpression [?Yield, ?Await]
[no LineTerminator here]
--
++
UnaryExpression [?Yield, ?Await]
--
UnaryExpression [?Yield, ?Await]
UnaryExpression [Yield, Await] :
UpdateExpression [?Yield, ?Await]
delete
UnaryExpression [?Yield, ?Await]
void
UnaryExpression [?Yield, ?Await]
typeof
UnaryExpression [?Yield, ?Await]
+
UnaryExpression [?Yield, ?Await]
-
UnaryExpression [?Yield, ?Await]
~
UnaryExpression [?Yield, ?Await]
!
UnaryExpression [?Yield, ?Await]
[+Await]
CoverAwaitExpressionAndAwaitUsingDeclarationHead [?Yield]
CoverAwaitExpressionAndAwaitUsingDeclarationHead [Yield] :
await
UnaryExpression [?Yield, +Await]
다음 생성물의 인스턴스를 처리할 때
UnaryExpression [Yield, Await] : [+Await]
CoverAwaitExpressionAndAwaitUsingDeclarationHead [?Yield]
CoverAwaitExpressionAndAwaitUsingDeclarationHead 의 해석은 다음 문법을 사용하여 정제됩니다:
AwaitExpression [Yield] :
await
UnaryExpression [?Yield, +Await]
ExponentiationExpression [Yield, Await] :
UnaryExpression [?Yield, ?Await]
UpdateExpression [?Yield, ?Await]
**
ExponentiationExpression [?Yield, ?Await]
MultiplicativeExpression [Yield, Await] :
ExponentiationExpression [?Yield, ?Await]
MultiplicativeExpression [?Yield, ?Await]
MultiplicativeOperator
ExponentiationExpression [?Yield, ?Await]
MultiplicativeOperator : one of * / %
AdditiveExpression [Yield, Await] :
MultiplicativeExpression [?Yield, ?Await]
AdditiveExpression [?Yield, ?Await]
+
MultiplicativeExpression [?Yield, ?Await]
AdditiveExpression [?Yield, ?Await]
-
MultiplicativeExpression [?Yield, ?Await]
ShiftExpression [Yield, Await] :
AdditiveExpression [?Yield, ?Await]
ShiftExpression [?Yield, ?Await]
<<
AdditiveExpression [?Yield, ?Await]
ShiftExpression [?Yield, ?Await]
>>
AdditiveExpression [?Yield, ?Await]
ShiftExpression [?Yield, ?Await]
>>>
AdditiveExpression [?Yield, ?Await]
RelationalExpression [In, Yield, Await] :
ShiftExpression [?Yield, ?Await]
RelationalExpression [?In, ?Yield, ?Await]
<
ShiftExpression [?Yield, ?Await]
RelationalExpression [?In, ?Yield, ?Await]
>
ShiftExpression [?Yield, ?Await]
RelationalExpression [?In, ?Yield, ?Await]
<=
ShiftExpression [?Yield, ?Await]
RelationalExpression [?In, ?Yield, ?Await]
>=
ShiftExpression [?Yield, ?Await]
RelationalExpression [?In, ?Yield, ?Await]
instanceof
ShiftExpression [?Yield, ?Await]
[+In]
RelationalExpression [+In, ?Yield, ?Await]
in
ShiftExpression [?Yield, ?Await]
[+In]
PrivateIdentifier
in
ShiftExpression [?Yield, ?Await]
EqualityExpression [In, Yield, Await] :
RelationalExpression [?In, ?Yield, ?Await]
EqualityExpression [?In, ?Yield, ?Await]
==
RelationalExpression [?In, ?Yield, ?Await]
EqualityExpression [?In, ?Yield, ?Await]
!=
RelationalExpression [?In, ?Yield, ?Await]
EqualityExpression [?In, ?Yield, ?Await]
===
RelationalExpression [?In, ?Yield, ?Await]
EqualityExpression [?In, ?Yield, ?Await]
!==
RelationalExpression [?In, ?Yield, ?Await]
BitwiseANDExpression [In, Yield, Await] :
EqualityExpression [?In, ?Yield, ?Await]
BitwiseANDExpression [?In, ?Yield, ?Await]
&
EqualityExpression [?In, ?Yield, ?Await]
BitwiseXORExpression [In, Yield, Await] :
BitwiseANDExpression [?In, ?Yield, ?Await]
BitwiseXORExpression [?In, ?Yield, ?Await]
^
BitwiseANDExpression [?In, ?Yield, ?Await]
BitwiseORExpression [In, Yield, Await] :
BitwiseXORExpression [?In, ?Yield, ?Await]
BitwiseORExpression [?In, ?Yield, ?Await]
|
BitwiseXORExpression [?In, ?Yield, ?Await]
LogicalANDExpression [In, Yield, Await] :
BitwiseORExpression [?In, ?Yield, ?Await]
LogicalANDExpression [?In, ?Yield, ?Await]
&&
BitwiseORExpression [?In, ?Yield, ?Await]
LogicalORExpression [In, Yield, Await] :
LogicalANDExpression [?In, ?Yield, ?Await]
LogicalORExpression [?In, ?Yield, ?Await]
||
LogicalANDExpression [?In, ?Yield, ?Await]
CoalesceExpression [In, Yield, Await] :
CoalesceExpressionHead [?In, ?Yield, ?Await]
??
BitwiseORExpression [?In, ?Yield, ?Await]
CoalesceExpressionHead [In, Yield, Await] :
CoalesceExpression [?In, ?Yield, ?Await]
BitwiseORExpression [?In, ?Yield, ?Await]
ShortCircuitExpression [In, Yield, Await] :
LogicalORExpression [?In, ?Yield, ?Await]
CoalesceExpression [?In, ?Yield, ?Await]
ConditionalExpression [In, Yield, Await] :
ShortCircuitExpression [?In, ?Yield, ?Await]
ShortCircuitExpression [?In, ?Yield, ?Await]
?
AssignmentExpression [+In, ?Yield, ?Await]
:
AssignmentExpression [?In, ?Yield, ?Await]
AssignmentExpression [In, Yield, Await] :
ConditionalExpression [?In, ?Yield, ?Await]
[+Yield]
YieldExpression [?In, ?Await]
ArrowFunction [?In, ?Yield, ?Await]
AsyncArrowFunction [?In, ?Yield, ?Await]
LeftHandSideExpression [?Yield, ?Await]
=
AssignmentExpression [?In, ?Yield, ?Await]
LeftHandSideExpression [?Yield, ?Await]
AssignmentOperator
AssignmentExpression [?In, ?Yield, ?Await]
LeftHandSideExpression [?Yield, ?Await]
&&=
AssignmentExpression [?In, ?Yield, ?Await]
LeftHandSideExpression [?Yield, ?Await]
||=
AssignmentExpression [?In, ?Yield, ?Await]
LeftHandSideExpression [?Yield, ?Await]
??=
AssignmentExpression [?In, ?Yield, ?Await]
AssignmentOperator : one of *= /= %= += -= <<= >>= >>>= &= ^= |= **=
특정 상황에서 다음 생성물의 인스턴스를 처리할 때
AssignmentExpression [In, Yield, Await] :
LeftHandSideExpression [?Yield, ?Await]
=
AssignmentExpression [?In, ?Yield, ?Await]
LeftHandSideExpression 의 해석은 다음 문법을 사용하여 정제됩니다:
AssignmentPattern [Yield, Await] :
ObjectAssignmentPattern [?Yield, ?Await]
ArrayAssignmentPattern [?Yield, ?Await]
ObjectAssignmentPattern [Yield, Await] :
{
}
{
AssignmentRestProperty [?Yield, ?Await]
}
{
AssignmentPropertyList [?Yield, ?Await]
,opt
}
{
AssignmentPropertyList [?Yield, ?Await]
,
AssignmentRestProperty [?Yield, ?Await]
}
ArrayAssignmentPattern [Yield, Await] :
[
Elision opt
AssignmentRestElement [?Yield, ?Await] opt
]
[
AssignmentElementList [?Yield, ?Await]
]
[
AssignmentElementList [?Yield, ?Await]
,
Elision opt
AssignmentRestElement [?Yield, ?Await] opt
]
AssignmentRestProperty [Yield, Await] :
...
DestructuringAssignmentTarget [?Yield, ?Await]
AssignmentPropertyList [Yield, Await] :
AssignmentProperty [?Yield, ?Await]
AssignmentPropertyList [?Yield, ?Await]
,
AssignmentProperty [?Yield, ?Await]
AssignmentElementList [Yield, Await] :
AssignmentElisionElement [?Yield, ?Await]
AssignmentElementList [?Yield, ?Await]
,
AssignmentElisionElement [?Yield, ?Await]
AssignmentElisionElement [Yield, Await] :
Elision opt
AssignmentElement [?Yield, ?Await]
AssignmentProperty [Yield, Await] :
IdentifierReference [?Yield, ?Await]
Initializer [+In, ?Yield, ?Await] opt
PropertyName [?Yield, ?Await]
:
AssignmentElement [?Yield, ?Await]
AssignmentElement [Yield, Await] :
DestructuringAssignmentTarget [?Yield, ?Await]
Initializer [+In, ?Yield, ?Await] opt
AssignmentRestElement [Yield, Await] :
...
DestructuringAssignmentTarget [?Yield, ?Await]
DestructuringAssignmentTarget [Yield, Await] :
LeftHandSideExpression [?Yield, ?Await]
Expression [In, Yield, Await] :
AssignmentExpression [?In, ?Yield, ?Await]
Expression [?In, ?Yield, ?Await]
,
AssignmentExpression [?In, ?Yield, ?Await]
A.3 문
Statement [Yield, Await, Return] :
BlockStatement [?Yield, ?Await, ?Return]
VariableStatement [?Yield, ?Await]
EmptyStatement
ExpressionStatement [?Yield, ?Await]
IfStatement [?Yield, ?Await, ?Return]
BreakableStatement [?Yield, ?Await, ?Return]
ContinueStatement [?Yield, ?Await]
BreakStatement [?Yield, ?Await]
[+Return]
ReturnStatement [?Yield, ?Await]
WithStatement [?Yield, ?Await, ?Return]
LabelledStatement [?Yield, ?Await, ?Return]
ThrowStatement [?Yield, ?Await]
TryStatement [?Yield, ?Await, ?Return]
DebuggerStatement
Declaration [Yield, Await] :
HoistableDeclaration [?Yield, ?Await, ~Default]
ClassDeclaration [?Yield, ?Await, ~Default]
LexicalDeclaration [+In, ?Yield, ?Await]
HoistableDeclaration [Yield, Await, Default] :
FunctionDeclaration [?Yield, ?Await, ?Default]
GeneratorDeclaration [?Yield, ?Await, ?Default]
AsyncFunctionDeclaration [?Yield, ?Await, ?Default]
AsyncGeneratorDeclaration [?Yield, ?Await, ?Default]
BreakableStatement [Yield, Await, Return] :
IterationStatement [?Yield, ?Await, ?Return]
SwitchStatement [?Yield, ?Await, ?Return]
BlockStatement [Yield, Await, Return] :
Block [?Yield, ?Await, ?Return]
Block [Yield, Await, Return] :
{
StatementList [?Yield, ?Await, ?Return] opt
}
StatementList [Yield, Await, Return] :
StatementListItem [?Yield, ?Await, ?Return]
StatementList [?Yield, ?Await, ?Return]
StatementListItem [?Yield, ?Await, ?Return]
StatementListItem [Yield, Await, Return] :
Statement [?Yield, ?Await, ?Return]
Declaration [?Yield, ?Await]
LexicalDeclaration [In, Yield, Await] :
LetOrConst
BindingList [?In, ?Yield, ?Await, +Pattern]
;
UsingDeclaration [?In, ?Yield, ?Await]
[+Await]
AwaitUsingDeclaration [?In, ?Yield]
LetOrConst :
let
const
UsingDeclaration [In, Yield, Await] :
using
[no LineTerminator here]
BindingList [?In, ?Yield, ?Await, ~Pattern]
;
AwaitUsingDeclaration [In, Yield] :
CoverAwaitExpressionAndAwaitUsingDeclarationHead [?Yield]
[no LineTerminator here]
BindingList [?In, ?Yield, +Await, ~Pattern]
;
BindingList [In, Yield, Await, Pattern] :
LexicalBinding [?In, ?Yield, ?Await, ?Pattern]
BindingList [?In, ?Yield, ?Await, ?Pattern]
,
LexicalBinding [?In, ?Yield, ?Await, ?Pattern]
LexicalBinding [In, Yield, Await, Pattern] :
BindingIdentifier [?Yield, ?Await]
Initializer [?In, ?Yield, ?Await] opt
[+Pattern]
BindingPattern [?Yield, ?Await]
Initializer [?In, ?Yield, ?Await]
다음 생성물의 인스턴스를 처리할 때
AwaitUsingDeclaration [In, Yield] :
CoverAwaitExpressionAndAwaitUsingDeclarationHead [?Yield]
[no LineTerminator here]
BindingList [?In, ?Yield, +Await, ~Pattern]
;
CoverAwaitExpressionAndAwaitUsingDeclarationHead 의 해석은 다음 문법을 사용하여 정제됩니다:
AwaitUsingDeclarationHead :
await
[no LineTerminator here]
using
VariableStatement [Yield, Await] :
var
VariableDeclarationList [+In, ?Yield, ?Await]
;
VariableDeclarationList [In, Yield, Await] :
VariableDeclaration [?In, ?Yield, ?Await]
VariableDeclarationList [?In, ?Yield, ?Await]
,
VariableDeclaration [?In, ?Yield, ?Await]
VariableDeclaration [In, Yield, Await] :
BindingIdentifier [?Yield, ?Await]
Initializer [?In, ?Yield, ?Await] opt
BindingPattern [?Yield, ?Await]
Initializer [?In, ?Yield, ?Await]
BindingPattern [Yield, Await] :
ObjectBindingPattern [?Yield, ?Await]
ArrayBindingPattern [?Yield, ?Await]
ObjectBindingPattern [Yield, Await] :
{
}
{
BindingRestProperty [?Yield, ?Await]
}
{
BindingPropertyList [?Yield, ?Await]
,opt
}
{
BindingPropertyList [?Yield, ?Await]
,
BindingRestProperty [?Yield, ?Await]
}
ArrayBindingPattern [Yield, Await] :
[
Elision opt
BindingRestElement [?Yield, ?Await] opt
]
[
BindingElementList [?Yield, ?Await]
]
[
BindingElementList [?Yield, ?Await]
,
Elision opt
BindingRestElement [?Yield, ?Await] opt
]
BindingRestProperty [Yield, Await] :
...
BindingIdentifier [?Yield, ?Await]
BindingPropertyList [Yield, Await] :
BindingProperty [?Yield, ?Await]
BindingPropertyList [?Yield, ?Await]
,
BindingProperty [?Yield, ?Await]
BindingElementList [Yield, Await] :
BindingElisionElement [?Yield, ?Await]
BindingElementList [?Yield, ?Await]
,
BindingElisionElement [?Yield, ?Await]
BindingElisionElement [Yield, Await] :
Elision opt
BindingElement [?Yield, ?Await]
BindingProperty [Yield, Await] :
SingleNameBinding [?Yield, ?Await]
PropertyName [?Yield, ?Await]
:
BindingElement [?Yield, ?Await]
BindingElement [Yield, Await] :
SingleNameBinding [?Yield, ?Await]
BindingPattern [?Yield, ?Await]
Initializer [+In, ?Yield, ?Await] opt
SingleNameBinding [Yield, Await] :
BindingIdentifier [?Yield, ?Await]
Initializer [+In, ?Yield, ?Await] opt
BindingRestElement [Yield, Await] :
...
BindingIdentifier [?Yield, ?Await]
...
BindingPattern [?Yield, ?Await]
EmptyStatement :
;
ExpressionStatement [Yield, Await] :
[lookahead ∉ { { , function , async
[no LineTerminator here]
function , class , let
[ }]
Expression [+In, ?Yield, ?Await]
;
IfStatement [Yield, Await, Return] :
if
(
Expression [+In, ?Yield, ?Await]
)
Statement [?Yield, ?Await, ?Return]
else
Statement [?Yield, ?Await, ?Return]
if
(
Expression [+In, ?Yield, ?Await]
)
Statement [?Yield, ?Await, ?Return]
[lookahead ≠ else ]
IterationStatement [Yield, Await, Return] :
DoWhileStatement [?Yield, ?Await, ?Return]
WhileStatement [?Yield, ?Await, ?Return]
ForStatement [?Yield, ?Await, ?Return]
ForInOfStatement [?Yield, ?Await, ?Return]
DoWhileStatement [Yield, Await, Return] :
do
Statement [?Yield, ?Await, ?Return]
while
(
Expression [+In, ?Yield, ?Await]
)
;
WhileStatement [Yield, Await, Return] :
while
(
Expression [+In, ?Yield, ?Await]
)
Statement [?Yield, ?Await, ?Return]
ForStatement [Yield, Await, Return] :
for
(
[lookahead ≠ let
[ ]
Expression [~In, ?Yield, ?Await] opt
;
Expression [+In, ?Yield, ?Await] opt
;
Expression [+In, ?Yield, ?Await] opt
)
Statement [?Yield, ?Await, ?Return]
for
(
var
VariableDeclarationList [~In, ?Yield, ?Await]
;
Expression [+In, ?Yield, ?Await] opt
;
Expression [+In, ?Yield, ?Await] opt
)
Statement [?Yield, ?Await, ?Return]
for
(
LexicalDeclaration [~In, ?Yield, ?Await]
Expression [+In, ?Yield, ?Await] opt
;
Expression [+In, ?Yield, ?Await] opt
)
Statement [?Yield, ?Await, ?Return]
ForInOfStatement [Yield, Await, Return] :
for
(
[lookahead ≠ let
[ ]
LeftHandSideExpression [?Yield, ?Await]
in
Expression [+In, ?Yield, ?Await]
)
Statement [?Yield, ?Await, ?Return]
for
(
var
ForBinding [?Yield, ?Await, +Pattern]
in
Expression [+In, ?Yield, ?Await]
)
Statement [?Yield, ?Await, ?Return]
for
(
ForDeclaration [?Yield, ?Await, ~Using]
in
Expression [+In, ?Yield, ?Await]
)
Statement [?Yield, ?Await, ?Return]
for
(
[lookahead ∉ { let , async
of }]
LeftHandSideExpression [?Yield, ?Await]
of
AssignmentExpression [+In, ?Yield, ?Await]
)
Statement [?Yield, ?Await, ?Return]
for
(
var
ForBinding [?Yield, ?Await, +Pattern]
of
AssignmentExpression [+In, ?Yield, ?Await]
)
Statement [?Yield, ?Await, ?Return]
for
(
[lookahead ≠ using
of ]
ForDeclaration [?Yield, ?Await, +Using]
of
AssignmentExpression [+In, ?Yield, ?Await]
)
Statement [?Yield, ?Await, ?Return]
[+Await]
for
await
(
[lookahead ≠ let ]
LeftHandSideExpression [?Yield, ?Await]
of
AssignmentExpression [+In, ?Yield, ?Await]
)
Statement [?Yield, ?Await, ?Return]
[+Await]
for
await
(
var
ForBinding [?Yield, ?Await, +Pattern]
of
AssignmentExpression [+In, ?Yield, ?Await]
)
Statement [?Yield, ?Await, ?Return]
[+Await]
for
await
(
[lookahead ≠ using
of ]
ForDeclaration [?Yield, ?Await, +Using]
of
AssignmentExpression [+In, ?Yield, ?Await]
)
Statement [?Yield, ?Await, ?Return]
ForDeclaration [Yield, Await, Using] :
LetOrConst
ForBinding [?Yield, ?Await, +Pattern]
[+Using]
using
[no LineTerminator here]
ForBinding [?Yield, ?Await, ~Pattern]
[+Using, +Await]
await
[no LineTerminator here]
using
[no LineTerminator here]
ForBinding [?Yield, +Await, ~Pattern]
ForBinding [Yield, Await, Pattern] :
BindingIdentifier [?Yield, ?Await]
[+Pattern]
BindingPattern [?Yield, ?Await]
ContinueStatement [Yield, Await] :
continue
;
continue
[no LineTerminator here]
LabelIdentifier [?Yield, ?Await]
;
BreakStatement [Yield, Await] :
break
;
break
[no LineTerminator here]
LabelIdentifier [?Yield, ?Await]
;
ReturnStatement [Yield, Await] :
return
;
return
[no LineTerminator here]
Expression [+In, ?Yield, ?Await]
;
WithStatement [Yield, Await, Return] :
with
(
Expression [+In, ?Yield, ?Await]
)
Statement [?Yield, ?Await, ?Return]
SwitchStatement [Yield, Await, Return] :
switch
(
Expression [+In, ?Yield, ?Await]
)
CaseBlock [?Yield, ?Await, ?Return]
CaseBlock [Yield, Await, Return] :
{
CaseClauses [?Yield, ?Await, ?Return] opt
}
{
CaseClauses [?Yield, ?Await, ?Return] opt
DefaultClause [?Yield, ?Await, ?Return]
CaseClauses [?Yield, ?Await, ?Return] opt
}
CaseClauses [Yield, Await, Return] :
CaseClause [?Yield, ?Await, ?Return]
CaseClauses [?Yield, ?Await, ?Return]
CaseClause [?Yield, ?Await, ?Return]
CaseClause [Yield, Await, Return] :
case
Expression [+In, ?Yield, ?Await]
:
StatementList [?Yield, ?Await, ?Return] opt
DefaultClause [Yield, Await, Return] :
default
:
StatementList [?Yield, ?Await, ?Return] opt
LabelledStatement [Yield, Await, Return] :
LabelIdentifier [?Yield, ?Await]
:
LabelledItem [?Yield, ?Await, ?Return]
LabelledItem [Yield, Await, Return] :
Statement [?Yield, ?Await, ?Return]
FunctionDeclaration [?Yield, ?Await, ~Default]
ThrowStatement [Yield, Await] :
throw
[no LineTerminator here]
Expression [+In, ?Yield, ?Await]
;
TryStatement [Yield, Await, Return] :
try
Block [?Yield, ?Await, ?Return]
Catch [?Yield, ?Await, ?Return]
try
Block [?Yield, ?Await, ?Return]
Finally [?Yield, ?Await, ?Return]
try
Block [?Yield, ?Await, ?Return]
Catch [?Yield, ?Await, ?Return]
Finally [?Yield, ?Await, ?Return]
Catch [Yield, Await, Return] :
catch
(
CatchParameter [?Yield, ?Await]
)
Block [?Yield, ?Await, ?Return]
catch
Block [?Yield, ?Await, ?Return]
Finally [Yield, Await, Return] :
finally
Block [?Yield, ?Await, ?Return]
CatchParameter [Yield, Await] :
BindingIdentifier [?Yield, ?Await]
BindingPattern [?Yield, ?Await]
DebuggerStatement :
debugger
;
A.4 함수와 클래스
UniqueFormalParameters [Yield, Await] :
FormalParameters [?Yield, ?Await]
FormalParameters [Yield, Await] :
[empty]
FunctionRestParameter [?Yield, ?Await]
FormalParameterList [?Yield, ?Await]
FormalParameterList [?Yield, ?Await]
,
FormalParameterList [?Yield, ?Await]
,
FunctionRestParameter [?Yield, ?Await]
FormalParameterList [Yield, Await] :
FormalParameter [?Yield, ?Await]
FormalParameterList [?Yield, ?Await]
,
FormalParameter [?Yield, ?Await]
FunctionRestParameter [Yield, Await] :
BindingRestElement [?Yield, ?Await]
FormalParameter [Yield, Await] :
BindingElement [?Yield, ?Await]
FunctionDeclaration [Yield, Await, Default] :
function
BindingIdentifier [?Yield, ?Await]
(
FormalParameters [~Yield, ~Await]
)
{
FunctionBody [~Yield, ~Await]
}
[+Default]
function
(
FormalParameters [~Yield, ~Await]
)
{
FunctionBody [~Yield, ~Await]
}
FunctionExpression :
function
BindingIdentifier [~Yield, ~Await] opt
(
FormalParameters [~Yield, ~Await]
)
{
FunctionBody [~Yield, ~Await]
}
FunctionBody [Yield, Await] :
FunctionStatementList [?Yield, ?Await]
FunctionStatementList [Yield, Await] :
StatementList [?Yield, ?Await, +Return] opt
ArrowFunction [In, Yield, Await] :
ArrowParameters [?Yield, ?Await]
[no LineTerminator here]
=>
ConciseBody [?In]
ArrowParameters [Yield, Await] :
BindingIdentifier [?Yield, ?Await]
CoverParenthesizedExpressionAndArrowParameterList [?Yield, ?Await]
ConciseBody [In] :
[lookahead ≠ { ]
ExpressionBody [?In, ~Await]
{
FunctionBody [~Yield, ~Await]
}
ExpressionBody [In, Await] :
AssignmentExpression [?In, ~Yield, ?Await]
다음 생성물의 인스턴스를 처리할 때
ArrowParameters [Yield, Await] :
CoverParenthesizedExpressionAndArrowParameterList [?Yield, ?Await]
CoverParenthesizedExpressionAndArrowParameterList 의 해석은 다음 문법을 사용하여 정제됩니다:
ArrowFormalParameters [Yield, Await] :
(
UniqueFormalParameters [?Yield, ?Await]
)
AsyncArrowFunction [In, Yield, Await] :
async
[no LineTerminator here]
AsyncArrowBindingIdentifier [?Yield]
[no LineTerminator here]
=>
AsyncConciseBody [?In]
CoverCallExpressionAndAsyncArrowHead [?Yield, ?Await]
[no LineTerminator here]
=>
AsyncConciseBody [?In]
AsyncConciseBody [In] :
[lookahead ≠ { ]
ExpressionBody [?In, +Await]
{
AsyncFunctionBody
}
AsyncArrowBindingIdentifier [Yield] :
BindingIdentifier [?Yield, +Await]
CoverCallExpressionAndAsyncArrowHead [Yield, Await] :
MemberExpression [?Yield, ?Await]
Arguments [?Yield, ?Await]
다음 생성물의 인스턴스를 처리할 때
AsyncArrowFunction [In, Yield, Await] :
CoverCallExpressionAndAsyncArrowHead [?Yield, ?Await]
[no LineTerminator here]
=>
AsyncConciseBody [?In]
CoverCallExpressionAndAsyncArrowHead 의 해석은 다음 문법을 사용하여 정제됩니다:
AsyncArrowHead :
async
[no LineTerminator here]
ArrowFormalParameters [~Yield, +Await]
MethodDefinition [Yield, Await] :
ClassElementName [?Yield, ?Await]
(
UniqueFormalParameters [~Yield, ~Await]
)
{
FunctionBody [~Yield, ~Await]
}
GeneratorMethod [?Yield, ?Await]
AsyncMethod [?Yield, ?Await]
AsyncGeneratorMethod [?Yield, ?Await]
get
ClassElementName [?Yield, ?Await]
(
)
{
FunctionBody [~Yield, ~Await]
}
set
ClassElementName [?Yield, ?Await]
(
PropertySetParameterList
)
{
FunctionBody [~Yield, ~Await]
}
PropertySetParameterList :
FormalParameter [~Yield, ~Await]
GeneratorDeclaration [Yield, Await, Default] :
function
*
BindingIdentifier [?Yield, ?Await]
(
FormalParameters [+Yield, ~Await]
)
{
GeneratorBody
}
[+Default]
function
*
(
FormalParameters [+Yield, ~Await]
)
{
GeneratorBody
}
GeneratorExpression :
function
*
BindingIdentifier [+Yield, ~Await] opt
(
FormalParameters [+Yield, ~Await]
)
{
GeneratorBody
}
GeneratorMethod [Yield, Await] :
*
ClassElementName [?Yield, ?Await]
(
UniqueFormalParameters [+Yield, ~Await]
)
{
GeneratorBody
}
GeneratorBody :
FunctionBody [+Yield, ~Await]
YieldExpression [In, Await] :
yield
yield
[no LineTerminator here]
AssignmentExpression [?In, +Yield, ?Await]
yield
[no LineTerminator here]
*
AssignmentExpression [?In, +Yield, ?Await]
AsyncGeneratorDeclaration [Yield, Await, Default] :
async
[no LineTerminator here]
function
*
BindingIdentifier [?Yield, ?Await]
(
FormalParameters [+Yield, +Await]
)
{
AsyncGeneratorBody
}
[+Default]
async
[no LineTerminator here]
function
*
(
FormalParameters [+Yield, +Await]
)
{
AsyncGeneratorBody
}
AsyncGeneratorExpression :
async
[no LineTerminator here]
function
*
BindingIdentifier [+Yield, +Await] opt
(
FormalParameters [+Yield, +Await]
)
{
AsyncGeneratorBody
}
AsyncGeneratorMethod [Yield, Await] :
async
[no LineTerminator here]
*
ClassElementName [?Yield, ?Await]
(
UniqueFormalParameters [+Yield, +Await]
)
{
AsyncGeneratorBody
}
AsyncGeneratorBody :
FunctionBody [+Yield, +Await]
AsyncFunctionDeclaration [Yield, Await, Default] :
async
[no LineTerminator here]
function
BindingIdentifier [?Yield, ?Await]
(
FormalParameters [~Yield, +Await]
)
{
AsyncFunctionBody
}
[+Default]
async
[no LineTerminator here]
function
(
FormalParameters [~Yield, +Await]
)
{
AsyncFunctionBody
}
AsyncFunctionExpression :
async
[no LineTerminator here]
function
BindingIdentifier [~Yield, +Await] opt
(
FormalParameters [~Yield, +Await]
)
{
AsyncFunctionBody
}
AsyncMethod [Yield, Await] :
async
[no LineTerminator here]
ClassElementName [?Yield, ?Await]
(
UniqueFormalParameters [~Yield, +Await]
)
{
AsyncFunctionBody
}
AsyncFunctionBody :
FunctionBody [~Yield, +Await]
AwaitExpression [Yield] :
await
UnaryExpression [?Yield, +Await]
ClassDeclaration [Yield, Await, Default] :
class
BindingIdentifier [?Yield, ?Await]
ClassTail [?Yield, ?Await]
[+Default]
class
ClassTail [?Yield, ?Await]
ClassExpression [Yield, Await] :
class
BindingIdentifier [?Yield, ?Await] opt
ClassTail [?Yield, ?Await]
ClassTail [Yield, Await] :
ClassHeritage [?Yield, ?Await] opt
{
ClassBody [?Yield, ?Await] opt
}
ClassHeritage [Yield, Await] :
extends
LeftHandSideExpression [?Yield, ?Await]
ClassBody [Yield, Await] :
ClassElementList [?Yield, ?Await]
ClassElementList [Yield, Await] :
ClassElement [?Yield, ?Await]
ClassElementList [?Yield, ?Await]
ClassElement [?Yield, ?Await]
ClassElement [Yield, Await] :
MethodDefinition [?Yield, ?Await]
static
MethodDefinition [?Yield, ?Await]
FieldDefinition [?Yield, ?Await]
;
static
FieldDefinition [?Yield, ?Await]
;
ClassStaticBlock
;
FieldDefinition [Yield, Await] :
ClassElementName [?Yield, ?Await]
Initializer [+In, ?Yield, ?Await] opt
ClassElementName [Yield, Await] :
PropertyName [?Yield, ?Await]
PrivateIdentifier
ClassStaticBlock :
static
{
ClassStaticBlockBody
}
ClassStaticBlockBody :
ClassStaticBlockStatementList
ClassStaticBlockStatementList :
StatementList [~Yield, +Await, ~Return] opt
A.5 스크립트와 모듈
Script :
ScriptBody opt
ScriptBody :
StatementList [~Yield, ~Await, ~Return]
Module :
ModuleBody opt
ModuleBody :
ModuleItemList
ModuleItemList :
ModuleItem
ModuleItemList
ModuleItem
ModuleItem :
ImportDeclaration
ExportDeclaration
StatementListItem [~Yield, +Await, ~Return]
ModuleExportName :
IdentifierName
StringLiteral
ImportDeclaration :
import
ImportClause
FromClause
WithClause opt
;
import
ModuleSpecifier
WithClause opt
;
ImportClause :
ImportedDefaultBinding
NameSpaceImport
NamedImports
ImportedDefaultBinding
,
NameSpaceImport
ImportedDefaultBinding
,
NamedImports
ImportedDefaultBinding :
ImportedBinding
NameSpaceImport :
*
as
ImportedBinding
NamedImports :
{
}
{
ImportsList
,opt
}
FromClause :
from
ModuleSpecifier
ImportsList :
ImportSpecifier
ImportsList
,
ImportSpecifier
ImportSpecifier :
ImportedBinding
ModuleExportName
as
ImportedBinding
ModuleSpecifier :
StringLiteral
ImportedBinding :
BindingIdentifier [~Yield, +Await]
WithClause :
with
{
}
with
{
WithEntries
,opt
}
WithEntries :
AttributeKey
:
StringLiteral
AttributeKey
:
StringLiteral
,
WithEntries
AttributeKey :
IdentifierName
StringLiteral
ExportDeclaration :
export
ExportFromClause
FromClause
WithClause opt
;
export
NamedExports
;
export
VariableStatement [~Yield, +Await]
export
[lookahead ∉ { using , await }]
Declaration [~Yield, +Await]
export
default
HoistableDeclaration [~Yield, +Await, +Default]
export
default
ClassDeclaration [~Yield, +Await, +Default]
export
default
[lookahead ∉ { function , async
[no LineTerminator here]
function , class }]
AssignmentExpression [+In, ~Yield, +Await]
;
ExportFromClause :
*
*
as
ModuleExportName
NamedExports
NamedExports :
{
}
{
ExportsList
,opt
}
ExportsList :
ExportSpecifier
ExportsList
,
ExportSpecifier
ExportSpecifier :
ModuleExportName
ModuleExportName
as
ModuleExportName
A.6 Number 변환
StringNumericLiteral :::
StrWhiteSpace opt
StrWhiteSpace opt
StrNumericLiteral
StrWhiteSpace opt
StrWhiteSpace :::
StrWhiteSpaceChar
StrWhiteSpace opt
StrWhiteSpaceChar :::
WhiteSpace
LineTerminator
StrNumericLiteral :::
StrDecimalLiteral
NonDecimalIntegerLiteral [~Sep]
StrDecimalLiteral :::
StrUnsignedDecimalLiteral
+
StrUnsignedDecimalLiteral
-
StrUnsignedDecimalLiteral
StrUnsignedDecimalLiteral :::
Infinity
DecimalDigits [~Sep]
.
DecimalDigits [~Sep] opt
ExponentPart [~Sep] opt
.
DecimalDigits [~Sep]
ExponentPart [~Sep] opt
DecimalDigits [~Sep]
ExponentPart [~Sep] opt
StringNumericLiteral 문법에서 명시적으로 정의되지 않은 모든 문법 기호는 숫자 리터럴의 어휘 문법 에서 사용되는 정의를 갖습니다.
StringIntegerLiteral :::
StrWhiteSpace opt
StrWhiteSpace opt
StrIntegerLiteral
StrWhiteSpace opt
StrIntegerLiteral :::
SignedInteger [~Sep]
NonDecimalIntegerLiteral [~Sep]
A.7 시간대 오프셋 String 형식
UTCOffset :::
ASCIISign
Hour
ASCIISign
Hour
HourSubcomponents [+Extended]
ASCIISign
Hour
HourSubcomponents [~Extended]
ASCIISign ::: one of + -
Hour :::
0
DecimalDigit
1
DecimalDigit
20
21
22
23
HourSubcomponents [Extended] :::
TimeSeparator [?Extended]
MinuteSecond
TimeSeparator [?Extended]
MinuteSecond
TimeSeparator [?Extended]
MinuteSecond
TemporalDecimalFraction opt
TimeSeparator [Extended] ::: [+Extended]
:
[~Extended]
[empty]
MinuteSecond :::
0
DecimalDigit
1
DecimalDigit
2
DecimalDigit
3
DecimalDigit
4
DecimalDigit
5
DecimalDigit
TemporalDecimalFraction :::
TemporalDecimalSeparator
DecimalDigit
TemporalDecimalSeparator
DecimalDigit
DecimalDigit
TemporalDecimalSeparator
DecimalDigit
DecimalDigit
DecimalDigit
TemporalDecimalSeparator
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
TemporalDecimalSeparator
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
TemporalDecimalSeparator
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
TemporalDecimalSeparator
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
TemporalDecimalSeparator
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
TemporalDecimalSeparator
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
DecimalDigit
TemporalDecimalSeparator ::: one of . ,
A.8 정규 표현식
Pattern [UnicodeMode, UnicodeSetsMode, NamedCaptureGroups] ::
Disjunction [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
Disjunction [UnicodeMode, UnicodeSetsMode, NamedCaptureGroups] ::
Alternative [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
Alternative [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
|
Disjunction [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
Alternative [UnicodeMode, UnicodeSetsMode, NamedCaptureGroups] ::
[empty]
Alternative [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
Term [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
Term [UnicodeMode, UnicodeSetsMode, NamedCaptureGroups] ::
Assertion [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
Atom [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
Atom [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
Quantifier
Assertion [UnicodeMode, UnicodeSetsMode, NamedCaptureGroups] ::
^
$
\b
\B
(?=
Disjunction [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
)
(?!
Disjunction [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
)
(?<=
Disjunction [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
)
(?<!
Disjunction [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
)
Quantifier ::
QuantifierPrefix
QuantifierPrefix
?
QuantifierPrefix ::
*
+
?
{
DecimalDigits [~Sep]
}
{
DecimalDigits [~Sep]
,}
{
DecimalDigits [~Sep]
,
DecimalDigits [~Sep]
}
Atom [UnicodeMode, UnicodeSetsMode, NamedCaptureGroups] ::
PatternCharacter
.
\
AtomEscape [?UnicodeMode, ?NamedCaptureGroups]
CharacterClass [?UnicodeMode, ?UnicodeSetsMode]
(
GroupSpecifier [?UnicodeMode] opt
Disjunction [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
)
(?
RegularExpressionModifiers
:
Disjunction [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
)
(?
RegularExpressionModifiers
-
RegularExpressionModifiers
:
Disjunction [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
)
RegularExpressionModifiers ::
[empty]
RegularExpressionModifiers
RegularExpressionModifier
RegularExpressionModifier :: one of i m s
SyntaxCharacter :: one of ^ $ \ . * + ? ( ) [ ] { } |
PatternCharacter ::
SourceCharacter but not SyntaxCharacter
AtomEscape [UnicodeMode, NamedCaptureGroups] ::
DecimalEscape
CharacterClassEscape [?UnicodeMode]
CharacterEscape [?UnicodeMode]
[+NamedCaptureGroups]
k
GroupName [?UnicodeMode]
CharacterEscape [UnicodeMode] ::
ControlEscape
c
AsciiLetter
0
[lookahead ∉ DecimalDigit ]
HexEscapeSequence
RegExpUnicodeEscapeSequence [?UnicodeMode]
IdentityEscape [?UnicodeMode]
ControlEscape :: one of f n r t v
GroupSpecifier [UnicodeMode] ::
?
GroupName [?UnicodeMode]
GroupName [UnicodeMode] ::
<
RegExpIdentifierName [?UnicodeMode]
>
RegExpIdentifierName [UnicodeMode] ::
RegExpIdentifierStart [?UnicodeMode]
RegExpIdentifierName [?UnicodeMode]
RegExpIdentifierPart [?UnicodeMode]
RegExpIdentifierStart [UnicodeMode] ::
IdentifierStartChar
\
RegExpUnicodeEscapeSequence [+UnicodeMode]
[~UnicodeMode]
UnicodeLeadSurrogate
UnicodeTrailSurrogate
RegExpIdentifierPart [UnicodeMode] ::
IdentifierPartChar
\
RegExpUnicodeEscapeSequence [+UnicodeMode]
[~UnicodeMode]
UnicodeLeadSurrogate
UnicodeTrailSurrogate
RegExpUnicodeEscapeSequence [UnicodeMode] :: [+UnicodeMode]
u
HexLeadSurrogate
\u
HexTrailSurrogate
[+UnicodeMode]
u
HexLeadSurrogate
[+UnicodeMode]
u
HexTrailSurrogate
[+UnicodeMode]
u
HexNonSurrogate
[~UnicodeMode]
u
Hex4Digits
[+UnicodeMode]
u{
CodePoint
}
UnicodeLeadSurrogate ::
any Unicode code point in the inclusive interval from U+D800 to U+DBFF
UnicodeTrailSurrogate ::
any Unicode code point in the inclusive interval from U+DC00 to U+DFFF
연결된 u HexLeadSurrogate 의 선택이 모호한 각 \u HexTrailSurrogate 는 그렇지 않으면 대응하는 \u HexTrailSurrogate 를 갖지 않게 되는 가장 가까운 가능한 u HexLeadSurrogate 와 연결해야 합니다.
HexLeadSurrogate ::
Hex4Digits
but only if the MV of Hex4Digits is in the inclusive interval from 0xD800 to 0xDBFF
HexTrailSurrogate ::
Hex4Digits
but only if the MV of Hex4Digits is in the inclusive interval from 0xDC00 to 0xDFFF
HexNonSurrogate ::
Hex4Digits
but only if the MV of Hex4Digits is not in the inclusive interval from 0xD800 to 0xDFFF
IdentityEscape [UnicodeMode] :: [+UnicodeMode]
SyntaxCharacter
[+UnicodeMode]
/
[~UnicodeMode]
SourceCharacter but not UnicodeIDContinue
DecimalEscape ::
NonZeroDigit
DecimalDigits [~Sep] opt
[lookahead ∉ DecimalDigit ]
CharacterClassEscape [UnicodeMode] ::
d
D
s
S
w
W
[+UnicodeMode]
p{
UnicodePropertyValueExpression
}
[+UnicodeMode]
P{
UnicodePropertyValueExpression
}
UnicodePropertyValueExpression ::
UnicodePropertyName
=
UnicodePropertyValue
LoneUnicodePropertyNameOrValue
UnicodePropertyName ::
UnicodePropertyNameCharacters
UnicodePropertyNameCharacters ::
UnicodePropertyNameCharacter
UnicodePropertyNameCharacters opt
UnicodePropertyValue ::
UnicodePropertyValueCharacters
LoneUnicodePropertyNameOrValue ::
UnicodePropertyValueCharacters
UnicodePropertyValueCharacters ::
UnicodePropertyValueCharacter
UnicodePropertyValueCharacters opt
UnicodePropertyValueCharacter ::
UnicodePropertyNameCharacter
DecimalDigit
UnicodePropertyNameCharacter ::
AsciiLetter
_
CharacterClass [UnicodeMode, UnicodeSetsMode] ::
[
[lookahead ≠ ^ ]
ClassContents [?UnicodeMode, ?UnicodeSetsMode]
]
[^
ClassContents [?UnicodeMode, ?UnicodeSetsMode]
]
ClassContents [UnicodeMode, UnicodeSetsMode] ::
[empty]
[~UnicodeSetsMode]
NonemptyClassRanges [?UnicodeMode]
[+UnicodeSetsMode]
ClassSetExpression
NonemptyClassRanges [UnicodeMode] ::
ClassAtom [?UnicodeMode]
ClassAtom [?UnicodeMode]
NonemptyClassRangesNoDash [?UnicodeMode]
ClassAtom [?UnicodeMode]
-
ClassAtom [?UnicodeMode]
ClassContents [?UnicodeMode, ~UnicodeSetsMode]
NonemptyClassRangesNoDash [UnicodeMode] ::
ClassAtom [?UnicodeMode]
ClassAtomNoDash [?UnicodeMode]
NonemptyClassRangesNoDash [?UnicodeMode]
ClassAtomNoDash [?UnicodeMode]
-
ClassAtom [?UnicodeMode]
ClassContents [?UnicodeMode, ~UnicodeSetsMode]
ClassAtom [UnicodeMode] ::
-
ClassAtomNoDash [?UnicodeMode]
ClassAtomNoDash [UnicodeMode] ::
SourceCharacter but not one of \ or ] or -
\
ClassEscape [?UnicodeMode]
ClassEscape [UnicodeMode] ::
b
[+UnicodeMode]
-
CharacterClassEscape [?UnicodeMode]
CharacterEscape [?UnicodeMode]
ClassSetExpression ::
ClassUnion
ClassIntersection
ClassSubtraction
ClassUnion ::
ClassSetRange
ClassUnion opt
ClassSetOperand
ClassUnion opt
ClassIntersection ::
ClassSetOperand
&&
[lookahead ≠ & ]
ClassSetOperand
ClassIntersection
&&
[lookahead ≠ & ]
ClassSetOperand
ClassSubtraction ::
ClassSetOperand
--
ClassSetOperand
ClassSubtraction
--
ClassSetOperand
ClassSetRange ::
ClassSetCharacter
-
ClassSetCharacter
ClassSetOperand ::
NestedClass
ClassStringDisjunction
ClassSetCharacter
NestedClass ::
[
[lookahead ≠ ^ ]
ClassContents [+UnicodeMode, +UnicodeSetsMode]
]
[^
ClassContents [+UnicodeMode, +UnicodeSetsMode]
]
\
CharacterClassEscape [+UnicodeMode]
ClassStringDisjunction ::
\q{
ClassStringDisjunctionContents
}
ClassStringDisjunctionContents ::
ClassString
ClassString
|
ClassStringDisjunctionContents
ClassString ::
[empty]
NonEmptyClassString
NonEmptyClassString ::
ClassSetCharacter
NonEmptyClassString opt
ClassSetCharacter ::
[lookahead ∉ ClassSetReservedDoublePunctuator ]
SourceCharacter but not ClassSetSyntaxCharacter
\
CharacterEscape [+UnicodeMode]
\
ClassSetReservedPunctuator
\b
ClassSetReservedDoublePunctuator :: one of && !! ## $$ %% ** ++ ,, .. :: ;; << == >> ?? @@ ^^ `` ~~
ClassSetSyntaxCharacter :: one of ( ) [ ] { } / - \ |
ClassSetReservedPunctuator :: one of & - ! # % , : ; < = > @ ` ~
부속서 B (규정) 웹 브라우저를 위한 추가 ECMAScript 기능
이 부속서에서 정의하는 ECMAScript 언어 구문과 의미론은 ECMAScript 호스트 가 웹 브라우저인 경우 요구됩니다. 이 부속서의 내용은 규범적이지만 ECMAScript 호스트 가 웹 브라우저가 아닌 경우 선택 사항입니다.
이 부속서에서 정의하는 일부 기능은 이 부속서에 명시되어 있고 일부는 이 문서의 본문에 명시되어 있습니다.
기능이 본문에 명시된 경우 문서에서 해당 기능의 영향을 받는 각 지점은 색상 상자 안의 “Normative Optional”이라는 문구로 표시됩니다. 또한 해당 기능이 알고리즘이나 early error 규칙의 특정 문구와 관련된 경우 관련 기능을 “호스트가 지원한다 ”는 조건으로 보호됩니다. 웹 브라우저는 그러한 모든 기능을 지원해야 합니다.
참고
이 부속서는 웹 브라우저 ECMAScript 호스트 의 다양한 레거시 기능과 그 밖의 특성을 설명합니다. 이 부속서에 지정된 모든 언어 기능과 동작은 하나 이상의 바람직하지 않은 특성을 가지며 레거시 사용이 없다면 이 명세에서 제거되었을 것입니다. 그러나 많은 기존 웹 페이지가 이러한 기능을 사용하므로 웹 브라우저는 계속 이를 지원해야 합니다. 이 부속서의 명세는 이러한 레거시 기능의 상호 운용 가능한 구현을 위한 요구 사항을 정의합니다.
이러한 기능은 핵심 ECMAScript 언어의 일부로 간주되지 않습니다. 프로그래머는 새로운 ECMAScript 코드를 작성할 때 이러한 기능과 동작을 사용하거나 존재한다고 가정해서는 안 됩니다. 구현이 웹 브라우저의 일부이거나 웹 브라우저가 접하는 동일한 레거시 ECMAScript 코드를 실행하는 데 필요하지 않은 한 ECMAScript 구현체가 이러한 기능을 구현하는 것은 권장되지 않습니다.
B.1 추가 구문
B.1.2 정규 표현식 패턴
22.2.1 의 구문은 다음과 같이 수정되고 확장됩니다. 이러한 변경은 문법 생성물의 순서와 컨텍스트 정보에 의해 해결되는 모호성을 도입합니다. 다음 문법을 사용하여 파싱할 때 각 대안은 이전 생성물 대안이 일치하지 않는 경우에만 고려됩니다.
이 대체 패턴 문법과 의미론은 BMP 패턴의 구문과 의미론만 변경합 니다. 다음 문법 확장에는 [UnicodeMode] 매개변수로 매개변수화된 생성물이 포함됩니다. 그러나 이러한 확장은 목표 기호 에 [UnicodeMode] 매개변수가 존재하는 상태로 파싱할 때 인식되는 Unicode 패턴의 구문을 변경하지 않습니다.
구문
Term [UnicodeMode, UnicodeSetsMode, NamedCaptureGroups] :: [+UnicodeMode]
Assertion [+UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
[+UnicodeMode]
Atom [+UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
Quantifier
[+UnicodeMode]
Atom [+UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
[~UnicodeMode]
QuantifiableAssertion [?NamedCaptureGroups]
Quantifier
[~UnicodeMode]
Assertion [~UnicodeMode, ~UnicodeSetsMode, ?NamedCaptureGroups]
[~UnicodeMode]
ExtendedAtom [?NamedCaptureGroups]
Quantifier
[~UnicodeMode]
ExtendedAtom [?NamedCaptureGroups]
Assertion [UnicodeMode, UnicodeSetsMode, NamedCaptureGroups] ::
^
$
\b
\B
[+UnicodeMode]
(?=
Disjunction [+UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
)
[+UnicodeMode]
(?!
Disjunction [+UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
)
[~UnicodeMode]
QuantifiableAssertion [?NamedCaptureGroups]
(?<=
Disjunction [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
)
(?<!
Disjunction [?UnicodeMode, ?UnicodeSetsMode, ?NamedCaptureGroups]
)
QuantifiableAssertion [NamedCaptureGroups] ::
(?=
Disjunction [~UnicodeMode, ~UnicodeSetsMode, ?NamedCaptureGroups]
)
(?!
Disjunction [~UnicodeMode, ~UnicodeSetsMode, ?NamedCaptureGroups]
)
ExtendedAtom [NamedCaptureGroups] ::
.
\
AtomEscape [~UnicodeMode, ?NamedCaptureGroups]
\
[lookahead = c ]
CharacterClass [~UnicodeMode, ~UnicodeSetsMode]
(
GroupSpecifier [~UnicodeMode] opt
Disjunction [~UnicodeMode, ~UnicodeSetsMode, ?NamedCaptureGroups]
)
(?
RegularExpressionModifiers
:
Disjunction [~UnicodeMode, ~UnicodeSetsMode, ?NamedCaptureGroups]
)
(?
RegularExpressionModifiers
-
RegularExpressionModifiers
:
Disjunction [~UnicodeMode, ~UnicodeSetsMode, ?NamedCaptureGroups]
)
InvalidBracedQuantifier
ExtendedPatternCharacter
InvalidBracedQuantifier ::
{
DecimalDigits [~Sep]
}
{
DecimalDigits [~Sep]
,}
{
DecimalDigits [~Sep]
,
DecimalDigits [~Sep]
}
ExtendedPatternCharacter ::
SourceCharacter but not one of ^
$
\
.
*
+
?
(
)
[
|
AtomEscape [UnicodeMode, NamedCaptureGroups] :: [+UnicodeMode]
DecimalEscape
[~UnicodeMode]
DecimalEscape
but only if the CapturingGroupNumber of DecimalEscape is ≤ CountLeftCapturingParensWithin (the Pattern containing DecimalEscape )
CharacterClassEscape [?UnicodeMode]
CharacterEscape [?UnicodeMode, ?NamedCaptureGroups]
[+NamedCaptureGroups]
k
GroupName [?UnicodeMode]
CharacterEscape [UnicodeMode, NamedCaptureGroups] ::
ControlEscape
c
AsciiLetter
0
[lookahead ∉ DecimalDigit ]
HexEscapeSequence
RegExpUnicodeEscapeSequence [?UnicodeMode]
[~UnicodeMode]
LegacyOctalEscapeSequence
IdentityEscape [?UnicodeMode, ?NamedCaptureGroups]
IdentityEscape [UnicodeMode, NamedCaptureGroups] :: [+UnicodeMode]
SyntaxCharacter
[+UnicodeMode]
/
[~UnicodeMode]
SourceCharacterIdentityEscape [?NamedCaptureGroups]
SourceCharacterIdentityEscape [NamedCaptureGroups] :: [~NamedCaptureGroups]
SourceCharacter but not c
[+NamedCaptureGroups]
SourceCharacter but not one of c or k
ClassAtomNoDash [UnicodeMode, NamedCaptureGroups] ::
SourceCharacter but not one of \ or ] or -
\
ClassEscape [?UnicodeMode, ?NamedCaptureGroups]
\
[lookahead = c ]
ClassEscape [UnicodeMode, NamedCaptureGroups] ::
b
[+UnicodeMode]
-
[~UnicodeMode]
c
ClassControlLetter
CharacterClassEscape [?UnicodeMode]
CharacterEscape [?UnicodeMode, ?NamedCaptureGroups]
ClassControlLetter ::
DecimalDigit
_
참고
동일한 좌변이 [+UnicodeMode]와 [~UnicodeMode] 가드 모두와 함께 나타나는 경우 이는 모호성 해소 우선순위를 제어하기 위한 것입니다.
B.1.2.1 Static Semantics: 조기 오류
22.2.1.1 의 의미론은 다음과 같이 확장됩니다:
ExtendedAtom :: InvalidBracedQuantifier
이 생성물이 어떤 소스 텍스트와 일치하면 Syntax Error입니다.
또한 다음 생성물에 대한 규칙은 강조된 텍스트를 추가하여 수정됩니다:
NonemptyClassRanges ::
ClassAtom
-
ClassAtom
ClassContents
NonemptyClassRangesNoDash ::
ClassAtomNoDash
-
ClassAtom
ClassContents
B.1.2.2 Static Semantics: CountLeftCapturingParensWithin 및 CountLeftCapturingParensBefore
CountLeftCapturingParensWithin 및 CountLeftCapturingParensBefore 의 정의에서 “
Atom ::
(
GroupSpecifier opt
Disjunction
)
”에 대한 참조는 “
Atom ::
(
GroupSpecifier opt
Disjunction
)
” 또는 “
ExtendedAtom ::
(
GroupSpecifier opt
Disjunction
)
”을 의미하는 것으로 해석해야 합니다.
B.1.2.3 Static Semantics: IsCharacterClass
IsCharacterClass 의 의미론은 다음과 같이 확장됩니다:
ClassAtomNoDash ::
\
[lookahead = c ]
false 를 반환합니다.
B.1.2.4 Static Semantics: CharacterValue
CharacterValue 의 의미론은 다음과 같이 확장됩니다:
ClassAtomNoDash ::
\
[lookahead = c ]
U+005C (REVERSE SOLIDUS)의 숫자 값을 반환합니다.
ClassEscape ::
c
ClassControlLetter
codePoint 를 ClassControlLetter 가 일치한 코드 포인트로 둡니다.i 를 codePoint 의 숫자 값으로 둡니다.i 를 32로 나눈 나머지를 반환합니다.
CharacterEscape :: LegacyOctalEscapeSequence
LegacyOctalEscapeSequence 의 MV를 반환합니다(12.9.4.3 참조).
B.1.2.5 Runtime Semantics: CompileSubpattern
인수 regexpRecord 와 direction 을 사용하는 CompileSubpattern 의 의미론은 다음과 같이 확장됩니다:
Term ::
QuantifiableAssertion
Quantifier
에 대한 규칙은 Atom 을 QuantifiableAssertion 로 대체한
Term ::
Atom
Quantifier
에 대한 규칙과 같습니다.
Term ::
ExtendedAtom
Quantifier
에 대한 규칙은 Atom 을 ExtendedAtom 으로 대체한
Term ::
Atom
Quantifier
에 대한 규칙과 같습니다.
Term :: ExtendedAtom
에 대한 규칙은 Atom 을 ExtendedAtom 으로 대체한
Term :: Atom
에 대한 규칙과 같습니다.
B.1.2.6 Runtime Semantics: CompileAssertion
인수 regexpRecord 를 사용하는 CompileAssertion 의 의미론은 다음과 같이 확장됩니다:
QuantifiableAssertion ::
(?=
Disjunction
)
에 대한 규칙은 Atom 을 QuantifiableAssertion 로 대체한
Assertion ::
(?=
Disjunction
)
에 대한 규칙과 같습니다.
QuantifiableAssertion ::
(?!
Disjunction
)
에 대한 규칙은 Atom 을 QuantifiableAssertion 로 대체한
Assertion ::
(?!
Disjunction
)
에 대한 규칙과 같습니다.
B.1.2.7 Runtime Semantics: CompileAtom
인수 regexpRecord 와 direction 을 사용하는 CompileAtom 의 의미론은 다음과 같이 확장됩니다:
Atom :: PatternCharacter
를 제외한 Atom 생성물의 규칙은 Atom 을 ExtendedAtom 으로 대체하여 ExtendedAtom 생성물에도 사용됩니다.
다음 규칙도 추가됩니다:
ExtendedAtom ::
\
[lookahead = c ]
charSet 을 단일 문자 \ U+005C (REVERSE SOLIDUS)를 포함하는 CharSet 으로 둡니다.CharacterSetMatcher (regexpRecord , charSet , false , direction )을 반환합니다.
ExtendedAtom :: ExtendedPatternCharacter
char 를 ExtendedPatternCharacter 가 나타내는 문자로 둡니다.charSet 을 문자 char 를 포함하는 단일 요소 CharSet 으로 둡니다.CharacterSetMatcher (regexpRecord , charSet , false , direction )을 반환합니다.
B.1.2.8 Runtime Semantics: CompileToCharSet
인수 regexpRecord 를 사용하는 CompileToCharSet 의 의미론은 다음과 같이 확장됩니다:
두 규칙이 대체됩니다:
NonemptyClassRanges ::
ClassAtom
-
ClassAtom
ClassContents
charSet 을 인수 regexpRecord 를 사용한 첫 번째 ClassAtom 의 CompileToCharSet 으로 둡니다.otherSet 을 인수 regexpRecord 를 사용한 두 번째 ClassAtom 의 CompileToCharSet 으로 둡니다.remainingSet 을 인수 regexpRecord 를 사용한 ClassContents 의 CompileToCharSet 으로 둡니다.rangeSet 을 CharacterRangeOrUnion (regexpRecord , charSet , otherSet )으로 둡니다.rangeSet 과 remainingSet 의 합집합을 반환합니다.
NonemptyClassRangesNoDash ::
ClassAtomNoDash
-
ClassAtom
ClassContents
charSet 을 인수 regexpRecord 를 사용한 ClassAtomNoDash 의 CompileToCharSet 으로 둡니다.otherSet 을 인수 regexpRecord 를 사용한 ClassAtom 의 CompileToCharSet 으로 둡니다.remainingSet 을 인수 regexpRecord 를 사용한 ClassContents 의 CompileToCharSet 으로 둡니다.rangeSet 을 CharacterRangeOrUnion (regexpRecord , charSet , otherSet )으로 둡니다.rangeSet 과 remainingSet 의 합집합을 반환합니다.
다음 규칙도 추가됩니다:
ClassEscape ::
c
ClassControlLetter
charValue 를 이 ClassEscape 의 CharacterValue 로 둡니다.char 를 문자 값이 charValue 인 문자로 둡니다.단일 문자 char 를 포함하는 CharSet 을 반환합니다.
ClassAtomNoDash ::
\
[lookahead = c ]
단일 문자 \ U+005C (REVERSE SOLIDUS)를 포함하는 CharSet 을 반환합니다.
참고 이 생성물은 허용 가능한 제어 문자가 뒤따르지 않는 문자 클래스 내부의 시퀀스 \c에서만 도달할 수 있습니다.
B.1.2.8.1 CharacterRangeOrUnion ( regexpRecord , charSet , otherSet )
추상 연산 CharacterRangeOrUnion. 인수 regexpRecord (RegExp 레코드 ), charSet (CharSet ) 및 otherSet (CharSet ). 반환값: CharSet . 호출되면 다음 단계를 수행한다.
HasEitherUnicodeFlag (regexpRecord )이 false 이면, 다음을 수행합니다.charSet 이 정확히 하나의 문자를 포함하지 않거나 otherSet 이 정확히 하나의 문자를 포함하지 않으면, 다음을 수행합니다.remainingSet 을 단일 문자 - U+002D (HYPHEN-MINUS)를 포함하는 CharSet 으로 둡니다.CharSet charSet , otherSet , remainingSet 의 합집합을 반환합니다.CharacterRange (charSet , otherSet )을 반환합니다.
B.1.2.9 Static Semantics: ParsePattern ( patternText , u , v )
인수 patternText , u , v 를 사용하는 ParsePattern 의 의미론은 다음과 같이 확장되며, 수정 사항은 강조되어 있습니다:
v 가 true 이고 u 가 true 이면, 다음을 수행합니다.parseResult 를 하나 이상의 SyntaxError 객체를 포함하는 List 로 둡니다.그렇지 않고 v 가 true 이면, 다음을 수행합니다.parseResult 를 ParseText (patternText , Pattern [+UnicodeMode, +UnicodeSetsMode, +NamedCaptureGroups] )로 둡니다. 그렇지 않고 u 가 true 이면, 다음을 수행합니다.parseResult 를 ParseText (patternText , Pattern [+UnicodeMode, ~UnicodeSetsMode, +NamedCaptureGroups] )로 둡니다. 그렇지 않으면,parseResult 를 ParseText (patternText , Pattern [~UnicodeMode, ~UnicodeSetsMode, ~NamedCaptureGroups] )로 둡니다.parseResult 가 Parse Node이고 parseResult 가 GroupName 을 포함하면, 다음을 수행합니다.parseResult 를 ParseText (patternText , Pattern [~UnicodeMode, ~UnicodeSetsMode, +NamedCaptureGroups] )로 설정합니다. parseResult 를 반환합니다.
B.2 추가 내장 프로퍼티
ECMAScript 호스트 가 웹 브라우저인 경우 표준 내장 객체의 다음 추가 프로퍼티가 정의됩니다.
B.2.1 전역 객체의 추가 프로퍼티
표 103 의 항목을 표 6 에 추가합니다.
표 103: 추가 잘 알려진 내재 객체
B.2.1.1 escape ( string )
이 함수는 전역 객체 의 프로퍼티입니다. 특정 코드 단위를 16진수 이스케이프 시퀀스로 대체한 새로운 버전의 String 값을 계산합니다.
숫자 값이 0x00FF 이하인 코드 단위를 대체할 때는 %xx 형식의 두 자리 이스케이프 시퀀스를 사용합니다. 숫자 값이 0x00FF보다 엄격하게 큰 코드 단위를 대체할 때는 %uxxxx 형식의 네 자리 이스케이프 시퀀스를 사용합니다.
이는 %escape% 내재 객체입니다.
호출되면 다음 단계를 수행합니다:
string 을 ? ToString (string )으로 설정합니다.length 를 string 의 길이로 둡니다.result 를 빈 String으로 둡니다.unescapedSet 을 ASCII word 문자와 "@*+-./" 의 문자열 연결 로 둡니다.k 를 0으로 둡니다.k < length 인 동안 다음을 반복합니다.codeUnit 을 string 안에서 인덱스 k 에 있는 코드 단위로 둡니다.unescapedSet 이 codeUnit 을 포함하면, 다음을 수행합니다.nextPart 를 codeUnit 으로 둡니다.그렇지 않으면,codeUnitNumber 를 codeUnit 의 숫자 값으로 둡니다.codeUnitNumber < 256이면, 다음을 수행합니다.hex 를 codeUnitNumber 를 대문자 16진수로 형식화한 String 표현으로 둡니다.nextPart 를 "%" 와 StringPad (hex , 2, "0" , start )의 문자열 연결 로 둡니다.그렇지 않으면,hex 를 codeUnitNumber 를 대문자 16진수로 형식화한 String 표현으로 둡니다.nextPart 를 "%u" 와 StringPad (hex , 4, "0" , start )의 문자열 연결 로 둡니다. result 를 result 와 nextPart 의 문자열 연결 로 설정합니다.k 를 k + 1로 설정합니다.result 를 반환합니다.
참고
인코딩은 일부 RFC 1738에 설명된 인코딩을 기반으로 하지만, 이 표준에 지정된 전체 인코딩은 RFC 1738의 내용과 관계없이 위에서 설명합니다. 이 인코딩은 RFC 3986이 RFC 1738에 적용한 변경 사항을 반영하지 않습니다.
B.2.1.2 unescape ( string )
이 함수는 전역 객체 의 프로퍼티입니다. escape 함수가 도입할 수 있는 종류의 각 이스케이프 시퀀스를 그것이 나타내는 코드 단위로 대체한 새로운 버전의 String 값을 계산합니다.
이는 %unescape% 내재 객체입니다.
호출되면 다음 단계를 수행합니다:
string 을 ? ToString (string )으로 설정합니다.length 를 string 의 길이로 둡니다.result 를 빈 String으로 둡니다.k 를 0으로 둡니다.k < length 인 동안 다음을 반복합니다.codeUnit 을 string 안에서 인덱스 k 에 있는 코드 단위로 둡니다.codeUnit 이 코드 단위 0x0025 (PERCENT SIGN)이면, 다음을 수행합니다.hexDigits 를 빈 String으로 둡니다.optionalAdvance 를 0으로 둡니다.k + 5 < length 이고 string 안에서 인덱스 k + 1에 있는 코드 단위가 코드 단위 0x0075 (LATIN SMALL LETTER U)이면, 다음을 수행합니다.hexDigits 를 string 의 k + 2부터 k + 6까지의 부분 문자열 로 설정합니다.optionalAdvance 를 5로 설정합니다.그렇지 않고 k + 3 ≤ length 이면, 다음을 수행합니다.hexDigits 를 string 의 k + 1부터 k + 3까지의 부분 문자열 로 설정합니다.optionalAdvance 를 2로 설정합니다. parseResult 를 ParseText (hexDigits , HexDigits [~Sep] )로 둡니다.parseResult 가 Parse Node이면, 다음을 수행합니다.codeUnitNumber 를 parseResult 의 MV로 둡니다.codeUnit 을 숫자 값이 codeUnitNumber 인 코드 단위로 설정합니다.k 를 k + optionalAdvance 로 설정합니다.result 를 result 와 codeUnit 의 문자열 연결 로 설정합니다.k 를 k + 1로 설정합니다.result 를 반환합니다.
B.2.2 String.prototype 객체의 추가 프로퍼티
B.2.2.1 String.prototype.substr ( start , length )
이 메서드는 this 값을 String으로 변환한 결과의 부분 문자열 을 반환하며, 인덱스 start 에서 시작하여 length 개의 코드 단위만큼 계속됩니다(length 가 undefined 이면 String 끝까지). start 가 음수이면 sourceLength 가 String의 길이일 때 sourceLength + start 로 취급합니다. 결과는 String 객체가 아니라 String 값입니다.
호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.? RequireObjectCoercible (obj )을 수행합니다. string 을 ? ToString (obj )으로 둡니다.size 를 string 의 길이로 둡니다.intStart 를 ? ToClampedIndex (start , size )로 둡니다.length 가 undefined 이면 intLength 를 size 로 둡니다. 그렇지 않으면 intLength 를 ? ToIntegerOrInfinity (length )을 0과 size 사이로 clamp한 결과로 둡니다.intEnd 를 min (intStart + intLength , size )로 둡니다.string 의 intStart 부터 intEnd 까지의 부분 문자열 을 반환합니다.
참고
이 메서드는 의도적으로 일반적이며 this 값이 String 객체일 필요가 없습니다. 따라서 다른 종류의 객체로 옮겨 메서드로 사용할 수 있습니다.
B.2.2.2 String.prototype.anchor ( name )
이 메서드는 호출되면 다음 단계를 수행합니다:
string 을 this 값으로 둡니다.? CreateHTML (string , "a" , "name" , name )을 반환합니다.
B.2.2.2.1 CreateHTML ( contents , tag , attr , attrValue )
추상 연산 CreateHTML. 인수 contents (ECMAScript 언어 값 ), tag (String), attr (String) 및 attrValue (ECMAScript 언어 값 ). 반환값: (정상 완료 (값: String) 또는 throw 완료 ). 호출되면 다음 단계를 수행한다.
? RequireObjectCoercible (contents )을 수행합니다. contentsString 을 ? ToString (contents )으로 둡니다.part1 을 "<" 와 tag 의 문자열 연결 로 둡니다.attr 이 빈 String이 아니면, 다음을 수행합니다.attrValueString 을 ? ToString (attrValue )으로 둡니다.escapedAttrValue 를 attrValueString 과 같지만 attrValueString 안의 코드 단위 0x0022 (QUOTATION MARK)의 각 발생을 여섯 코드 단위 시퀀스 "&quot;" 로 대체한 String 값으로 둡니다.part1 을 다음의 문자열 연결 로 설정합니다:part1 코드 단위 0x0020 (SPACE) attr 코드 단위 0x003D (EQUALS SIGN) 코드 단위 0x0022 (QUOTATION MARK) escapedAttrValue 코드 단위 0x0022 (QUOTATION MARK) part2 를 part1 과 ">" 의 문자열 연결 로 둡니다.part3 를 part2 와 contentsString 의 문자열 연결 로 둡니다.part4 를 part3 , "</" , tag , ">" 의 문자열 연결 로 둡니다.part4 를 반환합니다.
B.2.2.3 String.prototype.big ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
string 을 this 값으로 둡니다.? CreateHTML (string , "big" , "" , "" )을 반환합니다.
B.2.2.4 String.prototype.blink ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
string 을 this 값으로 둡니다.? CreateHTML (string , "blink" , "" , "" )을 반환합니다.
B.2.2.5 String.prototype.bold ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
string 을 this 값으로 둡니다.? CreateHTML (string , "b" , "" , "" )을 반환합니다.
B.2.2.6 String.prototype.fixed ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
string 을 this 값으로 둡니다.? CreateHTML (string , "tt" , "" , "" )을 반환합니다.
B.2.2.7 String.prototype.fontcolor ( colour )
이 메서드는 호출되면 다음 단계를 수행합니다:
string 을 this 값으로 둡니다.? CreateHTML (string , "font" , "color" , colour )을 반환합니다.
B.2.2.8 String.prototype.fontsize ( size )
이 메서드는 호출되면 다음 단계를 수행합니다:
string 을 this 값으로 둡니다.? CreateHTML (string , "font" , "size" , size )을 반환합니다.
B.2.2.9 String.prototype.italics ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
string 을 this 값으로 둡니다.? CreateHTML (string , "i" , "" , "" )을 반환합니다.
B.2.2.10 String.prototype.link ( url )
이 메서드는 호출되면 다음 단계를 수행합니다:
string 을 this 값으로 둡니다.? CreateHTML (string , "a" , "href" , url )을 반환합니다.
B.2.2.11 String.prototype.small ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
string 을 this 값으로 둡니다.? CreateHTML (string , "small" , "" , "" )을 반환합니다.
B.2.2.12 String.prototype.strike ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
string 을 this 값으로 둡니다.? CreateHTML (string , "strike" , "" , "" )을 반환합니다.
B.2.2.13 String.prototype.sub ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
string 을 this 값으로 둡니다.? CreateHTML (string , "sub" , "" , "" )을 반환합니다.
B.2.2.14 String.prototype.sup ( )
이 메서드는 호출되면 다음 단계를 수행합니다:
string 을 this 값으로 둡니다.? CreateHTML (string , "sup" , "" , "" )을 반환합니다.
B.2.2.15 String.prototype.trimLeft ( )
참고
"trimStart" 프로퍼티가 권장됩니다. "trimLeft" 프로퍼티는 주로 이전 코드와의 호환성을 위해 제공됩니다. 새로운 ECMAScript 코드에서는 "trimStart" 프로퍼티를 사용할 것을 권장합니다.
"trimLeft" 프로퍼티의 초기 값은 22.1.3.34 에 정의된 %String.prototype.trimStart%입니다.
B.2.2.16 String.prototype.trimRight ( )
참고
"trimEnd" 프로퍼티가 권장됩니다. "trimRight" 프로퍼티는 주로 이전 코드와의 호환성을 위해 제공됩니다. 새로운 ECMAScript 코드에서는 "trimEnd" 프로퍼티를 사용할 것을 권장합니다.
"trimRight" 프로퍼티의 초기 값은 22.1.3.33 에 정의된 %String.prototype.trimEnd%입니다.
B.2.3 Date.prototype 객체의 추가 프로퍼티
B.2.3.1 Date.prototype.getYear ( )
참고
getFullYear 메서드는 “2000년 문제”를 피하므로 거의 모든 목적에서 권장됩니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. tv 를 dateObj .[[DateValue]] 로 둡니다.tv 가 NaN 이면 NaN 을 반환합니다.𝔽 (YearFromTime (LocalTime (tv ))) - 1900 𝔽 을 반환합니다.
B.2.3.2 Date.prototype.setYear ( year )
참고
setFullYear 메서드는 “2000년 문제”를 피하므로 거의 모든 목적에서 권장됩니다.
이 메서드는 호출되면 다음 단계를 수행합니다:
dateObj 를 this 값으로 둡니다.? RequireInternalSlot (dateObj , [[DateValue]] )를 수행합니다. time 을 dateObj .[[DateValue]] 로 둡니다.time 이 NaN 이면 time 을 +0 𝔽 으로 설정합니다. 그렇지 않으면 time 을 LocalTime (time )으로 설정합니다.fullYear 를 MakeFullYear (? ToNumber (year ))로 둡니다.day 를 MakeDay (fullYear , 𝔽 (MonthFromTime (time )), 𝔽 (DateFromTime (time )))로 둡니다.date 를 MakeDate (day , 𝔽 (TimeWithinDay (time )))로 둡니다.utcTimestamp 를 TimeClip (UTC (date ))로 둡니다.dateObj .[[DateValue]] 를 utcTimestamp 로 설정합니다.utcTimestamp 를 반환합니다.
B.2.3.3 Date.prototype.toGMTString ( )
참고
toUTCString 메서드가 권장됩니다. 이 메서드는 주로 이전 코드와의 호환성을 위해 제공됩니다.
"toGMTString" 프로퍼티의 초기 값은 21.4.4.43 에 정의된 %Date.prototype.toUTCString%입니다.
B.2.4 RegExp.prototype 객체의 추가 프로퍼티
B.2.4.1 RegExp.prototype.compile ( pattern , flags )
이 메서드는 호출되면 다음 단계를 수행합니다:
obj 를 this 값으로 둡니다.? RequireInternalSlot (obj , [[RegExpMatcher]] )를 수행합니다. pattern 이 Object이고 pattern 에 [[RegExpMatcher]] 내부 슬롯이 있으면, 다음을 수행합니다.flags 가 undefined 가 아니면 TypeError 예외를 던집니다.flags 를 pattern .[[OriginalFlags]] 로 설정합니다.pattern 을 pattern .[[OriginalSource]] 로 설정합니다.? RegExpInitialize (obj , pattern , flags )를 반환합니다.
참고
이 메서드는 새로운 패턴과 플래그를 사용하여 this 값 RegExp를 완전히 다시 초기화합니다. 구현체는 이 메서드의 사용을 결과 RegExp 객체가 여러 번 사용될 것이라는 단언 으로 해석하여 추가 최적화의 후보로 삼을 수 있습니다.
B.3 그 밖의 추가 기능
B.3.1 레이블이 지정된 함수 선언
ECMAScript 2015 이전에는 LabelledStatement 의 명세에서 문 레이블을 FunctionDeclaration 과 연결하는 것을 허용하지 않았습니다. 그러나 레이블이 지정된 FunctionDeclaration 은 비엄격 코드 에서 허용되는 확장이었으며 대부분의 브라우저 호스팅 ECMAScript 구현체가 이 확장을 지원했습니다. ECMAScript 2015 이후에는 LabelledStatement 의 문법 생성물이 FunctionDeclaration 을 LabelledItem 으로 사용하는 것을 허용하지만 14.13.1 에는 그러한 경우 Syntax Error를 발생시키는 Early Error 규칙이 포함되어 있습니다. 이후 호스트 가 이 기능을 지원한다면 비엄격 코드 에서 Syntax Error를 억제하도록 해당 규칙을 수정합니다.
참고
B.3.2 블록 수준 함수 선언의 웹 레거시 호환성 의미론
ECMAScript 2015 이전에는 ECMAScript 명세에서 Block 문의 StatementList 요소로 FunctionDeclaration 이 나타나는 것을 정의하지 않았습니다. 그러나 이러한 형태의 FunctionDeclaration 지원은 허용되는 확장이었으며 대부분의 브라우저 호스팅 ECMAScript 구현체가 이를 허용했습니다. 불행히도 그러한 선언의 의미론은 구현체마다 다릅니다. 이러한 의미론적 차이 때문에 Block 수준 함수 선언을 사용하는 기존 웹 ECMAScript 소스 텍스트 는 그 사용이 해당 선언에 대한 모든 브라우저 구현체의 의미론적 교집합에만 의존하는 경우에만 브라우저 구현체 사이에서 이식 가능합니다. 다음은 그 교집합 의미론에 속하는 사용 사례입니다:
함수가 선언되고 하나의 블록 안에서만 참조됩니다.
함수가 하나의 Block 안에서 선언되고 사용될 수 있지만 동일한 Block 안에 포함되지 않은 내부 함수 정의에서도 참조됩니다.
함수가 하나의 블록 안에서 선언되고 사용될 수 있지만 이후 블록에서도 참조됩니다.
첫 번째 사용 사례는 ECMAScript 2015가 제공하는 Block 수준 함수 선언의 의미론과 상호 운용됩니다. 이 사용 사례를 사용하는 기존 ECMAScript 소스 텍스트 는 10 , 14 , 15 절에 정의된 블록 수준 함수 선언 의미론을 사용하여 동작합니다.
두 번째와 세 번째 사용 사례의 ECMAScript 2015 상호 운용성에는 10 절, 15 절, 19.2.1 절, 16.1.7 절의 의미론에 다음 확장이 필요합니다.
ECMAScript 구현체에 진단 경고 메시지를 보고하는 메커니즘이 있다면, 이러한 호환성 의미론이 적용되는 FunctionDeclaration 을 코드가 포함하고 비호환성 의미론과 관찰 가능한 차이를 도입할 때 경고를 생성해야 합니다. 예를 들어 var 바인딩 도입이 early error를 생성하기 때문에 도입되지 않는 경우에는 경고 메시지를 생성해서는 안 됩니다.
이 기능은 다음 지점에서 특별한 의미론을 포함합니다:
B.3.3 IfStatement 문 절의 FunctionDeclaration
다음은 14.6 의 IfStatement 생성물을 보강합니다:
IfStatement [Yield, Await, Return] :
if
(
Expression [+In, ?Yield, ?Await]
)
FunctionDeclaration [?Yield, ?Await, ~Default]
else
Statement [?Yield, ?Await, ?Return]
if
(
Expression [+In, ?Yield, ?Await]
)
Statement [?Yield, ?Await, ?Return]
else
FunctionDeclaration [?Yield, ?Await, ~Default]
if
(
Expression [+In, ?Yield, ?Await]
)
FunctionDeclaration [?Yield, ?Await, ~Default]
else
FunctionDeclaration [?Yield, ?Await, ~Default]
if
(
Expression [+In, ?Yield, ?Await]
)
FunctionDeclaration [?Yield, ?Await, ~Default]
[lookahead ≠ else ]
이 생성물은 비엄격 코드 를 파싱할 때만 적용됩니다. 이 생성물과 일치하는 소스 텍스트 는 일치하는 각 FunctionDeclaration [?Yield, ?Await, ~Default] 발생이 소스 텍스트의 해당 위치를 차지하는 BlockStatement 의 유일한 StatementListItem 인 것처럼 처리됩니다. 그러한 합성 BlockStatement 의 의미론에는 B.3.2 에 지정된 웹 레거시 호환성 의미론이 포함됩니다.
B.3.4 Catch 블록의 VariableStatement
이 기능에서 Catch 절의 Block 은 CatchParameter 에서도 바인딩되는 이름을 바인딩하는 var 선언을 포함할 수 있습니다. 이는 14.15.1 의
Catch :
catch
(
CatchParameter
)
Block
에 대한 early error 규칙을 수정하여 달성됩니다.
참고
런타임에서 그러한 바인딩은 VariableDeclarationEnvironment에 인스턴스화됩니다. 동일한 이름의 CatchParameter 가 도입한 바인딩을 가리지 않으므로 그러한 var 선언의 Initializer 는 var 바인딩이 아니라 대응하는 catch 매개변수에 할당합니다.
이 수정된 동작은 Catch 절의 Block 안에 포함된 직접 eval 호출이 도입하는 var 및 function 선언에도 적용됩니다. 이 변경은 EvalDeclarationInstantiation 의 3.d.i.2.a.i 및 13.b.ii.4.a.i.i 단계를 수정하여 달성됩니다.
B.3.5 ForIn 문 헤드의 이니셜라이저
다음은 14.7.5 의 ForInOfStatement 생성물을 보강합니다:
ForInOfStatement [Yield, Await, Return] :
for
(
var
BindingIdentifier [?Yield, ?Await]
Initializer [~In, ?Yield, ?Await]
in
Expression [+In, ?Yield, ?Await]
)
Statement [?Yield, ?Await, ?Return]
이 생성물은 비엄격 코드 를 파싱할 때만 적용됩니다.
인수 labelSet 을 사용하는 ContainsDuplicateLabels 의 정적 의미론 은 다음과 같이 보강됩니다:
ForInOfStatement :
for
(
var
BindingIdentifier
Initializer
in
Expression
)
Statement
인수 labelSet 을 사용한 Statement 의 ContainsDuplicateLabels 를 반환합니다.
인수 labelSet 을 사용하는 ContainsUndefinedBreakTarget 의 정적 의미론 은 다음과 같이 보강됩니다:
ForInOfStatement :
for
(
var
BindingIdentifier
Initializer
in
Expression
)
Statement
인수 labelSet 을 사용한 Statement 의 ContainsUndefinedBreakTarget 을 반환합니다.
인수 iterationSet 과 labelSet 을 사용하는 ContainsUndefinedContinueTarget 의 정적 의미론 은 다음과 같이 보강됩니다:
ForInOfStatement :
for
(
var
BindingIdentifier
Initializer
in
Expression
)
Statement
인수 iterationSet 과 « »를 사용한 Statement 의 ContainsUndefinedContinueTarget 을 반환합니다.
IsDestructuring 의 정적 의미론 은 다음과 같이 보강됩니다:
BindingIdentifier :
Identifier
yield
await
false 를 반환합니다.
VarDeclaredNames 의 정적 의미론 은 다음과 같이 보강됩니다:
ForInOfStatement :
for
(
var
BindingIdentifier
Initializer
in
Expression
)
Statement
names1 을 BindingIdentifier 의 BoundNames 로 둡니다.names2 를 Statement 의 VarDeclaredNames 로 둡니다.names1 과 names2 의 목록 연결 을 반환합니다.
VarScopedDeclarations 의 정적 의미론 은 다음과 같이 보강됩니다:
ForInOfStatement :
for
(
var
BindingIdentifier
Initializer
in
Expression
)
Statement
decls1 을 « BindingIdentifier »로 둡니다.decls2 를 Statement 의 VarScopedDeclarations 로 둡니다.decls1 과 decls2 의 목록 연결 을 반환합니다.
인수 labelSet 을 사용하는 ForInOfLoopEvaluation 의 런타임 의미론 은 다음과 같이 보강됩니다:
ForInOfStatement :
for
(
var
BindingIdentifier
Initializer
in
Expression
)
Statement
name 을 BindingIdentifier 의 StringValue 로 둡니다.lhs 를 ? ResolveBinding (name )으로 둡니다.IsAnonymousFunctionDefinition (Initializer )가 true 이면, 다음을 수행합니다.value 를 인수 name 을 사용한 Initializer 의 ? NamedEvaluation 으로 둡니다.그렇지 않으면,rhs 를 Initializer 의 ? Evaluation 으로 둡니다.value 를 ? GetValue (rhs )로 둡니다. ? PutValue (lhs , value )를 수행합니다. keyResult 를 ? ForIn/OfHeadEvaluation (« », Expression , enumerate )로 둡니다.? ForIn/OfBodyEvaluation (BindingIdentifier , Statement , keyResult , enumerate , var-binding , labelSet )을 반환합니다.
B.3.6 [[IsHTMLDDA]] 내부 슬롯
[[IsHTMLDDA]] 내부 슬롯 은 호스트 정의 객체에 존재할 수 있습니다. [[IsHTMLDDA]] 내부 슬롯을 갖는 객체는 ToBoolean 및 IsLooselyEqual 추상 연산 과 typeof 연산자 의 피연산자로 사용될 때 undefined 처럼 동작합니다.
참고
[[IsHTMLDDA]] 내부 슬롯을 갖는 객체는 이 명세에서 절대 생성하지 않습니다. 그러나 웹 브라우저의 document.all 객체 는 웹 호환성을 위해 존재하는 이 슬롯을 갖는 호스트 정의 특수 객체 입니다. 이러한 타입의 객체에 대한 다른 알려진 예는 없으며 구현체는 document.all을 제외하고 어떤 객체도 이러한 슬롯과 함께 생성해서는 안 됩니다.
이 기능은 다음 지점에서 특별한 의미론을 포함합니다:
B.3.7 HostMakeJobCallback의 비기본 동작
HostMakeJobCallback 추상 연산 은 웹 브라우저인 호스트 가 비기본 동작을 지정할 수 있도록 합니다.
B.3.8 HostEnsureCanAddPrivateElement의 비기본 동작
HostEnsureCanAddPrivateElement 추상 연산 은 웹 브라우저인 호스트 가 비기본 동작을 지정할 수 있도록 합니다.
B.3.9 함수 호출 할당 대상의 런타임 오류
함수 호출(13.3.6 )이 비엄격 코드 에서 할당 대상으로 사용되면 early error를 생성하는 대신 할당 평가 중 ReferenceError 예외를 던집니다.
참고
할당 대상이 AssignmentExpression 의 LeftHandSideExpression 인 경우 할당 연산자는 = 또는 AssignmentOperator 여야 합니다. 특히 여기의 허용 사항은 논리 할당 연산자(??=, &&=, ||=)에는 적용되지 않습니다.
CallExpression : CoverCallExpressionAndAsyncArrowHead
및
CallExpression :
CallExpression
Arguments
에 대한 AssignmentTargetType 의 1 단계를 참조하시기 바랍니다.
부속서 C (참고) ECMAScript의 엄격 모드
엄격 모드 제한과 예외
implements, interface, let, package, private, protected, public, static, yield는 엄격 모드 코드 에서 예약어 입니다. (12.7.2 ).
적합한 구현체는 엄격 모드 코드 를 처리할 때 생성물
NumericLiteral :: LegacyOctalIntegerLiteral
및
DecimalIntegerLiteral :: NonOctalDecimalIntegerLiteral
의 인스턴스를 허용해서는 안 됩니다.
적합한 구현체는 엄격 모드 코드 를 처리할 때 생성물
EscapeSequence :: LegacyOctalEscapeSequence
및
EscapeSequence :: NonOctalDecimalEscapeSequence
의 인스턴스를 허용해서는 안 됩니다.
선언되지 않은 식별자 또는 그 밖의 해결할 수 없는 Reference에 할당해도 전역 객체 에 프로퍼티가 생성되지 않습니다. 엄격 모드 코드 안에서 단순 할당이 발생하면 해당 LeftHandSideExpression 은 해결할 수 없는 Reference로 평가되어서는 안 됩니다. 그러한 경우 ReferenceError 예외가 던져집니다(6.2.5.6 ). LeftHandSideExpression 은 속성 값이 { [[Writable]] : false }인 데이터 프로퍼티 에 대한 참조, 속성 값이 { [[Setter]] : undefined }인 접근자 프로퍼티 에 대한 참조 또는 [[Extensible]] 내부 슬롯이 false 인 객체의 존재하지 않는 프로퍼티에 대한 참조여서도 안 됩니다. 이러한 경우 TypeError 예외가 던져집니다(13.15 ).
StringValue 가 "eval" 또는 "arguments" 인 IdentifierReference 는 Assignment 연산자(13.15 ) 또는 UpdateExpression (13.4 )의 LeftHandSideExpression 로 나타나거나 Prefix Increment(13.4.4 ) 또는 Prefix Decrement(13.4.5 ) 연산자가 작용하는 UnaryExpression 로 나타날 수 없습니다.
엄격 함수 의 arguments 객체는 접근 시 TypeError 예외를 던지는 구성 불가능한 접근자 프로퍼티 "callee" 를 정의합니다(10.4.4.6 ).
엄격 함수 의 arguments 객체는 해당 함수의 대응하는 형식 매개변수 바인딩과 배열 인덱스 프로퍼티 값을 동적으로 공유하지 않습니다. (10.4.4 ).
엄격 함수 에서 arguments 객체가 생성되면 로컬 식별자 arguments의 arguments 객체에 대한 바인딩은 변경 불가능하므로 할당 표현식의 대상이 될 수 없습니다. (10.2.11 ).
엄격 모드 코드 안에서 BindingIdentifier 의 StringValue 가 "eval" 또는 "arguments" 이면 SyntaxError 입니다(13.1.1 ).
엄격 모드 eval 코드는 eval 호출자의 변수 환경에 변수나 함수를 인스턴스화할 수 없습니다. 대신 새로운 변수 환경을 생성하고 그 환경을 eval 코드의 선언 바인딩 인스턴스화에 사용합니다(19.2.1 ).
엄격 모드 코드 안에서 this 가 평가되면 this 값은 객체로 강제 변환되지 않습니다. undefined 또는 null 인 this 값은 전역 객체 로 변환되지 않으며 프리미티브 값은 래퍼 객체로 변환되지 않습니다. 함수 호출(Function.prototype.apply 및 Function.prototype.call을 사용한 호출 포함)을 통해 전달된 this 값은 전달된 this 값을 객체로 강제 변환하지 않습니다(10.2.1.2 , 20.2.3.1 , 20.2.3.3 ).
엄격 모드 코드 안에서 delete 연산자가 나타날 때 해당 UnaryExpression 이 변수, 함수 인수 또는 함수 이름에 대한 직접 참조이면 SyntaxError 가 던져집니다(13.5.1.1 ).
엄격 모드 코드 안에서 delete 연산자가 나타날 때 삭제하려는 프로퍼티에 { [[Configurable]] : false } 속성이 있거나 그 밖의 이유로 삭제할 수 없으면 TypeError 가 던져집니다(13.5.1.2 ).
엄격 모드 코드 는 WithStatement 를 포함할 수 없습니다. 그러한 컨텍스트에 WithStatement 가 나타나면 SyntaxError 입니다(14.11.1 ).
엄격 모드 코드 안에 CatchParameter 가 나타나고 CatchParameter 의 BoundNames 가 eval 또는 arguments 중 하나를 포함하면 SyntaxError 입니다(14.15.1 ).
엄격 함수 의 FormalParameters 안에 같은 BindingIdentifier 가 두 번 이상 나타나면 SyntaxError 입니다. Function, Generator 또는 AsyncFunction 생성자 를 사용하여 그러한 함수를 생성하려는 시도도 SyntaxError 입니다(15.2.1 , 20.2.1.1.1 ).
구현체는 함수 인스턴스의 "caller" 또는 "arguments" 라는 이름의 프로퍼티가 엄격 함수 안에서 갖는 의미를 이 명세에 정의된 것 이상으로 확장할 수 없습니다.
부속서 D (참고) 호스트 계층화 지점
호스트 의 정의는 4.2 를 참조하시기 바랍니다.
D.1 호스트 훅
HostCallJobCallback (...)
HostEnqueueFinalizationRegistryCleanupJob (...)
HostEnqueueGenericJob (...)
HostEnqueuePromiseJob (...)
HostEnqueueTimeoutJob (...)
HostEnsureCanCompileStrings (...)
HostFinalizeImportMeta (...)
HostGetImportMetaProperties (...)
HostGrowSharedArrayBuffer (...)
HostHasSourceTextAvailable (...)
HostLoadImportedModule (...)
HostGetSupportedImportAttributes (...)
HostMakeJobCallback (...)
HostPromiseRejectionTracker (...)
HostResizeArrayBuffer (...)
InitializeHostDefinedRealm (...)
D.2 호스트 정의 필드
Realm Records 의 [[HostDefined]] : 표 20 를 참조하시기 바랍니다.
Script Records 의 [[HostDefined]] : 표 35 를 참조하시기 바랍니다.
Module Records 의 [[HostDefined]] : 표 39 를 참조하시기 바랍니다.
JobCallback Records 의 [[HostDefined]] : 표 24 를 참조하시기 바랍니다.
[[IsHTMLDDA]] : B.3.6 를 참조하시기 바랍니다.
D.3 호스트 정의 객체
전역 객체 : 19 절을 참조하시기 바랍니다.
D.4 작업 실행
Job Abstract Closure 호출 전의 준비 단계와 호출 후의 정리 단계입니다. 9.5 를 참조하시기 바랍니다.
D.5 특수 객체의 내부 메서드
이 명세에 지정되지 않은 모든 특수 객체 에 대한 표 4 의 필수 내부 메서드 중 하나입니다.
D.6 내장 객체와 메서드
17.1 에서 제한된 경우를 제외하고 이 명세 안에 정의되지 않은 모든 내장 객체와 메서드입니다.
부속서 E (참고) 호환성에 영향을 줄 수 있는 ECMAScript 2015의 수정 및 명확화
9.1.1.4.14 -9.1.1.4.17 Edition 5 및 5.1은 새로운 전역 선언에 대응하는 전역 객체 프로퍼티가 이미 존재하는지 판단하기 위해 프로퍼티 존재 검사를 사용했습니다. ECMAScript 2015는 자체 프로퍼티 존재 검사를 사용합니다. 이는 웹 브라우저에서 가장 일반적으로 구현된 방식에 대응합니다.
10.4.2.1 : 5th Edition은 배열 인덱스 또는 새 길이 값의 정수 변환 전에 현재 배열 길이를 캡처하도록 변경했습니다. 그러나 변환 과정에서 배열 길이를 변경하는 부수 효과가 발생하면 캡처한 길이 값이 무효가 될 수 있었습니다. ECMAScript 2015는 그러한 부수 효과가 발생할 수 있는 시점 이후에 현재 배열 길이를 캡처해야 한다고 지정합니다.
21.4.1.31 : 이전 판에서는 TimeClip 추상 연산 이 0 시간 값 의 표현으로 +0 𝔽 또는 -0 𝔽 중 하나를 반환하도록 허용했습니다. ECMAScript 2015는 +0 𝔽 이 항상 반환되도록 지정합니다. 이는 ECMAScript 2015에서 Date의 시간 값 이 관찰 가능하게 -0 𝔽 이 되는 일이 없으며 시간 값 을 반환하는 메서드도 절대 -0 𝔽 을 반환하지 않는다는 의미입니다.
21.4.1.32 : UTC 오프셋 표현이 없으면 로컬 시간대를 사용합니다. Edition 5.1은 시간대가 없을 때 "z" 로 해석해야 한다고 잘못 명시했습니다.
21.4.4.36 : 연도를 21.4.1.32 에 지정된 Date Time String Format으로 표현할 수 없으면 RangeError 예외를 던집니다. 이전 판에서는 해당 경우의 동작을 지정하지 않았습니다.
21.4.4.41 : 이전 판에서는 시간 값 이 NaN 일 때 Date.prototype.toString이 반환하는 값을 지정하지 않았습니다. ECMAScript 2015는 결과가 String 값 "Invalid Date" 라고 지정합니다.
22.2.4.1 , 22.2.6.13.1 : RegExp 인스턴스의 "source" 프로퍼티 값에 있는 모든 LineTerminator 코드 포인트는 이스케이프 시퀀스를 사용하여 표현해야 합니다. Edition 5.1은 /의 이스케이프만 요구했습니다.
22.2.6.8 , 22.2.6.11 : 이전 판에서는 pattern 인수가 global 플래그가 설정된 RegExp 값인 경우 String.prototype.match 및 String.prototype.replace의 명세가 잘못되어 있었습니다. 이전 명세에서는 패턴 일치 시도마다 lastIndex가 변경되지 않으면 1 증가시켜야 한다고 명시했습니다. 올바른 동작은 패턴이 빈 String과 일치한 경우에만 lastIndex를 1 증가시키는 것입니다.
23.1.3.30 : 이전 판에서는 comparator 가 반환한 NaN 값을 Array.prototype.sort가 어떻게 해석하는지 지정하지 않았습니다. ECMAScript 2015는 그러한 값을 comparator 가 +0 𝔽 을 반환한 것처럼 취급하도록 지정합니다. ECMAScript 2015는 comparator 가 반환한 결과에 ToNumber 를 적용하도록 지정하기도 합니다. 이전 판에서는 Number 값 이 아닌 comparator 결과의 효과가 구현체 정의 였습니다. 실제 구현체는 ToNumber 를 호출합니다.
부속서 F (참고) 이전 판과 비호환성을 도입하는 추가 및 변경 사항
6.2.5 : ECMAScript 2015에서는 Function 호출이 Reference Record 를 반환할 수 없습니다.
7.1.4.1 : ECMAScript 2015에서는 String 값에 적용된 ToNumber 가 이제 BinaryIntegerLiteral 및 OctalIntegerLiteral 숫자 문자열을 인식하고 변환합니다. 이전 판에서는 그러한 문자열이 NaN 으로 변환되었습니다.
9.3 : ECMAScript 2018에서는 Template 객체가 이전 판처럼 Realm 안의 해당 template literal 또는 tagged template의 모든 발생을 기준으로 하는 대신 Parse Node(소스 위치)를 기준으로 정규화됩니다.
12.2 : ECMAScript 2016에서는 Unicode 5.1을 요구했던 ECMAScript 2015와 달리 Unicode 8.0.0 이상을 요구합니다. 특히 이로 인해 ECMAScript 2015에서 Space_Separator (Zs) 범주에 속하여 공백으로 취급되던 U+180E MONGOLIAN VOWEL SEPARATOR가 Format (Cf) 범주로 이동했습니다(Unicode 6.3.0부터). 이에 따라 공백에 민감한 메서드의 동작이 달라집니다. 예를 들어 "\u180E".trim().length는 이전 판에서 0이었지만 ECMAScript 2016 이후에는 1입니다. 또한 ECMAScript 2017에서는 항상 최신 버전의 Unicode Standard를 사용하도록 요구했습니다.
12.7 : ECMAScript 2015에서 IdentifierName 에 유효한 코드 포인트는 Unicode 프로퍼티 “ID_Start” 및 “ID_Continue”를 기준으로 지정됩니다. 이전 판에서는 유효한 IdentifierName 또는 Identifier 코드 포인트를 다양한 Unicode 코드 포인트 범주를 열거하여 지정했습니다.
12.10.1 : ECMAScript 2015에서 Automatic Semicolon Insertion은 do-while 문의 끝에 세미콜론이 없으면 세미콜론을 추가합니다. 이 변경은 명세를 대부분의 기존 구현체의 실제 동작과 일치시킵니다.
13.2.5.1 : ECMAScript 2015에서는 Object Initializer에 중복 프로퍼티 이름 이 있어도 더 이상 early error가 아닙니다.
13.15.1 : ECMAScript 2015에서 FunctionExpression 의 함수 이름과 같은 변경 불가능한 바인딩에 대한 할당을 포함하는 엄격 모드 코드 는 early error를 생성하지 않습니다. 대신 런타임 오류를 생성합니다.
14.2 : ECMAScript 2015에서 토큰 let으로 시작하고 입력 요소 LineTerminator 다음에 Identifier 가 오는 StatementList 는 LexicalDeclaration 의 시작입니다. 이전 판에서는 automatic semicolon insertion이 항상 Identifier 입력 요소 앞에 세미콜론을 삽입했습니다.
14.5 : ECMAScript 2015에서 토큰 let 다음에 토큰 [이 오는 StatementListItem 은 LexicalDeclaration 의 시작입니다. 이전 판에서는 그러한 시퀀스가 ExpressionStatement 의 시작이었습니다.
14.6.2 : ECMAScript 2015에서 IfStatement 의 normal 결과는 절대 값 empty 가 아닙니다. 어떤 Statement 부분도 평가되지 않거나 평가된 Statement 부분이 empty 를 포함하는 normal completion을 생성하면 IfStatement 의 결과는 undefined 입니다.
14.7 : ECMAScript 2015에서 for 문의 ( 토큰 바로 뒤에 토큰 시퀀스 let [이 오면 let은 LexicalDeclaration 의 시작으로 취급됩니다. 이전 판에서는 그러한 토큰 시퀀스가 Expression 의 시작이었습니다.
14.7 : ECMAScript 2015에서 for-in 문의 ( 토큰 바로 뒤에 토큰 시퀀스 let [이 오면 let은 ForDeclaration 의 시작으로 취급됩니다. 이전 판에서는 그러한 토큰 시퀀스가 LeftHandSideExpression 의 시작이었습니다.
14.7 : ECMAScript 2015 이전에는 초기화 표현식이 in 키워드 앞의 VariableDeclaration 일부로 나타날 수 있었습니다. ECMAScript 2015에서는 같은 위치의 ForBinding 이 그러한 이니셜라이저의 발생을 허용하지 않습니다. ECMAScript 2017에서는 그러한 이니셜라이저가 비엄격 코드 에서만 허용됩니다.
14.7 : ECMAScript 2015에서 IterationStatement 평가 결과는 [[Value]] 가 empty 인 normal completion이 아닙니다. IterationStatement 의 Statement 부분이 평가되지 않거나 Statement 부분의 최종 평가가 [[Value]] 가 empty 인 normal completion을 생성하면 IterationStatement 평가 결과는 [[Value]] 가 undefined 인 normal completion입니다.
14.11.2 : ECMAScript 2015에서 WithStatement 평가 결과는 [[Value]] 가 empty 인 normal completion이 아닙니다. WithStatement 의 Statement 부분 평가가 [[Value]] 가 empty 인 normal completion을 생성하면 WithStatement 평가 결과는 [[Value]] 가 undefined 인 normal completion입니다.
14.12.4 : ECMAScript 2015에서 SwitchStatement 평가 결과는 [[Value]] 가 empty 인 normal completion이 아닙니다. SwitchStatement 의 CaseBlock 부분 평가가 [[Value]] 가 empty 인 normal completion을 생성하면 SwitchStatement 평가 결과는 [[Value]] 가 undefined 인 normal completion입니다.
14.15 : ECMAScript 2015에서 Catch 절이 Catch 절 매개변수에 나타나는 것과 같은 Identifier 에 대한 var 선언을 포함하면 early error입니다. 이전 판에서는 그러한 변수 선언이 둘러싸는 변수 환경에 인스턴스화되었지만 선언의 Initializer 값은 Catch 매개변수에 할당되었습니다.
14.15 , 19.2.1.3 : ECMAScript 2015에서 Catch 절이 eval 코드에 Catch 절 매개변수에 나타나는 것과 같은 Identifier 를 바인딩하는 var 또는 FunctionDeclaration 선언이 포함된 비엄격 직접 eval을 평가하면 런타임 SyntaxError 가 던져집니다.
14.15.3 : ECMAScript 2015에서 TryStatement 의 결과는 절대 값 empty 가 아닙니다. TryStatement 의 Block 부분이 empty 를 포함하는 normal completion으로 평가되면 TryStatement 의 결과는 undefined 입니다. TryStatement 의 Block 부분이 throw completion으로 평가되고 empty 를 포함하는 normal completion으로 평가되는 Catch 부분을 갖는 경우, Finally 절이 없거나 Finally 절이 empty normal completion으로 평가되면 TryStatement 의 결과는 undefined 입니다.
15.4.5 ECMAScript 2015에서 ObjectLiteral 의 접근자 프로퍼티 [[Getter]] 또는 [[Setter]] 속성 값으로 생성되는 함수 객체 는 생성자 함수가 아니며 "prototype" 자체 프로퍼티를 갖지 않습니다. 이전 판에서는 생성자 였고 "prototype" 프로퍼티를 가졌습니다.
20.1.2.6 : ECMAScript 2015에서 Object.freeze의 인수가 객체가 아니면 자체 프로퍼티가 없는 확장 불가능한 일반 객체 인 것처럼 취급합니다. 이전 판에서는 비객체 인수가 항상 TypeError 를 발생시켰습니다.
20.1.2.8 : ECMAScript 2015에서 Object.getOwnPropertyDescriptor의 인수가 객체가 아니면 ToObject 를 사용하여 인수를 강제 변환하려고 시도합니다. 강제 변환이 성공하면 그 결과를 원래 인수 값 대신 사용합니다. 이전 판에서는 비객체 인수가 항상 TypeError 를 발생시켰습니다.
20.1.2.10 : ECMAScript 2015에서 Object.getOwnPropertyNames의 인수가 객체가 아니면 ToObject 를 사용하여 인수를 강제 변환하려고 시도합니다. 강제 변환이 성공하면 그 결과를 원래 인수 값 대신 사용합니다. 이전 판에서는 비객체 인수가 항상 TypeError 를 발생시켰습니다.
20.1.2.12 : ECMAScript 2015에서 Object.getPrototypeOf의 인수가 객체가 아니면 ToObject 를 사용하여 인수를 강제 변환하려고 시도합니다. 강제 변환이 성공하면 그 결과를 원래 인수 값 대신 사용합니다. 이전 판에서는 비객체 인수가 항상 TypeError 를 발생시켰습니다.
20.1.2.16 : ECMAScript 2015에서 Object.isExtensible의 인수가 객체가 아니면 자체 프로퍼티가 없는 확장 불가능한 일반 객체 인 것처럼 취급합니다. 이전 판에서는 비객체 인수가 항상 TypeError 를 발생시켰습니다.
20.1.2.17 : ECMAScript 2015에서 Object.isFrozen의 인수가 객체가 아니면 자체 프로퍼티가 없는 확장 불가능한 일반 객체 인 것처럼 취급합니다. 이전 판에서는 비객체 인수가 항상 TypeError 를 발생시켰습니다.
20.1.2.18 : ECMAScript 2015에서 Object.isSealed의 인수가 객체가 아니면 자체 프로퍼티가 없는 확장 불가능한 일반 객체 인 것처럼 취급합니다. 이전 판에서는 비객체 인수가 항상 TypeError 를 발생시켰습니다.
20.1.2.19 : ECMAScript 2015에서 Object.keys의 인수가 객체가 아니면 ToObject 를 사용하여 인수를 강제 변환하려고 시도합니다. 강제 변환이 성공하면 그 결과를 원래 인수 값 대신 사용합니다. 이전 판에서는 비객체 인수가 항상 TypeError 를 발생시켰습니다.
20.1.2.20 : ECMAScript 2015에서 Object.preventExtensions의 인수가 객체가 아니면 자체 프로퍼티가 없는 확장 불가능한 일반 객체 인 것처럼 취급합니다. 이전 판에서는 비객체 인수가 항상 TypeError 를 발생시켰습니다.
20.1.2.22 : ECMAScript 2015에서 Object.seal의 인수가 객체가 아니면 자체 프로퍼티가 없는 확장 불가능한 일반 객체 인 것처럼 취급합니다. 이전 판에서는 비객체 인수가 항상 TypeError 를 발생시켰습니다.
20.2.3.2 : ECMAScript 2015에서 바인딩된 함수의 [[Prototype]] 내부 슬롯은 대상 함수의 [[GetPrototypeOf]] 값으로 설정됩니다. 이전 판에서는 [[Prototype]] 이 항상 %Function.prototype% 으로 설정되었습니다.
20.2.4.1 : ECMAScript 2015에서 함수 인스턴스의 "length" 프로퍼티는 구성 가능합니다. 이전 판에서는 구성 불가능했습니다.
20.5.6.2 : ECMAScript 2015에서 NativeError 생성자 의 [[Prototype]] 내부 슬롯은 Error 생성자 입니다. 이전 판에서는 Function 프로토타입 객체 였습니다.
21.4.4 ECMAScript 2015에서 Date 프로토타입 객체 는 Date 인스턴스가 아닙니다. 이전 판에서는 TimeValue가 NaN 인 Date 인스턴스였습니다.
22.1.3.12 ECMAScript 2015에서 String.prototype.localeCompare 함수는 Unicode Standard에 따라 정규적으로 동등한 String을 동일한 것으로 취급해야 합니다. 이전 판에서는 구현체가 정규적 동등성을 무시하고 대신 비트 단위 비교를 사용할 수 있었습니다.
22.1.3.28 및 22.1.3.30 ECMAScript 2015에서 소문자/대문자 변환 처리는 코드 포인트에 대해 동작합니다. 이전 판에서는 그러한 변환 처리가 개별 코드 단위에만 적용되었습니다. 영향을 받는 유일한 코드 포인트는 Unicode의 Deseret 블록에 있는 코드 포인트입니다.
22.1.3.32 ECMAScript 2015에서 String.prototype.trim 메서드는 Unicode BMP 밖에 존재할 수 있는 공백 코드 포인트를 인식하도록 정의됩니다. 그러나 Unicode 7 기준으로 그러한 코드 포인트는 정의되어 있지 않습니다. 이전 판에서는 그러한 코드 포인트를 공백으로 인식하지 않았습니다.
22.2.4.1 ECMAScript 2015에서 pattern 인수가 RegExp 인스턴스이고 flags 인수가 undefined 가 아니면 pattern 과 같지만 pattern 의 플래그가 인수 flags 로 대체된 새로운 RegExp 인스턴스를 생성합니다. 이전 판에서는 pattern 이 RegExp 인스턴스이고 flags 가 undefined 가 아니면 TypeError 예외를 던졌습니다.
22.2.6 ECMAScript 2015에서 RegExp 프로토타입 객체 는 RegExp 인스턴스가 아닙니다. 이전 판에서는 패턴이 빈 String인 RegExp 인스턴스였습니다.
22.2.6 ECMAScript 2015에서 "source" , "global" , "ignoreCase" , "multiline" 은 RegExp 프로토타입 객체 에 정의된 접근자 프로퍼티 입니다. 이전 판에서는 RegExp 인스턴스에 정의된 데이터 프로퍼티 였습니다.
25.4.10 : ECMAScript 2019에서 Atomics.wake는 Atomics.wait와의 혼동을 방지하기 위해 Atomics.notify로 이름이 변경되었습니다.
27.1.5.4 , 27.9.3.6 : ECMAScript 2019에서 await가 큐에 넣는 Job 의 수가 줄어들어 then() 호출과 await 표현식 사이의 resolve 순서에 관찰 가능한 차이가 생길 수 있게 되었습니다.
참고 문헌
IEEE 754-2019 : IEEE Standard for Floating-Point Arithmetic . Institute of Electrical and Electronic Engineers, New York (2019)
참고
IEEE 754-2008과 IEEE 754-2019 사이에는 ECMA-262 명세에 영향을 주는 규범적 변경이 없습니다.
The Unicode Standard , <https://unicode.org/versions/latest >에서 이용 가능
Unicode Technical Note #5: Canonical Equivalence in Applications , <https://unicode.org/notes/tn5/ >에서 이용 가능
Unicode Technical Standard #10: Unicode Collation Algorithm , <https://unicode.org/reports/tr10/ >에서 이용 가능
Unicode Standard Annex #15, Unicode Normalization Forms , <https://unicode.org/reports/tr15/ >에서 이용 가능
Unicode Standard Annex #18: Unicode Regular Expressions , <https://unicode.org/reports/tr18/ >에서 이용 가능
Unicode Standard Annex #24: Unicode Script Property , <https://unicode.org/reports/tr24/ >에서 이용 가능
Unicode Standard Annex #31, Unicode Identifiers and Pattern Syntax , <https://unicode.org/reports/tr31/ >에서 이용 가능
Unicode Standard Annex #44: Unicode Character Database , <https://unicode.org/reports/tr44/ >에서 이용 가능
Unicode Technical Standard #51: Unicode Emoji , <https://unicode.org/reports/tr51/ >에서 이용 가능
IANA Time Zone Database , <https://www.iana.org/time-zones >에서 이용 가능
ISO 8601-1:2019(E) Date and time — Representations for information interchange — Part 1: Basic rules 및 Amendment 1:2022.
RFC 1738 “Uniform Resource Locators (URL)” , <https://rfc-editor.org/info/rfc1738 >에서 이용 가능
RFC 2396 “Uniform Resource Identifiers (URI): Generic Syntax” , <https://rfc-editor.org/info/rfc2396 >에서 이용 가능
RFC 3629 “UTF-8, a transformation format of ISO 10646” , <https://rfc-editor.org/info/rfc3629 >에서 이용 가능
RFC 7231 “Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content” , <https://rfc-editor.org/info/rfc7231 >에서 이용 가능
RFC 9557 “Date and Time on the Internet: Timestamps with Additional Information” , <https://rfc-editor.org/info/rfc9557 >에서 이용 가능
판권 정보
이 명세는 GitHub 에서 Ecmarkup 이라는 일반 텍스트 소스 형식으로 작성됩니다. Ecmarkup은 일반 텍스트로 Ecma 명세를 작성하고 이 문서의 편집 관례를 따르는 완전한 기능의 HTML 렌더링으로 명세를 처리하기 위한 프레임워크와 도구 모음을 제공하는 HTML 및 Markdown 방언입니다. Ecmarkup은 구문 정의를 위한 Grammarkdown 과 알고리즘 단계 작성을 위한 Ecmarkdown 을 포함한 여러 다른 형식과 기술을 기반으로 하며 통합합니다. 이 명세의 PDF 렌더링은 CSS Paged Media 명세를 활용하는 인쇄 스타일시트를 사용하여 생성되며 PrinceXML 을 사용하여 변환됩니다.
이 명세의 이전 판은 Word를 사용하여 작성되었습니다. 이 판의 기반이 된 Ecmarkup 소스 텍스트는 자동 변환 도구를 사용하여 ECMAScript 2015 Word 문서를 Ecmarkup으로 변환하여 생성되었습니다.
저작권 및 소프트웨어 라이선스
Ecma International
Rue du Rhone 114
CH-1204 Geneva
Tel: +41 22 849 6000
Fax: +41 22 849 6001
Web: https://ecma-international.org/
저작권 고지
ALTERNATIVE COPYRIGHT NOTICE AND COPYRIGHT LICENSE
© 2026 Ecma International
By obtaining and/or copying this work, you (the licensee) agree that you
have read, understood, and will comply with the following terms and
conditions.
Permission under Ecma’s copyright to copy, modify, prepare derivative works
of, and distribute this work, with or without modification, for any purpose
and without fee or royalty is hereby granted, provided that you include the
following on ALL copies of the work or portions thereof, including
modifications:
(i) The full text of this COPYRIGHT NOTICE AND COPYRIGHT LICENSE in a location
viewable to users of the redistributed or derivative work.
(ii) Any pre-existing intellectual property disclaimers, notices, or terms and
conditions. If none exist, the Ecma alternative copyright notice should be
included.
(iii) Notice of any changes or modifications, through a copyright statement on
the document such as “This document includes material copied from or
derived from ECMAScript® 2027 언어 명세 https://tc39.es/ecma262/.
Copyright © Ecma International.”
Disclaimers
THIS WORK IS PROVIDED “AS IS,” AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS
OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES
OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF
THE DOCUMENT WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS,
TRADEMARKS OR OTHER RIGHTS.
COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE DOCUMENT.
The name and trademarks of copyright holders may NOT be used in advertising
or publicity pertaining to the work without specific, written prior
permission. Title to copyright in this work will at all times remain with
copyright holders.
소프트웨어 라이선스
All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.