이 Ecma 표준은 ECMAScript 2027 언어를 정의합니다. 이는 ECMAScript 언어 명세의 제18판입니다. ECMAScript는 여러 기원 기술을 기반으로 하며, 그중 가장 잘 알려진 것은 JavaScript(Netscape)와 JScript(Microsoft)입니다. 이 언어는 Netscape의 Brendan Eich가 발명했으며, 그 회사의 Navigator 2.0 브라우저에 처음 등장했습니다. 웹 브라우저에 내장된 언어로 가장 잘 알려져 있지만, 서버 및 임베디드 애플리케이션을 포함하여 브라우저 밖에서도 널리 채택되었으며, 세계에서 가장 널리 사용되는 범용 프로그래밍 언어 중 하나로 성장했습니다.
ECMAScript 언어 명세의 개발은 1996년 11월에 시작되었습니다. 이 Ecma 표준의 초판은 1997년 6월 Ecma 총회에서 채택되었습니다.
그 Ecma 표준은 fast-track 절차에 따라 ISO/IEC JTC 1에 채택을 위해 제출되었고, 1998년 4월에 국제 표준 ISO/IEC 16262로 승인되었습니다. 1998년 6월 Ecma 총회는 ECMA-262의 제2판을 ISO/IEC 16262와 완전히 일치하도록 승인했습니다. 초판과 제2판 사이의 변경 사항은 편집상 변경입니다.
표준의 제3판은 강력한 정규 표현식, 더 나은 문자열 처리, 새로운 제어문, try/catch 예외 처리, 오류의 더 엄밀한 정의, 숫자 출력 형식화 및 향후 언어 성장을 예상한 소규모 변경을 도입했습니다. ECMAScript 표준 제3판은 1999년 12월 Ecma 총회에서 채택되었고 2002년 6월 ISO/IEC 16262:2002로 공개되었습니다.
제3판 공개 이후, ECMAScript는 World Wide Web과 함께 대규모로 채택되어 사실상 모든 웹 브라우저가 지원하는 프로그래밍 언어가 되었습니다. ECMAScript 제4판 개발을 위한 중요한 작업이 수행되었습니다. 그러나 그 작업은 완료되지 않았고 ECMAScript 제4판으로 공개되지 않았지만, 그 일부는 제6판 개발에 포함되었습니다.
ECMAScript 제5판(ECMA-262 5th edition으로 공개됨)은 브라우저 구현 사이에서 일반화된 언어 명세의 사실상 해석을 성문화하고, 제3판 공개 이후 등장한 새로운 기능에 대한 지원을 추가했습니다. 그러한 기능에는 접근자 속성, 객체의 반사적 생성과 검사, 속성 어트리뷰트의 프로그램 제어, 추가 배열 조작 함수, JSON 객체 인코딩 형식 지원, 그리고 향상된 오류 검사와 프로그램 보안을 제공하는 strict mode가 포함됩니다. 제5판은 2009년 12월 Ecma 총회에서 채택되었습니다.
제5판은 fast-track 절차에 따라 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 사용을 더 잘 지원하는 것이 포함되었습니다. 주요 개선 사항에는 모듈, 클래스 선언, lexical block scoping, 이터레이터와 제너레이터, 비동기 프로그래밍을 위한 promise, 구조 분해 패턴, proper tail calls가 포함되었습니다. ECMAScript 내장 라이브러리는 맵, 세트, 이진 숫자 값의 배열을 포함한 추가 데이터 추상화를 지원하도록 확장되었으며, 문자열과 정규 표현식에서 Unicode supplementary character에 대한 추가 지원도 포함했습니다. 또한 내장 객체는 서브클래싱을 통해 확장 가능하게 만들어졌습니다. 제6판은 정기적이고 점진적인 언어 및 라이브러리 향상의 기반을 제공합니다. 제6판은 2015년 6월 총회에서 채택되었습니다.
ECMAScript 2016은 Ecma TC39의 새로운 연간 릴리스 주기와 개방형 개발 절차에 따라 릴리스된 첫 번째 ECMAScript 판이었습니다. ECMAScript 2015 소스 문서에서 평문 소스 문서를 만들어 GitHub에서 완전히 이어지는 개발의 기반으로 삼았습니다. 이 표준이 개발된 1년 동안 수백 개의 pull request와 issue가 제출되었으며, 이는 수천 건의 버그 수정, 편집상 수정 및 기타 개선을 나타냅니다. 또한 Ecmarkup, Ecmarkdown, Grammarkdown을 포함하여 이 작업을 돕기 위한 수많은 소프트웨어 도구가 개발되었습니다. ES2016은 또한 새로운 지수 연산자 지원을 포함하고, Array.prototype에 includes라는 새 메서드를 추가했습니다.
ECMAScript 2017은 Async Functions, Shared Memory, Atomics를 도입했으며, 이와 함께 더 작은 언어 및 라이브러리 개선, 버그 수정, 편집상 업데이트를 포함했습니다. Async functions는 promise를 반환하는 함수를 위한 구문을 제공하여 비동기 프로그래밍 경험을 개선합니다. Shared Memory와 Atomics는 여러 agent 프로그램이 병렬 CPU에서도 잘 정의된 실행 순서를 보장하는 atomic operation을 사용하여 통신할 수 있게 하는 새로운 메모리 모델을 도입합니다. 또한 Object의 새로운 static method인 Object.values, Object.entries, Object.getOwnPropertyDescriptors도 포함되었습니다.
ECMAScript 2018은 async iterator protocol과 async generator를 통한 비동기 반복 지원을 도입했습니다. 또한 네 가지 새로운 정규 표현식 기능인 dotAll 플래그, named capture group, Unicode property escape, look-behind assertion을 포함했습니다. 마지막으로 object rest 및 spread properties를 포함했습니다.
ECMAScript 2019는 몇 가지 새로운 내장 함수를 도입했습니다: 배열을 평탄화하기 위한 Array.prototype의 flat과 flatMap, Object.entries의 반환값을 직접 새 Object로 바꾸기 위한 Object.fromEntries, 그리고 널리 구현되었지만 비표준인 String.prototype.trimLeft 및 trimRight 내장 함수의 더 나은 이름을 가진 대안으로서 String.prototype의 trimStart와 trimEnd가 포함됩니다. 또한 구문과 의미에 대한 몇 가지 사소한 업데이트가 포함되었습니다. 업데이트된 구문에는 optional catch binding parameter와 JSON에 맞추기 위해 문자열 리터럴에서 U+2028(LINE SEPARATOR) 및 U+2029(PARAGRAPH SEPARATOR)를 허용하는 것이 포함되었습니다. 다른 업데이트에는 Array.prototype.sort가 stable sort여야 한다는 요구, JSON.stringify가 입력과 관계없이 well-formed UTF-8을 반환해야 한다는 요구, 그리고 Function.prototype.toString이 해당 원본 소스 텍스트 또는 표준 placeholder를 반환해야 한다고 명확히 하는 것이 포함되었습니다.
ECMAScript 2020, 제11판은 전역 정규 표현식이 생성하는 모든 match object에 대한 iterator를 생성하기 위해 String의 matchAll 메서드; 동적 specifier로 Module을 비동기적으로 import하는 구문인 import(); 임의 정밀도 정수 작업을 위한 새로운 number primitive인 BigInt; short-circuit하지 않는 새로운 Promise combinator인 Promise.allSettled; 전역 this 값에 접근하는 보편적 방법인 globalThis; module 내에서 사용하기 위한 전용 export * as ns from 'module' 구문; for-in 열거 순서의 표준화 확대; Module에서 사용할 수 있고 Module에 대한 문맥 정보를 포함할 수 있는 host-populated object인 import.meta; 그리고 “nullish” 값(undefined 또는 null) 작업을 개선하기 위한 두 가지 새로운 구문 기능인 값 선택 연산자 nullish coalescing과, 접근/호출할 값이 nullish이면 short-circuit하는 속성 접근 및 함수 호출 연산자 optional chaining을 도입했습니다.
ECMAScript 2021, 제12판은 String의 replaceAll 메서드; 입력 값이 fulfilled되면 short-circuit하는 Promise combinator인 Promise.any; 여러 오류를 한 번에 표현하는 새로운 Error 타입인 AggregateError; logical assignment operators(??=, &&=, ||=); 대상 객체가 garbage collection되지 않도록 보존하지 않고 참조하기 위한 WeakRef, 그리고 대상 객체가 garbage collection될 때 수행되는 cleanup operation의 등록과 해제를 관리하기 위한 FinalizationRegistry; 숫자 리터럴의 separator(1_000); 그리고 Array.prototype.sort를 더 정밀하게 만들어 구현 정의 정렬 순서가 되는 경우의 수를 줄인 것을 도입했습니다.
ECMAScript 2022, 제13판은 top-level await를 도입하여 module의 top level에서 해당 keyword를 사용할 수 있게 했습니다; 새로운 class element로 public 및 private instance field, public 및 private static field, private instance method와 accessor, private static method와 accessor를 도입했습니다; class 내부에서 per-class evaluation initialization을 수행하기 위한 static block; 객체에 private field가 존재하는지 테스트하기 위한 #x in obj 구문; match된 substring의 start 및 end index를 제공하는 /d 플래그를 통한 regular expression match indices; 오류에서 causation chain을 기록하는 데 사용할 수 있는 Error object의 cause 속성; relative indexing을 허용하는 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을 weak collection의 key로 사용할 수 있게 했습니다.
ECMAScript 2024, 제15판은 ArrayBuffer와 SharedArrayBuffer의 resizing 및 transferring을 위한 기능을 추가했습니다; string set 작업을 위한 더 고급 기능을 갖춘 RegExp를 만들기 위한 새로운 RegExp /v 플래그를 추가했습니다; 그리고 Promise를 구성하기 위한 편의 메서드 Promise.withResolvers, 데이터를 집계하기 위한 Object.groupBy와 Map.groupBy 메서드, shared memory 변경을 비동기적으로 기다리기 위한 Atomics.waitAsync 메서드, 문자열이 well-formed Unicode만 포함하는지 확인하고 보장하기 위한 String.prototype.isWellFormed와 String.prototype.toWellFormed 메서드를 도입했습니다.
ECMAScript 2025, 제16판은 iterator 작업을 위한 관련 static 및 prototype method를 가진 새로운 Iterator global을 추가했습니다; Set에 대한 일반적인 operation을 수행하기 위한 메서드를 Set.prototype에 추가했습니다; JSON module import 지원과 imported module의 attribute를 선언하는 구문을 추가했습니다; 문자열을 정규 표현식에서 안전하게 사용할 수 있도록 escape하는 RegExp.escape 메서드를 추가했습니다; 정규 표현식 내에서 modifier flag를 inline으로 활성화하고 비활성화하는 구문을 추가했습니다; Promise를 반환할 수도 있고 반환하지 않을 수도 있는 함수를 호출하고 결과가 항상 Promise가 되도록 보장하기 위한 Promise.try 메서드를 추가했습니다; 그리고 새로운 Float16ArrayTypedArray kind와 관련된 DataView.prototype.getFloat16, DataView.prototype.setFloat16, Math.f16round 메서드를 추가했습니다.
ECMAScript 2026, 제17판은 precision loss를 최소화하면서 크기가 다양한 Number의 iterable을 합산하기 위한 Math.sumPrecise; iterator를 순서대로 연결하기 위한 Iterator.concat; async iterable과 다른 async source로부터 Array를 구성하기 위한 Array.fromAsync; error object를 식별하기 위한 Error.isError; key가 아직 존재하지 않을 때 retrieval 중 사용할 default value를 제공하기 위한 Map.prototype과 WeakMap.prototype의 메서드; 16진수 및 base64로 인코딩된 이진 데이터 String으로 변환하거나 그로부터 변환하기 위한 Uint8Array의 메서드; JSON source의 match된 segment에 접근하기 위한 JSON.parse reviver의 parameter; 그리고 primitive value에 대한 JSON.stringify 출력을 세밀하게 제어하기 위한 JSON.rawJSON을 추가했습니다.
많은 조직을 대표하는 수십 명의 개인이 Ecma TC39 내에서 이 판과 이전 판들의 개발에 매우 중요한 기여를 했습니다. 또한 TC39의 ECMAScript 작업을 지원하는 활발한 커뮤니티가 형성되었습니다. 이 커뮤니티는 수많은 draft를 검토하고, 수천 건의 bug report를 제출하고, implementation experiment를 수행하고, test suite에 기여하고, 전 세계 개발자 커뮤니티에 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의 conforming implementation은 이 명세에 설명된 모든 타입, 값, 객체, 속성, 함수, 그리고 프로그램 구문과 의미를 제공하고 지원해야 합니다.
ECMAScript의 conforming implementation은 최신 버전의 Unicode Standard 및 ISO/IEC 10646에 부합하게 source text input을 해석해야 합니다.
서로 다른 인간 언어와 국가에서 사용되는 언어적·문화적 관례에 적응해야 하는 프로그램을 지원하는 application programming interface(API)를 제공하는 ECMAScript의 conforming implementation은 이 명세와 호환되는 ECMA-402의 가장 최근 판에서 정의한 interface를 구현해야 합니다.
ECMAScript의 conforming implementation은 이 명세에 설명된 것 외에 추가 타입, 값, 객체, 속성 및 함수를 제공할 수 있습니다. 특히, ECMAScript의 conforming implementation은 이 명세에 설명된 객체에 대해 이 명세에 설명되지 않은 속성과 그 속성의 값을 제공할 수 있습니다.
ECMAScript의 conforming implementation은 이 명세에 설명되지 않은 프로그램 및 정규 표현식 구문을 지원할 수 있습니다. 특히, ECMAScript의 conforming implementation은 이 명세의 하위 절 12.7.2에 언급된 모든 “future reserved words”를 사용하는 프로그램 구문을 지원할 수 있습니다.
ECMAScript의 conforming implementation은 하위 절 17.1에서 Forbidden Extension으로 열거된 어떤 확장도 구현해서는 안 됩니다.
ECMAScript의 conforming implementation은 달리 명시되지 않는 한 Normative Optional 하위 절을 구현할지 여부를 선택할 수 있습니다. 웹 브라우저는 일반적으로 모든 normative optional 하위 절을 구현해야 합니다. (Annex B 참조.) 어떤 Normative Optional 동작이 구현되면, 이를 포함하는 Normative Optional clause의 모든 동작이 구현되어야 합니다. Normative Optional clause는 아래에 표시된 것처럼 이 명세에서 색이 있는 상자 안의 “Normative Optional”이라는 단어로 표시됩니다.
ECMAScript의 conforming implementation은 Legacy 하위 절이 Normative Optional로도 표시되어 있지 않은 한 Legacy 하위 절을 구현해야 합니다. Legacy 하위 절 안에 명시된 모든 언어 기능과 동작은 하나 이상의 바람직하지 않은 특성을 가집니다. 그러나 기존 애플리케이션에서 계속 사용되고 있기 때문에 이 명세에서 제거할 수 없습니다. 이러한 기능은 핵심 ECMAScript 언어의 일부로 간주되지 않습니다. 프로그래머는 새로운 ECMAScript 코드를 작성할 때 이러한 기능과 동작의 존재를 사용하거나 가정해서는 안 됩니다.
ISO/IEC 10646, Information Technology — Universal Multiple-Octet Coded Character Set (UCS) 및 Amendment 1:2005, Amendment 2:2006, Amendment 3:2008, Amendment 4:2008, 그리고 추가 amendment와 corrigenda, 또는 successor.
ECMAScript는 host environment 안에서 계산을 수행하고 computational object를 조작하기 위한 객체 지향 프로그래밍 언어입니다. 여기서 정의된 ECMAScript는 계산적으로 자급자족하도록 의도되지 않았습니다. 실제로 이 명세에는 외부 데이터 입력이나 계산 결과 출력에 대한 규정이 없습니다. 대신 ECMAScript 프로그램의 computational environment는 이 명세에 설명된 객체와 기타 기능뿐만 아니라, 이 명세의 범위를 벗어나는 설명과 동작을 갖는 특정 environment-specific object도 제공할 것으로 기대됩니다. 다만 그러한 객체가 ECMAScript 프로그램에서 접근할 수 있는 특정 속성과 호출할 수 있는 특정 함수를 제공할 수 있음을 나타내는 경우는 예외입니다.
ECMAScript는 원래 scripting language로 사용되도록 설계되었지만, 현재는 general-purpose programming language로 널리 사용됩니다. scripting language는 기존 시스템의 기능을 조작, 사용자화, 자동화하는 데 사용되는 프로그래밍 언어입니다. 그러한 시스템에서는 유용한 기능이 이미 user interface를 통해 제공되고, scripting language는 그 기능을 프로그램 제어에 노출하는 메커니즘입니다. 이런 방식으로 기존 시스템은 scripting language의 기능을 완성하는 객체와 기능의 host environment를 제공한다고 말합니다. scripting language는 전문 프로그래머와 비전문 프로그래머 모두가 사용하도록 의도됩니다.
ECMAScript는 원래 Web scripting language가 되도록 설계되어, 브라우저에서 Web page에 생동감을 부여하고 Web 기반 client-server architecture의 일부로 server computation을 수행하는 메커니즘을 제공했습니다. ECMAScript는 이제 다양한 host environment에 core scripting capability를 제공하는 데 사용됩니다. 따라서 core language는 특정 host environment와 분리되어 이 문서에 명시됩니다.
ECMAScript 사용은 단순 scripting을 넘어섰으며, 이제 많은 서로 다른 환경과 규모에서 프로그래밍 작업의 전체 범위에 사용됩니다. ECMAScript 사용이 확장됨에 따라, ECMAScript가 제공하는 기능과 시설도 확장되었습니다. ECMAScript는 이제 충분한 기능을 갖춘 general-purpose programming language입니다.
4.1 Web Scripting
웹 브라우저는 client-side computation을 위한 ECMAScript host environment를 제공합니다. 여기에는 예를 들어 windows, menus, pop-ups, dialog boxes, text areas, anchors, frames, history, cookies, 그리고 input/output을 나타내는 객체가 포함됩니다. 또한 host environment는 focus 변경, page와 image loading, unloading, error와 abort, selection, form submission, mouse action과 같은 이벤트에 scripting code를 붙이는 수단을 제공합니다. Scripting code는 HTML 안에 나타나며, 표시되는 page는 user interface element와 고정 및 계산된 text와 image의 조합입니다. Scripting code는 user interaction에 반응하며, main program은 필요하지 않습니다.
웹 서버는 requests, clients, files를 나타내는 객체와 데이터를 잠그고 공유하는 메커니즘을 포함하여 server-side computation을 위한 다른 host environment를 제공합니다. browser-side와 server-side scripting을 함께 사용하면, Web 기반 애플리케이션에 사용자화된 user interface를 제공하면서 client와 server 사이에 computation을 분산할 수 있습니다.
ECMAScript를 지원하는 각 Web browser와 server는 자신만의 host environment를 제공하여 ECMAScript execution environment를 완성합니다.
4.2 Hosts와 Implementations
ECMAScript를 host environment에 통합하는 데 도움을 주기 위해, 이 명세는 특정 기능(예: abstract operations)의 정의를 전체 또는 일부에 대해 이 명세 외부의 source로 위임합니다. 편집상, 이 명세는 다음과 같은 종류의 위임을 구분합니다.
implementation-defined facility는 추가 한정 없이 그 정의를 외부 source로 위임하는 것입니다. 이 명세는 특정 동작에 대해 어떤 권고도 하지 않으며, conforming implementation은 이 명세가 제시한 제약 내에서 어떤 동작이든 자유롭게 선택할 수 있습니다.
implementation-approximated facility는 그 정의를 외부 source로 위임하면서 이상적인 동작을 권고하는 것입니다. conforming implementation은 이 명세가 제시한 제약 내에서 어떤 동작이든 자유롭게 선택할 수 있지만, 그 이상에 가깝게 근사하려고 노력하도록 권장됩니다. Math.exp와 같은 일부 mathematical operation은 implementation-approximated입니다.
hosts와 implementations는 모두 여기에 정의된 language type, specification type, abstract operation, grammar production, intrinsic object, intrinsic symbol을 통해 이 명세와 interface할 수 있습니다.
4.3 ECMAScript 개요
다음은 ECMAScript에 대한 비공식 개요입니다. 언어의 모든 부분이 설명되는 것은 아닙니다. 이 개요는 표준 본문 자체의 일부가 아닙니다.
ECMAScript는 object-based입니다. 기본 언어와 host facility는 object에 의해 제공되며, ECMAScript 프로그램은 서로 통신하는 object의 cluster입니다. ECMAScript에서 object는 각각의 property가 어떻게 사용될 수 있는지를 결정하는 attributes를 가진, 0개 이상의 properties의 collection입니다. 예를 들어 property의 Writable attribute가 false로 설정되면, 실행되는 ECMAScript code가 그 property에 다른 값을 할당하려는 모든 시도는 실패합니다. Properties는 다른 object, primitive values, 또는 functions를 담는 container입니다. primitive value는 다음 built-in type 중 하나의 member입니다: Undefined, Null, Boolean, Number, BigInt, String, 그리고 Symbol; object는 built-in type Object의 member입니다; 그리고 function은 callable object입니다. property를 통해 object와 연결된 function을 method라고 합니다.
ECMAScript는 ECMAScript entity의 정의를 완성하는 built-in objects의 collection을 정의합니다. 이러한 built-in object에는 global object; Object, Function, Boolean, Symbol, 그리고 다양한 Error object를 포함하여 언어의 runtime semantics에 근본적인 object; Math, Number, Date를 포함하여 numeric value를 나타내고 조작하는 object; text processing object인 String과 RegExp; Array와, element가 모두 특정 numeric data representation을 갖는 아홉 가지 다른 종류의 Typed Array를 포함하여 value의 indexed collection인 object; Map과 Set object를 포함하는 keyed collection; JSON object, ArrayBuffer, SharedArrayBuffer, DataView를 포함하여 structured data를 지원하는 object; generator function과 Promise object를 포함하여 control abstraction을 지원하는 object; 그리고 Proxy와 Reflect를 포함하는 reflection object가 포함됩니다.
ECMAScript는 또한 built-in operators의 집합을 정의합니다. ECMAScript operator에는 다양한 unary operation, multiplicative operator, additive operator, bitwise shift operator, relational operator, equality operator, binary bitwise operator, binary logical operator, assignment operator, 그리고 comma operator가 포함됩니다.
대규모 ECMAScript 프로그램은 modules에 의해 지원되며, module은 프로그램을 statements와 declarations의 여러 sequence로 나눌 수 있게 합니다. 각 module은 자신이 사용하며 다른 module이 제공해야 하는 declaration과, 다른 module이 사용할 수 있는 자신의 declaration을 명시적으로 식별합니다.
ECMAScript 구문은 의도적으로 Java 구문과 유사합니다. ECMAScript 구문은 사용하기 쉬운 scripting language로 기능할 수 있도록 완화되어 있습니다. 예를 들어 variable은 type을 선언할 필요가 없고, type은 property와 연결되어 있지 않으며, 정의된 function은 호출보다 텍스트상 앞에 declaration이 나타날 필요가 없습니다.
4.3.1 Objects
ECMAScript에는 class definition을 위한 구문이 포함되어 있지만, ECMAScript object는 C++, Smalltalk, Java의 object처럼 근본적으로 class-based가 아닙니다. 대신 object는 literal notation을 통해서나, object를 만들고 그 property에 initial value를 할당하여 그 전부 또는 일부를 초기화하는 code를 실행하는 constructors를 통해서 등 다양한 방식으로 생성될 수 있습니다. 각 constructor는 "prototype"이라는 이름의 property를 가진 function이며, 이 property는 prototype-based inheritance와 shared properties를 구현하는 데 사용됩니다. Object는 new expression에서 constructor를 사용하여 생성됩니다. 예를 들어 new Date(2009, 11)은 새 Date object를 생성합니다. new를 사용하지 않고 constructor를 호출하는 것은 constructor에 따라 다른 결과를 가집니다. 예를 들어 Date()는 object가 아니라 현재 date와 time의 string representation을 생성합니다.
constructor에 의해 생성된 모든 object는 자신의 constructor의 "prototype" property 값에 대한 암시적 reference(object의 prototype이라고 함)를 가집니다. 또한 prototype은 자신의 prototype에 대한 non-null 암시적 reference를 가질 수 있으며, 이런 식으로 이어질 수 있습니다. 이를 prototype chain이라고 합니다. object의 property를 참조할 때, 그 reference는 해당 이름의 property를 포함하는 prototype chain의 첫 번째 object 안의 그 이름 property를 가리킵니다. 달리 말하면, 먼저 직접 언급된 object가 그러한 property를 갖는지 검사됩니다. 그 object가 named property를 포함하면, 그것이 reference가 가리키는 property입니다. 그 object가 named property를 포함하지 않으면, 그 object의 prototype이 다음으로 검사됩니다. 그리고 이런 식으로 계속됩니다.
Figure 1: Object/Prototype Relationships
class-based object-oriented language에서는 일반적으로 state는 instance가 보유하고, method는 class가 보유하며, inheritance는 structure와 behaviour에 대해서만 이루어집니다. ECMAScript에서는 state와 method가 object에 의해 보유되는 반면, structure, behaviour, state가 모두 inherited됩니다.
prototype이 포함하는 특정 property를 직접 포함하지 않는 모든 object는 그 property와 그 값을 공유합니다. Figure 1은 이를 보여줍니다:
CF는 constructor이며 object이기도 합니다. new expression을 사용하여 다섯 개의 object가 생성되었습니다: cf1, cf2, cf3, cf4, 그리고 cf5. 이 object들은 각각 "q1"과 "q2"라는 이름의 property를 포함합니다. 점선은 암시적 prototype 관계를 나타냅니다. 따라서 예를 들어 cf3의 prototype은 CFp입니다. constructor인 CF는 그 자체로 "P1"과 "P2"라는 두 property를 가지며, 이들은 CFp, cf1, cf2, cf3, cf4, 또는 cf5에는 보이지 않습니다. CFp의 "CFP1"이라는 이름의 property는 cf1, cf2, cf3, cf4, 그리고 cf5가 공유합니다(CF와는 공유하지 않음). CFp의 암시적 prototype chain에서 발견되는 property 중 "q1", "q2", 또는 "CFP1"이라는 이름이 아닌 모든 property도 마찬가지입니다. CF와 CFp 사이에는 암시적 prototype link가 없다는 점에 유의하십시오.
대부분의 class-based object language와 달리, property는 값 할당을 통해 object에 동적으로 추가될 수 있습니다. 즉 constructor는 constructed object의 property 전부 또는 일부의 이름을 정하거나 값을 할당할 필요가 없습니다. 위 그림에서 CFp의 property에 새 값을 할당함으로써 cf1, cf2, cf3, cf4, 그리고 cf5를 위한 새로운 shared property를 추가할 수 있습니다.
ECMAScript object가 본질적으로 class-based는 아니지만, constructor function, prototype object, method의 공통 pattern에 기반하여 class-like abstraction을 정의하는 것이 편리한 경우가 많습니다. ECMAScript built-in object 자체도 그러한 class-like pattern을 따릅니다. ECMAScript 2015부터 ECMAScript language에는 built-in object가 사용하는 동일한 class-like abstraction pattern을 따르는 object를 프로그래머가 간결하게 정의할 수 있게 하는 syntactic class definition이 포함됩니다.
4.3.2 ECMAScript의 Strict Variant
ECMAScript 언어는 언어에서 사용할 수 있는 일부 기능의 사용을 제한하고자 하는 사용자가 있을 수 있음을 인정합니다. 그들은 security를 위해, 오류가 발생하기 쉽다고 여기는 기능을 피하기 위해, 향상된 error checking을 얻기 위해, 또는 자신이 선택한 다른 이유로 그렇게 할 수 있습니다. 이 가능성을 지원하기 위해 ECMAScript는 언어의 strict variant를 정의합니다. 언어의 strict variant는 일반 ECMAScript 언어의 특정 syntactic 및 semantic feature를 제외하고, 일부 기능의 자세한 semantics를 수정합니다. strict variant는 또한 언어의 non-strict form에서 오류로 명시되지 않은 상황에서 error exception을 throw하여 보고해야 하는 추가 error condition을 명시합니다.
ECMAScript의 strict variant는 일반적으로 언어의 strict mode라고 불립니다. strict mode 선택과 ECMAScript의 strict mode syntax 및 semantics 사용은 11.2.2에 설명된 대로 개별 ECMAScript source text unit 수준에서 명시적으로 이루어집니다. strict mode는 syntactic source text unit 수준에서 선택되므로, strict mode는 그러한 source text unit 안에서 local effect를 갖는 제한만 부과합니다. strict mode는 여러 source text unit에 걸쳐 일관되게 동작해야 하는 ECMAScript semantics의 어떤 측면도 제한하거나 수정하지 않습니다. 완전한 ECMAScript 프로그램은 strict mode와 non-strict mode ECMAScript source text unit 둘 다로 구성될 수 있습니다. 이 경우 strict mode는 strict mode source text unit 안에 정의된 code를 실제로 실행할 때만 적용됩니다.
이 명세에 부합하기 위해, ECMAScript implementation은 이 명세에서 정의한 full unrestricted ECMAScript language와 ECMAScript language의 strict variant를 모두 구현해야 합니다. 또한 implementation은 unrestricted와 strict mode source text unit을 하나의 composite program으로 결합하는 것을 지원해야 합니다.
constructor의 "prototype" property 값은 inheritance와 shared property를 구현하는 데 사용되는 prototype object입니다.
4.4.8 prototype
다른 object에 shared property를 제공하는 object
Note
constructor가 object를 생성할 때, 그 object는 property reference를 resolve하기 위해 constructor의 "prototype" property를 암시적으로 참조합니다. constructor의 "prototype" property는 프로그램 expression constructor.prototype으로 참조될 수 있으며, object의 prototype에 추가된 property는 inheritance를 통해 그 prototype을 공유하는 모든 object가 공유합니다. 또는 Object.create built-in function을 사용하여 명시적으로 지정된 prototype을 가진 새 object를 생성할 수 있습니다.
4.4.9 ordinary object
모든 object가 지원해야 하는 essential internal method에 대한 default behaviour를 가진 object
4.4.10 exotic object
하나 이상의 essential internal method에 대해 default behaviour를 갖지 않는 object
Boolean object는 Boolean constructor를 new expression에서 사용하고 Boolean value를 argument로 제공하여 생성됩니다. 결과 object는 그 값이 Boolean value인 internal slot을 가집니다. Boolean object는 Boolean value로 coerced될 수 있습니다.
4.4.20 String value
0개 이상의 16-bit unsigned integer value의 finite ordered sequence인 primitive value
Note
String value는 String type의 member입니다. sequence 안의 각 integer value는 보통 UTF-16 text의 단일 16-bit unit을 나타냅니다. 그러나 ECMAScript는 값이 16-bit unsigned integer여야 한다는 것 외에는 그 값에 어떤 제한이나 요구사항도 두지 않습니다.
Number object는 Number constructor를 new expression에서 사용하고 Number value를 argument로 제공하여 생성됩니다. 결과 object는 그 값이 Number value인 internal slot을 가집니다. Number object는 Number constructor를 function으로 호출함으로써 Number value로 coerced될 수 있습니다(21.1.1.1).
4.4.26 Infinity
positive infinite Number value인 Number value
4.4.27 NaN
IEEE 754-2019 NaN(“not a number”) value인 Number value
4.4.28 BigInt value
arbitrary-precision integer value에 대응하는 primitive value
context-free grammar는 여러 production으로 구성됩니다. 각 production은 left-hand side로서 nonterminal이라고 하는 abstract symbol을 가지며, right-hand side로서 0개 이상의 nonterminal 및 terminal symbol의 sequence를 가집니다. 각 grammar에 대해 terminal symbol은 지정된 alphabet에서 가져옵니다.
chain production은 right-hand side에 정확히 하나의 nonterminal symbol과 0개 이상의 terminal symbol을 가진 production입니다.
goal symbol이라고 하는 하나의 distinguished nonterminal로 이루어진 sentence에서 시작하여, 주어진 context-free grammar는 하나의 language, 즉 sequence 안의 nonterminal을 그 nonterminal이 left-hand side인 production의 right-hand side로 반복해서 대체함으로써 얻을 수 있는 가능한 terminal symbol sequence의 (아마도 무한한) 집합을 명시합니다.
white space와 comment 이외의 input element는 ECMAScript의 syntactic grammar를 위한 terminal symbol을 형성하며 ECMAScript tokens라고 불립니다. 이러한 token은 ECMAScript 언어의 reserved word, identifier, literal, punctuator입니다. 또한 line terminator는 token으로 간주되지는 않지만 input element의 stream의 일부가 되어 automatic semicolon insertion 과정(12.10)을 안내합니다. 단순 white space와 single-line comment는 버려지며 syntactic grammar를 위한 input element의 stream에 나타나지 않습니다. MultiLineComment(즉, 여러 줄에 걸치는지와 관계없이 /*…*/ 형식의 comment)도 line terminator를 포함하지 않으면 마찬가지로 단순히 버려집니다. 그러나 MultiLineComment가 하나 이상의 line terminator를 포함하면, 이는 하나의 line terminator로 대체되어 syntactic grammar를 위한 input element의 stream의 일부가 됩니다.
ECMAScript의 RegExp grammar는 22.2.1에 제시됩니다. 이 grammar도 SourceCharacter로 정의된 code point를 terminal symbol로 가집니다. 이는 goal symbolPattern에서 시작하여 code point의 sequence가 regular expression pattern으로 어떻게 변환되는지를 설명하는 production의 집합을 정의합니다.
lexical 및 RegExp grammar의 production은 분리 punctuation으로 두 개의 colon “::”을 가진다는 점으로 구분됩니다. lexical 및 RegExp grammar는 일부 production을 공유합니다.
numeric string grammar의 production은 punctuation으로 세 개의 colon “:::”을 가진다는 점으로 구분되며, source text를 parsing하는 데 사용되지 않습니다.
5.1.4 Syntactic Grammar
ECMAScript의 syntactic grammar는 clauses 13 through 16에 제시됩니다. 이 grammar는 lexical grammar에 의해 정의된 ECMAScript token을 terminal symbol로 가집니다(5.1.2). 이는 두 alternative goal symbolScript와 Module에서 시작하여, token의 sequence가 ECMAScript 프로그램의 syntactically correct independent component를 어떻게 형성하는지를 설명하는 production의 집합을 정의합니다.
code point의 stream을 ECMAScript Script 또는 Module로 parsing하려면, 먼저 lexical grammar의 반복 적용에 의해 input element의 stream으로 변환됩니다. 그런 다음 이 input element의 stream은 syntactic grammar를 한 번 적용하여 parsed됩니다. input element의 stream 안의 token이 goal nonterminal(Script 또는 Module)의 단일 instance로, token을 남기지 않고 parsed될 수 없으면 input stream은 syntactically in error입니다.
parse가 성공하면, root가 있는 tree structure인 parse tree를 구성하며, 이 tree의 각 node는 Parse Node입니다. 각 Parse Node는 grammar 안의 symbol의 instance입니다. 이는 그 symbol로부터 derivable한 source text의 span을 나타냅니다. parse tree의 root node는 source text 전체를 나타내며 parse의 goal symbol의 instance입니다. Parse Node가 nonterminal의 instance일 때, 이는 또한 그 nonterminal을 left-hand side로 갖는 어떤 production의 instance입니다. 또한 이는 0개 이상의 children을 가지며, production의 right-hand side에 있는 각 symbol마다 하나씩 존재합니다. 각 child는 해당 symbol의 instance인 Parse Node입니다.
New Parse Node는 parser의 각 invocation마다 instantiated되며, 동일한 source text의 parse 사이에서도 결코 재사용되지 않습니다. Parse Node는 같은 source text span을 나타내고, 같은 grammar symbol의 instance이며, 같은 parser invocation에서 나온 경우에만 the same Parse Node로 간주됩니다.
Note 1
같은 String을 여러 번 parsing하면 서로 다른 Parse Node가 생성됩니다. 예를 들어 다음을 고려하십시오:
let str = "1 + 1;";
eval(str);
eval(str);
eval 호출 각각은 str의 값을 ECMAScript source text로 변환하고, 독립적인 parse를 수행하여 자신만의 별도 Parse Node tree를 생성합니다. 각 parse가 같은 String value에서 derived된 source text에 대해 동작하더라도 tree들은 distinct합니다.
Note 2
Parse Node는 specification artefact이며, implementation은 유사한 data structure를 사용할 필요가 없습니다.
syntactic grammar의 production은 punctuation으로 단 하나의 colon “:”을 가진다는 점으로 구분됩니다.
clauses 13 through 16에 제시된 syntactic grammar는 어떤 token sequence가 올바른 ECMAScript Script 또는 Module로 받아들여지는지에 대한 완전한 설명이 아닙니다. 특정 위치(예: line terminator character 앞)에 semicolon을 추가하기만 하면 grammar가 설명할 수 있는 token sequence도 추가로 허용됩니다. 또한 grammar에 의해 설명되는 특정 token sequence라도 line terminator character가 특정 “awkward” 위치에 나타나면 허용 가능한 것으로 간주되지 않습니다.
어떤 경우에는 ambiguity를 피하기 위해 syntactic grammar가 유효한 ECMAScript Script 또는 Module을 형성하지 않는 token sequence를 허용하는 generalized production을 사용합니다. 예를 들어 이 기법은 object literal과 object destructuring pattern에 사용됩니다. 그런 경우 허용 가능한 token sequence를 더 제한하는 보다 제한적인 supplemental grammar가 제공됩니다. 일반적으로 early error rule은 특정 context에서 “p must cover an n”이라고 명시하며, 여기서 p는 Parse Node(generalized production의 instance)이고 n은 supplemental grammar의 nonterminal입니다. 이는 다음을 의미합니다:
원래 p에 의해 match된 token sequence는 n을 goal symbol로 사용하여 다시 parsed됩니다. n이 grammatical parameter를 취하면, 이는 p가 원래 parsed될 때 사용된 값과 같은 값으로 설정됩니다.
token sequence가 token을 남기지 않고 n의 단일 instance로 parsed될 수 있으면, 다음과 같습니다:
그 n의 instance(주어진 p에 대해 unique한 Parse Node)를 “p에 의해 covered되는 n”이라고 부릅니다.
n과 그 derived production에 대한 모든 Early Error rule도 p에 의해 covered되는 n에 적용됩니다.
그렇지 않으면(parse가 실패하면) early Syntax Error입니다.
5.1.5 Grammar Notation
5.1.5.1 Terminal Symbols
ECMAScript grammar에서 일부 terminal symbol은 fixed-width font로 표시됩니다. 이들은 source text에 쓰인 그대로 나타나야 합니다. 이런 방식으로 명시된 모든 terminal symbol code point는 다른 Unicode range의 비슷하게 보이는 code point가 아니라 Basic Latin block의 적절한 Unicode code point로 이해되어야 합니다. terminal symbol 안의 code point는 \UnicodeEscapeSequence로 표현될 수 없습니다.
terminal symbol이 개별 Unicode code point인 grammar(즉 lexical, RegExp, numeric string grammar)에서 production에 나타나는 여러 fixed-width code point의 contiguous run은 standalone terminal symbol로 쓰인 같은 code point sequence에 대한 단순한 shorthand입니다.
syntactic grammar에서 특정 terminal symbol(예: IdentifierName 및 RegularExpressionLiteral)은 italic으로 표시되며, 이는 lexical grammar의 같은 이름의 nonterminal을 참조하기 때문입니다.
5.1.5.2 Nonterminal Symbols and Productions
Nonterminal symbol은 italic type으로 표시됩니다. nonterminal의 정의(“production”이라고도 함)는 정의되는 nonterminal의 name과 그 뒤에 오는 하나 이상의 colon으로 시작됩니다. (colon의 수는 production이 어떤 grammar에 속하는지를 나타냅니다.) 그런 다음 nonterminal에 대한 하나 이상의 alternative right-hand side가 다음 줄들에 이어집니다. 예를 들어 syntactic definition:
은 nonterminal WhileStatement가 token while, 그 뒤의 left parenthesis token, 그 뒤의 Expression, 그 뒤의 right parenthesis token, 그 뒤의 Statement를 나타낸다고 명시합니다. Expression과 Statement의 occurrence는 그 자체로 nonterminal입니다. 또 다른 예로, syntactic definition:
terminal 또는 nonterminal 뒤에 나타날 수 있는 subscripted suffix “opt”는 optional symbol을 나타냅니다. optional symbol을 포함하는 alternative는 실제로 optional element를 생략한 것과 포함한 것, 두 right-hand side를 명시합니다. 이는 다음을 의미합니다:
따라서 이 예에서 nonterminal ForStatement는 실제로 네 개의 alternative right-hand side를 가집니다.
5.1.5.4 Grammatical Parameters
production은 정의되는 production의 nonterminal symbol에 suffix로 나타날 수 있는 “[parameters]” 형식의 subscripted annotation으로 parameterized될 수 있습니다. “parameters”는 하나의 name이거나 comma로 구분된 name의 list일 수 있습니다. parameterized production은 parameterized nonterminal symbol에 underscore를 앞에 붙인 parameter name의 모든 조합을 덧붙여 정의하는 production 집합에 대한 shorthand입니다. 이는 다음을 의미합니다:
right-hand side nonterminal reference에서 parameter name 앞에 “?”를 붙이면, 그 parameter value는 현재 production의 left-hand side symbol에 대한 reference에서 parameter name이 occurrence하는지에 따라 달라집니다. 예를 들어:
right-hand side alternative 앞에 “[+parameter]”가 붙으면, 그 alternative는 production의 nonterminal symbol을 참조할 때 named parameter가 사용된 경우에만 available합니다. right-hand side alternative 앞에 “[~parameter]”가 붙으면, 그 alternative는 production의 nonterminal symbol을 참조할 때 named parameter가 사용되지 않은 경우에만 available합니다. 이는 다음을 의미합니다:
grammar definition에서 colon(s) 뒤에 “one of”라는 단어가 오면, 이는 다음 line 또는 lines의 각 terminal symbol이 alternative definition임을 의미합니다. 예를 들어 ECMAScript의 lexical grammar에는 다음 production이 포함됩니다:
production의 right-hand side에 “[empty]”라는 phrase가 나타나면, 이는 그 production의 right-hand side가 terminal이나 nonterminal을 포함하지 않음을 나타냅니다.
5.1.5.7 Lookahead Restrictions
production의 right-hand side에 “[lookahead = seq]”라는 phrase가 나타나면, 이는 immediately following input token sequence의 prefix가 token sequence seq인 경우에만 그 production을 사용할 수 있음을 나타냅니다. 마찬가지로 “[lookahead ∈ set]”에서 set이 token sequence의 finite non-empty set이면, immediately following token sequence의 prefix가 set의 어떤 element인 경우에만 그 production을 사용할 수 있음을 나타냅니다. 편의를 위해 set은 nonterminal로도 쓸 수 있으며, 이 경우 그 nonterminal이 expand될 수 있는 모든 token sequence의 집합을 나타냅니다. nonterminal이 무한히 많은 distinct token sequence로 expand될 수 있으면 이는 editorial error로 간주됩니다.
이러한 condition은 negated될 수 있습니다. “[lookahead ≠ seq]”는 containing production이 seq가 immediately following input token sequence의 prefix가 아닌 경우에만 사용될 수 있음을 나타내며, “[lookahead ∉ set]”는 immediately following token sequence의 prefix가 set의 어떤 element도 아닌 경우에만 production을 사용할 수 있음을 나타냅니다.
letter n 뒤에 하나 이상의 decimal digit가 오며 그 첫 번째가 even인 경우, 또는 다른 decimal digit가 뒤따르지 않는 decimal digit 중 하나와 match합니다.
이 phrase들이 syntactic grammar에서 사용될 때는, 이후 token을 결정하려면 이후 위치에서 어떤 lexical goal symbol을 사용할지 알아야 하기 때문에 immediately following token sequence를 unambiguously identify할 수 없을 수도 있습니다. 따라서 syntactic grammar에서 이것들이 사용될 때, lexical goal symbol 선택이 resulting token sequence의 prefix가 seq인지 여부를 바꿀 수 있다면 token sequence seq가 lookahead restriction에(시퀀스 집합의 일부로 포함되는 경우도 포함) 나타나는 것은 editorial error로 간주됩니다.
syntactic grammar의 production의 right-hand side에 “[no LineTerminator here]”라는 phrase가 나타나면, 이는 그 production이 restricted production임을 나타냅니다. 즉 indicated position의 input stream에 LineTerminator가 occurrence하면 사용할 수 없습니다. 예를 들어 production:
은 script에서 throw token과 Expression 사이에 LineTerminator가 occurrence하면 그 production을 사용할 수 없음을 나타냅니다.
LineTerminator의 존재가 restricted production에 의해 forbidden되지 않는 한, LineTerminator는 input element의 stream에서 연속된 두 token 사이에 임의의 횟수로 나타날 수 있으며 script의 syntactic acceptability에 영향을 주지 않습니다.
5.1.5.9 but not
production의 right-hand side는 “but not”이라는 phrase를 사용한 다음 excluded될 expansion을 표시하여 특정 expansion이 허용되지 않음을 명시할 수 있습니다. 예를 들어 production:
은 nonterminal Identifier가 IdentifierName을 replace할 수 있는 어떤 code point sequence로도 replace될 수 있되, 같은 code point sequence가 ReservedWord를 replace할 수 없는 경우에 한한다는 의미입니다.
5.1.5.10 Descriptive Phrases
마지막으로, 모든 alternative를 나열하는 것이 비실용적인 경우에는 몇몇 nonterminal symbol이 sans-serif type의 descriptive phrase로 설명됩니다:
이 명세는 algorithm의 step을 명시하기 위해 numbered list를 자주 사용합니다. 이러한 algorithm은 ECMAScript language construct의 요구되는 semantics를 정밀하게 명시하는 데 사용됩니다. algorithm은 특정 implementation technique의 사용을 함의하도록 의도되지 않습니다. 실제로 주어진 feature를 구현하는 데 더 효율적인 algorithm이 있을 수 있습니다.
algorithm은 algorithm step 안에서 해당 위치에 전달된 argument를 참조하는 데 사용할 수 있는 alias name의 ordered, comma-separated sequence로 명시적으로 parameterized될 수 있습니다. optional parameter는 surrounding brackets([ , name ])로 표시되며 algorithm step 안에서는 required parameter와 다르지 않습니다. rest parameter는 parameter list의 끝에 나타날 수 있으며, leading ellipsis(, ...name)로 표시됩니다. rest parameter는 required 및 optional parameter 뒤에 제공된 모든 argument를 List로 capture합니다. 그러한 additional argument가 없으면 그 List는 empty입니다.
algorithm step은 sequential substep으로 세분될 수 있습니다. substep은 indented되며 그 자체가 다시 indented substep으로 더 나뉠 수 있습니다. outline numbering convention은 substep을 식별하는 데 사용되며, 첫 번째 수준의 substep은 lowercase alphabetic character로, 두 번째 수준의 substep은 lowercase roman numeral로 labelled됩니다. 세 수준보다 더 많은 수준이 필요하면 이 규칙이 반복되며 네 번째 수준은 numeric label을 사용합니다. 예를 들어:
Top-level step
Substep.
Substep.
Subsubstep.
Subsubsubstep
Subsubsubsubstep
Subsubsubsubsubstep
step 또는 substep은 그 substep을 condition하는 “if” predicate로 작성될 수 있습니다. 이 경우 substep은 predicate가 true일 때만 적용됩니다. step 또는 substep이 “else”라는 단어로 시작하면, 이는 같은 level의 preceding “if” predicate step의 negation인 predicate입니다.
step은 그 substep의 iterative application을 명시하기 위해 “For each” 또는 “Repeat”로 시작할 수 있습니다.
“Assert:”로 시작하는 step은 algorithm의 invariant condition을 assertion합니다. 이러한 assertion은 그렇지 않으면 암시적일 algorithmic invariant를 명시적으로 만들기 위해 사용됩니다. 마찬가지로 “NOTE:”로 시작하는 step은 nearby step에 관련된 context를 제공합니다. Assertion step과 note step은 strictly informative입니다. 이는 추가 semantic requirement를 더하지 않으므로 implementation이 check할 필요가 없습니다.
algorithm step은 “Let x be someValue” 형식을 사용하여 어떤 value에 대해서도 named alias를 선언할 수 있습니다. 이러한 alias는 x와 someValue 모두 같은 underlying data를 참조하고 어느 쪽에 대한 modification도 양쪽에 보인다는 점에서 reference-like입니다. 이 reference-like behaviour를 피하고자 하는 algorithm step은 right-hand side의 copy를 명시적으로 만들어야 합니다. “Let x be a copy of someValue”는 someValue의 shallow copy를 만듭니다.
일단 선언되면, alias는 이후의 어떤 step에서도 참조될 수 있으며 alias의 declaration 이전 step에서 참조되어서는 안 됩니다. alias는 “Set x to someOtherValue” 형식을 사용하여 수정될 수 있습니다.
5.2.1 Evaluation Order
complex expression이 algorithm step에 나타날 때, 이는 left-to-right, inside-to-outside order로 evaluated되는 것으로 이해해야 합니다. 예를 들어 step
Return A(B(), C.[[D]]) + E(F()).
은 다음과 equivalent합니다
Let tmp1 be B().
Let tmp2 be C.[[D]].
Let tmp3 be A(tmp1, tmp2).
Let tmp4 be F().
Let tmp5 be E(tmp4).
Let tmp6 be tmp3 + tmp5.
Return tmp6.
여기서 여러 tmpN alias는 ephemeral하며 이 step들 안에서만 visible합니다.
5.2.2 Abstract Operations
이 명세의 여러 부분에서 사용하기 쉽도록, abstract operations라고 하는 일부 algorithm은 이름을 가지며 parameterized functional form으로 작성되어 다른 algorithm 안에서 이름으로 참조될 수 있습니다. abstract operation은 보통 OperationName(arg1, arg2)와 같은 functional application style을 사용하여 참조됩니다. 일부 abstract operation은 class-like specification abstraction의 polymorphically dispatched method로 취급됩니다. 그러한 method-like abstract operation은 보통 someValue.OperationName(arg1, arg2)와 같은 method application style을 사용하여 참조됩니다.
5.2.3 Syntax-Directed Operations
syntax-directed operation은 named operation이며, 그 정의는 algorithm들로 구성되고, 각 algorithm은 ECMAScript grammar 중 하나의 하나 이상의 production과 associated됩니다. 여러 alternative definition을 가진 production은 보통 각 alternative마다 distinct algorithm을 가집니다. algorithm이 grammar production과 associated될 때, 이는 production alternative의 terminal 및 nonterminal symbol을 algorithm의 parameter인 것처럼 참조할 수 있습니다. 이런 방식으로 사용될 때 nonterminal symbol은 source text를 parsing할 때 match되는 실제 alternative definition을 참조합니다. grammar production 또는 그로부터 derived된 Parse Node가 matched by한 source text는 match에 참여한 첫 번째 terminal의 시작에서 시작하여 match에 참여한 마지막 terminal의 끝에서 끝나는 source text 부분입니다.
algorithm이 production alternative와 associated될 때, alternative는 보통 “[ ]” grammar annotation 없이 표시됩니다. 그러한 annotation은 alternative의 syntactic recognition에만 영향을 주어야 하며 alternative에 associated된 semantics에는 영향을 주지 않아야 합니다.
Syntax-directed operation은 다음 algorithm의 steps 1, 3, 그리고 4에 있는 convention을 사용하여 parse node와, 선택적으로, 다른 parameter와 함께 invoked됩니다:
Let status be SyntaxDirectedOperation of SomeNonTerminal.
Let someParseNode be the parse of some source text.
Perform SyntaxDirectedOperation of someParseNode.
Perform SyntaxDirectedOperation of someParseNode with argument "value".
명시적으로 달리 specified되지 않는 한, 모든 chain production은 그 production의 left-hand side nonterminal에 적용될 수 있는 모든 operation에 대해 implicit definition을 가집니다. implicit definition은 같은 operation을 같은 parameter가 있으면 그대로, chain production의 sole right-hand side nonterminal에 다시 적용하고 그 결과를 반환합니다. 예를 들어 어떤 algorithm에 “Return Evaluation of Block” 형식의 step이 있고 다음 production이 있다고 가정합니다:
runtime에 호출되어야 하는 semantics를 명시하는 algorithm은 runtime semantics라고 합니다. Runtime semantics는 abstract operation 또는 syntax-directed operation에 의해 정의됩니다.
5.2.4.1 Completion ( completionRecord )
The abstract operation Completion takes argument completionRecord (a Completion Record) and returns a Completion Record. Completion Record가 반환되고 있음을 강조하는 데 사용됩니다. It performs the following steps when called:
Completion Record를 반환하도록 declared된 abstract operation 안의 algorithm과 모든 built-in function 안에서는, 반환된 value가 먼저 NormalCompletion에 전달되고 그 결과가 대신 사용됩니다. 이 rule은 Completion algorithm 안이나 반환되는 value가 그 step에서 명확하게 Completion Record로 표시된 경우에는 적용되지 않습니다. 이러한 경우는 다음과 같습니다:
? shorthand expansion을 통해, 다음 예는 허용된다는 점에 유의하십시오. expanded step 안에서 abrupt case에는 Completion을 적용한 결과가 직접 반환되고, normal case에는 unwrapping 후 implicit NormalCompletion application이 발생하기 때문입니다.
Return ? completion.
다음 예는 Completion Record가 그 step에서 annotated되지 않은 채 반환되므로 editorial error입니다.
Context-free grammar는 input element의 stream이 evaluated될 수 있는 유효한 ECMAScript Script 또는 Module을 형성하는지 정의하는 모든 rule을 표현할 만큼 충분히 강력하지 않습니다. 어떤 상황에서는 ECMAScript algorithm convention 또는 prose requirement를 사용하여 표현될 수 있는 additional rule이 필요합니다. 그러한 rule은 항상 grammar의 production과 associated되며 production의 static semantics라고 불립니다.
Static Semantic Rule은 name을 가지며 보통 algorithm을 사용하여 정의됩니다. Named Static Semantic Rule은 grammar production과 associated되며, 여러 alternative definition을 가진 production은 보통 각 applicable named static semantic rule에 대해 각 alternative마다 distinct algorithm을 가집니다.
특별한 종류의 static semantic rule은 Early Error Rule입니다. Early error rule은 특정 grammar production과 associated된 early error condition을 정의합니다(절 17 참조). 대부분의 early error rule의 evaluation은 이 명세의 algorithm 안에서 명시적으로 invoked되지 않습니다. conforming implementation은 Script 또는 Module의 첫 evaluation 이전에, 해당 Script 또는 Module을 parse하는 데 사용된 production의 모든 early error rule을 validate해야 합니다. early error rule 중 하나라도 위반되면 Script 또는 Module은 invalid이며 evaluated될 수 없습니다.
5.2.6 Mathematical Operations
이 명세는 다음 종류의 numeric value를 참조합니다:
Mathematical values: 기본 numeric type으로 사용되는 arbitrary real number.
이 명세의 언어에서 numerical value는 subscript suffix를 사용하여 서로 다른 numeric kind 사이에서 구분됩니다. subscript 𝔽는 Number를 가리키고, subscript ℤ는 BigInt를 가리킵니다. subscript suffix가 없는 numeric value는 mathematical value를 가리킵니다. 이 명세는 대부분의 numeric value를 base 10으로 나타내며, 0x 뒤에 digit 0-9 또는 A-F가 오는 형식의 numeric value도 base-16 value로 사용합니다.
일반적으로 이 명세가 “the length of y” 또는 “the integer represented by the four hexadecimal digits ...”와 같은 phrase에서 numeric kind를 명시적으로 지정하지 않고 numerical value를 참조하면, 그 phrase는 mathematical value를 가리킵니다. Number 또는 BigInt value를 가리키는 phrase는 명시적으로 그렇게 annotated됩니다. 예를 들어 “the Number value for the number of code points in …” 또는 “the BigInt value for …”와 같습니다.
+, ×, =, ≥와 같은 numeric operator는 operand의 type에 따라 결정되는 operation을 가리킵니다. mathematical value에 적용될 때, operator는 일반적인 mathematical operation을 가리킵니다. extended mathematical value에 적용될 때, operator는 extended real number에 대한 일반적인 mathematical operation을 가리킵니다. indeterminate form은 정의되지 않으며, 이 명세에서 그 사용은 editorial error로 간주되어야 합니다. Number에 적용될 때, operator는 IEEE 754-2019 안의 관련 operation을 가리킵니다. BigInt에 적용될 때, operator는 BigInt의 mathematical value에 적용되는 일반적인 mathematical operation을 가리킵니다. mixed-type operand(예: Number와 mathematical value)에 적용된 numeric operator는 정의되지 않으며 이 명세에서 editorial error로 간주되어야 합니다.
mathematical function abs(x)는 x의 absolute value를 생성하며, 이는 x < 0이면 -x, 그렇지 않으면 x 자체입니다.
mathematical function ln(x)는 x의 natural logarithm을 생성합니다. mathematical function log10(x)는 x의 base 10 logarithm을 생성합니다. mathematical function log2(x)는 x의 base 2 logarithm을 생성합니다.
mathematical function min(x1, x2, … , xN)는 x1부터 xN까지 중 mathematically smallest인 것을 생성합니다. mathematical function max(x1, x2, ..., xN)는 x1부터 xN까지 중 mathematically largest인 것을 생성합니다. 이러한 mathematical function의 domain과 range는 extended mathematical value입니다.
notation “x modulo y”(y는 finite이고 non-zero여야 함)은 abs(k) < abs(y) 그리고 x - k = q × y가 어떤 integerq에 대해 성립하도록, y와 같은 sign(또는 zero)을 가진 값 k를 계산합니다.
phrase “the result of clamping x between lower and upper”(x는 extended mathematical value이고 lower와 upper는 lower ≤ upper인 mathematical value)는 x < lower이면 lower를 생성하고, x > upper이면 upper를 생성하며, 그렇지 않으면 x를 생성합니다.
mathematical function floor(x)는 x보다 크지 않은 가장 큰 integer(+∞에 가장 가까운)를 생성합니다.
mathematical function truncate(x)는 x를 zero 쪽으로 rounding하여 fractional part를 제거하며, x < 0이면 -floor(-x)를 생성하고 그렇지 않으면 floor(x)를 생성합니다.
mathematical function min, max, abs, floor, truncate는 Number와 BigInt에 대해 정의되지 않으며, non-mathematical value argument를 가진 이러한 method의 어떤 사용도 이 명세에서 editorial error가 됩니다.
lower bound a에서 upper bound b까지의 interval은 같은 numeric type의 numeric value로 이루어진 possibly-infinite, possibly-empty set입니다. 각 bound는 inclusive 또는 exclusive 중 하나로 설명되며 둘 다일 수는 없습니다. interval에는 다음 네 종류가 있습니다:
a(inclusive)에서 b(inclusive)까지의 interval, 또한 a에서 b까지의 inclusive interval이라고도 하며, a ≤ x ≤ b인 같은 numeric type의 모든 value x를 포함하고 그 외에는 포함하지 않습니다.
a(inclusive)에서 b(exclusive)까지의 interval은 a ≤ x < b인 같은 numeric type의 모든 value x를 포함하고 그 외에는 포함하지 않습니다.
a(exclusive)에서 b(inclusive)까지의 interval은 a < x ≤ b인 같은 numeric type의 모든 value x를 포함하고 그 외에는 포함하지 않습니다.
a(exclusive)에서 b(exclusive)까지의 interval은 a < x < b인 같은 numeric type의 모든 value x를 포함하고 그 외에는 포함하지 않습니다.
예를 들어 1(inclusive)에서 2(exclusive)까지의 interval은 1과 2 사이의 모든 mathematical value로 구성되며, 1을 포함하고 2를 포함하지 않습니다. interval을 정의하는 목적상, -0𝔽 < +0𝔽입니다. 따라서 예를 들어 lower bound가 +0𝔽인 inclusive interval은 +0𝔽를 포함하지만 -0𝔽는 포함하지 않습니다. NaN은 interval에 결코 포함되지 않습니다.
이 명세에서는 specification value와 ECMAScript language value 모두가 equality를 위해 비교됩니다. equality를 비교할 때 value는 두 category 중 하나에 속합니다. Values without identity는 integer의 magnitude나 sequence의 length와 같은 모든 innate characteristic이 같으면 다른 value without identity와 equal합니다. value without identity는 그 characteristic을 완전히 설명함으로써 prior reference 없이 manifest될 수 있습니다. 반대로 각 value with identity는 unique하므로 자기 자신과만 equal합니다. value with identity는 value without identity와 비슷하지만 identity라고 하는 추가적인 unguessable, unchangeable, universally-unique characteristic을 가집니다. identity 자체는 indescribable이므로 existing value with identity에 대한 reference는 단순히 설명함으로써 manifest될 수 없습니다. 대신 이러한 value에 대한 reference는 한 곳에서 다른 곳으로 명시적으로 전달되어야 합니다. 일부 value with identity는 mutable하므로 그 characteristic(identity 제외)을 in-place로 변경할 수 있으며, 그 value를 보유한 모든 이는 새로운 characteristic을 observe하게 됩니다. value without identity는 value with identity와 결코 equal하지 않습니다.
이 명세의 관점에서, “is”라는 단어는 “If bool is true, then ...”에서처럼 두 value를 equality로 비교하는 데 사용되고, “contains”라는 단어는 “If list contains a Recordr such that r.[[Foo]] is true, then ...”에서처럼 equality comparison을 사용하여 list 안에서 value를 search하는 데 사용됩니다. value의 specification identity는 이러한 comparison의 결과를 결정하며 이 명세에서 axiomatic입니다.
ECMAScript 언어의 관점에서, language value는 SameValue abstract operation과 그것이 transitively 호출하는 abstract operation을 사용하여 equality로 비교됩니다. 이러한 comparison abstract operation의 algorithm은 ECMAScript language value의 language identity를 결정합니다.
이 명세 안의 알고리즘은 각각 associated type을 가진 값을 조작합니다. 가능한 값 타입은 정확히 이 절에서 정의된 것들입니다. 타입은 다시 ECMAScript language type과 specification type으로 분류됩니다.
6.1 ECMAScript Language Types
ECMAScript language type은 ECMAScript 프로그래머가 ECMAScript 언어를 사용하여 직접 조작하는 값에 대응합니다. ECMAScript language type은 Undefined, Null, Boolean, String, Symbol, Number, BigInt, Object입니다. ECMAScript language value는 ECMAScript language type으로 특징지어지는 값입니다.
6.1.1 Undefined Type
Undefined type은 정확히 하나의 값을 가지며, 이를 undefined라고 합니다. 값이 할당되지 않은 모든 variable은 undefined 값을 가집니다.
6.1.2 Null Type
Null type은 정확히 하나의 값을 가지며, 이를 null이라고 합니다.
6.1.3 Boolean Type
Boolean type은 true와 false라고 불리는 두 값을 가진 logical entity를 나타냅니다.
6.1.4 String Type
String type은 0개 이상의 16-bit unsigned integer value(“elements”)의 ordered sequence 전체의 집합이며, 최대 길이는 253 - 1 elements입니다. String type은 일반적으로 실행 중인 ECMAScript 프로그램에서 textual data를 나타내는 데 사용되며, 이 경우 String 안의 각 element는 UTF-16 code unit value로 취급됩니다. 각 element는 sequence 안의 한 position을 차지하는 것으로 간주됩니다. 이러한 position은 non-negative integer로 indexed됩니다. 첫 번째 element가 있으면 index 0에 있고, 다음 element가 있으면 index 1에 있으며, 이런 식으로 계속됩니다. String의 length는 그 안의 element 수(즉, 16-bit value의 수)입니다. empty String은 length가 zero이므로 element를 포함하지 않습니다.
String contents를 interpret하지 않는 ECMAScript operation은 추가 semantics를 적용하지 않습니다. String value를 interpret하는 operation은 각 element를 단일 UTF-16 code unit으로 취급합니다. 그러나 ECMAScript는 이러한 code unit의 값이나 관계에 제한이나 요구사항을 두지 않으므로, String contents를 UTF-16으로 encoded된 Unicode code point의 sequence로 추가 interpret하는 operation은 ill-formed subsequence를 고려해야 합니다. 이러한 operation은 numeric value가 0xD800부터 0xDBFF까지의 inclusive interval에 있는 모든 code unit(Unicode Standard에서 leading surrogate, 더 형식적으로는 high-surrogate code unit으로 정의됨)과 numeric value가 0xDC00부터 0xDFFF까지의 inclusive interval에 있는 모든 code unit(trailing surrogate, 더 형식적으로는 low-surrogate code unit으로 정의됨)에 대해 다음 규칙을 사용하여 특별한 처리를 적용합니다:
두 code unit의 sequence에서 첫 번째 code unit c1이 leading surrogate이고 두 번째 code unit c2가 trailing surrogate이면, 이는 surrogate pair이며 값 (c1 - 0xD800) × 0x400 + (c2 - 0xDC00) + 0x10000을 가진 code point로 interpret됩니다. (11.1.3 참조)
String.prototype.normalize 함수(22.1.3.15 참조)는 String value를 명시적으로 normalize하는 데 사용할 수 있습니다. String.prototype.localeCompare(22.1.3.12 참조)는 내부적으로 String value를 normalize하지만, 다른 operation은 자신이 동작하는 string을 implicitly normalize하지 않습니다. 달리 stated되지 않는 한 operation 결과는 language- 및/또는 locale-sensitive하지 않습니다.
Note
이 설계의 rationale은 String 구현을 가능한 한 simple하고 high-performing하게 유지하기 위한 것이었습니다. ECMAScript source text가 Normalized Form C이면, string literal은 Unicode escape sequence를 포함하지 않는 한 normalized되어 있음이 보장됩니다.
이 명세에서 “A, B, ...의 string-concatenation”이라는 phrase(각 argument가 String value, code unit, 또는 code unit sequence인 경우)는 각 argument의 code unit을 (순서대로) concatenation한 code unit sequence를 가진 String value를 나타냅니다.
“inclusiveStart부터 exclusiveEnd까지의 string의 substring”이라는 phrase(string이 String value 또는 code unit sequence이고 inclusiveStart와 exclusiveEnd가 integer인 경우)는 string의 index inclusiveStart에서 시작하여 index exclusiveEnd 바로 앞에서 끝나는 consecutive code unit으로 구성된 String value를 나타냅니다(inclusiveStart = exclusiveEnd인 경우 empty String). "to" suffix가 생략되면 string의 length가 exclusiveEnd 값으로 사용됩니다.
“ASCII word characters”라는 phrase는 Unicode Basic Latin block의 모든 letter와 number 및 U+005F(LOW LINE)만으로 구성된 다음 String value를 나타냅니다: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_".
역사적 이유로, 이는 여러 algorithm에서 의미를 가집니다.
The abstract operation StringIndexOf takes arguments string (a String), searchValue (a String), and fromIndex (a non-negative integer) and returns a non-negative integer or not-found. It performs the following steps when called:
fromIndex ≤ i ≤ length - searchLength인 각 integeri에 대해, ascending order로, 다음을 수행한다.
candidate를 string의 i부터 i + searchLength까지의 substring으로 둔다.
candidate가 searchValue이면, i를 반환한다.
not-found를 반환한다.
Note 1
searchValue가 empty String이고 fromIndex ≤ string의 length이면, 이 알고리즘은 fromIndex를 반환합니다. empty String은 string 안의 모든 position에서, 마지막 code unit 뒤를 포함하여, 사실상 found됩니다.
Note 2
fromIndex + searchValue의 length > string의 length이면, 이 알고리즘은 항상 not-found를 반환합니다.
The abstract operation StringLastIndexOf takes arguments string (a String), searchValue (a String), and fromIndex (a non-negative integer) and returns a non-negative integer or not-found. It performs the following steps when called:
0 ≤ i ≤ fromIndex인 각 integeri에 대해, descending order로, 다음을 수행한다.
candidate를 string의 i부터 i + searchLength까지의 substring으로 둔다.
candidate가 searchValue이면, i를 반환한다.
not-found를 반환한다.
Note
searchValue가 empty String이면, 이 알고리즘은 fromIndex를 반환합니다. empty String은 string 안의 모든 position에서, 마지막 code unit 뒤를 포함하여, 사실상 found됩니다.
6.1.5 Symbol Type
Symbol type은 Object property의 key로 사용할 수 있는 모든 non-String value의 집합입니다(6.1.7).
각 Symbol은 unique하고 immutable합니다.
각 Symbol은 값이 String 또는 undefined인 immutable [[Description]] internal slot을 가집니다.
6.1.5.1 Well-Known Symbols
Well-known symbol은 이 명세의 algorithm에서 명시적으로 참조되는 built-in Symbol value입니다. 보통 specification algorithm의 extension point 역할을 하는 value를 가진 property의 key로 사용됩니다. 달리 specified되지 않는 한, well-known symbol value는 모든 realm이 공유합니다(9.3).
이 명세의 이전 판들은 @@name 형식의 notation을 사용했으며, 현재 판에서는 %Symbol.name%을 사용합니다. 특히 다음 이름들이 사용되었습니다: @@asyncIterator, @@hasInstance, @@isConcatSpreadable, @@iterator, @@match, @@matchAll, @@replace, @@search, @@species, @@split, @@toPrimitive, @@toStringTag, and @@unscopables.
Table 1: 잘 알려진 심벌
명세 이름
[[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 연산자의 의미론에 의해 호출된다.
자체 및 상속된 속성 이름이 연결된 객체의 with 환경 바인딩에서 제외되는 속성 이름인 객체 값 속성.
6.1.6 Numeric Types
ECMAScript에는 두 built-in numeric type이 있습니다: Number와 BigInt. 다음 abstract operation은 이러한 numeric type 위에서 정의됩니다. “Result” column은 return type을 보여주며, operation의 일부 invocation이 abrupt completion을 반환할 수 있는지도 함께 나타냅니다.
numeric type은 일반적으로 precision loss 또는 truncation 없이 convert될 수 없으므로, ECMAScript 언어는 이러한 type 사이의 implicit conversion을 제공하지 않습니다. 다른 type을 요구하는 function을 호출할 때 type 간 convert를 하려면, 프로그래머는 Number와 BigInt function을 명시적으로 호출해야 합니다.
Note
ECMAScript의 초판과 이후 판들은 특정 operator에 대해 precision을 잃거나 truncate될 수 있는 implicit numeric conversion을 제공해 왔습니다. 이러한 legacy implicit conversion은 backward compatibility를 위해 유지되지만, programmer error의 가능성을 최소화하고 향후 판에서 generalized value types의 선택지를 열어두기 위해 BigInt에는 제공되지 않습니다.
6.1.6.1 Number Type
Number type은 정확히 18,437,736,874,454,810,627개(즉, 264 - 253 + 3)의 값을 가지며, IEEE Standard for Binary Floating-Point Arithmetic에 명시된 double-precision floating point IEEE 754-2019 binary64 값을 나타냅니다. 다만 IEEE Standard의 9,007,199,254,740,990개(즉, 253 - 2) distinct NaN 값은 ECMAScript에서 하나의 special NaN value로 표현됩니다. (주의: NaN value는 program expression NaN에 의해 생성됩니다.) 일부 implementation에서는 external code가 여러 NaN value 사이의 차이를 detect할 수 있을 수 있지만, 그러한 behaviour는 implementation-defined입니다. ECMAScript code에서는 모든 NaN value가 서로 indistinguishable합니다.
Note
Number value가 ArrayBuffer(25.1 참조) 또는 SharedArrayBuffer(25.2 참조)에 저장된 뒤 관찰될 수 있는 bit pattern은 ECMAScript implementation이 사용하는 그 Number value의 internal representation과 반드시 같지는 않습니다.
positive Infinity와 negative Infinity라고 불리는 두 special value가 더 있습니다. 간결함을 위해, 이 값들은 설명 목적상 각각 +∞𝔽와 -∞𝔽 symbol로도 지칭됩니다. (주의: 이 두 infinite Number value는 program expression +Infinity(또는 간단히 Infinity)와 -Infinity에 의해 생성됩니다.)
다른 18,437,736,874,454,810,624개(즉, 264 - 253)의 값은 finite number라고 불립니다. 이 중 절반은 positive number이고 절반은 negative number입니다. 모든 finite positive Number value에 대해 같은 magnitude를 가진 대응하는 negative value가 있습니다.
positive zero와 negative zero가 모두 있다는 점에 유의하십시오. 간결함을 위해, 이 값들은 설명 목적상 각각 +0𝔽와 -0𝔽 symbol로도 지칭됩니다. (주의: 이 두 다른 zero Number value는 program expression +0(또는 간단히 0)와 -0에 의해 생성됩니다.)
나머지 9,007,199,254,740,990개(즉, 253 - 2)의 값은 denormalized이며, 다음 형식을 가집니다
s × m × 2e
여기서 s는 1 또는 -1이고, m은 0(exclusive)부터 252(exclusive)까지의 interval에 있는 integer이며, e는 -1074입니다.
magnitude가 253보다 크지 않은 모든 positive 및 negative integer는 Number type에서 representable하다는 점에 유의하십시오. integer 0은 Number type에서 두 representation을 가집니다: +0𝔽와 -0𝔽.
finite number가 non-zero이고 위에 표시된 두 형식 중 하나로 표현하는 데 사용된 integerm이 odd이면, 이는 odd significand를 가집니다. 그렇지 않으면 even significand를 가집니다.
이 명세에서 “x에 대한 Number value for”라는 phrase에서 x가 exact real mathematical quantity(π와 같은 irrational number일 수도 있음)를 나타낼 때, 이는 다음 방식으로 선택된 Number value를 의미합니다. Number type의 모든 finite value의 집합에서 -0𝔽를 제거하고, Number type에서 representable하지 않는 두 additional value, 즉 21024(이는 +1 × 253 × 2971)와 -21024(이는 -1 × 253 × 2971)를 추가한 집합을 고려합니다. 이 집합의 member 중 x에 가장 가까운 값을 선택합니다. 집합의 두 값이 equally close이면, even significand를 가진 것을 선택합니다. 이 목적상 두 extra value 21024와 -21024는 even significand를 가진 것으로 간주됩니다. 마지막으로 21024가 선택되었으면 이를 +∞𝔽로 replace합니다. -21024가 선택되었으면 이를 -∞𝔽로 replace합니다. +0𝔽가 선택되었으면 x < 0인 경우에만 이를 -0𝔽로 replace합니다. 그 밖의 선택된 값은 unchanged로 사용됩니다. 그 결과가 x에 대한 Number value입니다. (이 절차는 IEEE 754-2019 roundTiesToEven mode의 behaviour와 정확히 대응합니다.)
+∞에 대한 Number value는 +∞𝔽이고, -∞에 대한 Number value는 -∞𝔽입니다.
일부 ECMAScript operator는 -231부터 231 - 1까지의 inclusive interval이나 0부터 216 - 1까지의 inclusive interval과 같은 특정 range의 integer만 다룹니다. 이러한 operator는 Number type의 어떤 값이든 accept하지만 먼저 그러한 각 값을 expected range의 integer value로 convert합니다. 7.1의 numeric conversion operation 설명을 참조하십시오.
6.1.6.1.1 Number::unaryMinus ( number )
The abstract operation Number::unaryMinus takes argument number (a Number) and returns a Number. It performs the following steps when called:
number가 NaN이면, NaN을 반환한다.
number의 negation을 반환한다. 즉, 같은 magnitude이지만 opposite sign을 가진 Number를 계산한다.
6.1.6.1.2 Number::bitwiseNOT ( number )
The abstract operation Number::bitwiseNOT takes argument number (a Number) and returns an integral Number. It performs the following steps when called:
oldValue의 bitwise complement를 반환한다. 결과의 mathematical value는 32-bit two's complement bit string으로 정확히 representable하다.
6.1.6.1.3 Number::exponentiate ( base, exponent )
The abstract operation Number::exponentiate takes arguments base (a Number) and exponent (a Number) and returns a Number. base를 exponent power로 올린 결과를 나타내는 implementation-approximated value를 반환합니다. It performs the following steps when called:
base가 1𝔽 또는 -1𝔽이고 exponent가 +∞𝔽 또는 -∞𝔽일 때, 또는 base가 1𝔽이고 exponent가 NaN일 때의 base**exponent 결과는 IEEE 754-2019와 다릅니다. ECMAScript 초판은 이 operation의 결과를 NaN으로 명시했지만, 이후 IEEE 754 개정판은 1𝔽를 명시했습니다. 역사적 ECMAScript behaviour는 compatibility 이유로 보존됩니다.
6.1.6.1.4 Number::multiply ( x, y )
The abstract operation Number::multiply takes arguments x (a Number) and y (a Number) and returns a Number. IEEE 754-2019 binary double-precision arithmetic의 규칙에 따라 multiplication을 수행하여 x와 y의 product를 생성합니다. It performs the following steps when called:
Finite-precision multiplication은 commutative이지만, 항상 associative인 것은 아닙니다.
6.1.6.1.5 Number::divide ( x, y )
The abstract operation Number::divide takes arguments x (a Number) and y (a Number) and returns a Number. IEEE 754-2019 binary double-precision arithmetic의 규칙에 따라 division을 수행하여, x가 dividend이고 y가 divisor인 x와 y의 quotient를 생성합니다. It performs the following steps when called:
The abstract operation Number::remainder takes arguments numerator (a Number) and denominator (a Number) and returns a Number. numerator가 dividend이고 denominator가 divisor인 operand의 implied division에서 remainder를 산출합니다. It performs the following steps when called:
% operator로 계산되는 floating-point remainder operation의 결과는 IEEE 754-2019가 정의하는 “remainder” operation과 같지 않습니다. IEEE 754-2019 “remainder” operation은 truncating division이 아니라 rounding division에서 remainder를 계산하므로, 그 behaviour는 일반적인 integer remainder operator의 behaviour와 analogous하지 않습니다. 대신 ECMAScript 언어는 floating-point operation에서 %가 Java integer remainder operator와 analogous한 방식으로 behave하도록 정의합니다. 이는 C library function fmod와 비교될 수 있습니다.
6.1.6.1.7 Number::add ( x, y )
The abstract operation Number::add takes arguments x (a Number) and y (a Number) and returns a Number. IEEE 754-2019 binary double-precision arithmetic의 규칙에 따라 addition을 수행하여 argument의 sum을 생성합니다. It performs the following steps when called:
Finite-precision addition은 commutative이지만, 항상 associative인 것은 아닙니다.
6.1.6.1.8 Number::subtract ( x, y )
The abstract operation Number::subtract takes arguments x (a Number) and y (a Number) and returns a Number. subtraction을 수행하여 operand의 difference를 생성합니다. x는 minuend이고 y는 subtrahend입니다. It performs the following steps when called:
The abstract operation Number::leftShift takes arguments x (a Number) and y (a Number) and returns an integral Number. It performs the following steps when called:
leftNumber를 shiftCount bit만큼 left shifting한 결과를 반환한다. 결과의 mathematical value는 32-bit two's complement bit string으로 정확히 representable하다.
6.1.6.1.10 Number::signedRightShift ( x, y )
The abstract operation Number::signedRightShift takes arguments x (a Number) and y (a Number) and returns an integral Number. It performs the following steps when called:
leftNumber를 shiftCount bit만큼 sign-extending right shift한 결과를 반환한다. most significant bit가 propagated된다. 결과의 mathematical value는 32-bit two's complement bit string으로 정확히 representable하다.
6.1.6.1.11 Number::unsignedRightShift ( x, y )
The abstract operation Number::unsignedRightShift takes arguments x (a Number) and y (a Number) and returns an integral Number. It performs the following steps when called:
leftNumber를 shiftCount bit만큼 zero-filling right shift한 결과를 반환한다. 비워진 bit는 zero로 채워진다. 결과의 mathematical value는 32-bit unsigned bit string으로 정확히 representable하다.
6.1.6.1.12 Number::lessThan ( x, y )
The abstract operation Number::lessThan takes arguments x (a Number) and y (a Number) and returns a Boolean or undefined. It performs the following steps when called:
The abstract operation Number::equal takes arguments x (a Number) and y (a Number) and returns a Boolean. It performs the following steps when called:
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 )
The abstract operation Number::sameValue takes arguments x (a Number) and y (a Number) and returns a Boolean. It performs the following steps when called:
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 )
The abstract operation Number::sameValueZero takes arguments x (a Number) and y (a Number) and returns a Boolean. It performs the following steps when called:
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 )
The abstract operation NumberBitwiseOp takes arguments op (&, ^, or |), x (a Number), and y (a Number) and returns an integral Number. It performs the following steps when called:
result를 leftBits와 rightBits에 bitwise inclusive OR operation을 적용한 결과로 둔다.
32-bit two's complement bit string result가 나타내는 integer에 대한 Number value를 반환한다.
6.1.6.1.17 Number::bitwiseAND ( x, y )
The abstract operation Number::bitwiseAND takes arguments x (a Number) and y (a Number) and returns an integral Number. It performs the following steps when called:
The abstract operation Number::bitwiseXOR takes arguments x (a Number) and y (a Number) and returns an integral Number. It performs the following steps when called:
The abstract operation Number::bitwiseOR takes arguments x (a Number) and y (a Number) and returns an integral Number. It performs the following steps when called:
The abstract operation Number::toString takes arguments x (a Number) and radix (an integer in the inclusive interval from 2 to 36) and returns a String. radix를 radix로 하는 positional numeral system을 사용하여 x를 String으로 나타냅니다. radix r을 사용한 number representation에서 사용되는 digit은 "0123456789abcdefghijklmnopqrstuvwxyz"의 처음 r code unit에서 순서대로 가져옵니다. magnitude가 1𝔽 이상인 number의 representation은 leading zero를 결코 포함하지 않습니다. It performs the following steps when called:
n, k, s를 다음을 만족하는 integer로 둔다: k ≥ 1, radixk - 1 ≤ s < radixk, 𝔽(s × radixn - k)가 x이고, k는 가능한 한 작다. k는 radix radix를 사용한 s의 representation에서 digit 수이고, s는 radix로 divisible하지 않으며, s의 least significant digit은 이러한 criteria에 의해 반드시 uniquely determined되는 것은 아니라는 점에 유의한다.
s의 least significant digit은 step 5에 나열된 requirements에 의해 항상 uniquely determined되는 것은 아닙니다.
Note 2
위 규칙이 요구하는 것보다 더 정확한 conversion을 제공하는 implementation의 경우, step 5의 다음 alternative version을 guideline으로 사용할 것을 권장합니다:
n, k, s를 다음을 만족하는 integer로 둔다: k ≥ 1, radixk - 1 ≤ s < radixk, 𝔽(s × radixn - k)가 x이고, k는 가능한 한 작다. s에 대해 여러 가능성이 있으면, s × radixn - k가 ℝ(x)에 가장 가까운 s를 선택한다. 그러한 가능한 s 값이 두 개 있으면, even인 것을 선택한다. k는 radix radix를 사용한 s의 representation에서 digit 수이며 s는 radix로 divisible하지 않는다는 점에 유의한다.
Note 3
ECMAScript implementer는 floating-point number의 binary-to-decimal conversion에 대해 David M. Gay가 작성한 논문과 code가 유용할 수 있습니다:
BigInt type은 integer value를 나타냅니다. 값은 어떤 size도 될 수 있으며 특정 bit-width로 제한되지 않습니다. 일반적으로 달리 noted되지 않은 곳에서 operation은 exact mathematically-based answer를 반환하도록 설계됩니다. binary operation의 경우, BigInt는 two's complement binary string처럼 동작하며, negative number는 왼쪽으로 infinite하게 bit가 set된 것으로 취급됩니다.
6.1.6.2.1 BigInt::unaryMinus ( bigint )
The abstract operation BigInt::unaryMinus takes argument bigint (a BigInt) and returns a BigInt. It performs the following steps when called:
bigint = 0ℤ이면, 0ℤ를 반환한다.
-bigint를 반환한다.
6.1.6.2.2 BigInt::bitwiseNOT ( bigint )
The abstract operation BigInt::bitwiseNOT takes argument bigint (a BigInt) and returns a BigInt. bigint의 one's complement를 반환합니다. It performs the following steps when called:
-bigint - 1ℤ를 반환한다.
6.1.6.2.3 BigInt::exponentiate ( base, exponent )
The abstract operation BigInt::exponentiate takes arguments base (a BigInt) and exponent (a BigInt) and returns either a normal completion containing a BigInt or a throw completion. It performs the following steps when called:
exponent < 0ℤ이면, RangeError exception을 throw한다.
base = 0ℤ이고 exponent = 0ℤ이면, 1ℤ를 반환한다.
base raised to the power exponent를 반환한다.
6.1.6.2.4 BigInt::multiply ( x, y )
The abstract operation BigInt::multiply takes arguments x (a BigInt) and y (a BigInt) and returns a BigInt. It performs the following steps when called:
x × y를 반환한다.
Note
결과가 input보다 훨씬 더 큰 bit width를 가지더라도, exact mathematical answer가 제공됩니다.
6.1.6.2.5 BigInt::divide ( x, y )
The abstract operation BigInt::divide takes arguments x (a BigInt) and y (a BigInt) and returns either a normal completion containing a BigInt or a throw completion. It performs the following steps when called:
The abstract operation BigInt::remainder takes arguments numerator (a BigInt) and denominator (a BigInt) and returns either a normal completion containing a BigInt or a throw completion. It performs the following steps when called:
The abstract operation BigInt::add takes arguments x (a BigInt) and y (a BigInt) and returns a BigInt. It performs the following steps when called:
x + y를 반환한다.
6.1.6.2.8 BigInt::subtract ( x, y )
The abstract operation BigInt::subtract takes arguments x (a BigInt) and y (a BigInt) and returns a BigInt. It performs the following steps when called:
x - y를 반환한다.
6.1.6.2.9 BigInt::leftShift ( x, y )
The abstract operation BigInt::leftShift takes arguments x (a BigInt) and y (a BigInt) and returns a BigInt. It performs the following steps when called:
여기서 semantics는 BigInt를 infinite length string of binary two's complement digit으로 취급하는 bitwise shift와 equivalent해야 합니다.
6.1.6.2.10 BigInt::signedRightShift ( x, y )
The abstract operation BigInt::signedRightShift takes arguments x (a BigInt) and y (a BigInt) and returns a BigInt. It performs the following steps when called:
The abstract operation BigInt::unsignedRightShift takes arguments x (a BigInt) and y (a BigInt) and returns a throw completion. It performs the following steps when called:
TypeError exception을 throw한다.
6.1.6.2.12 BigInt::lessThan ( x, y )
The abstract operation BigInt::lessThan takes arguments x (a BigInt) and y (a BigInt) and returns a Boolean. It performs the following steps when called:
The abstract operation BinaryAnd takes arguments x (0 or 1) and y (0 or 1) and returns 0 or 1. It performs the following steps when called:
x = 1이고 y = 1이면, 1을 반환한다.
0을 반환한다.
6.1.6.2.15 BinaryOr ( x, y )
The abstract operation BinaryOr takes arguments x (0 or 1) and y (0 or 1) and returns 0 or 1. It performs the following steps when called:
x = 1이거나 y = 1이면, 1을 반환한다.
0을 반환한다.
6.1.6.2.16 BinaryXor ( x, y )
The abstract operation BinaryXor takes arguments x (0 or 1) and y (0 or 1) and returns 0 or 1. It performs the following steps when called:
x = 1이고 y = 0이면, 1을 반환한다.
x = 0이고 y = 1이면, 1을 반환한다.
0을 반환한다.
6.1.6.2.17 BigIntBitwiseOp ( op, x, y )
The abstract operation BigIntBitwiseOp takes arguments op (&, ^, or |), x (a BigInt), and y (a BigInt) and returns a BigInt. It performs the following steps when called:
The abstract operation BigInt::bitwiseAND takes arguments x (a BigInt) and y (a BigInt) and returns a BigInt. It performs the following steps when called:
The abstract operation BigInt::bitwiseXOR takes arguments x (a BigInt) and y (a BigInt) and returns a BigInt. It performs the following steps when called:
The abstract operation BigInt::bitwiseOR takes arguments x (a BigInt) and y (a BigInt) and returns a BigInt. It performs the following steps when called:
The abstract operation BigInt::toString takes arguments x (a BigInt) and radix (an integer in the inclusive interval from 2 to 36) and returns a String. radix를 radix로 하는 positional numeral system을 사용하여 x를 String으로 나타냅니다. radix r을 사용한 BigInt representation에서 사용되는 digit은 "0123456789abcdefghijklmnopqrstuvwxyz"의 처음 r code unit에서 순서대로 가져옵니다. 0ℤ 이외의 BigInt representation은 leading zero를 결코 포함하지 않습니다. It performs the following steps when called:
accessor property는 key value를 하나 또는 두 개의 accessor function 및 Boolean attribute의 set과 연관시킵니다. accessor function은 property와 연관된 ECMAScript language value를 store하거나 retrieve하는 데 사용됩니다.
object의 property는 property key를 사용하여 unique하게 식별됩니다. property key는 String 또는 Symbol입니다. empty String을 포함한 모든 String과 Symbol은 property key로 valid합니다. property name은 String인 property key입니다.
Property key는 property와 그 value에 access하는 데 사용됩니다. property에 대한 access에는 두 종류가 있습니다: 각각 value retrieval과 assignment에 대응하는 get과 set입니다. get 및 set access를 통해 accessible한 property에는 object의 직접적인 부분인 own properties와 property inheritance relationship을 통해 다른 associated object가 제공하는 inherited properties가 모두 포함됩니다. Inherited property는 associated object의 own 또는 inherited property일 수 있습니다. object의 각 own property는 그 object의 다른 own property의 key value와 distinct한 key value를 각각 가져야 합니다.
모든 object는 논리적으로 property의 collection이지만, property에 access하고 manipulate하는 semantics가 서로 다른 여러 form의 object가 있습니다. object의 여러 form에 대한 정의는 6.1.7.2를 참조하십시오.
또한 일부 object는 callable합니다. 이러한 object는 function 또는 function object라고 불리며 아래에서 더 자세히 설명됩니다. ECMAScript의 모든 function은 Object type의 member입니다.
6.1.7.1 Property Attributes
Attribute는 Table 3에 설명된 Object property의 state를 정의하고 설명하기 위해 이 명세에서 사용됩니다. 명시적으로 specified되지 않는 한, 각 attribute의 initial value는 그 Default Value입니다.
value가 Object이면 function object여야 합니다. property의 set access가 수행될 때마다, assigned value를 sole argument로 포함하는 arguments list와 함께 function의 [[Call]] internal method(Table 5)가 호출됩니다. property의 [[Set]] internal method의 effect는 subsequent call에서 property의 [[Get]] internal method가 반환하는 value에 effect를 가질 수 있지만, 반드시 그래야 하는 것은 아닙니다.
6.1.7.2 Object Internal Methods and Internal Slots
ECMAScript에서 object의 실제 semantics는 internal methods라고 불리는 algorithm을 통해 specified됩니다. ECMAScript engine의 각 object는 그 runtime behaviour를 정의하는 internal method의 set과 associated됩니다. 이러한 internal method는 ECMAScript language의 일부가 아닙니다. 이들은 순전히 expository purpose를 위해 이 명세에서 정의됩니다. 그러나 ECMAScript implementation 안의 각 object는 자신과 associated된 internal method에 의해 specified된 대로 behave해야 합니다. 이를 달성하는 정확한 방식은 implementation에 의해 결정됩니다.
Internal method name은 polymorphic입니다. 이는 common internal method name이 서로 다른 object value에서 invoked될 때 서로 다른 algorithm을 수행할 수 있음을 의미합니다. internal method가 invoked되는 실제 object는 invocation의 “target”입니다. runtime에 algorithm의 implementation이 object가 support하지 않는 internal method를 사용하려고 하면, TypeError exception이 thrown됩니다.
Internal slot은 object, Symbol 또는 Private Name과 associated되어 다양한 ECMAScript specification algorithm에서 사용되는 internal state에 대응합니다. Internal slot은 object property가 아니며 inherited되지 않습니다. 특정 internal slot specification에 따라, 이러한 state는 어떤 ECMAScript language type의 value나 특정 ECMAScript specification type value로 구성될 수 있습니다. 달리 explicitly specified되지 않는 한, internal slot은 object, Symbol 또는 Private Name을 생성하는 process의 일부로 allocated되며 dynamically added될 수 없습니다. 달리 specified되지 않는 한, internal slot의 initial value는 undefined 값입니다. 이 명세 안의 다양한 algorithm은 internal slot을 가진 value를 생성합니다. 그러나 ECMAScript language는 internal slot을 manipulate하는 직접적인 방법을 제공하지 않습니다.
모든 object는 [[PrivateElements]]라는 internal slot을 가지며, 이는 PrivateElements의 List입니다. 이 List는 object에 대한 private field, method 및 accessor의 value를 나타냅니다. Initially, 이는 empty List입니다.
Internal method와 internal slot은 이 명세 안에서 double square bracket [[ ]]으로 둘러싸인 name을 사용하여 식별됩니다.
Table 4는 ECMAScript code에 의해 생성되거나 manipulated되는 모든 object에 applicable한 이 명세에서 사용되는 essential internal methods를 요약합니다. 모든 object는 모든 essential internal method에 대한 algorithm을 가져야 합니다. 그러나 모든 object가 그 method에 대해 반드시 같은 algorithm을 사용하는 것은 아닙니다.
ordinary object는 다음 criteria를 모두 만족하는 object입니다:
Table 4에 나열된 internal method에 대해, object는 10.1에 정의된 것들을 사용합니다.
object가 [[Call]] internal method를 가지는 경우, 10.2.1에 정의된 것 또는 10.3.1에 정의된 것 중 하나를 사용합니다.
object가 [[Construct]] internal method를 가지는 경우, 10.2.2에 정의된 것 또는 10.3.2에 정의된 것 중 하나를 사용합니다.
Table 4 및 기타 유사한 table의 “Signature” column은 각 internal method의 invocation pattern을 설명합니다. invocation pattern은 항상 descriptive parameter name의 parenthesized list를 포함합니다. parameter name이 ECMAScript type name과 같으면 그 name은 parameter value의 required type을 설명합니다. internal method가 명시적으로 value를 반환하면, parameter list 뒤에 symbol “→”와 returned value의 type name이 옵니다. signature에서 사용되는 type name은 6 절에 정의된 type에 다음 additional name을 보강한 것을 가리킵니다. “any”는 value가 어떤 ECMAScript language type도 될 수 있음을 의미합니다.
parameter 외에도, internal method는 항상 method invocation의 target인 object에 access할 수 있습니다.
이 object에 대해 inherited property를 제공하는 object를 결정합니다. null value는 inherited property가 없음을 나타냅니다.
[[SetPrototypeOf]]
(Object | Null) → Boolean
inherited property를 제공하는 다른 object와 이 object를 associate합니다. null을 passing하는 것은 inherited property가 없음을 나타냅니다. operation이 successfully completed되었음을 나타내는 true 또는 operation이 successful하지 않았음을 나타내는 false를 반환합니다.
[[IsExtensible]]
( ) → Boolean
이 object에 additional property를 add하는 것이 permitted되는지 결정합니다.
[[PreventExtensions]]
( ) → Boolean
new property가 이 object에 added될 수 있는지 control합니다. operation이 successful이면 true를, unsuccessful이면 false를 반환합니다.
key가 propertyKey인 이 object의 own property에 대한 Property Descriptor를 반환하거나, 그러한 property가 없으면 undefined를 반환합니다.
[[DefineOwnProperty]]
(propertyKey, propertyDesc) → Boolean
key가 propertyKey인 own property가 propertyDesc가 설명하는 state를 가지도록 create하거나 alter합니다. 해당 property가 successfully created/updated되었으면 true를 반환하고, property를 create하거나 update할 수 없으면 false를 반환합니다.
[[HasProperty]]
(propertyKey) → Boolean
이 object가 이미 key가 propertyKey인 own 또는 inherited property를 가지고 있는지 나타내는 Boolean value를 반환합니다.
[[Get]]
(propertyKey, receiver) →any
이 object에서 key가 propertyKey인 property의 value를 반환합니다. property value를 retrieve하기 위해 ECMAScript code가 실행되어야 하는 경우, code를 evaluating할 때 receiver가 this value로 사용됩니다.
[[Set]]
(propertyKey, value, receiver) → Boolean
key가 propertyKey인 property의 value를 value로 set합니다. property value를 set하기 위해 ECMAScript code가 실행되어야 하는 경우, code를 evaluating할 때 receiver가 this value로 사용됩니다. property value가 set되었으면 true를, set될 수 없으면 false를 반환합니다.
[[Delete]]
(propertyKey) → Boolean
key가 propertyKey인 own property를 이 object에서 remove합니다. property가 deleted되지 않았고 여전히 present하면 false를 반환합니다. property가 deleted되었거나 present하지 않으면 true를 반환합니다.
Table 5는 function으로 called될 수 있는 object가 support하는 additional essential internal method를 요약합니다. function object는 [[Call]] internal method를 support하는 object입니다. constructor는 [[Construct]] internal method를 support하는 object입니다. [[Construct]]를 support하는 모든 object는 [[Call]]을 support해야 합니다. 즉, 모든 constructor는 function object여야 합니다. 따라서 constructor는 constructor function 또는 constructorfunction object라고도 지칭될 수 있습니다.
Table 5: Additional Essential Internal Methods of Function Objects
이 object와 associated된 code를 executes합니다. function call expression을 통해 invoked됩니다. internal method에 대한 argument는 this value와 call expression에 의해 function에 passed된 argument를 element로 하는 List입니다. 이 internal method를 implement하는 object는 callable입니다.
object를 creates합니다. new operator 또는 super call을 통해 invoked됩니다. internal method의 첫 번째 argument는 constructor invocation 또는 super call의 argument를 element로 하는 List입니다. 두 번째 argument는 new operator가 initially applied된 object입니다. 이 internal method를 implement하는 object는 constructors라고 불립니다. function object가 반드시 constructor인 것은 아니며, 그러한 non-constructorfunction object는 [[Construct]] internal method를 가지지 않습니다.
ordinary object 및 standard exotic object에 대한 essential internal method의 semantics는 10 절에 specified되어 있습니다. exotic object의 internal method의 specified된 사용이 implementation에서 support되지 않는 경우, 해당 usage를 시도할 때 TypeError exception을 throw해야 합니다.
6.1.7.3 Essential Internal Methods의 Invariants
ECMAScript engine의 Object의 Internal Method는 아래에 specified된 invariant list를 conform해야 합니다. Ordinary ECMAScript Object뿐 아니라 이 명세의 모든 standard exotic object도 이러한 invariant를 유지합니다. ECMAScript Proxy object는 [[ProxyHandler]] object에서 invoked된 trap의 result에 대한 runtime check를 통해 이러한 invariant를 유지합니다.
implementation provided exotic object도 해당 object에 대해 이러한 invariant를 유지해야 합니다. 이러한 invariant를 위반하면 ECMAScript code가 unpredictable behaviour를 보일 수 있고 security issue를 만들 수 있습니다. 그러나 이러한 invariant의 위반은 implementation의 memory safety를 결코 compromise해서는 안 됩니다.
implementation은 essential internal method의 functionality를 implement하면서 invariant를 enforce하지 않는 alternative interface를 제공하는 등의 어떠한 방식으로도 이러한 invariant가 circumvent되도록 허용해서는 안 됩니다.
target이 non-extensible이고 [[GetPrototypeOf]]가 value proto를 반환하면, 이후 [[GetPrototypeOf]]에 대한 모든 call은 proto와 SameValue를 반환해야 합니다.
Note 2
object의 prototype chain은 finite length를 가져야 합니다(즉, 어떤 object에서 시작하여 [[GetPrototypeOf]] internal method를 그 result에 recursively applying하면 결국 null value에 도달해야 합니다). 그러나 prototype chain이 [[GetPrototypeOf]]의 ordinary object definition을 사용하지 않는 exotic object를 포함하는 경우, 이 requirement는 object level invariant로 enforce될 수 없습니다. 그러한 circular prototype chain은 object property에 access할 때 infinite loop를 초래할 수 있습니다.
[[SetPrototypeOf]] ( proto )
normal return type은 Boolean입니다.
target이 non-extensible이면, proto가 target의 observed [[GetPrototypeOf]] value와 SameValue가 아닌 한 [[SetPrototypeOf]]는 false를 반환해야 합니다.
[[IsExtensible]] ( )
normal return type은 Boolean입니다.
[[IsExtensible]]가 false를 반환하면, target에 대한 [[IsExtensible]]의 모든 future call은 false를 반환해야 합니다.
[[PreventExtensions]] ( )
normal return type은 Boolean입니다.
[[PreventExtensions]]가 true를 반환하면, target에 대한 [[IsExtensible]]의 모든 future call은 false를 반환해야 하며 target은 이제 non-extensible로 간주됩니다.
propertyKey가 non-configurable, non-writable own data property로 described되면, [[GetOwnProperty]] ( propertyKey )에 대한 모든 future call은 [[Value]]가 propertyKey의 [[Value]] attribute와 SameValue인 Property Descriptor를 반환해야 합니다.
propertyKey의 [[Writable]] 및 [[Value]] 이외의 attribute가 시간이 지나면서 change될 수 있거나, property가 deleted될 수도 있으면, propertyKey의 [[Configurable]] attribute는 true여야 합니다.
target이 non-extensible이고 propertyKey가 non-existent이면, target에 대한 [[GetOwnProperty]] (propertyKey)의 모든 future call은 propertyKey를 non-existent로 describe해야 합니다(즉, [[GetOwnProperty]] (propertyKey)는 undefined를 반환해야 합니다).
Note 3
세 번째 invariant의 consequence로, property가 data property로 described되고 시간이 지나면서 다른 value를 반환할 수 있으면, 다른 essential internal method를 통해 value를 change하는 mechanism이 exposed되지 않더라도 [[Writable]] 및 [[Configurable]] attribute 중 하나 또는 둘 다 true여야 합니다.
propertyKey가 이전에 target의 value value를 가진 non-configurable, non-writable own data property로 observed되었으면, [[Get]]은 value와 SameValue를 반환해야 합니다.
propertyKey가 이전에 [[Get]] attribute가 undefined인 target의 non-configurable own accessor property로 observed되었으면, [[Get]] operation은 undefined를 반환해야 합니다.
[[Set]] ( propertyKey, value, receiver )
normal return type은 Boolean입니다.
propertyKey가 이전에 target의 non-configurable, non-writable own data property로 observed되었으면, value가 propertyKey의 [[Value]] attribute와 SameValue가 아닌 한 [[Set]]은 false를 반환해야 합니다.
propertyKey가 이전에 [[Set]] attribute가 undefined인 target의 non-configurable own accessor property로 observed되었으면, [[Set]] operation은 false를 반환해야 합니다.
[[Delete]] ( propertyKey )
normal return type은 Boolean입니다.
propertyKey가 이전에 target의 non-configurable own data 또는 accessor property로 observed되었으면, [[Delete]]는 false를 반환해야 합니다.
Well-known intrinsic은 이 명세의 algorithm에서 명시적으로 referenced되는 built-in object이며, 보통 realm-specific identity를 가집니다. 달리 specified되지 않는 한 각 intrinsic object는 실제로 realm마다 하나씩, 유사한 object의 set에 대응합니다.
이 명세 안에서 %name% 같은 reference는 current realm과 associated되고 해당 name에 대응하는 intrinsic object를 의미합니다. %name.a.b% 같은 reference는, ECMAScript code가 evaluated되기 전에 intrinsic object %name%의 "a" property value의 "b" property가 accessed된 것처럼 의미합니다. current realm과 그 intrinsic의 determination은 9.4에 설명되어 있습니다. well-known intrinsic은 Table 6에 listed되어 있습니다.
specification type은 ECMAScript language construct와 ECMAScript language type의 semantics를 설명하기 위해 algorithm 안에서 사용되는 meta-value에 대응합니다. specification type에는 Reference Record, List, Completion Record, Property Descriptor, Environment Record, Abstract Closure, Data Block이 포함됩니다. Specification type value는 ECMAScript implementation 안의 특정 entity와 반드시 대응하지는 않는 specification artefact입니다. Specification type value는 ECMAScript expression evaluation의 intermediate result를 설명하는 데 사용될 수 있지만, 그러한 value는 object의 property나 ECMAScript language variable의 value로 저장될 수 없습니다.
6.2.1 Enum Specification Type
Enum은 specification 내부의 value이며 ECMAScript code에서 직접 observable하지 않습니다. Enum은 sans-serif typeface를 사용하여 upper kebab case로 표시됩니다. 예를 들어 Completion Record의 [[Type]] field는 normal, return, throw와 같은 value를 취합니다. Enum은 name 외의 characteristic을 가지지 않습니다. enum의 name은 다른 enum과 구별하는 것 외의 목적을 가지지 않으며, context에서의 usage나 meaning에 대해 아무것도 imply하지 않습니다.
6.2.2 List and Record Specification Types
List type은 new expression, function call, 그리고 simple ordered list of values가 필요한 다른 algorithm에서 argument list(13.3.8 참조)의 evaluation을 설명하는 데 사용됩니다. List type의 value는 individual value를 포함하는 list element의 ordered sequence일 뿐입니다. 이러한 sequence는 어떤 length도 될 수 있습니다. list의 element는 0-origin index를 사용하여 randomly accessed될 수 있습니다. notation 편의를 위해 array-like syntax를 사용하여 List element에 access할 수 있습니다. 예를 들어 args[2]는 List args의 3rd element를 말하는 shorthand입니다.
algorithm이 order를 지정하지 않고 List의 element를 iterate하면, 사용되는 order는 List 안의 element order입니다.
이 명세 안에서 notation 편의를 위해 literal syntax를 사용하여 새 List value를 표현할 수 있습니다. 예를 들어 « 1, 2 »는 각각 특정 value로 initialized된 두 element를 가진 List value를 정의합니다. 새 empty List는 « »로 표현할 수 있습니다.
이 명세에서 “A, B, ...의 list-concatenation”이라는 phrase(각 argument가 possibly empty List인 경우)는 각 argument의 element를 (순서대로) concatenation한 element를 가진 새 List value를 나타냅니다.
List of Strings에 적용될 때, “lexicographic code unit order에 따라 sorted”라는 phrase는 더 짧은 string의 length까지 각 code unit의 numeric value로 sorting하고, 모두 같으면 더 짧은 string을 더 긴 string보다 앞에 sorting함을 의미하며, 이는 abstract operation IsLessThan에 설명되어 있습니다.
Record type은 이 명세의 algorithm 안에서 data aggregation을 설명하는 데 사용됩니다. Record type value는 하나 이상의 named field로 구성됩니다. 각 field의 value는 ECMAScript language value 또는 specification value입니다. field name은 항상 double bracket으로 둘러싸입니다. 예: [[Value]].
이 명세 안에서 notation 편의를 위해 object literal-like syntax를 사용하여 Record value를 표현할 수 있습니다. 예를 들어 { [[Field1]]: 42, [[Field2]]: false, [[Field3]]: empty }는 세 field를 가지며 각각 특정 value로 initialized된 Record value를 정의합니다. Field name order는 중요하지 않습니다. 명시적으로 listed되지 않은 field는 absent인 것으로 간주됩니다.
specification text와 algorithm에서 dot notation은 Record value의 특정 field를 refer하는 데 사용될 수 있습니다. 예를 들어 R이 이전 paragraph에 표시된 record이면 R.[[Field2]]는 “[[Field2]]라는 name을 가진 R의 field”에 대한 shorthand입니다.
일반적으로 사용되는 Record field combination에 대한 schema에는 name이 붙을 수 있으며, 그 name은 literal Record value의 prefix로 사용되어 설명되는 aggregation의 특정 kind를 identify할 수 있습니다. 예: PropertyDescriptor { [[Value]]: 42, [[Writable]]: false, [[Configurable]]: true }.
6.2.3 Set and Relation Specification Types
Set type은 memory model에서 사용하기 위한 unordered element의 collection을 설명하는 데 사용됩니다. 이는 같은 name의 ECMAScript collection type과 distinct합니다. 구별을 위해, 이 명세 안에서 ECMAScript collection의 instance는 일관되게 “Set objects”라고 지칭됩니다. Set type의 value는 simple collection of elements이며, 어떤 element도 한 번보다 많이 나타나지 않습니다. element는 Set에 added되거나 removed될 수 있습니다. Set은 서로 unioned, intersected, subtracted될 수 있습니다.
Relation type은 Set에 대한 constraint를 설명하는 데 사용됩니다. Relation type의 value는 그 value domain에서 온 ordered pair of values의 Set입니다. 예를 들어 Memory event에 대한 Relation은 Memory event의 ordered pair의 set입니다. Relation R과 R의 value domain 안의 두 value a와 b에 대해, aRb는 ordered pair (a, b)가 R의 member임을 말하는 shorthand입니다. 어떤 condition에 관해 least Relation인 Relation은 그 condition을 만족하는 가장 작은 Relation입니다.
strict partial order는 다음을 만족하는 Relation value R입니다.
R의 domain 안의 모든 a, b, c에 대해:
aRa인 경우는 없고,
aRb이고 bRc이면, aRc입니다.
Note 1
위의 두 property는 각각 irreflexivity와 transitivity라고 불립니다.
strict total order는 다음을 만족하는 Relation value R입니다.
R의 domain 안의 모든 a, b, c에 대해:
a가 b이거나 aRb이거나 bRa이고,
aRa인 경우는 없고,
aRb이고 bRc이면, aRc입니다.
Note 2
위의 세 property는 각각 totality, irreflexivity, transitivity라고 불립니다.
6.2.4 Completion Record Specification Type
Completion Record specification type은 nonlocal transfer of control을 수행하는 statement(break, continue, return, throw)의 behaviour와 같은 value 및 control flow의 runtime propagation을 설명하는 데 사용됩니다.
다음 shorthand term은 때때로 Completion Record를 refer하는 데 사용됩니다.
normal completion은 [[Type]] value가 normal인 모든 Completion Record를 가리킵니다.
break completion은 [[Type]] value가 break인 모든 Completion Record를 가리킵니다.
continue completion은 [[Type]] value가 continue인 모든 Completion Record를 가리킵니다.
return completion은 [[Type]] value가 return인 모든 Completion Record를 가리킵니다.
throw completion은 [[Type]] value가 throw인 모든 Completion Record를 가리킵니다.
abrupt completion은 [[Type]] value가 normal이 아닌 모든 Completion Record를 가리킵니다.
어떤 type의 value를 normal completion containing한다는 것은 [[Value]] field에 그 type의 value를 가진 normal completion을 가리킵니다.
이 명세에서 정의된 callable object는 normal completion 또는 throw completion만 반환합니다. 다른 종류의 Completion Record를 반환하는 것은 editorial error로 간주됩니다.
Implementation-defined callable object는 normal completion 또는 throw completion 중 하나를 반환해야 합니다.
6.2.4.1 NormalCompletion ( value )
The abstract operation NormalCompletion takes argument value (any value except a Completion Record) and returns a normal completion. It performs the following steps when called:
The abstract operation ThrowCompletion takes argument value (an ECMAScript language value) and returns a throw completion. It performs the following steps when called:
The abstract operation ReturnCompletion takes argument value (an ECMAScript language value) and returns a return completion. It performs the following steps when called:
The abstract operation UpdateEmpty takes arguments completionRecord (a Completion Record) and value (any value except a Completion Record) and returns a Completion Record. It performs the following steps when called:
Reference Record type은 delete, typeof, assignment operator, superkeyword 및 기타 language feature와 같은 operator의 behaviour를 설명하는 데 사용됩니다. 예를 들어 assignment의 left-hand operand는 Reference Record를 생성할 것으로 expected됩니다.
Reference Record는 resolved name 또는 (possibly not-yet-resolved) property binding입니다. 그 field는 Table 8에 의해 정의됩니다.
empty가 아니면, Reference Record는 superkeyword를 사용하여 표현된 property binding을 나타냅니다. 이는 Super Reference Record라고 불리며, 그 [[Base]] value는 결코 Environment Record가 아닙니다. 이 경우 [[ThisValue]] field는 Reference Record가 생성된 시점의 this value를 hold합니다.
다음 abstract operation은 Reference Record를 대상으로 operate하기 위해 이 명세에서 사용됩니다:
6.2.5.1 IsPropertyReference ( refRecord )
The abstract operation IsPropertyReference takes argument refRecord (a Reference Record) and returns a Boolean. It performs the following steps when called:
The abstract operation IsUnresolvableReference takes argument refRecord (a Reference Record) and returns a Boolean. It performs the following steps when called:
refRecord.[[Base]]가 unresolvable이면, true를 반환한다.
false를 반환한다.
6.2.5.3 IsSuperReference ( refRecord )
The abstract operation IsSuperReference takes argument refRecord (a Reference Record) and returns a Boolean. It performs the following steps when called:
refRecord.[[ThisValue]]가 empty이면, false를 반환한다.
true를 반환한다.
6.2.5.4 IsPrivateReference ( refRecord )
The abstract operation IsPrivateReference takes argument refRecord (a Reference Record) and returns a Boolean. It performs the following steps when called:
step 3.a에서 생성될 수 있는 object는 위 abstract operation 및 ordinary object[[Get]] internal method 밖에서 accessible하지 않습니다. implementation은 object의 실제 생성을 피하도록 선택할 수도 있습니다.
step 3.a에서 생성될 수 있는 object는 위 abstract operation 및 ordinary object[[Set]] internal method 밖에서 accessible하지 않습니다. implementation은 해당 object의 실제 생성을 피하도록 선택할 수도 있습니다.
6.2.5.7 GetThisValue ( refRecord )
The abstract operation GetThisValue takes argument refRecord (a Reference Record) and returns an ECMAScript language value. It performs the following steps when called:
The abstract operation MakePrivateReference takes arguments baseValue (an ECMAScript language value) and privateIdentifier (a String) and returns a Reference Record. It performs the following steps when called:
Property Descriptor type은 Object property attribute의 manipulation과 reification을 설명하는 데 사용됩니다. Property Descriptor는 zero or more field를 가진 Record이며, 각 field의 name은 attribute name이고 그 value는 6.1.7.1에 specified된 대응하는 attribute value입니다. Property Descriptor record의 literal description에 tag를 붙이기 위해 이 명세 안에서 사용되는 schema name은 “PropertyDescriptor”입니다.
Property Descriptor value는 특정 field의 existence 또는 use에 따라 data Property Descriptor와 accessor Property Descriptor로 further classified될 수 있습니다. data Property Descriptor는 [[Value]] 또는 [[Writable]]이라는 이름의 field 중 하나를 포함하는 것입니다. accessor Property Descriptor는 [[Get]] 또는 [[Set]]이라는 이름의 field 중 하나를 포함하는 것입니다. 어떤 Property Descriptor든 [[Enumerable]] 및 [[Configurable]]이라는 이름의 field를 가질 수 있습니다. Property Descriptor value는 data Property Descriptor이면서 동시에 accessor Property Descriptor일 수 없습니다. 그러나 둘 다 아닐 수는 있습니다(이 경우 generic Property Descriptor입니다). fully populated Property Descriptor는 accessor Property Descriptor 또는 data Property Descriptor이며, Table 3에 정의된 대응하는 field를 모두 가진 것입니다.
다음 abstract operation은 Property Descriptor value를 대상으로 operate하기 위해 이 명세에서 사용됩니다:
6.2.6.1 IsAccessorDescriptor ( propertyDesc )
The abstract operation IsAccessorDescriptor takes argument propertyDesc (a Property Descriptor) and returns a Boolean. It performs the following steps when called:
propertyDesc가 [[Get]] field를 가지면, true를 반환한다.
propertyDesc가 [[Set]] field를 가지면, true를 반환한다.
false를 반환한다.
6.2.6.2 IsDataDescriptor ( propertyDesc )
The abstract operation IsDataDescriptor takes argument propertyDesc (a Property Descriptor) and returns a Boolean. It performs the following steps when called:
The abstract operation IsGenericDescriptor takes argument propertyDesc (a Property Descriptor) and returns a Boolean. It performs the following steps when called:
The abstract operation FromPropertyDescriptor takes argument propertyDesc (a Property Descriptor or undefined) and returns an Object or undefined. It performs the following steps when called:
The abstract operation CompletePropertyDescriptor takes argument propertyDesc (a Property Descriptor) and returns unused. It performs the following steps when called:
like를 Record { [[Value]]: undefined, [[Writable]]: false, [[Get]]: undefined, [[Set]]: undefined, [[Enumerable]]: false, [[Configurable]]: false }로 둔다.
propertyDesc가 [[Value]] field를 가지지 않으면, propertyDesc.[[Value]]를 like.[[Value]]로 설정한다.
propertyDesc가 [[Writable]] field를 가지지 않으면, propertyDesc.[[Writable]]을 like.[[Writable]]로 설정한다.
그렇지 않으면,
propertyDesc가 [[Get]] field를 가지지 않으면, propertyDesc.[[Get]]을 like.[[Get]]로 설정한다.
propertyDesc가 [[Set]] field를 가지지 않으면, propertyDesc.[[Set]]을 like.[[Set]]로 설정한다.
propertyDesc가 [[Enumerable]] field를 가지지 않으면, propertyDesc.[[Enumerable]]을 like.[[Enumerable]]로 설정한다.
propertyDesc가 [[Configurable]] field를 가지지 않으면, propertyDesc.[[Configurable]]을 like.[[Configurable]]로 설정한다.
unused를 반환한다.
6.2.7 Environment Record Specification Type
Environment Record type은 nested function 및 block에서 name resolution의 behaviour를 설명하는 데 사용됩니다. 이 type과 그 operation은 9.1에 정의되어 있습니다.
6.2.8 Abstract Closure Specification Type
Abstract Closure specification type은 algorithm step과 value collection을 함께 refer하는 데 사용됩니다. Abstract Closure는 meta-value이며 closure(arg1, arg2)와 같은 function application style을 사용하여 invoked됩니다. abstract operation처럼 invocation은 Abstract Closure가 설명하는 algorithm step을 수행합니다.
Abstract Closure를 생성하는 algorithm step에서 value는 “capture”라는 verb 뒤에 alias list를 사용하여 captured됩니다. Abstract Closure가 생성되면, 그 시점에 각 alias와 associated된 value를 capture합니다. Abstract Closure가 called될 때 수행될 algorithm을 specify하는 step에서 각 captured value는 value를 capture하는 데 사용된 alias로 referred됩니다.
Data Block specification type은 byte-sized(8 bit) numeric value의 distinct하고 mutable한 sequence를 설명하는 데 사용됩니다. byte value는 0부터 255까지의 inclusive interval에 있는 integer입니다. Data Block value는 fixed number of byte로 생성되며, 각 byte의 initial value는 0입니다.
이 명세 안에서 notation 편의를 위해 array-like syntax를 사용하여 Data Block value의 individual byte에 access할 수 있습니다. 이 notation은 Data Block value를 byte의 0-based integer-indexed sequence로 나타냅니다. 예를 들어 dataBlock가 5 byte Data Block value이면 dataBlock[2]를 사용하여 그 3rd byte에 access할 수 있습니다.
여러 agent에서 concurrently referenced될 수 있는 memory에 resides하는 data block은 Shared Data Block으로 지정됩니다. Shared Data Block은 (Shared Data Block value의 equality testing 목적상) address-free인 identity를 가집니다. 이는 block이 어떤 process에 mapped되는 virtual address에 묶이는 것이 아니라, block이 나타내는 memory의 location set에 묶입니다. 두 data block은 자신들이 포함하는 location set이 equal할 때만 equal합니다. 그렇지 않으면 equal하지 않으며 자신들이 포함하는 location set의 intersection은 empty입니다. 마지막으로, Shared Data Block은 Data Block과 distinguished될 수 있습니다.
The abstract operation CopyDataBlockBytes takes arguments toBlock (a Data Block or a Shared Data Block), toIndex (a non-negative integer), fromBlock (a Data Block or a Shared Data Block), fromIndex (a non-negative integer), and count (a non-negative integer) and returns unused. It performs the following steps when called:
PrivateElement 타입은 비공개 클래스 필드, 메서드 및 접근자 명세에서 사용되는 Record이다. Property Descriptor는 비공개 요소에 사용되지 않지만, 비공개 필드는 구성 불가능하고 열거 불가능하며 쓰기 가능한 데이터 프로퍼티와 유사하게 동작하고, 비공개 메서드는 구성 불가능하고 열거 불가능하며 쓰기 불가능한 데이터 프로퍼티와 유사하게 동작하며, 비공개 접근자는 구성 불가능하고 열거 불가능한 접근자 프로퍼티와 유사하게 동작한다.
PrivateElement 타입의 값은 Table 9에 의해 필드가 정의되는 Record 값이다. 이러한 값은 PrivateElements라고 한다.
Private Name specification type은 private class element(field, method, accessor)의 key를 나타내는 globally unique value(그 밖에는 indistinguishable하더라도 다른 어떤 Private Name과도 다른 value)를 설명하는 데 사용됩니다. 각 Private Name은 String인 immutable [[Description]] internal slot을 가집니다. Private Name은 PrivateFieldAdd 또는 PrivateMethodOrAccessorAdd를 사용하여 어떤 ECMAScript object에도 installed될 수 있으며, 그런 다음 PrivateGet과 PrivateSet을 사용하여 read 또는 written될 수 있습니다.
6.2.13 ClassStaticBlockDefinition Record Specification Type
ClassStaticBlockDefinition Record는 class static initialization block을 위한 executable code를 encapsulate하는 데 사용되는 Record value입니다.
이 operation들은 ECMAScript language의 일부가 아닙니다. 이들은 ECMAScript language의 semantics specification을 돕기 위해서만 여기에 정의됩니다. 더 specialized된 다른 abstract operation은 이 명세 전반에 걸쳐 정의됩니다.
7.1 Type Conversion
ECMAScript language는 필요에 따라 automatic type conversion을 implicitly 수행합니다. 특정 construct의 semantics를 명확히 하기 위해 conversion abstract operation의 set을 정의하는 것이 유용합니다. conversion abstract operation은 polymorphic합니다. 즉, 어떤 ECMAScript language type의 value도 accept할 수 있습니다. 그러나 이러한 operation에는 다른 specification type이 사용되지 않습니다.
BigInt type은 ECMAScript language에서 implicit conversion을 가지지 않습니다. programmer는 다른 type의 value를 convert하려면 BigInt를 명시적으로 호출해야 합니다.
7.1.1 ToPrimitive ( input [ , preferredType ] )
The abstract operation ToPrimitive takes argument input (an ECMAScript language value) and optional argument preferredType (string or number) and returns either a normal completion containing an ECMAScript language value or a throw completion. input argument를 non-Object type으로 convert합니다. object가 둘 이상의 primitive type으로 convert할 수 있으면, optional hint preferredType을 사용하여 그 type을 favour할 수 있습니다. It performs the following steps when called:
ToPrimitive가 hint 없이 호출되면, 일반적으로 hint가 number인 것처럼 behave합니다. 그러나 object는 %Symbol.toPrimitive% method를 정의하여 이 behaviour를 over-ride할 수 있습니다. 이 명세에서 정의된 object 중 Date(21.4.4.45 참조)와 Symbol object(20.4.3.5 참조)만 default ToPrimitive behaviour를 over-ride합니다. Date는 hint의 absence를 hint가 string인 것처럼 취급합니다.
The abstract operation ToBoolean takes argument arg (an ECMAScript language value) and returns a Boolean. arg를 Boolean type의 value로 convert합니다. It performs the following steps when called:
arg가 Boolean이면, arg를 반환한다.
arg가 undefined, null, +0𝔽, -0𝔽, NaN, 0ℤ, 또는 empty String 중 하나이면, false를 반환한다.
The abstract operation RoundMVResult takes argument n (a mathematical value) and returns a Number. n을 implementation-defined 방식으로 Number로 convert합니다. 이 abstract operation의 목적상, digit은 zero가 아니거나 그 왼쪽에 non-zero digit이 있고 그 오른쪽에 non-zero digit이 있으면 significant합니다. 이 abstract operation의 목적상, mathematical value의 representation이 “denoted by”하는 mathematical value는 mathematical value의 “decimal representation of”의 inverse입니다. It performs the following steps when called:
n의 decimal representation이 20개 이하의 significant digit을 가지면, 𝔽(n)을 반환한다.
option1을 n의 decimal representation에서 20번째 뒤의 각 significant digit을 0 digit으로 replacing한 결과가 denoted by하는 mathematical value로 둔다.
option2를 n의 decimal representation에서 20번째 뒤의 각 significant digit을 0 digit으로 replacing한 다음 20번째 position에서 incrementing한 결과가 denoted by하는 mathematical value로 둔다(필요에 따라 carrying).
The abstract operation ToIntegerOrInfinity takes argument arg (an ECMAScript language value) and returns either a normal completion containing either an integer, +∞, or -∞, or a throw completion. arg를 fractional part가 truncated된 Number value를 나타내는 integer로 convert하거나, 그 Number value가 infinite이면 +∞ 또는 -∞로 convert합니다. It performs the following steps when called:
The abstract operation ToFixedSizeInteger takes arguments int (an integer, +∞, or -∞), signed (unsigned or signed), and bitWidth (a positive integer) and returns an integer. int를 0부터 2bitWidth - 1까지의 inclusive interval(signed가 unsigned인 경우) 또는 -2bitWidth - 1부터 2bitWidth - 1 - 1까지의 inclusive interval(signed가 signed인 경우)에 있는 2bitWidth개 integer 중 하나로 map합니다. It performs the following steps when called:
대부분의 다른 ECMAScript integer conversion operation과 달리, ToUint8Clamp는 non-integral value를 truncate하지 않고 round합니다. 또한 “round half to even” tie-breaking을 사용하며, 이는 Math.round의 “round half up” tie-breaking과 다릅니다.
7.1.14 ToBigInt ( arg )
The abstract operation ToBigInt takes argument arg (an ECMAScript language value) and returns either a normal completion containing a BigInt or a throw completion. arg를 BigInt value로 convert하거나, Number로부터의 implicit conversion이 required되면 throw합니다. It performs the following steps when called:
The abstract operation CanonicalNumericIndexString takes argument arg (a String) and returns a Number or undefined. arg가 "-0"이거나 어떤 Number value n에 대해 정확히 ToString(n)과 match하면, 각각의 Number value를 반환합니다. 그렇지 않으면 undefined를 반환합니다. It performs the following steps when called:
The abstract operation IsCallable takes argument arg (an ECMAScript language value) and returns a Boolean. arg가 [[Call]] internal method를 가진 callable function인지 determine합니다. It performs the following steps when called:
arg가 Object가 아니면, false를 반환한다.
arg가 [[Call]] internal method를 가지면, true를 반환한다.
false를 반환한다.
7.2.4 IsConstructor ( arg )
The abstract operation IsConstructor takes argument arg (an ECMAScript language value) and returns a Boolean. arg가 [[Construct]] internal method를 가진 function object인지 determine합니다. It performs the following steps when called:
The abstract operation IsExtensible takes argument obj (an Object) and returns either a normal completion containing a Boolean or a throw completion. additional property가 obj에 added될 수 있는지 determine하는 데 사용됩니다. It performs the following steps when called:
The abstract operation IsStringWellFormedUnicode takes argument string (a String) and returns a Boolean. 6.1.4에 설명된 대로 string을 UTF-16으로 encoded된 code point의 sequence로 interpret하고, 이것이 well formed UTF-16 sequence인지 determine합니다. It performs the following steps when called:
The abstract operation SameType takes arguments x (an ECMAScript language value) and y (an ECMAScript language value) and returns a Boolean. 두 argument가 같은 type인지 여부를 determine합니다. It performs the following steps when called:
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 )
The abstract operation SameValue takes arguments x (an ECMAScript language value) and y (an ECMAScript language value) and returns a Boolean. 두 argument가 같은 value인지 여부를 determine합니다. It performs the following steps when called:
이 algorithm은 모든 NaN value를 equivalent로 취급하고 +0𝔽와 -0𝔽를 differentiate한다는 점에서 IsStrictlyEqual Algorithm과 다릅니다.
7.2.10 SameValueZero ( x, y )
The abstract operation SameValueZero takes arguments x (an ECMAScript language value) and y (an ECMAScript language value) and returns a Boolean. 두 argument가 같은 value인지 여부를 determine합니다(+0𝔽와 -0𝔽의 차이를 ignoring). It performs the following steps when called:
The abstract operation SameValueNonNumber takes arguments x (an ECMAScript language value, but not a Number) and y (an ECMAScript language value, but not a Number) and returns a Boolean. It performs the following steps when called:
The abstract operation IsLessThan takes arguments x (an ECMAScript language value), y (an ECMAScript language value), and leftFirst (a Boolean) and returns either a normal completion containing either a Boolean or undefined, or a throw completion. comparison x < y에 대한 semantics를 제공하며, true, false, 또는 undefined(operand가 같은 numeric type의 comparable value로 coerced될 수 없음을 나타냄)를 반환합니다. leftFirst flag는 potentially visible side-effect가 있는 operation이 x와 y에 대해 수행되는 order를 control하는 데 사용됩니다. 이는 ECMAScript가 expression의 left to right evaluation을 specify하기 때문에 필요합니다. leftFirst가 true이면, x parameter는 y parameter에 대응하는 expression의 왼쪽에 나타나는 expression에 대응합니다. leftFirst가 false이면, 그 반대이며 operation은 x보다 y에 먼저 수행되어야 합니다. It performs the following steps when called:
Step 3는 logical-or operation 대신 logical-and operation을 사용한다는 점에서 addition operator +(13.15.3)를 handle하는 algorithm의 step 1.c와 다릅니다.
Note 2
String의 comparison은 UTF-16 code unit value의 sequence에 대한 simple lexicographic ordering을 사용합니다. Unicode specification에 정의된 character 또는 string equality와 collating order의 더 complex하고 semantically oriented definition을 사용하려는 attempt는 없습니다. 따라서 Unicode Standard에 따라 canonically equal하지만 같은 normalization form이 아닌 String value는 unequal로 test될 수 있습니다. 또한 code unit에 의한 lexicographic ordering은 surrogate pair를 포함하는 String에서 code point에 의한 ordering과 다르다는 점에 유의하십시오.
The abstract operation IsStrictlyEqual takes arguments x (an ECMAScript language value) and y (an ECMAScript language value) and returns a Boolean. === operator에 대한 semantics를 제공합니다. It performs the following steps when called:
이 algorithm은 signed zero와 NaN의 treatment에서 SameValue Algorithm과 다릅니다.
7.3 Operations on Objects
7.3.1 MakeBasicObject ( internalSlotsList )
The abstract operation MakeBasicObject takes argument internalSlotsList (a List of internal slot names) and returns an Object. algorithmically 생성되는 모든 ECMAScript object의 source이며, ordinary object와 exotic object를 모두 포함합니다. 모든 object를 creating하는 데 사용되는 common step을 factored out하고 object creation을 centralize합니다. It performs the following steps when called:
Assert: caller가 obj의 [[GetPrototypeOf]]와 [[SetPrototypeOf]] essential internal method를 모두 overriding하지 않을 것이라면, internalSlotsList는 [[Prototype]]을 포함한다.
Assert: caller가 obj의 [[SetPrototypeOf]], [[IsExtensible]], [[PreventExtensions]] essential internal method를 모두 overriding하지 않을 것이라면, internalSlotsList는 [[Extensible]]을 포함한다.
이 명세 안에서 exotic object는 ArrayCreate와 BoundFunctionCreate 같은 abstract operation에서 먼저 MakeBasicObject를 호출하여 basic, foundational object를 얻은 다음, 해당 object의 internal method 일부 또는 전부를 overriding하여 생성됩니다. exotic object creation을 encapsulate하기 위해, object의 essential internal method는 이러한 operation 밖에서는 결코 modified되지 않습니다.
The abstract operation Set takes arguments obj (an Object), propertyKey (a property key), value (an ECMAScript language value), and throw (a Boolean) and returns either a normal completion containingunused or a throw completion. object의 특정 property의 value를 set하는 데 사용됩니다. value는 property의 new value입니다. It performs the following steps when called:
success를 ? obj.[[Set]](propertyKey, value, obj)로 둔다.
이 abstract operation은 ECMAScript language assignment operator가 생성하는 property에 사용되는 것과 같은 default로 attribute가 set된 property를 생성합니다. 일반적으로 property는 이미 존재하지 않습니다. 존재하지만 configurable하지 않거나 obj가 extensible하지 않으면, [[DefineOwnProperty]]는 false를 반환합니다.
7.3.6 CreateDataPropertyOrThrow ( obj, propertyKey, value )
The abstract operation CreateDataPropertyOrThrow takes arguments obj (an Object), propertyKey (a property key), and value (an ECMAScript language value) and returns either a normal completion containingunused or a throw completion. object의 new own property를 create하는 데 사용됩니다. requested property update를 수행할 수 없으면 TypeError exception을 throw합니다. It performs the following steps when called:
이 abstract operation은 ECMAScript language assignment operator가 생성하는 property에 사용되는 것과 같은 default로 attribute가 set된 property를 생성합니다. 일반적으로 property는 이미 존재하지 않습니다. 존재하지만 configurable하지 않거나 obj가 extensible하지 않으면, [[DefineOwnProperty]]는 false를 반환하여 이 operation이 TypeError exception을 throw하게 합니다.
7.3.7 CreateNonEnumerableDataPropertyOrThrow ( obj, propertyKey, value )
The abstract operation CreateNonEnumerableDataPropertyOrThrow takes arguments obj (an Object), propertyKey (a property key), and value (an ECMAScript language value) and returns unused. ordinary object의 new non-enumerable own property를 create하는 데 사용됩니다. It performs the following steps when called:
Assert: obj는 non-configurable property가 없는 ordinary, extensible object이다.
이 abstract operation은 enumerable하지 않다는 점을 제외하고 ECMAScript language assignment operator가 생성하는 property에 사용되는 것과 같은 default로 attribute가 set된 property를 생성합니다. 일반적으로 property는 이미 존재하지 않습니다. 존재하는 경우에도, DefinePropertyOrThrow는 정상적으로 complete함이 guaranteed됩니다.
The abstract operation DefinePropertyOrThrow takes arguments obj (an Object), propertyKey (a property key), and propertyDesc (a Property Descriptor) and returns either a normal completion containingunused or a throw completion. requested property update를 수행할 수 없으면 TypeError exception을 throw하는 방식으로 object의 [[DefineOwnProperty]] internal method를 call하는 데 사용됩니다. It performs the following steps when called:
success를 ? obj.[[DefineOwnProperty]](propertyKey, propertyDesc)로 둔다.
success가 false이면, TypeError exception을 throw한다.
unused를 반환한다.
7.3.9 DeletePropertyOrThrow ( obj, propertyKey )
The abstract operation DeletePropertyOrThrow takes arguments obj (an Object) and propertyKey (a property key) and returns either a normal completion containingunused or a throw completion. object의 특정 own property를 remove하는 데 사용됩니다. property가 configurable하지 않으면 exception을 throw합니다. It performs the following steps when called:
The abstract operation HasProperty takes arguments obj (an Object) and propertyKey (a property key) and returns either a normal completion containing a Boolean or a throw completion. object가 specified property key를 가진 property를 가지는지 determine하는 데 사용됩니다. property는 own 또는 inherited일 수 있습니다. It performs the following steps when called:
? obj.[[HasProperty]](propertyKey)를 반환한다.
7.3.12 HasOwnProperty ( obj, propertyKey )
The abstract operation HasOwnProperty takes arguments obj (an Object) and propertyKey (a property key) and returns either a normal completion containing a Boolean or a throw completion. object가 specified property key를 가진 own property를 가지는지 determine하는 데 사용됩니다. It performs the following steps when called:
propertyDesc를 ? obj.[[GetOwnProperty]](propertyKey)로 둔다.
The abstract operation Construct takes argument ctor (a constructor) and optional arguments argList (a List of ECMAScript language values) and newTarget (a constructor) and returns either a normal completion containing an Object or a throw completion. function object의 [[Construct]] internal method를 call하는 데 사용됩니다. argList와 newTarget은 internal method의 corresponding argument로 passed될 value입니다. argList가 present하지 않으면, 새 empty List가 그 value로 사용됩니다. newTarget이 present하지 않으면, ctor가 그 value로 사용됩니다. It performs the following steps when called:
newTarget이 present하지 않으면, newTarget을 ctor로 설정한다.
argList가 present하지 않으면, argList를 새 empty List로 설정한다.
? ctor.[[Construct]](argList, newTarget)를 반환한다.
Note
newTarget이 present하지 않으면, 이 operation은 new F(...argumentsList)와 equivalent합니다.
7.3.15 SetIntegrityLevel ( obj, level )
The abstract operation SetIntegrityLevel takes arguments obj (an Object) and level (sealed or frozen) and returns either a normal completion containing a Boolean or a throw completion. object의 own property set을 fix하는 데 사용됩니다. It performs the following steps when called:
status를 ? obj.[[PreventExtensions]]()로 둔다.
status가 false이면, false를 반환한다.
keys를 ? obj.[[OwnPropertyKeys]]()로 둔다.
level이 sealed이면, 다음을 수행한다.
keys의 각 element key에 대해, 다음을 수행한다.
? DefinePropertyOrThrow(obj, key, PropertyDescriptor { [[Configurable]]: false })를 수행한다.
The abstract operation TestIntegrityLevel takes arguments obj (an Object) and level (sealed or frozen) and returns either a normal completion containing a Boolean or a throw completion. object의 own property set이 fixed되어 있는지 determine하는 데 사용됩니다. It performs the following steps when called:
level이 frozen이고 IsDataDescriptor(currentDesc)가 true이면, 다음을 수행한다.
currentDesc.[[Writable]]이 true이면, false를 반환한다.
true를 반환한다.
7.3.17 CreateArrayFromList ( elements )
The abstract operation CreateArrayFromList takes argument elements (a List of ECMAScript language values) and returns an Array. elements가 제공하는 element를 가진 Array를 create하는 데 사용됩니다. It performs the following steps when called:
The abstract operation LengthOfArrayLike takes argument obj (an Object) and returns either a normal completion containing a non-negative integer or a throw completion. array-like object의 "length" property value를 반환합니다. It performs the following steps when called:
The abstract operation CreateListFromArrayLike takes argument obj (an ECMAScript language value) and optional argument validElementTypes (all or property-key) and returns either a normal completion containing a List of ECMAScript language values or a throw completion. obj의 indexed property가 제공하는 element를 가진 List value를 create하는 데 사용됩니다. validElementTypes는 element로 allowed되는 value의 type을 나타냅니다. It performs the following steps when called:
The abstract operation OrdinaryHasInstance takes arguments ctor (an ECMAScript language value) and instance (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. instance가 ctor가 제공하는 instance object inheritance path에서 inherit하는지 determine하기 위한 default algorithm을 implements합니다. It performs the following steps when called:
여기서 passed되는 target은 항상 newly created object이며, error가 thrown되는 경우 직접 accessible하지 않습니다.
7.3.26 PrivateElementFind ( obj, privateName )
The abstract operation PrivateElementFind takes arguments obj (an Object) and privateName (a Private Name) and returns a PrivateElement or empty. It performs the following steps when called:
obj.[[PrivateElements]]가 entry.[[Key]]가 privateName인 PrivateElemententry를 contain하면, 다음을 수행한다.
entry를 반환한다.
empty를 반환한다.
7.3.27 PrivateFieldAdd ( obj, privateName, value )
The abstract operation PrivateMethodOrAccessorAdd takes arguments obj (an Object) and method (a PrivateElement) and returns either a normal completion containingunused or a throw completion. It performs the following steps when called:
Assert: method.[[Kind]]는 method 또는 accessor 중 하나이다.
The abstract operation IteratorComplete takes argument iteratorResult (an Object) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:
The abstract operation IteratorStep takes argument iteratorRecord (an Iterator Record) and returns either a normal completion containing either an Object or done, or a throw completion. iteratorRecord.[[NextMethod]]를 호출하여 iteratorRecord.[[Iterator]]로부터 next value를 request하고, iterator가 끝에 도달했음을 나타내는 done 또는 next value가 available하면 IteratorResult object를 반환합니다. It performs the following steps when called:
The abstract operation IteratorClose takes arguments iteratorRecord (an Iterator Record) and completion (a Completion Record) and returns a Completion Record. iterator가 completed state에 도달했을 때 일반적으로 수행할 action을 수행해야 함을 notify하는 데 사용됩니다. It performs the following steps when called:
The abstract operation AsyncIteratorClose takes arguments iteratorRecord (an Iterator Record) and completion (a Completion Record) and returns a Completion Record. async iterator가 completed state에 도달했을 때 일반적으로 수행할 action을 수행해야 함을 notify하는 데 사용됩니다. It performs the following steps when called:
The abstract operation CreateListIteratorRecord takes argument list (a List of ECMAScript language values) and returns an Iterator Record. [[NextMethod]]가 list의 successive element를 반환하는 Iterator Record를 생성합니다. It performs the following steps when called:
closure를 parameter가 없고 list를 capture하며 called될 때 다음 step을 수행하는 새 Abstract Closure로 둔다:
DisposableResource 레코드는 폐기 가능한 객체를 해당 객체를 폐기하는 데 사용되는 메서드와 함께 캡슐화하는 데 사용되는 Record 값이다. DisposableResource 레코드는 CreateDisposableResource 추상 연산에 의해 생성된다.
The abstract operation AddDisposableResource takes arguments disposableResourceStack (DisposableResource 레코드의 List), value (ECMAScript 언어 값), and kind (sync-dispose 또는 async-dispose) and optional argument method (함수 객체) and returns unused를 포함하는 정상 완료 또는 throw 완료. It performs the following steps when called:
The abstract operation CreateDisposableResource takes arguments value (ECMAScript 언어 값) and kind (sync-dispose 또는 async-dispose) and optional argument method (함수 객체) and returns DisposableResource 레코드를 포함하는 정상 완료 또는 throw 완료. It performs the following steps when called:
"*default*"는 이 명세 안에서 module의 default export가 다른 name을 가지지 않을 때 그 synthetic name으로 사용됩니다. module의 [[Environment]] 안의 entry가 그 name으로 생성되어 corresponding value를 hold하며, module에 대해 ResolveExport ( exportName [ , resolveSet ] )를 호출하여 "default"라는 name의 export를 resolving하면 [[BindingName]]이 "*default*"인 ResolvedBinding Record가 반환되고, 이는 module의 [[Environment]] 안에서 위에서 언급한 value로 resolve됩니다. 이는 anonymous default export가 다른 export와 마찬가지로 resolve될 수 있도록 하기 위한 specification 편의를 위해서만 수행됩니다. 이 "*default*" string은 ECMAScript code나 module linking algorithm에서 결코 accessible하지 않습니다.
It is defined piecewise over the following productions:
export defaultAssignmentExpression을 constant declaration으로 취급할 필요는 없습니다. module의 default object를 reference하는 데 사용되는 internal bound name에 assignment를 허용하는 syntax가 없기 때문입니다.
8.2.4 Static Semantics: IsUsingDeclaration
The syntax-directed operation IsUsingDeclaration takes no arguments and returns Boolean. It is defined piecewise over the following productions:
The syntax-directed operation LexicallyDeclaredNames takes no arguments and returns a List of Strings. It is defined piecewise over the following productions:
The syntax-directed operation LexicallyScopedDeclarations takes no arguments and returns a List of Parse Nodes. It is defined piecewise over the following productions:
The syntax-directed operation VarDeclaredNames takes no arguments and returns a List of Strings. It is defined piecewise over the following productions:
The syntax-directed operation VarScopedDeclarations takes no arguments and returns a List of Parse Nodes. It is defined piecewise over the following productions:
The syntax-directed operation TopLevelLexicallyDeclaredNames takes no arguments and returns a List of Strings. It is defined piecewise over the following productions:
The syntax-directed operation TopLevelLexicallyScopedDeclarations takes no arguments and returns a List of Parse Nodes. It is defined piecewise over the following productions:
The syntax-directed operation TopLevelVarDeclaredNames takes no arguments and returns a List of Strings. It is defined piecewise over the following productions:
The syntax-directed operation TopLevelVarScopedDeclarations takes no arguments and returns a List of Parse Nodes. It is defined piecewise over the following productions:
The syntax-directed operation ContainsDuplicateLabels takes argument labelSet (a List of Strings) and returns a Boolean. It is defined piecewise over the following productions:
The syntax-directed operation ContainsUndefinedBreakTarget takes argument labelSet (a List of Strings) and returns a Boolean. It is defined piecewise over the following productions:
The syntax-directed operation ContainsUndefinedContinueTarget takes arguments iterationSet (a List of Strings) and labelSet (a List of Strings) and returns a Boolean. It is defined piecewise over the following productions:
The abstract operation IsAnonymousFunctionDefinition takes argument expr (an AssignmentExpressionParse Node, an InitializerParse Node, or an ExpressionParse Node) and returns a Boolean. argument가 name을 bind하지 않는 function definition인지 determine합니다. It performs the following steps when called:
The syntax-directed operation ComputedPropertyContains takes argument symbol (a grammar symbol) and returns a Boolean. It is defined piecewise over the following productions:
undefined는 initialization value를 assign하기 위해 PutValue operation을 사용해야 함을 나타내기 위해 envRecord로 passed됩니다. 이는 var statement와 일부 non-strict function의 formal parameter list의 경우입니다(10.2.11 참조). 이러한 경우 lexical binding은 initializer의 evaluation 전에 hoisted되고 preinitialized됩니다.
It is defined piecewise over the following productions:
undefined가 envRecord로 passed되면 initialization value를 assign하기 위해 PutValue operation을 사용해야 함을 나타냅니다. 이는 non-strict function의 formal parameter list의 경우입니다. 그 경우 formal parameter binding은 같은 name을 가진 multiple parameter의 possibility를 처리하기 위해 preinitialized됩니다.
It is defined piecewise over the following productions:
The syntax-directed operation AssignmentTargetType takes no arguments and returns simple, web-compat, or invalid. It is defined piecewise over the following productions:
Environment Record는 ECMAScript code의 lexical nesting structure에 기반하여 Identifier를 특정 variable 및 function과 associate하는 것을 define하는 데 사용되는 specification type입니다. 보통 Environment Record는 FunctionDeclaration, BlockStatement 또는 TryStatement의 Catch clause 같은 ECMAScript code의 특정 syntactic structure와 associated됩니다. 그러한 code가 evaluate될 때마다, 그 code가 생성하는 identifier binding을 record하기 위해 새 Environment Record가 생성됩니다.
모든 Environment Record는 [[OuterEnv]] field를 가지며, 이는 null이거나 outer Environment Record에 대한 reference입니다. 이는 Environment Record value의 logical nesting을 model하는 데 사용됩니다. (inner) Environment Record의 outer reference는 inner Environment Record를 logically surround하는 Environment Record에 대한 reference입니다. 물론 outer Environment Record는 자체 outer Environment Record를 가질 수 있습니다. 하나의 Environment Record가 여러 inner Environment Record의 outer environment 역할을 할 수 있습니다. 예를 들어, FunctionDeclaration이 두 개의 nested FunctionDeclaration을 포함하면, 각 nested function의 Environment Record는 surrounding function의 current evaluation의 Environment Record를 outer Environment Record로 갖게 됩니다.
Environment Record는 순수하게 specification mechanism이며 ECMAScript implementation의 특정 artefact에 대응할 필요가 없습니다. ECMAScript program이 이러한 value에 직접 access하거나 manipulate하는 것은 불가능합니다.
Function Environment Record는 ECMAScript function object의 invocation에 대응하며, 해당 function 안의 top-level declaration에 대한 binding을 포함합니다. 이는 새 this binding을 establish할 수 있습니다. 또한 super method invocation을 support하는 데 필요한 state를 capture합니다.
Global Environment Record는 Script global declaration에 사용됩니다. outer environment를 갖지 않으며, 그 [[OuterEnv]]는 null입니다. identifier binding으로 prepopulated될 수 있고, global environment의 identifier binding 중 일부를 제공하는 property를 가진 associated global object를 포함합니다. ECMAScript code가 execute됨에 따라, additional property가 global object에 added될 수 있고 initial property가 modified될 수 있습니다.
Environment Record abstract class는 Table 15에 정의된 abstract specification method를 포함합니다. 이러한 abstract method는 각 concrete subclass에 대해 distinct concrete algorithm을 가집니다.
The abstract method CreateMutableBinding takes arguments name (a String) and deletable (a Boolean) and returns either a normal completion containingunused or a throw completion.
Environment Record 안에 새롭지만 uninitialized인 mutable binding을 생성합니다. name은 bound name의 text입니다. deletable이 true이면 binding은 subsequently deleted될 수 있습니다.
The abstract method CreateImmutableBinding takes arguments name (a String) and strict (a Boolean) and returns either a normal completion containingunused or a throw completion.
Environment Record 안에 새롭지만 uninitialized인 immutable binding을 생성합니다. name은 bound name의 text입니다. strict가 true이면 initialized된 후 이를 set하려는 attempt는 그 binding을 reference하는 operation의 strict mode setting과 관계없이 항상 exception을 throw합니다.
각 Declarative Environment Record는 variable, constant, let, class, module, import 및/또는 function declaration을 포함하는 ECMAScript program scope와 associated됩니다. Declarative Environment Record는 그 scope 안에 contained된 declaration이 정의하는 identifier의 set을 bind합니다.
The HasBinding concrete method of a Declarative Environment RecordenvRecord takes argument name (a String) and returns a normal completion containing a Boolean. argument identifier가 record에 의해 bound된 identifier 중 하나인지 determine합니다. It performs the following steps when called:
The CreateMutableBinding concrete method of a Declarative Environment RecordenvRecord takes arguments name (a String) and deletable (a Boolean) and returns a normal completion containingunused. uninitialized인 name name에 대한 새 mutable binding을 생성합니다. 이 Environment Record 안에는 name에 대한 binding이 already exist하지 않아야 합니다. deletable이 true이면, 새 binding은 deletion subject로 marked됩니다. It performs the following steps when called:
Assert: envRecord는 name에 대한 binding을 already have하지 않는다.
envRecord 안에 name에 대한 mutable binding을 생성하고 그것이 uninitialized임을 record한다. deletable이 true이면, newly created binding이 subsequent DeleteBinding call에 의해 deleted될 수 있음을 record한다.
unused를 반환한다.
9.1.1.1.3 CreateImmutableBinding ( name, strict )
The CreateImmutableBinding concrete method of a Declarative Environment RecordenvRecord takes arguments name (a String) and strict (a Boolean) and returns a normal completion containingunused. uninitialized인 name name에 대한 새 immutable binding을 생성합니다. 이 Environment Record 안에는 name에 대한 binding이 already exist하지 않아야 합니다. strict가 true이면, 새 binding은 strict binding으로 marked됩니다. It performs the following steps when called:
Assert: envRecord는 name에 대한 binding을 already have하지 않는다.
envRecord 안에 name에 대한 immutable binding을 생성하고 그것이 uninitialized임을 record한다. strict가 true이면, newly created binding이 strict binding임을 record한다.
The SetMutableBinding concrete method of a Declarative Environment RecordenvRecord takes arguments name (a String), value (an ECMAScript language value), and strict (a Boolean) and returns either a normal completion containingunused or a throw completion. name이 name인 identifier의 current binding의 bound value를 value value로 change하려고 attempt합니다. name에 대한 binding은 normally already exist하지만, rare case에는 그렇지 않을 수 있습니다. binding이 immutable binding이면 strict가 true일 때 TypeError가 thrown됩니다. It performs the following steps when called:
각 Object Environment Record는 그 binding object라고 불리는 object와 associated됩니다. Object Environment Record는 그 binding object의 property name에 직접 corresponding하는 string identifier name의 set을 bind합니다. IdentifierName form의 string이 아닌 property key는 bound identifier의 set에 포함되지 않습니다. own property와 inherited property는 [[Enumerable]] attribute의 setting과 관계없이 set에 포함됩니다. property는 object에서 dynamically added되고 deleted될 수 있으므로, Object Environment Record에 의해 bound된 identifier의 set은 property를 add하거나 delete하는 모든 operation의 side-effect로 potentially change될 수 있습니다. 그러한 side-effect의 결과로 created되는 binding은 corresponding property의 Writable attribute가 false이더라도 mutable binding으로 considered됩니다. Immutable binding은 Object Environment Record에는 존재하지 않습니다.
with statement(14.11)에 대해 created된 Object Environment Record는 function call에서 사용하기 위한 implicit this value로 그 binding object를 제공할 수 있습니다. 이 capability는 Boolean [[IsWithEnvironment]] field에 의해 controlled됩니다.
Object Environment Record는 Table 16에 listed된 additional state field를 가집니다.
The CreateMutableBinding concrete method of an Object Environment RecordenvRecord takes arguments name (a String) and deletable (a Boolean) and returns either a normal completion containingunused or a throw completion. Environment Record의 associated binding object 안에 name이라는 name의 property를 생성하고 이를 value undefined로 initialize합니다. deletable이 true이면, 새 property의 [[Configurable]] attribute는 true로 set됩니다. 그렇지 않으면 false로 set됩니다. It performs the following steps when called:
Normally envRecord는 name에 대한 binding을 가지지 않지만, 만약 가진다면 DefinePropertyOrThrow의 semantics는 existing binding이 replaced되거나 shadowed되게 하거나 abrupt completion을 returned하게 할 수 있습니다.
The SetMutableBinding concrete method of an Object Environment RecordenvRecord takes arguments name (a String), value (an ECMAScript language value), and strict (a Boolean) and returns either a normal completion containingunused or a throw completion. Environment Record의 associated binding object's property 중 name이 name인 것의 value를 value value로 set하려고 attempt합니다. name이라는 name의 property는 normally already exist하지만, 존재하지 않거나 현재 writable하지 않으면 error handling은 strict에 의해 determined됩니다. It performs the following steps when called:
bindingObj를 envRecord.[[BindingObject]]로 둔다.
stillExists를 ? HasProperty(bindingObj, name)으로 둔다.
The DeleteBinding concrete method of an Object Environment RecordenvRecord takes argument name (a String) and returns either a normal completion containing a Boolean or a throw completion. environment object의 property에 대응하고 [[Configurable]] attribute의 value가 true인 binding만 delete할 수 있습니다. It performs the following steps when called:
bindingObj를 envRecord.[[BindingObject]]로 둔다.
? bindingObj.[[Delete]](name)를 반환한다.
9.1.1.2.8 HasThisBinding ( )
The HasThisBinding concrete method of an Object Environment RecordenvRecord takes no arguments and returns false. It performs the following steps when called:
The WithBaseObject concrete method of an Object Environment RecordenvRecord takes no arguments and returns an Object or undefined. It performs the following steps when called:
Function Environment Record는 function의 top-level scope를 represent하는 데 사용되는 Declarative Environment Record이며, function이 ArrowFunction function이나 AsyncArrowFunction function이 아니면 this binding을 제공합니다. function이 ArrowFunction function이나 AsyncArrowFunction function이 아니고 super를 reference하면, 그 Function Environment Record는 function 내부에서 super method invocation을 수행하는 데 사용되는 state도 포함합니다.
Function Environment Record는 Table 17에 listed된 additional state field를 가집니다.
이 Environment Record가 [[Construct]] internal method에 의해 created되었다면, [[NewTarget]]은 [[Construct]]newTarget parameter의 value입니다. 그렇지 않으면 그 value는 undefined입니다.
The abstract operation GetSuperBase takes argument envRecord (a Function Environment Record) and returns an Object, null, or undefined. envRecord에 bound된 super property access의 base인 object를 반환합니다. value undefined는 그러한 access가 runtime error를 produce함을 나타냅니다. It performs the following steps when called:
home을 envRecord.[[FunctionObject]].[[HomeObject]]로 둔다.
Global Environment Record는 common realm에서 processed되는 모든 ECMAScript Script element가 shared하는 outer most scope를 represent하는 데 사용됩니다. Global Environment Record는 built-in global(clause 19), global object의 property, 그리고 Script 안에서 occur하는 모든 top-level declaration(8.2.11, 8.2.13)에 대한 binding을 제공합니다.
The CreateMutableBinding concrete method of a Global Environment RecordenvRecord takes arguments name (a String) and deletable (a Boolean) and returns either a normal completion containingunused or a throw completion. uninitialized인 name name에 대한 새 mutable binding을 생성합니다. binding은 associated DeclarativeRecord 안에 created됩니다. name에 대한 binding은 DeclarativeRecord 안에 already exist하지 않아야 합니다. deletable이 true이면, 새 binding은 deletion subject로 marked됩니다. It performs the following steps when called:
The CreateImmutableBinding concrete method of a Global Environment RecordenvRecord takes arguments name (a String) and strict (a Boolean) and returns either a normal completion containingunused or a throw completion. uninitialized인 name name에 대한 새 immutable binding을 생성합니다. 이 Environment Record 안에는 name에 대한 binding이 already exist하지 않아야 합니다. strict가 true이면, 새 binding은 strict binding으로 marked됩니다. It performs the following steps when called:
The SetMutableBinding concrete method of a Global Environment RecordenvRecord takes arguments name (a String), value (an ECMAScript language value), and strict (a Boolean) and returns either a normal completion containingunused or a throw completion. name이 name인 identifier의 current binding의 bound value를 value value로 change하려고 attempt합니다. binding이 immutable binding이고 strict가 true이면, TypeError가 thrown됩니다. name이라는 binding은 normally already exist하지만, 존재하지 않거나 currently writable하지 않으면 error handling은 strict에 의해 determined됩니다. It performs the following steps when called:
The GetBindingValue concrete method of a Global Environment RecordenvRecord takes arguments name (a String) and strict (a Boolean) and returns either a normal completion containing an ECMAScript language value or a throw completion. name이 name인 bound identifier의 value를 반환합니다. binding이 uninitialized binding이면, ReferenceError exception을 throw합니다. name이라는 binding은 normally already exist하지만, 존재하지 않거나 currently writable하지 않으면 error handling은 strict에 의해 determined됩니다. It performs the following steps when called:
The HasThisBinding concrete method of a Global Environment RecordenvRecord takes no arguments and returns true. It performs the following steps when called:
The WithBaseObject concrete method of a Global Environment RecordenvRecord takes no arguments and returns undefined. It performs the following steps when called:
undefined를 반환한다.
9.1.1.4.12 HasLexicalDeclaration ( envRecord, name )
The abstract operation HasLexicalDeclaration takes arguments envRecord (a Global Environment Record) and name (a String) and returns a Boolean. argument identifier가 LexicalDeclaration 또는 ClassDeclaration 같은 lexical declaration을 사용하여 created된 envRecord 안의 binding을 가지는지 determine합니다. It performs the following steps when called:
var 또는 function declaration을 사용하여 declared된 것이 아니라 directly created된 property가 global object 위에 존재할 수 있습니다. global lexical binding은 global object의 non-configurable property와 같은 name으로 created될 수 없습니다. global property "undefined"는 그러한 property의 example입니다.
9.1.1.4.14 CanDeclareGlobalVar ( envRecord, name )
The abstract operation CanDeclareGlobalVar takes arguments envRecord (a Global Environment Record) and name (a String) and returns either a normal completion containing a Boolean or a throw completion. same argument name에 대해 corresponding CreateGlobalVarBinding call이 called된다면 succeed할지 determine합니다. Redundant var declaration과 pre-existing global object property에 대한 var declaration은 allowed됩니다. It performs the following steps when called:
The abstract operation CreateGlobalVarBinding takes arguments envRecord (a Global Environment Record), name (a String), and deletable (a Boolean) and returns either a normal completion containingunused or a throw completion. associated Object Environment Record 안에 mutable binding을 create하고 initialize합니다. binding이 already exist하면, 재사용되며 initialized된 것으로 assumed됩니다. It performs the following steps when called:
Global function declaration은 항상 global object의 own property로 represented됩니다. 가능하면, existing own property는 standard set of attribute values를 가지도록 reconfigured됩니다. Step 7은 InitializeBinding concrete method를 calling하는 것이 수행할 것과 equivalent하며 globalObj가 Proxy이면 같은 sequence의 Proxy trap call을 produce합니다.
9.1.1.5 Module Environment Records
Module Environment Record는 ECMAScript Module의 outer scope를 represent하는 데 사용되는 Declarative Environment Record입니다. normal mutable 및 immutable binding에 더해, Module Environment Record는 다른 Environment Record에 존재하는 target binding에 대한 indirect access를 제공하는 binding인 immutable import binding도 제공합니다.
The GetBindingValue concrete method of a Module Environment RecordenvRecord takes arguments name (a String) and strict (a Boolean) and returns either a normal completion containing an ECMAScript language value or a throw completion. name이 name인 bound identifier의 value를 반환합니다. 그러나 binding이 indirect binding이면 target binding의 value가 returned됩니다. binding이 존재하지만 uninitialized이면 ReferenceError가 thrown됩니다. It performs the following steps when called:
The HasThisBinding concrete method of a Module Environment RecordenvRecord takes no arguments and returns true. It performs the following steps when called:
The abstract operation CreateImportBinding takes arguments envRecord (a Module Environment Record), name (a String), targetModule (a Module Record), and targetName (a String) and returns unused. name name에 대한 새 initialized immutable indirect binding을 생성합니다. envRecord 안에는 name에 대한 binding이 already exist하지 않아야 합니다. targetName은 targetModule의 Module Environment Record에 존재하는 binding의 name입니다. 새 binding의 value에 대한 access는 target binding의 bound value에 indirectly access합니다. It performs the following steps when called:
Assert: envRecord는 name에 대한 binding을 already have하지 않는다.
Assert: targetModule.[[Environment]]가 instantiated되면, 이는 targetName에 대한 direct binding을 가질 것이다.
envRecord 안에 targetModule과 targetName을 target binding으로 reference하는 name에 대한 immutable indirect binding을 생성하고, 그 binding이 initialized되었음을 record한다.
The abstract operation NewDeclarativeEnvironment takes argument outerEnv (an Environment Record or null) and returns a Declarative Environment Record. It performs the following steps when called:
The abstract operation NewObjectEnvironment takes arguments obj (an Object), isWithEnv (a Boolean), and outerEnv (an Environment Record or null) and returns an Object Environment Record. It performs the following steps when called:
The abstract operation NewFunctionEnvironment takes arguments func (an ECMAScript function object) and newTarget (an Object or undefined) and returns a Function Environment Record. It performs the following steps when called:
envRecord.[[DisposableResourceStack]]을 새 빈 List로 설정한다.
envRecord를 반환한다.
9.1.2.5 NewGlobalEnvironment ( obj, thisValue )
The abstract operation NewGlobalEnvironment takes arguments obj (an Object) and thisValue (an Object) and returns a Global Environment Record. It performs the following steps when called:
The abstract operation ResolvePrivateIdentifier takes arguments privateEnv (a PrivateEnvironment Record) and identifier (a String) and returns a Private Name. It performs the following steps when called:
evaluate되기 전에, 모든 ECMAScript code는 realm과 associated되어야 합니다. Conceptually, realm은 intrinsic object의 set, ECMAScript global environment, 그 global environment의 scope 안에 loaded된 모든 ECMAScript code, 그리고 기타 associated state와 resource로 구성됩니다.
realm은 이 명세에서 Table 20에 specified된 field를 가진 Realm Record로 represented됩니다:
Realm Record와 additional information을 associate해야 하는 host가 사용하기 위해 reserved된 field입니다.
9.3.1 InitializeHostDefinedRealm ( )
The abstract operation InitializeHostDefinedRealm takes no arguments and returns either a normal completion containingunused or a throw completion. It performs the following steps when called:
realmRecord.[[Intrinsics]]의 field를 Table 6에 listed된 value로 설정한다. field name은 table의 “Intrinsic Name” column에 listed된 name입니다. 각 field의 value는 clause 19부터 28까지의 각 object specification에 의해 정의된 property value로 fully and recursively populated된 새 object value입니다. 모든 object property value는 newly created object value입니다. built-in function object인 모든 value는 CreateBuiltinFunction(steps, length, name, slots, realmRecord, proto, async)를 수행하여 created되며, 여기서 steps는 이 명세가 제공하는 해당 function의 definition, name은 function의 "name" property의 initial value, length는 function의 "length" property의 initial value, slots는 function의 specified internal slot의 name list(있는 경우), proto는 function의 [[Prototype]] internal slot의 specified value, async는 function이 “async”로 described되면 true이고 그렇지 않으면 false입니다. intrinsics와 그 property의 creation은 아직 created되지 않은 object에 대한 dependency를 피하도록 ordered되어야 합니다.
propertyDesc를 property에 대한 specified attribute를 contain하는, property에 대한 fully populated data Property Descriptor로 둔다. 19.2, 19.3 또는 19.4에 listed된 property에 대해서는 [[Value]] attribute의 value가 realmRecord의 corresponding intrinsic object입니다.
execution context는 ECMAScript implementation에 의한 code의 runtime evaluation을 track하는 데 사용되는 specification device입니다. 어느 시점에서든, 실제로 code를 executing하고 있는 execution context는 agent마다 at most one입니다. 이는 agent의 running execution context로 알려져 있습니다. 이 명세에서 running execution context에 대한 모든 reference는 surrounding agent의 running execution context를 denote합니다.
execution context stack은 execution context를 track하는 데 사용됩니다. running execution context는 항상 이 stack의 top element입니다. currently running execution context와 associated된 executable code에서 그 execution context와 associated되지 않은 executable code로 control이 transferred될 때마다 새 execution context가 created됩니다. newly created execution context는 stack 위로 pushed되고 running execution context가 됩니다.
execution context는 associated code의 execution progress를 track하는 데 필요한 implementation specific state를 포함합니다. 각 execution context는 적어도 Table 21에 listed된 state component를 가집니다.
Table 21: State Components for All Execution Contexts
Component
Purpose
code evaluation state
이 execution context와 associated된 code의 evaluation을 perform, suspend, resume하는 데 필요한 모든 state입니다.
실행 중인 실행 컨텍스트에 의한 코드 평가는 이 명세 안에 정의된 여러 지점에서 중단될 수 있다. 실행 중인 실행 컨텍스트가 일단 중단되면, 다른 실행 컨텍스트가 실행 중인 실행 컨텍스트가 되어 그 코드를 평가하기 시작할 수 있다. 나중의 어느 시점에 중단된 실행 컨텍스트가 다시 실행 중인 실행 컨텍스트가 되어 이전에 중단되었던 지점에서 그 코드 평가를 계속할 수 있다. 실행 컨텍스트들 사이에서 실행 중인 실행 컨텍스트 상태의 전환은 보통 스택과 같은 후입선출 방식으로 일어난다. 그러나 일부 ECMAScript 기능은 실행 중인 실행 컨텍스트의 비-LIFO 전환을 필요로 한다.
실행 중인 실행 컨텍스트의 Realm 구성 요소 값은 현재 Realm Record라고도 한다. 실행 중인 실행 컨텍스트의 Function 구성 요소 값은 활성 함수 객체라고도 한다.
ECMAScript 코드 실행 컨텍스트에는 Table 22에 나열된 추가 상태 구성 요소가 있다.
Table 22: Additional State Components for ECMAScript Code Execution Contexts
execution context는 순수하게 specification mechanism이며 ECMAScript implementation의 특정 artefact에 대응할 필요가 없습니다. ECMAScript code가 execution context에 직접 access하거나 observe하는 것은 불가능합니다.
9.4.1 GetActiveScriptOrModule ( )
The abstract operation GetActiveScriptOrModule takes no arguments and returns a Script Record, a Module Record, or null. running execution context에 기반하여 running script 또는 module을 determine하는 데 사용됩니다. It performs the following steps when called:
The abstract operation ResolveBinding takes argument name (a String) and optional argument envRecord (an Environment Record or undefined) and returns either a normal completion containing a Reference Record or a throw completion. name의 binding을 determine하는 데 사용됩니다. envRecord는 binding을 search할 Environment Record를 명시적으로 provide하는 데 사용될 수 있습니다. It performs the following steps when called:
envRecord가 present하지 않거나 envRecord가 undefined이면, 다음을 수행한다.
ResolveBinding의 result는 항상 [[ReferencedName]] field가 name인 Reference Record입니다.
9.4.3 GetThisEnvironment ( )
The abstract operation GetThisEnvironment takes no arguments and returns an Environment Record. keywordthis의 binding을 currently supply하는 Environment Record를 찾습니다. It performs the following steps when called:
The abstract operation GetNewTarget takes no arguments and returns an Object or undefined. running execution context의 LexicalEnvironment를 사용하여 NewTarget value를 determine합니다. It performs the following steps when called:
The abstract operation GetGlobalObject takes no arguments and returns an Object. currently running execution context가 사용하는 global object를 반환합니다. It performs the following steps when called:
The abstract operation RunCallerContext takes argument value (ECMAScript 언어 값 또는 empty) and returns Completion Record. 호출자 컨텍스트를 재개하고(value를 재개 값으로 보냄), 결과가 있으면 그 결과를 기다린다. It performs the following steps when called:
genContext를 실행 중인 실행 컨텍스트라 하자.
실행 컨텍스트 스택에서 genContext를 제거하고, 실행 컨텍스트 스택의 맨 위에 있는 실행 컨텍스트를 실행 중인 실행 컨텍스트로 복원한다.
Host environment는 scheduling과 관련하여 Job을 uniformly 취급할 필요가 없습니다. 예를 들어, web browser와 Node.js는 Promise-handling Job을 다른 work보다 higher priority로 취급합니다. future feature는 그렇게 high priority로 취급되지 않는 Job을 add할 수 있습니다.
특정 시점에서 scriptOrModule(Script Record, Module Record 또는 null)은 다음 조건이 모두 true이면 active script or module입니다:
HostMakeJobCallback의 default implementation은 called될 때 다음 step을 수행합니다:
JobCallback Record { [[Callback]]: callback, [[HostDefined]]: empty }를 반환한다.
web browser가 아닌 ECMAScript host는 HostMakeJobCallback의 default implementation을 사용해야 합니다.
Note
이는 callback이 eventually scheduled되고 run되는 것을 responsible하는 function에 passed되는 시점에 called됩니다. 예를 들어, promise.then(thenAction)은 reaction Job을 scheduling하는 시점이 아니라 Promise.prototype.then을 invoking하는 시점에 thenAction에 대해 MakeJobCallback을 call합니다.
web browser가 아닌 ECMAScript host는 HostCallJobCallback의 default implementation을 사용해야 합니다.
9.5.4 HostEnqueueGenericJob ( job, realm )
The host-defined abstract operation HostEnqueueGenericJob takes arguments job (a JobAbstract Closure) and realm (a Realm Record) and returns unused. realm.[[AgentSignifier]]가 signified하는 agent 안에서, realmrealm 안에 job을 future time에 performed되도록 schedule합니다. 이 algorithm과 함께 사용되는 Abstract Closure는 priority와 ordering 같은 additional constraint 없이 scheduled되도록 intended됩니다.
The host-defined abstract operation HostEnqueuePromiseJob takes arguments job (a JobAbstract Closure) and realm (a Realm Record or null) and returns unused. job을 future time에 performed되도록 schedule합니다. 이 algorithm과 함께 사용되는 Abstract Closure는 Promise의 handling과 관련되거나, 그 밖에 Promise handling operation과 equal priority로 scheduled되도록 intended됩니다.
HostEnqueuePromiseJob의 implementation은 9.5의 requirement와 다음 requirement를 conform해야 합니다:
realm이 null이 아니면, job이 invoked될 때마다 implementation은 job의 invocation 시점에 execution이 ECMAScript code를 evaluate할 준비가 되도록 implementation-defined step을 수행해야 합니다.
The host-defined abstract operation HostEnqueueTimeoutJob takes arguments timeoutJob (a JobAbstract Closure), realm (a Realm Record), and milliseconds (a non-negative finite Number) and returns unused. realm.[[AgentSignifier]]가 signified하는 agent 안에서, realmrealm 안에 timeoutJob을 at least milliseconds milliseconds 후에 performed되도록 schedule합니다.
[[IsLockFree1]], [[IsLockFree2]], [[IsLockFree8]]의 value는 necessarily hardware에 의해 determined되는 것은 아니며, over time 및 ECMAScript implementation 사이에서 vary할 수 있는 implementation choice를 reflect할 수도 있습니다.
[[IsLockFree4]] field는 없습니다: 4-byte atomic operation은 항상 lock-free입니다.
실제로 atomic operation이 어떤 type의 lock으로 implement되면 그 operation은 lock-free가 아닙니다. Lock-free는 wait-free를 imply하지 않습니다: lock-free atomic operation을 complete하는 데 필요한 machine step 수에는 upper bound가 없습니다.
size가 n인 atomic access가 lock-free라는 것이 size가 n인 non-atomic access의 (perceived) atomicity에 대해 어떤 것도 imply하지 않습니다. 특히 non-atomic access는 여전히 여러 separate memory access의 sequence로 performed될 수 있습니다. detail은 ReadSharedMemory와 WriteSharedMemory를 참조하십시오.
Note 3
agent는 specification mechanism이며 ECMAScript implementation의 특정 artefact에 대응할 필요가 없습니다.
9.6.1 AgentSignifier ( )
The abstract operation AgentSignifier takes no arguments and returns an agent signifier. It performs the following steps when called:
일부 environment에서는 주어진 agent가 suspend되는 것이 reasonable하지 않을 수 있습니다. 예를 들어, web browser environment에서는 document의 main event handling thread가 suspend되는 것을 disallow하면서 worker의 event handling thread는 suspend하도록 allow하는 것이 reasonable할 수 있습니다.
9.6.3 IncrementModuleAsyncEvaluationCount ( )
The abstract operation IncrementModuleAsyncEvaluationCount takes no arguments and returns a non-negative integer. It performs the following steps when called:
count를 agentRecord.[[ModuleAsyncEvaluationCount]]로 둔다.
agentRecord.[[ModuleAsyncEvaluationCount]]를 count + 1로 설정한다.
count를 반환한다.
Note
이 value는 pending module 사이의 relative evaluation order를 keep track하는 데만 사용됩니다. implementation은 pending module이 없을 때마다 unobservably [[ModuleAsyncEvaluationCount]]를 0으로 reset할 수 있습니다.
9.7 Agent Clusters
agent cluster는 shared memory를 operate함으로써 communicate할 수 있는 agent의 maximal set입니다.
Note 1
서로 다른 agent 안의 program은 unspecified means로 memory를 share할 수 있습니다. 최소한 SharedArrayBuffer의 backing memory는 cluster 안의 agent들 사이에서 shared될 수 있습니다.
message passing으로 communicate할 수 있지만 memory를 share할 수 없는 agent가 있을 수 있습니다. 이들은 결코 같은 agent cluster에 있지 않습니다.
cluster 안의 agent가 모두 특정 시점에 alive일 필요는 없습니다. agentA가 다른 agentB를 create한 후 A가 terminate되고 B가 agentC를 create하면, A가 B와 some memory를 share할 수 있었고 B가 C와 some memory를 share할 수 있었다면 세 agent는 같은 cluster에 있습니다.
cluster 안의 모든 agent는 각각의 Agent Record 안의 [[LittleEndian]] field에 대해 같은 value를 가져야 합니다.
Note 3
agent cluster 안의 서로 다른 agent가 [[LittleEndian]]의 different value를 가지면 multi-byte data에 shared memory를 use하기 어려워집니다.
cluster 안의 모든 agent는 각각의 Agent Record 안의 [[IsLockFree1]] field에 대해 같은 value를 가져야 합니다; [[IsLockFree2]]와 [[IsLockFree8]] field도 마찬가지입니다.
cluster 안의 모든 agent는 각각의 Agent Record 안의 [[Signifier]] field에 대해 서로 다른 value를 가져야 합니다.
embedding은 agent의 knowledge나 cooperation 없이 agent를 deactivate(forward progress를 stop)하거나 activate(forward progress를 resume)할 수 있습니다. embedding이 그렇게 하는 경우, cluster 안의 일부 agent를 active로 남겨둔 채 다른 agent를 indefinitely deactivated 상태로 두어서는 안 됩니다.
Note 4
preceding restriction의 purpose는 다른 agent가 deactivated되어 agent가 deadlock되거나 starve되는 situation을 avoid하는 것입니다. 예를 들어, 어떤 window의 document와 independent한 lifetime을 가진 HTML shared worker가 그러한 independent document의 dedicated worker와 memory를 share할 수 있도록 allowed되었고, document와 그 dedicated worker가 dedicated worker가 lock을 hold하고 있는 동안 deactivated된다면(예: document가 window의 history에 pushed됨), shared worker가 그 lock을 acquire하려고 할 때 shared worker는 dedicated worker가 다시 activated될 때까지, 혹은 ever, blocked됩니다. Meanwhile 다른 window에서 shared worker에 access하려는 다른 worker는 starve됩니다.
restriction의 implication은 embedding 안에서 같은 suspend/wake collective에 belong하지 않는 agent 사이에서는 memory를 share할 수 없다는 것입니다.
embedding은 agent cluster의 다른 agent가 prior knowledge나 cooperation을 가지지 않아도 agent를 terminate할 수 있습니다. agent가 cluster 안의 자체 programmatic action이나 다른 agent의 programmatic action이 아니라 cluster 외부의 force에 의해 terminated되면, embedding은 두 strategy 중 하나를 choose해야 합니다: cluster 안의 모든 agent를 terminate하거나, cluster 안의 agent가 coordinate하여 cluster의 적어도 하나의 remaining member가 termination을 detect할 수 있게 하는 reliable API를 provide해야 하며, termination data는 terminated된 agent를 identify하기에 충분한 information을 contain해야 합니다.
Note 5
그 type의 termination example은 다음과 같습니다: operating system 또는 user가 separate process에서 running 중인 agent를 terminate하는 경우; per-agent resource accounting이 agent가 runaway임을 indicate할 때 embedding 자체가 다른 agent와 in-process로 running 중인 agent를 terminate하는 경우.
다음 specification value 각각과, 그것들로부터 transitively reachable한 value는 exactly one agent cluster에 belong합니다.
이는 memory model의 liveness guarantee와 함께, 모든 seq-cst write가 eventually 모든 agent에 observable하게 됨을 ensure합니다.
9.9 Processing Model of WeakRef and FinalizationRegistry Targets
9.9.1 Objectives
이 명세는 어떤 object 또는 symbol도 garbage collected될 것이라는 guarantee를 하지 않습니다. live가 아닌 object 또는 symbol은 long period of time 후에 released될 수도 있고, 전혀 released되지 않을 수도 있습니다. 이러한 이유로, 이 명세는 garbage collection에 의해 triggered되는 behaviour를 describing할 때 “may”라는 term을 사용합니다.
WeakRef.prototype.deref가 called될 때, referent(undefined가 returned되지 않는 경우)는 subsequent synchronous access도 같은 value를 return하도록 alive로 kept됩니다. 이 list는 ClearKeptObjects abstract operation을 사용하여 synchronous work가 done될 때 reset됩니다.
일부 ECMAScript implementation은 ECMAScript가 idle일 때를 포함하여 background에서 run하는 garbage collector implementation을 포함합니다. host environment가 CleanupFinalizationRegistry를 schedule하게 하면 finalizer work를 run하기 위해 ECMAScript execution을 resume할 수 있으며, 이는 held value를 free up하여 overall memory usage를 reduce할 수 있습니다.
9.9.2 Liveness
object 및/또는 symbol의 어떤 set objSet에 대해 objSet와 관련한 hypothetical WeakRef-oblivious execution은 referent가 objSet의 element인 WeakRef의 abstract operation WeakRefDeref가 항상 undefined를 반환하는 execution입니다.
Note 1
WeakRef-obliviousness는 liveness와 함께 두 notion을 capture합니다. 첫째, WeakRef 자체는 그 referent를 alive로 keep하지 않습니다. 둘째, liveness의 cycle은 value가 live임을 imply하지 않습니다. 구체적으로, v의 liveness를 determining하는 것이 WeakRef referent r의 liveness를 determining하는 것에 depend한다면, r의 liveness는 v의 liveness를 assume할 수 없습니다. 이는 circular reasoning이기 때문입니다.
Note 2
WeakRef-obliviousness는 cycle을 account하기 위해 individual value 대신 object 또는 symbol의 set에 대해 정의됩니다. individual value에 대해 정의된다면, cycle 안의 WeakRef referent는 그 identity가 cycle 안의 다른 WeakRef referent를 통해서만 observed되더라도 live로 considered될 것입니다.
Note 3
Colloquially, 우리는 individual object 또는 symbol이 그것을 contain하는 모든 set이 live이면 live라고 말합니다.
evaluation 중 어느 point에서든, object 및/또는 symbol의 set objSet는 다음 조건 중 하나가 met되면 live로 considered됩니다:
objSet 안의 어떤 element가 어떤 agent의 [[KeptAlive]]List에 included되어 있습니다.
objSet와 관련하여 valid future hypothetical WeakRef-oblivious execution이 존재하며, 이는 objSet 안의 어떤 value의 identity를 observe합니다.
Note 4
위의 두 번째 condition은 value의 identity가 non-WeakRef means를 통해 observable하면 그 value가 live라는 intuition을 capture하려는 의도입니다. value의 identity는 strict equality comparison을 observing하거나 Map의 key로 사용되는 value를 observing함으로써 observed될 수 있습니다.
Note 5
field, internal slot 또는 property 안에 object나 symbol이 존재한다는 것은 그 value가 live임을 imply하지 않습니다. 예를 들어 해당 value가 program에 다시 passed되지 않으면, it cannot be observed.
이는 WeakMap의 key, WeakSet의 member, 그리고 FinalizationRegistry Cell record의 [[WeakRefTarget]] 및 [[UnregisterToken]] field의 경우에 해당합니다.
위 definition은, WeakMap 안의 key가 live가 아니면, 그 corresponding value도 necessarily live인 것은 아님을 imply합니다.
Note 6
Liveness는 engine이 반드시 empty하지 않아야 하는 WeakRef를 guarantee하기 위한 lower bound입니다. 여기서 정의된 Liveness는 undecidable입니다. 실제로 engine은 reachability 같은 conservative approximation을 사용합니다. significant implementation leeway가 expected됩니다.
9.9.3 Execution
어느 때든 object 및/또는 symbol의 set objSet가 live가 아니면, ECMAScript implementation은 다음 step을 atomically perform할 수 있습니다:
objSet의 각 element value에 대해, 다음을 수행한다.
ref.[[WeakRefTarget]]이 value인 각 WeakRefref에 대해, 다음을 수행한다.
ref.[[WeakRefTarget]]를 empty로 설정한다.
finalizationRegistry.[[Cells]]가 cell.[[WeakRefTarget]]이 value인 Recordcell을 contain하는 각 FinalizationRegistryfinalizationRegistry에 대해, 다음을 수행한다.
map.[[WeakMapData]]가 entry.[[Key]]가 value인 Recordentry를 contain하는 각 WeakMap map에 대해, 다음을 수행한다.
entry.[[Key]]를 empty로 설정한다.
entry.[[Value]]를 empty로 설정한다.
set.[[WeakSetData]]가 value를 contain하는 각 WeakSet set에 대해, 다음을 수행한다.
set.[[WeakSetData]] 안에서 value가 value인 element를 value가 empty인 element로 replace한다.
Note 1
liveness의 definition과 함께, 이 clause는 implementation이 WeakRef와 관련하여 apply할 수 있는 optimization을 prescribe합니다.
object의 identity를 observing하지 않고 object에 access하는 것이 가능합니다. identity가 observed되지 않는 non-escaping object의 property에 대한 dead variable elimination 및 scalar replacement 같은 optimization은 allowed됩니다. 따라서 이러한 optimization은 그러한 object를 point하는 WeakRef를 observably empty하는 것을 allow합니다.
반면, object의 identity가 observable이고 그 object가 WeakRef의 [[WeakRefTarget]] internal slot 안에 있으면, WeakRef를 observably empty하는 rematerialization 같은 optimization은 prohibited됩니다.
implementation은 non-live object 또는 symbol의 maximal set에 대해 WeakRef를 empty할 의무가 없습니다.
implementation이 WeakRef를 empty할 non-live set objSet을 choose하면, 이 definition은 objSet 안의 모든 value에 대한 WeakRef를 simultaneously empty할 것을 require합니다. 다시 말해, implementation이 value v를 point하는 WeakRef를 empty하면서, empty하지 않으면 v의 value를 observe하는 execution을 result할 수 있는 다른 WeakRef를 empty하지 않는 것은 conformant하지 않습니다.
The host-defined abstract operation HostEnqueueFinalizationRegistryCleanupJob takes argument finalizationRegistry (a FinalizationRegistry) and returns unused.
cleanupJob을 parameter가 없고 finalizationRegistry를 capture하며 called될 때 다음 step을 수행하는 새 JobAbstract Closure로 둔다:
The abstract operation ClearKeptObjects takes no arguments and returns unused. ECMAScript implementation은 synchronous sequence of ECMAScript executions가 completes될 때 ClearKeptObjects를 call할 것으로 expected됩니다. It performs the following steps when called:
abstract operation AddToKeptObjects가 target object 또는 symbol과 함께 called되면, 이는 ClearKeptObjects가 called될 때까지 target을 strongly point할 list에 target을 add합니다.
The abstract operation CanBeHeldWeakly takes argument arg (an ECMAScript language value) and returns a Boolean. arg가 weak reference로 사용하기에 suitable하면 and only if true를 반환합니다. weak reference로 사용하기에 suitable한 value만 WeakMap의 key, WeakSet의 element, WeakRef의 target, 또는 FinalizationRegistry의 target 중 하나일 수 있습니다. It performs the following steps when called:
language identity가 없는 language value는 prior reference 없이 manifested될 수 있으므로 weak reference로 사용하기에 unsuitable합니다. Symbol.for가 produced한 Symbol value는 다른 Symbol value와 달리 language identity를 가지지 않으며 weak reference로 사용하기에 unsuitable합니다. Well-known symbols는 collected되지 않을 가능성이 높지만, number가 limited되어 다양한 implementation approach로 manageable하기 때문에 nonetheless weak reference로 사용하기에 suitable한 것으로 treated됩니다. 그러나 live WeakMap 안의 well-known symbol에 associated된 value는 collected될 가능성이 낮고 implementation에서 memory resource를 “leak”할 수 있습니다.
10 Ordinary 및 Exotic Objects Behaviours
10.1 Ordinary Object Internal Methods and Internal Slots
모든 ordinary object는 [[Prototype]]이라는 internal slot을 가집니다. 이 internal slot의 value는 null 또는 object이며 inheritance를 implementing하는 데 사용됩니다. propertyKey라는 property가 ordinary objectobj에는 missing이지만 그 [[Prototype]] object에는 존재한다고 가정합니다. propertyKey가 [[Prototype]] object 위의 data property를 refer하면, obj는 get access에 대해 이를 inherit하여 propertyKey가 obj의 property인 것처럼 behave하게 합니다. propertyKey가 [[Prototype]] object 위의 writable data property를 refer하면, obj 위의 propertyKey의 set access는 obj 위에 propertyKey라는 새 data property를 create합니다. propertyKey가 [[Prototype]] object 위의 non-writable data property를 refer하면, obj 위의 propertyKey의 set access는 fail합니다. propertyKey가 [[Prototype]] object 위의 accessor property를 refer하면, accessor는 get access와 set access 모두에 대해 obj에 inherited됩니다.
모든 ordinary object는 Boolean-valued [[Extensible]] internal slot을 가지며, 이는 6.1.7.3에 specified된 extensibility-related internal method invariant를 fulfill하는 데 사용됩니다. 즉, object의 [[Extensible]] internal slot의 value가 일단 false로 set되면, 그 object에 property를 add하거나, object의 [[Prototype]] internal slot의 value를 modify하거나, 이후 [[Extensible]]의 value를 true로 change하는 것은 더 이상 possible하지 않습니다.
각 ordinary object internal method는 similarly-named abstract operation에 delegate합니다. 그러한 abstract operation이 다른 internal method에 depend하면, similarly-named abstract operation을 직접 calling하는 대신 obj 위에서 internal method가 invoked됩니다. 이러한 semantics는 ordinary object internal method가 exotic object에 applied될 때 그 overridden internal method가 invoked되도록 ensure합니다.
10.1.1[[GetPrototypeOf]] ( )
The [[GetPrototypeOf]] internal method of an ordinary objectobj takes no arguments and returns a normal completion containing either an Object or null. It performs the following steps when called:
The abstract operation OrdinaryGetPrototypeOf takes argument obj (an Object) and returns an Object or null. It performs the following steps when called:
obj.[[Prototype]]을 반환한다.
10.1.2[[SetPrototypeOf]] ( proto )
The [[SetPrototypeOf]] internal method of an ordinary objectobj takes argument proto (an Object or null) and returns a normal completion containing a Boolean. It performs the following steps when called:
The abstract operation OrdinarySetPrototypeOf takes arguments obj (an Object) and proto (an Object or null) and returns a Boolean. It performs the following steps when called:
step 7의 loop는 [[GetPrototypeOf]]와 [[SetPrototypeOf]]에 대해 ordinary object definition을 사용하는 object만 포함하는 prototype chain 안에는 cycle이 없음을 guarantee합니다.
10.1.3[[IsExtensible]] ( )
The [[IsExtensible]] internal method of an ordinary objectobj takes no arguments and returns a normal completion containing a Boolean. It performs the following steps when called:
The abstract operation OrdinaryIsExtensible takes argument obj (an Object) and returns a Boolean. It performs the following steps when called:
obj.[[Extensible]]을 반환한다.
10.1.4[[PreventExtensions]] ( )
The [[PreventExtensions]] internal method of an ordinary objectobj takes no arguments and returns a normal completion containingtrue. It performs the following steps when called:
The abstract operation OrdinaryGetOwnProperty takes arguments obj (an Object) and propertyKey (a property key) and returns a Property Descriptor or undefined. It performs the following steps when called:
obj가 key가 propertyKey인 own property를 가지지 않으면, undefined를 반환한다.
10.1.6.2 IsCompatiblePropertyDescriptor ( extensible, propertyDesc, current )
The abstract operation IsCompatiblePropertyDescriptor takes arguments extensible (a Boolean), propertyDesc (a Property Descriptor), and current (a Property Descriptor or undefined) and returns a Boolean. It performs the following steps when called:
10.1.6.3 ValidateAndApplyPropertyDescriptor ( obj, propertyKey, extensible, propertyDesc, current )
The abstract operation ValidateAndApplyPropertyDescriptor takes arguments obj (an Object or undefined), propertyKey (a property key), extensible (a Boolean), propertyDesc (a Property Descriptor), and current (a Property Descriptor or undefined) and returns a Boolean. specified extensibility와 current property current를 가진 object의 property로 propertyDesc를 invariant를 uphold하면서 apply할 수 있으면 and only if true를 반환합니다. 그러한 application이 possible하고 obj가 undefined가 아니면, propertyKey라는 name의 property에 대해 performed됩니다(필요하면 created됩니다). It performs the following steps when called:
object obj 위에 propertyKey라는 own accessor property를 create하되, 그 [[Get]], [[Set]], [[Enumerable]], [[Configurable]] attribute는 propertyDesc가 해당 field를 가지면 propertyDesc 안의 corresponding field의 value로, 그렇지 않으면 attribute의 default value로 설정한다.
그렇지 않으면,
object obj 위에 propertyKey라는 own data property를 create하되, 그 [[Value]], [[Writable]], [[Enumerable]], [[Configurable]] attribute는 propertyDesc가 해당 field를 가지면 propertyDesc 안의 corresponding field의 value로, 그렇지 않으면 attribute의 default value로 설정한다.
propertyDesc가 [[Configurable]] field를 가지면, configurable을 propertyDesc.[[Configurable]]로 둔다; 그렇지 않으면 configurable을 current.[[Configurable]]로 둔다.
propertyDesc가 [[Enumerable]] field를 가지면, enumerable을 propertyDesc.[[Enumerable]]로 둔다; 그렇지 않으면 enumerable을 current.[[Enumerable]]으로 둔다.
object obj의 propertyKey라는 property를 data property로 replace하되, 그 [[Configurable]]과 [[Enumerable]] attribute는 각각 configurable과 enumerable로 설정하고, [[Value]]와 [[Writable]] attribute는 propertyDesc가 해당 field를 가지면 propertyDesc 안의 corresponding field의 value로, 그렇지 않으면 attribute의 default value로 설정한다.
그렇지 않으면,
propertyDesc의 각 field name fieldName에 대해, object obj의 propertyKey라는 property의 fieldName이라는 attribute를 propertyDesc의 fieldName field의 value로 설정한다.
The abstract operation OrdinaryHasProperty takes arguments obj (an Object) and propertyKey (a property key) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:
hasOwn을 ? obj.[[GetOwnProperty]](propertyKey)로 둔다.
The abstract operation OrdinaryDelete takes arguments obj (an Object) and propertyKey (a property key) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:
propertyDesc를 ? obj.[[GetOwnProperty]](propertyKey)로 둔다.
The abstract operation OrdinaryOwnPropertyKeys takes argument obj (an Object) and returns a List of property keys. It performs the following steps when called:
obj의 각 own property keypropertyKey 중 propertyKey가 array index인 것에 대해, ascending numeric index order로 다음을 수행한다.
propertyKey를 keys에 append한다.
obj의 각 own property keypropertyKey 중 propertyKey가 String이고 propertyKey가 array index가 아닌 것에 대해, property creation의 ascending chronological order로 다음을 수행한다.
propertyKey를 keys에 append한다.
obj의 각 own property keypropertyKey 중 propertyKey가 Symbol인 것에 대해, property creation의 ascending chronological order로 다음을 수행한다.
propertyKey를 keys에 append한다.
keys를 반환한다.
10.1.12 OrdinaryObjectCreate ( proto [ , additionalInternalSlotsList ] )
The abstract operation OrdinaryObjectCreate takes argument proto (an Object or null) and optional argument additionalInternalSlotsList (a List of names of internal slots) and returns an Object. 새 ordinary object의 runtime creation을 specify하는 데 사용됩니다. additionalInternalSlotsList는 [[Prototype]]과 [[Extensible]]을 넘어 object의 part로 define되어야 하는 additional internal slot의 name을 contain합니다. additionalInternalSlotsList가 provided되지 않으면, 새 empty List가 사용됩니다. It performs the following steps when called:
internalSlotsList를 « [[Prototype]], [[Extensible]] »로 둔다.
OrdinaryObjectCreate는 MakeBasicObject를 call하는 것 이상의 일을 거의 하지 않지만, 그 use는 exotic object가 아니라 ordinary object를 create하려는 intention을 communicate합니다. 따라서 이 명세 안에서는 result가 non-ordinary가 되도록 object의 internal method를 subsequently modify하는 algorithm에 의해 called되지 않습니다. exotic object를 create하는 operation은 MakeBasicObject를 직접 invoke합니다.
The abstract operation OrdinaryCreateFromConstructor takes arguments ctor (a function object) and intrinsicDefaultProto (a String) and optional argument internalSlotsList (a List of names of internal slots) and returns either a normal completion containing an Object or a throw completion. constructor의 "prototype" property가 존재하면 그 property에서 retrieved된 [[Prototype]] value를 가지는 ordinary object를 create합니다. 그렇지 않으면 intrinsicDefaultProto가 naming하는 intrinsic이 [[Prototype]]에 사용됩니다. internalSlotsList는 object의 part로 define되어야 하는 additional internal slot의 name을 contain합니다. internalSlotsList가 provided되지 않으면, 새 empty List가 사용됩니다. It performs the following steps when called:
Assert: intrinsicDefaultProto는 이 명세의 intrinsic object name이다. corresponding object는 object의 [[Prototype]] value로 사용되도록 intended된 intrinsic이어야 한다.
The abstract operation GetPrototypeFromConstructor takes arguments ctor (a function object) and intrinsicDefaultProto (a String) and returns either a normal completion containing an Object or a throw completion. specific constructor에 corresponding하는 object를 create하는 데 사용해야 하는 [[Prototype]] value를 determine합니다. value는 constructor의 "prototype" property가 존재하면 그 property에서 retrieved됩니다. 그렇지 않으면 intrinsicDefaultProto가 naming하는 intrinsic이 [[Prototype]]에 사용됩니다. It performs the following steps when called:
Assert: intrinsicDefaultProto는 이 명세의 intrinsic object name이다. corresponding object는 object의 [[Prototype]] value로 사용되도록 intended된 intrinsic이어야 한다.
ctor가 [[Prototype]] value를 supply하지 않으면, 사용되는 default value는 running execution context가 아니라 ctor function의 realm에서 obtained됩니다.
10.1.15 RequireInternalSlot ( obj, internalSlot )
The abstract operation RequireInternalSlot takes arguments obj (an ECMAScript language value) and internalSlot (an internal slot name) and returns either a normal completion containingunused or a throw completion. obj가 Object이고 given internal slot을 가지지 않는 한 exception을 throw합니다. It performs the following steps when called:
obj가 Object가 아니면, TypeError exception을 throw한다.
obj가 internalSlot internal slot을 가지지 않으면, TypeError exception을 throw한다.
function이 closed over된 Private Name에 대한 PrivateEnvironment Record입니다. 이 function이 syntactically class 안에 contained되어 있지 않으면 null입니다. function의 code를 evaluating할 때 inner class를 위한 outer PrivateEnvironment로 사용됩니다.
function의 formal parameter와 code body 안에서 this reference가 어떻게 interpreted되는지 define합니다. lexical은 this가 lexically enclosing function의 this value를 refer함을 의미합니다. strict는 this value가 function invocation에 의해 provided된 그대로 사용됨을 의미합니다. global은 undefined 또는 null인 this value가 global object에 대한 reference로 interpreted되고, 그 밖의 this value는 먼저 ToObject에 passed됨을 의미합니다.
step 7에서 calleeContext가 execution context stack에서 removed될 때, accessible Generator에 의해 later resumption을 위해 suspended되고 retained되어 있다면 destroyed되어서는 안 됩니다.
The abstract operation PrepareForOrdinaryCall takes arguments func (an ECMAScript function object) and newTarget (an Object or undefined) and returns an execution context. It performs the following steps when called:
The abstract operation OrdinaryCallBindThis takes arguments func (an ECMAScript function object), calleeContext (an execution context), and thisArg (an ECMAScript language value) and returns unused. It performs the following steps when called:
The abstract operation OrdinaryFunctionCreate takes arguments proto (an Object), sourceText (a sequence of Unicode code points), paramList (a Parse Node), body (a Parse Node), thisMode (lexical-this or non-lexical-this), envRecord (an Environment Record), and privateEnv (a PrivateEnvironment Record or null) and returns an ECMAScript function object. default [[Call]] internal method를 가지며 [[Construct]] internal method는 없는 새 function의 runtime creation을 specify하는 데 사용됩니다(단, MakeConstructor 같은 operation에 의해 subsequently added될 수 있습니다). sourceText는 created될 function의 syntactic definition의 source text입니다. It performs the following steps when called:
internalSlotsList를 Table 26에 listed된 internal slot으로 둔다.
The abstract operation AddRestrictedFunctionProperties takes arguments func (a function object) and realm (a Realm Record) and returns unused. It performs the following steps when called:
The abstract operation MakeConstructor takes argument func (an ECMAScript function object or a built-in function object) and optional arguments writableProto (a Boolean) and proto (an Object) and returns unused. func를 constructor로 convert합니다. It performs the following steps when called:
! DefinePropertyOrThrow(func, "prototype", PropertyDescriptor { [[Value]]: proto, [[Writable]]: writableProto, [[Enumerable]]: false, [[Configurable]]: false })를 수행한다.
unused를 반환한다.
10.2.6 MakeClassConstructor ( func )
The abstract operation MakeClassConstructor takes argument func (an ECMAScript function object) and returns unused. It performs the following steps when called:
The abstract operation MakeMethod takes arguments func (an ECMAScript function object) and homeObj (an Object) and returns unused. func를 method로 configure합니다. It performs the following steps when called:
10.2.9 SetFunctionName ( func, name [ , prefix ] )
The abstract operation SetFunctionName takes arguments func (a function object) and name (a property key or Private Name) and optional argument prefix (a String) and returns unused. func에 "name" property를 add합니다. It performs the following steps when called:
Assert: func는 "name" own property를 가지지 않는 extensible object이다.
The abstract operation SetFunctionLength takes arguments func (a function object) and length (a non-negative integer or +∞) and returns unused. func에 "length" property를 add합니다. It performs the following steps when called:
Assert: func는 "length" own property를 가지지 않는 extensible object이다.
ECMAScript function을 evaluating하기 위해 execution context가 established될 때 새 Function Environment Record가 created되고 각 formal parameter에 대한 binding이 그 Environment Record 안에 instantiated됩니다. function body 안의 각 declaration도 instantiated됩니다. function의 formal parameter가 default value initializer를 포함하지 않으면 body declaration은 parameter와 같은 Environment Record 안에 instantiated됩니다. default value parameter initializer가 존재하면 body declaration을 위해 두 번째 Environment Record가 created됩니다. Formal parameter와 function은 FunctionDeclarationInstantiation의 일부로 initialized됩니다. 다른 모든 binding은 function body의 evaluation 중에 initialized됩니다.
built-in function object는 “constructor”로 described되거나 이 명세의 어떤 algorithm이 그 [[Construct]] internal method를 explicit하게 set하는 경우에 and only if [[Construct]] internal method를 가집니다. 그러한 [[Construct]] internal method는 10.3.2의 definition을 conform해야 합니다.
implementation은 이 명세에 정의되지 않은 additional built-in function object를 provide할 수 있습니다.
resultsClosure를 func, thisArg, argList, newTarget을 capture하고 called될 때 다음 step을 수행하는, parameter가 없는 새 Abstract Closure로 둔다:
result를 func의 specification을 conform하는 manner로 func를 evaluating한 result인 Completion Record로 둔다. thisArg가 uninitialized이면, this value는 uninitialized입니다; 그렇지 않으면 thisArg가 this value를 제공합니다. argList는 named parameter를 제공합니다. newTarget은 NewTarget value를 제공합니다.
NOTE: func가 이 document에 defined되어 있으면, “func의 specification”은 algorithm step 또는 기타 means를 통해 그것에 대해 specified된 behaviour입니다.
result를 func의 specification을 conform하는 manner로 func를 evaluating한 result인 Completion Record로 둔다. thisArg가 uninitialized이면, this value는 uninitialized입니다; 그렇지 않으면 thisArg가 this value를 제공합니다. argList는 named parameter를 제공합니다. newTarget은 NewTarget value를 제공합니다.
NOTE: func가 이 document에 defined되어 있으면, “func의 specification”은 algorithm step 또는 기타 means를 통해 그것에 대해 specified된 behaviour입니다.
The abstract operation CreateBuiltinFunction takes arguments behaviour (an Abstract Closure, a set of algorithm steps, or some other definition of a function's behaviour provided in this specification), length (a non-negative integer or +∞), name (a property key or a Private Name), and additionalInternalSlotsList (a List of names of internal slots) and optional arguments realm (a Realm Record), proto (an Object or null), prefix (a String), and async (a Boolean) and returns a built-in function object. additionalInternalSlotsList는 object의 part로 define되어야 하는 additional internal slot의 name을 contain합니다. 이 operation은 built-in function object를 create합니다. It performs the following steps when called:
realm이 present하지 않으면, realm을 current Realm Record로 설정한다.
func를 called될 때 behaviour에 의해 specified된 corresponding parameter의 value로 provided argument를 사용하여 behaviour가 describe한 action을 수행하는 새 built-in function object로 둔다. 새 function object는 name이 internalSlotsList의 element인 internal slot과 [[InitialName]] internal slot을 가진다.
object의 [[Call]]과 (applicable하면) [[Construct]] internal method가 다음 implementation을 사용하고, 그 other essential internal method가 10.1에 있는 definition을 사용하면, 그 object는 bound function exotic object입니다. 이러한 method는 BoundFunctionCreate에서 installed됩니다.
Array는 array indexproperty key(6.1.7 참조)에 special treatment를 제공하는 exotic object입니다. property name이 array index인 property는 element라고도 합니다. 모든 Array는 non-configurable "length" property를 가지며, 그 value는 항상 mathematical value가 232보다 strictly less인 non-negative integral Number입니다. "length" property의 value는 name이 array index인 모든 own property의 name보다 numerically greater합니다; Array의 own property가 created되거나 changed될 때마다, 이 invariant를 maintain하기 위해 other property가 necessary하게 adjusted됩니다. Specifically, name이 array index인 own property가 added될 때마다, "length" property의 value는 필요하면 그 array index의 numeric value보다 하나 큰 값으로 changed됩니다; 그리고 "length" property의 value가 changed될 때마다, name이 array index이고 value가 new length보다 작지 않은 모든 own property는 deleted됩니다. 이 constraint는 Array의 own property에만 apply되며, 그 prototype에서 inherited될 수 있는 "length" 또는 array index property의 영향을 받지 않습니다.
object의 [[DefineOwnProperty]] internal method가 다음 implementation을 사용하고, 그 other essential internal method가 10.1에 있는 definition을 사용하면, 그 object는 Array exotic object(또는 simply, Array)입니다. 이러한 method는 ArrayCreate에서 installed됩니다.
The abstract operation ArrayCreate takes argument length (a non-negative integer) and optional argument proto (an Object) and returns either a normal completion containing an Array exotic object or a throw completion. 새 Array의 creation을 specify하는 데 사용됩니다. It performs the following steps when called:
The abstract operation ArraySpeciesCreate takes arguments originalArray (an Object) and length (a non-negative integer) and returns either a normal completion containing an Object or a throw completion. originalArray에서 derived된 constructor function을 사용하여 새 Array 또는 similar object의 creation을 specify하는 데 사용됩니다. constructor function이 Array를 return해야 한다고 enforce하지는 않습니다. It performs the following steps when called:
originalArray가 running execution context의 realm이 아닌 realm에 대한 standard built-in Array constructor를 사용하여 created되었다면, running execution context의 realm을 사용하여 새 Array가 created됩니다. 이는 역사적으로 ArraySpeciesCreate를 사용하여 now defined된 Array.prototype method에 대해 해당 behaviour를 가졌던 Web browser와의 compatibility를 maintain합니다.
array의 각 own property keypropertyKey 중 propertyKey가 array index이고 ! ToUint32(propertyKey) ≥ newLength인 것에 대해, descending numeric index order로 다음을 수행한다.
deleteSucceeded를 ! array.[[Delete]](propertyKey)로 둔다.
step 3 및 4에서, propertyDesc.[[Value]]가 object이면 그 valueOf method가 두 번 called됩니다. 이는 이 명세의 2nd Edition부터 이 effect로 specified된 legacy behaviour입니다.
10.4.3 String Exotic Objects
String object는 String value를 encapsulate하고 String value의 individual code unit element에 corresponding하는 virtual integer-indexeddata property를 expose하는 exotic object입니다. String exotic object는 항상 "length"라는 data property를 가지며, 그 value는 encapsulated String value의 length입니다. code unit data property와 "length" property는 모두 non-writable 및 non-configurable입니다.
object의 [[GetOwnProperty]], [[DefineOwnProperty]], [[OwnPropertyKeys]] internal method가 다음 implementation을 사용하고, 그 other essential internal method가 10.1에 있는 definition을 사용하면, 그 object는 String exotic object(또는 simply, String object)입니다. 이러한 method는 StringCreate에서 installed됩니다.
obj의 각 own property keypropertyKey 중 propertyKey가 String이고 propertyKey가 array index가 아닌 것에 대해, property creation의 ascending chronological order로 다음을 수행한다.
propertyKey를 keys에 append한다.
obj의 각 own property keypropertyKey 중 propertyKey가 Symbol인 것에 대해, property creation의 ascending chronological order로 다음을 수행한다.
propertyKey를 keys에 append한다.
keys를 반환한다.
10.4.3.4 StringCreate ( value, proto )
The abstract operation StringCreate takes arguments value (a String) and proto (an Object) and returns a String exotic object. 새 String exotic object의 creation을 specify하는 데 사용됩니다. It performs the following steps when called:
string을 MakeBasicObject(« [[Prototype]], [[Extensible]], [[StringData]] »)로 둔다.
string.[[Prototype]]을 proto로 설정한다.
string.[[StringData]]를 value로 설정한다.
string.[[GetOwnProperty]]를 10.4.3.1에 specified된 대로 설정한다.
string.[[DefineOwnProperty]]를 10.4.3.2에 specified된 대로 설정한다.
string.[[OwnPropertyKeys]]를 10.4.3.3에 specified된 대로 설정한다.
The abstract operation StringGetOwnProperty takes arguments string (an Object that has a [[StringData]] internal slot) and propertyKey (a property key) and returns a Property Descriptor or undefined. It performs the following steps when called:
object의 internal method가 다음 implementation을 사용하고, 여기서 specified되지 않은 것은 10.1에 있는 것을 사용하면, 그 object는 arguments exotic object입니다. 이러한 method는 CreateMappedArgumentsObject에서 installed됩니다.
Arguments exotic object는 ordinary object와 같은 internal slot을 가집니다. 또한 [[ParameterMap]] internal slot을 가집니다. Ordinary arguments object도 value가 항상 undefined인 [[ParameterMap]] internal slot을 가집니다. ordinary argument object의 경우 [[ParameterMap]] internal slot은 Object.prototype.toString(20.1.3.6)에 의해 그것을 그렇게 identify하는 데만 사용됩니다.
Note 2
numeric name value가 corresponding function object의 formal parameter 수보다 작은 arguments exotic object의 integer-indexeddata property는 initially function의 execution context 안의 corresponding argument binding과 그 value를 share합니다. 이는 property를 changing하면 corresponding argument binding의 value가 changed되고 그 반대도 성립함을 의미합니다. 그러한 property가 deleted된 다음 redefined되거나 property가 accessor property로 changed되면 이 correspondence는 broken됩니다. arguments object가 ordinary object이면, 그 property의 value는 단순히 function에 passed된 argument의 copy이며, property value와 formal parameter value 사이에 dynamic linkage는 없습니다.
Note 3
ParameterMap object와 그 property value는 arguments object correspondence to argument binding을 specifying하는 device로 사용됩니다. ParameterMap object와 그 property의 value인 object는 ECMAScript code에서 directly observable하지 않습니다. ECMAScript implementation은 specified semantics를 implement하기 위해 실제로 그러한 object를 create하거나 사용할 필요가 없습니다.
Note 4
Ordinary arguments object는 access 시 TypeError exception을 throw하는 "callee"라는 non-configurable accessor property를 define합니다. "callee" property는 일부 class의 non-strict function에 대해서만 created되는 arguments exotic object에 대해 더 specific한 meaning을 가집니다. ordinary variant에서 이 property의 definition은 conforming ECMAScript implementation이 다른 manner로 define하지 않도록 ensure하기 위해 존재합니다.
Note 5
arguments exotic object의 ECMAScript implementation은 역사적으로 "caller"라는 accessor property를 contained했습니다. ECMAScript 2017 이전에는, 이 명세가 ordinary arguments object 위의 throwing "caller" property의 definition을 포함했습니다. implementation이 더 이상 이 extension을 contain하지 않으므로, ECMAScript 2017은 throwing "caller" accessor에 대한 requirement를 dropped했습니다.
The abstract operation CreateUnmappedArgumentsObject takes argument argList (a List of ECMAScript language values) and returns an ordinary object. It performs the following steps when called:
The abstract operation MakeArgGetter takes arguments name (a String) and envRecord (an Environment Record) and returns a function object. executed될 때 envRecord 안에서 name에 bound된 value를 반환하는 built-in function object를 create합니다. It performs the following steps when called:
getterClosure를 name과 envRecord를 capture하고 called될 때 다음 step을 수행하는, parameter가 없는 새 Abstract Closure로 둔다:
NOTE: getter는 ECMAScript code에서 결코 directly accessible하지 않습니다.
getter를 반환한다.
10.4.4.7.2 MakeArgSetter ( name, envRecord )
The abstract operation MakeArgSetter takes arguments name (a String) and envRecord (an Environment Record) and returns a function object. executed될 때 envRecord 안에서 name에 bound된 value를 set하는 built-in function object를 create합니다. It performs the following steps when called:
setterClosure를 name과 envRecord를 capture하고 called될 때 다음 step을 수행하는, parameter (value)를 가진 새 Abstract Closure로 둔다:
TypedArray는 ordinary object와 같은 internal slot을 가지며, 추가로 [[ViewedArrayBuffer]], [[TypedArrayName]], [[ContentType]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] internal slot을 가집니다.
object의 [[PreventExtensions]], [[GetOwnProperty]], [[HasProperty]], [[DefineOwnProperty]], [[Get]], [[Set]], [[Delete]], [[OwnPropertyKeys]] internal method가 이 section의 definition을 사용하고, 그 other essential internal method가 10.1에 있는 definition을 사용하면, 그 object는 TypedArray입니다. 이러한 method는 TypedArrayCreate에 의해 installed됩니다.
10.4.5.1[[PreventExtensions]] ( )
The [[PreventExtensions]] internal method of a TypedArrayobj takes no arguments and returns a normal completion containing a Boolean. It performs the following steps when called:
NOTE: 6.1.7.3에 specified된 extensibility-related invariant는 obj가 property를 gain할 수 있을 때(또는 lose한 후 regain할 수 있을 때) 이 method가 true를 return하는 것을 allow하지 않습니다. 이는 underlying buffer가 resized될 때 integer index name을 가진 property에 대해 occur할 수 있습니다.
obj의 각 own property keypropertyKey 중 propertyKey가 String이고 propertyKey가 integer index가 아닌 것에 대해, property creation의 ascending chronological order로 다음을 수행한다.
propertyKey를 keys에 append한다.
obj의 각 own property keypropertyKey 중 propertyKey가 Symbol인 것에 대해, property creation의 ascending chronological order로 다음을 수행한다.
propertyKey를 keys에 append한다.
keys를 반환한다.
10.4.5.9 TypedArray With Buffer Witness Records
TypedArray With Buffer Witness Record는 viewed buffer의 cached byte length와 함께 TypedArray를 encapsulate하는 데 사용되는 Record value입니다. 이는 viewed buffer가 growable SharedArrayBuffer일 때 byte length data block의 single ReadSharedMemory event가 있음을 ensure하는 데 help하기 위해 사용됩니다.
TypedArray With Buffer Witness Record는 Table 28에 listed된 field를 가집니다.
Record가 created되었을 때 object의 [[ViewedArrayBuffer]]의 byte length입니다.
10.4.5.10 MakeTypedArrayWithBufferWitnessRecord ( obj, order )
The abstract operation MakeTypedArrayWithBufferWitnessRecord takes arguments obj (a TypedArray) and order (seq-cst or unordered) and returns a TypedArray With Buffer Witness Record. It performs the following steps when called:
The abstract operation TypedArrayCreate takes argument proto (an Object) and returns a TypedArray. 새 TypedArray의 creation을 specify하는 데 사용됩니다. It performs the following steps when called:
ta.[[OwnPropertyKeys]]를 10.4.5.8에 specified된 대로 설정한다.
ta.[[Prototype]]을 proto로 설정한다.
ta를 반환한다.
10.4.5.12 TypedArrayByteLength ( taRecord )
The abstract operation TypedArrayByteLength takes argument taRecord (a TypedArray With Buffer Witness Record) and returns a non-negative integer. It performs the following steps when called:
NOTE: underlying buffer가 non-integer multiple로 resized되었을 때도 returned byte length는 항상 elementSize의 integer multiple입니다.
length × elementSize를 반환한다.
10.4.5.13 TypedArrayLength ( taRecord )
The abstract operation TypedArrayLength takes argument taRecord (a TypedArray With Buffer Witness Record) and returns a non-negative integer. It performs the following steps when called:
The abstract operation IsTypedArrayOutOfBounds takes argument taRecord (a TypedArray With Buffer Witness Record) and returns a Boolean. object의 numeric property 중 어떤 것이 underlying buffer's bounds 안에 contained되지 않은 index의 value를 reference하는지 check합니다. It performs the following steps when called:
obj를 taRecord.[[Object]]로 둔다.
bufferByteLength를 taRecord.[[CachedBufferByteLength]]로 둔다.
The abstract operation IsValidIntegerIndex takes arguments obj (a TypedArray) and index (a Number) and returns a Boolean. It performs the following steps when called:
The abstract operation TypedArrayGetElement takes arguments obj (a TypedArray) and index (a Number) and returns a Number, a BigInt, or undefined. It performs the following steps when called:
SetValueInBuffer(obj.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, number, true, unordered)를 수행한다.
unused를 반환한다.
Note
이 operation은 항상 succeed하는 것처럼 보이지만, TypedArray의 end를 지나서 write하려고 하거나 detached ArrayBuffer가 backing하는 TypedArray에 write하려고 할 때는 effect가 없습니다.
10.4.5.19 IsArrayBufferViewOutOfBounds ( obj )
The abstract operation IsArrayBufferViewOutOfBounds takes argument obj (a TypedArray or a DataView) and returns a Boolean. TypedArray의 numeric property 중 어떤 것이나 DataView object의 method가 underlying data block's bounds 안에 contained되지 않은 index의 value를 reference할 수 있는지 check합니다. 이 abstract operation은 upstream specification을 위한 convenience로 존재합니다. It performs the following steps when called:
ResolveExport는 side-effect free입니다. 이 operation이 specific exportName, resolveSet pair를 argument로 called될 때마다 같은 result를 반환해야 합니다. implementation은 각 module namespace exotic object의 [[Exports]]에 대한 ResolveExport result를 pre-compute하거나 cache하도록 choose할 수 있습니다.
object의 [[SetPrototypeOf]] internal method가 다음 implementation을 사용하면, 그 object는 immutable prototype exotic object입니다. (그 other essential internal method는 문제의 specific immutable prototype exotic object에 따라 어떤 implementation이든 사용할 수 있습니다.)
The abstract operation SetImmutablePrototype takes arguments obj (an Object) and proto (an Object or null) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:
10.5 Proxy Object Internal Methods and Internal Slots
Proxy object는 essential internal method가 ECMAScript code를 사용하여 partially implemented되는 exotic object입니다. 모든 Proxy object는 [[ProxyHandler]]라는 internal slot을 가집니다. [[ProxyHandler]]의 value는 proxy의 handler object라고 불리는 object 또는 null입니다. handler object의 method(Table 30 참조)는 Proxy object's internal method 중 하나 이상에 대한 implementation을 augment하는 데 사용될 수 있습니다. 모든 Proxy object는 또한 [[ProxyTarget]]이라는 internal slot을 가지며, 그 value는 object 또는 null입니다. 이 object를 proxy의 target object라고 합니다.
object의 essential internal method(applicable하면 [[Call]] 및 [[Construct]] 포함)가 이 section의 definition을 사용하면, 그 object는 Proxy exotic object입니다. 이러한 internal method는 ProxyCreate에서 installed됩니다.
Table 30: Proxy Handler Methods
Internal Method
Handler Method
[[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 object internal method의 implementation을 provide하기 위해 handler method가 called될 때, handler method에는 proxy의 target object가 parameter로 passed됩니다. proxy의 handler object가 모든 essential internal method에 corresponding하는 method를 반드시 가지는 것은 아닙니다. proxy 위에서 internal method를 invoking하면 handler object가 internal trap에 corresponding하는 method를 가지지 않는 경우 proxy의 target object 위의 corresponding internal method가 invoked됩니다.
Proxy object의 [[ProxyHandler]] 및 [[ProxyTarget]] internal slot은 object가 created될 때 항상 initialized되며 일반적으로 modified될 수 없습니다. 일부 Proxy object는 subsequently revoked될 수 있도록 허용하는 manner로 created됩니다. proxy가 revoked되면, 그 [[ProxyHandler]]와 [[ProxyTarget]] internal slot은 null로 set되어 이후 그 Proxy object 위의 internal method invocation이 TypeError exception을 throw하게 합니다.
Proxy object는 internal method의 implementation이 arbitrary ECMAScript code에 의해 provided되는 것을 permit하므로, handler method가 6.1.7.3에 정의된 invariant를 violate하는 Proxy object를 define하는 것이 가능합니다. 6.1.7.3에 정의된 internal method invariant 중 일부는 essential integrity invariant입니다. 이러한 invariant는 이 section에 specified된 Proxy object internal method에 의해 explicitly enforced됩니다. ECMAScript implementation은 가능한 모든 invariant violation이 presence하더라도 robust해야 합니다.
corresponding target object property가 non-writable, non-configurable own data property이면, property의 value를 corresponding target object property의 value와 다르게 change할 수 없습니다.
corresponding target object property가 [[Set]] attribute로 undefined를 가지는 non-configurable own accessor property이면, property의 value를 set할 수 없습니다.
Proxy exotic object는 그 [[ProxyTarget]] internal slot의 initial value가 [[Construct]] internal method를 가지는 object인 경우에만 [[Construct]] internal method를 가집니다.
Note 2
Proxy object의 [[Construct]]는 다음 invariant를 enforce합니다:
[[Construct]]의 result는 Object여야 합니다.
10.5.14 ValidateNonRevokedProxy ( proxy )
The abstract operation ValidateNonRevokedProxy takes argument proxy (a Proxy exotic object) and returns either a normal completion containingunused or a throw completion. proxy가 revoked되었으면 TypeError exception을 throw합니다. It performs the following steps when called:
ECMAScript source text는 Unicode code point의 sequence입니다. surrogate code point를 포함하여 U+0000부터 U+10FFFF까지의 모든 Unicode code point value는 ECMAScript grammar가 허용하는 곳에서 ECMAScript source text에 occur할 수 있습니다. ECMAScript source text를 store하고 interchange하는 데 사용되는 actual encoding은 이 명세와 관련이 없습니다. external source text encoding과 관계없이, conforming ECMAScript implementation은 source text를 equivalent한 SourceCharacter value의 sequence인 것처럼 process하며, 각 SourceCharacter는 Unicode code point입니다. Conforming ECMAScript implementation은 source text의 normalization을 수행하거나, source text의 normalization을 수행하는 것처럼 behave할 필요가 없습니다.
combining character sequence의 component는 user가 전체 sequence를 single character로 생각할 수 있더라도 individual Unicode code point로 treated됩니다.
Note
string literal, regular expression literal, template literal 및 identifier 안에서는 어떤 Unicode code point든 code point의 numeric value를 explicitly express하는 Unicode escape sequence를 사용하여 표현할 수도 있습니다. comment 안에서는 그러한 escape sequence가 comment의 part로 effectively ignored됩니다.
ECMAScript는 Unicode escape sequence의 behaviour에서 Java programming language와 다릅니다. Java program에서는 예를 들어 Unicode escape sequence \u000A가 single-line comment 안에 occur하면, line terminator(Unicode code point U+000A는 LINE FEED (LF))로 interpreted되므로 다음 code point는 comment의 part가 아닙니다. 마찬가지로 Unicode escape sequence \u000A가 Java program의 string literal 안에 occur하면, 역시 line terminator로 interpreted되며, 이는 string literal 안에서 allowed되지 않습니다 — string literal의 value의 part로 LINE FEED (LF)를 cause하려면 \u000A 대신 \n을 써야 합니다. ECMAScript program에서는 comment 안에 occur하는 Unicode escape sequence가 never interpreted되므로 comment의 termination에 contribute할 수 없습니다. 마찬가지로 ECMAScript program의 string literal 안에 occur하는 Unicode escape sequence는 항상 literal에 contribute하며 line terminator로 또는 string literal을 terminate할 수 있는 code point로 never interpreted되지 않습니다.
The abstract operation UTF16EncodeCodePoint takes argument codePoint (a Unicode code point) and returns a String. It performs the following steps when called:
11.1.2 Static Semantics: CodePointsToString ( text )
The abstract operation CodePointsToString takes argument text (a sequence of Unicode code points) and returns a String. 6.1.4에 described된 대로 text를 String value로 convert합니다. It performs the following steps when called:
The abstract operation UTF16SurrogatePairToCodePoint takes arguments lead (a code unit) and trail (a code unit) and returns a code point. UTF-16 surrogate pair를 form하는 두 code unit이 code point로 converted됩니다. It performs the following steps when called:
11.1.4 Static Semantics: CodePointAt ( string, position )
The abstract operation CodePointAt takes arguments string (a String) and position (a non-negative integer) and returns a Record with fields [[CodePoint]] (a code point), [[CodeUnitCount]] (a positive integer), and [[IsUnpairedSurrogate]] (a Boolean). 6.1.4에 described된 대로 string을 UTF-16 encoded code point의 sequence로 interpret하고, index position의 code unit부터 시작하여 single code point를 read합니다. It performs the following steps when called:
The abstract operation StringToCodePoints takes argument string (a String) and returns a List of code points. 6.1.4에 described된 대로 string을 UTF-16 encoded Unicode text로 interpreting한 결과인 Unicode code point의 sequence를 반환합니다. It performs the following steps when called:
The abstract operation ParseText takes arguments sourceText (a String or a sequence of Unicode code points) and goalSymbol (a nonterminal in one of the ECMAScript grammars) and returns a Parse Node or a non-empty List of SyntaxError objects. It performs the following steps when called:
parse가 succeeded하고 early error가 발견되지 않았으면, parse의 result로 생긴 parse tree의 root에 있는 Parse Node(goalSymbol의 instance)를 반환한다.
parsing error 및/또는 early error를 represent하는 하나 이상의 SyntaxError object의 List를 반환한다. 둘 이상의 parsing error 또는 early error가 present하면, list 안의 error object의 number와 ordering은 implementation-defined이지만, 적어도 하나는 present해야 한다.
Note 1
particular point에 early error가 있고, later point에도 syntax error가 있는 text를 consider하십시오. parse pass 뒤에 early errors pass를 수행하는 implementation은 syntax error를 report하고 early errors pass로 proceed하지 않을 수 있습니다. 두 activity를 interleave하는 implementation은 early error를 report하고 syntax error를 찾기 위해 proceed하지 않을 수 있습니다. 세 번째 implementation은 두 error를 모두 report할 수 있습니다. 이 모든 behaviour는 conformant입니다.
Eval code는 built-in eval function에 supplied되는 source text입니다. 더 정확히 말하면, built-in eval function에 대한 parameter가 String이면, 이는 ECMAScript Script로 treated됩니다. eval의 particular invocation에 대한 eval code는 그 Script의 global code portion입니다.
Function code는 일반적으로 Function Definitions(15.2), Arrow Function Definitions(15.3), Method Definitions(15.4), Generator Function Definitions(15.5), Async Function Definitions(15.8), Async Generator Function Definitions(15.6), Async Arrow Functions(15.9)의 body로 provided됩니다. Function code는 Function constructor(20.2.1.1), GeneratorFunction constructor(27.6.1.1), AsyncFunction constructor(27.10.1.1), AsyncGeneratorFunction constructor(27.7.1.1)에 대한 argument로부터도 derived됩니다.
ECMAScript syntactic unit은 unrestricted 또는 strict mode syntax and semantics(4.3.2)를 사용하여 processed될 수 있습니다. Code는 다음 situation에서 strict mode code로 interpreted됩니다:
ECMAScript Script 또는 Module의 source text는 먼저 token, line terminator, comment 또는 white space인 input element의 sequence로 converted됩니다. source text는 left to right로 scanned되며, 가능한 가장 긴 code point sequence를 반복적으로 next input element로 취합니다.
multiple lexical goal의 사용은 automatic semicolon insertion에 영향을 줄 lexical ambiguity가 없음을 ensure합니다. 예를 들어 leading division 또는 division-assignment와 leading RegularExpressionLiteral이 둘 다 permitted되는 syntactic grammar context는 없습니다. 이는 semicolon insertion(12.10 참조)의 영향을 받지 않습니다; 다음과 같은 예에서:
a = b
/hi/g.exec(c).map(d);
LineTerminator 뒤의 first non-whitespace, non-comment code point가 U+002F (SOLIDUS)이고 syntactic context가 division 또는 division-assignment를 allow하면, LineTerminator에서 semicolon은 inserted되지 않습니다. 즉, 위 example은 다음과 같은 방식으로 interpreted됩니다:
Unicode format-control character(즉, LEFT-TO-RIGHT MARK 또는 RIGHT-TO-LEFT MARK 같은 Unicode Character Database의 category “Cf” 안의 character)는 이를 위한 higher-level protocol(mark-up language 등)이 없을 때 text range의 formatting을 control하는 데 사용되는 control code입니다.
editing과 display를 facilitate하기 위해 source text 안에서 format-control character를 allow하는 것은 useful합니다. 모든 format control character는 comment 안에서, 그리고 string literal, template literal, regular expression literal 안에서 사용될 수 있습니다.
U+FEFF (ZERO WIDTH NO-BREAK SPACE)는 primarily text의 start에서 그것을 Unicode로 mark하고 text의 encoding과 byte order의 detection을 allow하는 데 사용되는 format-control character입니다. 이 purpose로 intended된 <ZWNBSP> character는 때때로 text의 start 뒤에도 나타날 수 있습니다. 예를 들어 file을 concatenating한 result로 그렇습니다. ECMAScript source text에서 <ZWNBSP> code point는 comment, string literal, template literal, regular expression literal 밖에서는 white space character(12.2 참조)로 treated됩니다.
12.2 White Space
White space code point는 source text readability를 improve하고 token(indivisible lexical unit)을 서로 separate하는 데 사용되지만, otherwise insignificant합니다. White space code point는 어떤 두 token 사이에도, input의 start 또는 end에도 occur할 수 있습니다. White space code point는 StringLiteral, RegularExpressionLiteral, Template 또는 TemplateSubstitutionTail 안에서도 occur할 수 있으며, 여기서는 literal value의 part를 forming하는 significant code point로 considered됩니다. 또한 Comment 안에서도 occur할 수 있지만, 그 밖의 어떤 kind의 token 안에는 appear할 수 없습니다.
ECMAScript white space code point는 Table 31에 listed되어 있습니다.
Table 31: White Space Code Points
Code Points
Name
Abbreviation
U+0009
CHARACTER TABULATION
<TAB>
U+000B
LINE TABULATION
<VT>
U+000C
FORM FEED (FF)
<FF>
U+FEFF
ZERO WIDTH NO-BREAK SPACE
<ZWNBSP>
general category “Space_Separator” 안의 모든 code point
<USP>
Note 1
U+0020 (SPACE) 및 U+00A0 (NO-BREAK SPACE) code point는 <USP>의 part입니다.
Note 2
Table 31에 listed된 code point 외에는, ECMAScript WhiteSpace는 Unicode “White_Space” property를 가지지만 general category “Space_Separator”(“Zs”)로 classified되지 않은 모든 code point를 intentionally excludes합니다.
white space code point와 마찬가지로, line terminator code point는 source text readability를 improve하고 token(indivisible lexical unit)을 서로 separate하는 데 사용됩니다. 그러나 white space code point와 달리, line terminator는 syntactic grammar의 behaviour에 어느 정도 influence를 가집니다. 일반적으로 line terminator는 어떤 두 token 사이에도 occur할 수 있지만, syntactic grammar에 의해 forbidden되는 몇몇 place가 있습니다. Line terminator는 automatic semicolon insertion(12.10) process에도 affect합니다. line terminator는 StringLiteral, Template 또는 TemplateSubstitutionTail을 제외한 어떤 token 안에도 occur할 수 없습니다. <LF> 및 <CR> line terminator는 LineContinuation의 part인 경우를 제외하고 StringLiteral token 안에 occur할 수 없습니다.
Line terminator는 regular expression 안의 \s class가 match하는 white space code point의 set에 included됩니다.
ECMAScript line terminator code point는 Table 32에 listed되어 있습니다.
Table 32: Line Terminator Code Points
Code Point
Unicode Name
Abbreviation
U+000A
LINE FEED (LF)
<LF>
U+000D
CARRIAGE RETURN (CR)
<CR>
U+2028
LINE SEPARATOR
<LS>
U+2029
PARAGRAPH SEPARATOR
<PS>
Table 32 안의 Unicode code point만 line terminator로 treated됩니다. 다른 new line 또는 line breaking Unicode code point는 line terminator로 treated되지 않지만, Table 31에 listed된 requirement를 meet하면 white space로 treated됩니다. sequence <CR><LF>는 commonly line terminator로 사용됩니다. 이는 line number를 reporting하기 위한 purpose에서는 single SourceCharacter로 considered되어야 합니다.
Comment는 single-line 또는 multi-line일 수 있습니다. Multi-line comment는 nest할 수 없습니다.
single-line comment는 LineTerminator code point를 제외한 어떤 Unicode code point든 contain할 수 있고, token은 항상 가능한 한 길다는 general rule 때문에, single-line comment는 항상 // marker부터 line의 end까지의 모든 code point로 구성됩니다. 그러나 line end의 LineTerminator는 single-line comment의 part로 considered되지 않습니다; 이는 lexical grammar에 의해 separately recognized되고 syntactic grammar를 위한 input element stream의 part가 됩니다. 이 point는 매우 important합니다. 왜냐하면 single-line comment의 presence 또는 absence가 automatic semicolon insertion process에 affect하지 않음을 imply하기 때문입니다(12.10 참조).
Comment는 white space처럼 behave하며 discarded됩니다. 단, MultiLineComment가 line terminator code point를 contain하면, syntactic grammar에 의한 parsing purpose에서 전체 comment가 LineTerminator로 considered됩니다.
IdentifierName 및 ReservedWord는 Unicode Standard Annex #31, Identifier and Pattern Syntax에 given된 Default Identifier Syntax에 따라 interpreted되는 token이며, 약간의 modification이 있습니다. ReservedWord는 IdentifierName의 enumerated subset입니다. syntactic grammar는 Identifier를 ReservedWord가 아닌 IdentifierName으로 define합니다. Unicode identifier grammar는 Unicode Standard가 specified한 character property에 기반합니다. Unicode Standard의 latest version에서 specified된 category 안의 Unicode code point는 모든 conforming ECMAScript implementation에 의해 해당 category 안에 있는 것으로 treated되어야 합니다. ECMAScript implementation은 Unicode Standard의 later edition에 defined된 identifier code point를 recognize할 수 있습니다.
Note 1
이 standard는 specific code point addition을 specify합니다: U+0024 (DOLLAR SIGN) 및 U+005F (LOW LINE)는 IdentifierName 안의 어디에서나 permitted됩니다.
Unicode Standard에 따라 canonically equivalent한 두 IdentifierName은, 각 UnicodeEscapeSequence의 replacement 후 exact same sequence의 code point로 represented되지 않는 한 not equal입니다.
The syntax-directed operation IdentifierCodePoints takes no arguments and returns a List of code points. It is defined piecewise over the following productions:
keyword는 IdentifierName과 match되지만 syntactic use도 가지는 token입니다; 즉, 어떤 syntactic production 안에서 fixed width font로 literally appear합니다. ECMAScript의 keyword에는 if, while, async, await 및 many others가 포함됩니다.
reserved word는 identifier로 사용할 수 없는 IdentifierName입니다. 많은 keyword는 reserved word이지만, 일부는 그렇지 않으며, 일부는 certain context에서만 reserved됩니다. if와 while은 reserved word입니다. await는 async function과 module 안에서만 reserved됩니다. async는 reserved되지 않습니다; variable name 또는 statement label로 restriction 없이 사용할 수 있습니다.
이 명세는 어떤 name이 valid identifier이고 어떤 것이 reserved word인지 specify하기 위해 grammatical production과 early error rule의 combination을 사용합니다. 아래 ReservedWord list 안의 모든 token은 await와 yield를 제외하고 unconditionally reserved됩니다. await와 yield에 대한 exception은 parameterized syntactic production을 사용하여 13.1에 specified되어 있습니다. Lastly, several early error rule이 valid identifier의 set을 restrict합니다. 13.1.1, 14.3.1.1, 14.7.5.1, 15.7.1를 참조하십시오. 요약하면, identifier name에는 다섯 category가 있습니다:
Math, window, toString, _처럼 always identifier로 allowed되고 keyword가 아닌 것;
identifier로 never allowed되지 않는 것, 즉 await와 yield를 제외하고 아래 listed된 ReservedWord;
contextually identifier로 allowed되는 것, 즉 await와 yield;
always identifier로 allowed되지만 Identifier가 allowed되지 않는 place에서 certain syntactic production 안의 keyword로도 appear하는 것: as, async, from, get, meta, of, set, target.
conditional keyword 또는 contextual keyword라는 term은 때때로 last three category에 속해 일부 context에서는 identifier로, 다른 context에서는 keyword로 사용될 수 있는 keyword를 refer하는 데 사용됩니다.
The syntax-directed operation NumericValue takes no arguments and returns a Number or a BigInt. It is defined piecewise over the following productions:
string literal은 single 또는 double quote로 enclosed된 0개 이상의 Unicode code point입니다. Unicode code point는 escape sequence로 represented될 수도 있습니다. closing quote code point, U+005C (REVERSE SOLIDUS), U+000D (CARRIAGE RETURN), U+000A (LINE FEED)를 제외한 모든 code point는 string literal에 literally appear할 수 있습니다. 어떤 code point든 escape sequence의 form으로 appear할 수 있습니다. String literal은 ECMAScript String value로 evaluate됩니다. 이러한 String value를 generating할 때 Unicode code point는 11.1.1에 defined된 대로 UTF-16 encoded됩니다. Basic Multilingual Plane에 속하는 code point는 string의 single code unit element로 encoded됩니다. 그 밖의 모든 code point는 string의 two code unit element로 encoded됩니다.
<LF> 및 <CR>은 empty code point sequence를 produce하는 LineContinuation의 part인 경우를 제외하고 string literal 안에 appear할 수 없습니다. string literal의 String value 안에 둘 중 하나를 include하는 proper way는 \n 또는 \u000A 같은 escape sequence를 사용하는 것입니다.
string literal이 enclosing code를 strict mode로 place하는 Use Strict Directive보다 preceding할 수 있으며, implementation은 그러한 literal에 대해 위 rule을 enforce하도록 care해야 합니다. 예를 들어 다음 source text는 Syntax Error를 contain합니다:
string literal은 String type의 value를 나타냅니다. SV는 string literal의 various part에 대한 recursive application을 통해 string literal에 대한 String value를 produce합니다. 이 process의 part로, string literal 안의 일부 Unicode code point는 아래 또는 12.9.3에 described된 대로 mathematical value를 가지는 것으로 interpreted됩니다.
regular expression literal은 literal이 evaluated될 때마다 RegExp object(22.2 참조)로 converted되는 input element입니다. program 안의 두 regular expression literal은 두 literal의 content가 identical하더라도 서로 ===로 compare되는 regular expression object로 evaluate되지 않습니다. RegExp object는 runtime에 new RegExp에 의해 또는 RegExp constructor를 function으로 calling하여 created될 수도 있습니다(22.2.4 참조).
아래 production은 regular expression literal의 syntax를 describe하며 input element scanner가 regular expression literal의 end를 find하는 데 사용됩니다. RegularExpressionBody 및 RegularExpressionFlags를 comprising하는 source text는 subsequently 더 stringent한 ECMAScript Regular Expression grammar(22.2.1)를 사용하여 다시 parsed됩니다.
implementation은 22.2.1에 defined된 ECMAScript Regular Expression grammar를 extend할 수 있지만, 아래 defined된 RegularExpressionBody 및 RegularExpressionFlags production이나 이러한 production이 사용하는 production을 extend해서는 안 됩니다.
The syntax-directed operation TRV takes no arguments and returns a String. template literal component는 TRV에 의해 String type의 value로 interpreted됩니다. TRV는 template object의 raw component(colloquially, template raw values)를 construct하는 데 사용됩니다. TRV는 TV와 similar하지만 차이점은 TRV에서 escape sequence가 literal에 appear하는 그대로 interpreted된다는 것입니다.
대부분의 ECMAScript statement와 declaration은 semicolon으로 terminated되어야 합니다. 그러한 semicolon은 source text에 항상 explicitly appear할 수 있습니다. 그러나 convenience를 위해, certain situation에서는 그러한 semicolon을 source text에서 omitted할 수 있습니다. 이러한 situation은 semicolon이 그 situation에서 source code token stream에 automatically inserted된다고 말함으로써 described됩니다.
12.10.1 Rules of Automatic Semicolon Insertion
다음 rule에서 “token”은 clause 12에 described된 대로 current lexical goal symbol을 사용하여 determined된 actual recognized lexical token을 의미합니다.
semicolon insertion에는 세 가지 basic rule이 있습니다:
source text가 left to right로 parsed될 때, grammar의 어떤 production에도 allowed되지 않는 token(offending token이라고 함)이 encountered되면, 다음 condition 중 하나 이상이 true인 경우 semicolon이 offending token 앞에 automatically inserted됩니다:
offending token이 previous token과 적어도 하나의 LineTerminator에 의해 separated되어 있습니다.
source text가 left to right로 parsed될 때, token의 input stream의 end가 encountered되고 parser가 input token stream을 goal nonterminal의 single instance로 parse할 수 없으면, semicolon이 input stream의 end에 automatically inserted됩니다.
source text가 left to right로 parsed될 때, grammar의 어떤 production에서는 allowed되지만 그 production이 restricted production이고, 그 token이 restricted production 안에서 annotation “[no LineTerminator here]” 바로 뒤의 terminal 또는 nonterminal을 위한 first token이 될 수 있는 token(restricted token이라고 함)이며, restricted token이 previous token과 적어도 하나의 LineTerminator에 의해 separated되어 있으면, semicolon이 restricted token 앞에 automatically inserted됩니다.
그러나 preceding rule에는 additional overriding condition이 있습니다: semicolon이 empty statement로 parsed될 경우 또는 그 semicolon이 for statement(14.7.4 참조)의 header 안의 두 semicolon 중 하나가 될 경우, semicolon은 never automatically inserted되지 않습니다.
break 또는 continue 문에서의 LabelIdentifier는 break 또는 continue 토큰과 같은 줄에 있어야 한다.
화살표 함수의 매개변수 끝과 그 =>는 같은 줄에 있어야 한다.
비동기 함수 또는 메서드 앞의 async 토큰은 바로 뒤따르는 토큰과 같은 줄에 있어야 한다.
12.10.2 Examples of Automatic Semicolon Insertion
This section is non-normative.
source
{ 12 } 3
는 automatic semicolon insertion rule이 있어도 ECMAScript grammar에서 valid sentence가 아닙니다. 반대로, source
{ 12 } 3
역시 valid ECMAScript sentence는 아니지만, automatic semicolon insertion에 의해 다음으로 transformed됩니다:
{ 1
;2 ;} 3;
이는 valid ECMAScript sentence입니다.
source
for (a; b
)
는 valid ECMAScript sentence가 아니며, semicolon이 for statement의 header에 needed되기 때문에 automatic semicolon insertion에 의해 altered되지 않습니다. Automatic semicolon insertion은 for statement의 header 안의 두 semicolon 중 하나를 never inserts하지 않습니다.
source
return
a + b
는 automatic semicolon insertion에 의해 다음으로 transformed됩니다:
return;
a + b;
Note 1
LineTerminator가 token return과 expression a + b를 separate하기 때문에, expression a + b는 return statement에 의해 returned될 value로 treated되지 않습니다.
source
a = b
++c
는 automatic semicolon insertion에 의해 다음으로 transformed됩니다:
a = b;
++c;
Note 2
LineTerminator가 b와 ++ 사이에 occur하기 때문에, token ++는 variable b에 applying되는 postfix operator로 treated되지 않습니다.
source
if (a > b)
else c = d
는 valid ECMAScript sentence가 아니며, grammar의 어떤 production도 그 point에 apply되지 않더라도, automatically inserted된 semicolon이 empty statement로 parsed될 것이기 때문에 else token 앞에서 automatic semicolon insertion에 의해 altered되지 않습니다.
source
a = b + c
(d + e).print()
는 not automatic semicolon insertion에 의해 transformed되지 않습니다. second line을 begin하는 parenthesized expression이 function call의 argument list로 interpreted될 수 있기 때문입니다:
a = b + c(d + e).print()
assignment statement가 left parenthesis로 begin해야 하는 circumstance에서는, programmer가 automatic semicolon insertion에 rely하기보다는 preceding statement의 end에 explicit semicolon을 provide하는 것이 good idea입니다.
12.10.3 Interesting Cases of Automatic Semicolon Insertion
This section is non-normative.
ECMAScript program은 automatic semicolon insertion에 relying함으로써 very few semicolon을 가진 style로 written될 수 있습니다. 위에 described된 것처럼, semicolon은 every newline에 inserted되지 않으며, automatic semicolon insertion은 line terminator를 across하는 multiple token에 depend할 수 있습니다.
새 syntactic feature가 ECMAScript에 added됨에 따라, automatic semicolon insertion에 preceding하여 relying하는 line이 parsed될 때 grammar production을 change하게 하는 additional grammar production이 added될 수 있습니다.
이 section의 purpose상, automatic semicolon insertion의 case는 preceding source text에 따라 semicolon이 inserted될 수도 있고 inserted되지 않을 수도 있는 place이면 interesting하다고 considered됩니다. 이 section의 rest는 이 version의 ECMAScript에서 automatic semicolon insertion의 여러 interesting case를 describe합니다.
12.10.3.1 Statement List 안의 Automatic Semicolon Insertion의 Interesting Cases
StatementList에서 많은 StatementListItem은 semicolon으로 end하며, 이는 automatic semicolon insertion을 사용하여 omitted될 수 있습니다. 위 rule의 consequence로, expression을 ending하는 line의 end에서는 following line이 다음 중 하나로 begin하면 semicolon이 required됩니다:
opening parenthesis((). semicolon이 없으면 두 line은 together CallExpression으로 treated됩니다.
template literal(`). semicolon이 없으면 두 line은 previous expression을 MemberExpression으로 하는 tagged Template(13.3.11)으로 interpreted됩니다.
Unary + 또는 -. semicolon이 없으면 두 line은 corresponding binary operator의 usage로 interpreted됩니다.
RegExp literal. semicolon이 없으면 두 line은 instead /MultiplicativeOperator로 parsed될 수 있습니다. 예를 들어 RegExp에 flag가 있는 경우입니다.
12.10.3.2 Automatic Semicolon Insertion 및 “[no LineTerminator here]”의 Cases
This section is non-normative.
ECMAScript는 “[no LineTerminator here]”를 include하는 grammar production을 contain합니다. 이러한 production은 때때로 grammar 안에서 optional operand를 가지기 위한 means입니다. 이러한 location에 LineTerminator를 introducing하면 optional operand가 없는 grammar production을 사용하여 source text의 grammar production을 change하게 됩니다.
이 section의 rest는 이 version의 ECMAScript에서 “[no LineTerminator here]”를 사용하는 여러 production을 describe합니다.
12.10.3.2.1 Optional Operand와 “[no LineTerminator here]”를 가진 Grammar Production의 List
yield와 await는 grammar에서 BindingIdentifier로 permitted되고, 아래 static semantics에 의해 prohibited됩니다. 이는 다음과 같은 case에서 automatic semicolon insertion을 prohibit하기 위한 것입니다.
ArrayLiteral은 square bracket으로 enclosed된, 각각 array element를 represent하는 0개 이상의 expression list를 사용하여 Array의 initialization을 describe하는 expression입니다. element는 literal일 필요가 없습니다; 이는 array initializer가 evaluated될 때마다 evaluated됩니다.
Array element는 element list의 beginning, middle 또는 end에서 elided될 수 있습니다. element list 안의 comma가 AssignmentExpression에 의해 preceded되지 않을 때마다(즉, beginning의 comma 또는 another comma 뒤의 comma), missing array element는 Array의 length에 contribute하고 subsequent element의 index를 increase합니다. Elided array element는 defined되지 않습니다. array의 end에서 element가 elided되면, 그 element는 Array의 length에 contribute하지 않습니다.
CreateDataPropertyOrThrow는 standard built-in Array prototype object가 [[Set]]을 사용한 new own property creation을 preclude하는 manner로 modified되었더라도 own property가 array에 defined되도록 ensure하기 위해 사용됩니다.
certain context에서 ObjectLiteral은 더 restricted된 secondary grammar를 위한 cover grammar로 사용됩니다. CoverInitializedName production은 이러한 secondary grammar를 fully cover하기 위해 necessary합니다. 그러나 이 production의 사용은 actual ObjectLiteral이 expected되는 normal context에서 early Syntax Error를 result합니다.
The syntax-directed operation PropertyDefinitionNodes takes no arguments and returns a List of Parse Nodes. It is defined piecewise over the following productions:
The syntax-directed operation PropertyNameList takes no arguments and returns a List of Strings. It is defined piecewise over the following productions:
The abstract operation IsValidRegularExpressionLiteral takes argument literal (a RegularExpressionLiteralParse Node) and returns a Boolean. argument가 valid regular expression literal인지 determine합니다. It performs the following steps when called:
The syntax-directed operation TemplateStrings takes argument raw (a Boolean) and returns a List of either Strings or undefined. It is defined piecewise over the following productions:
이 operation은 raw가 false이고 templateToken이 NotEscapeSequence를 contain하면 undefined를 반환합니다. 그 밖의 모든 경우에는 String을 반환합니다.
13.2.8.4 GetTemplateObject ( templateLiteral )
The abstract operation GetTemplateObject takes argument templateLiteral (a Parse Node) and returns an Array. It performs the following steps when called:
realm의 program code 안의 각 TemplateLiteral은 tagged Template의 evaluation(13.2.8.6)에 사용되는 unique template object와 associated됩니다. template object는 frozen되며, specific tagged Template이 evaluated될 때마다 같은 template object가 사용됩니다. template object가 TemplateLiteral의 first evaluation 시 lazily created되는지 또는 first evaluation 전에 eagerly created되는지는 ECMAScript code에는 observable하지 않은 implementation choice입니다.
Note 3
이 명세의 future edition은 template object의 additional non-enumerable property를 define할 수 있습니다.
이 algorithm은 Expression의 Evaluation에 GetValue를 apply하지 않습니다. 이에 대한 principal motivation은 delete 및 typeof 같은 operator가 parenthesized expression에 applied될 수 있도록 하기 위한 것입니다.
The abstract operation EvaluatePropertyAccessWithIdentifierKey takes arguments baseValue (an ECMAScript language value), identifierName (an IdentifierNameParse Node), and strict (a Boolean) and returns a Reference Record. It performs the following steps when called:
propertyNameString을 identifierName의 StringValue로 둔다.
The abstract operation EvaluateImportCall takes argument specifierExpr (a Parse Node) and optional argument optionsExpr (a Parse Node) and returns either a normal completion containing a Promise or an abrupt completion. It performs the following steps when called:
The abstract operation ContinueDynamicImport takes arguments promiseCapability (a PromiseCapability Record) and moduleCompletion (either a normal completion containing a Module Record or a throw completion) and returns unused. import() call에 의해 originally started된 dynamic import process를 complete하여, 해당 call이 반환한 promise를 appropriate하게 resolving하거나 rejecting합니다. It performs the following steps when called:
The host-defined abstract operation HostFinalizeImportMeta takes arguments importMeta (an Object) and moduleRecord (a Module Record) and returns unused. host가 import.meta에서 반환된 object를 prepare하기 위해 extraordinary operation을 perform할 수 있게 합니다.
대부분의 host는 단순히 HostGetImportMetaProperties를 define하고, HostFinalizeImportMeta를 default behaviour로 leave할 수 있습니다. 그러나 HostFinalizeImportMeta는 ECMAScript code에 exposed되기 전에 object를 직접 manipulate해야 하는 host를 위한 “escape hatch”를 제공합니다.
delete operator가 strict mode code 안에 occur할 때, 그 UnaryExpression이 variable, function argument 또는 function name에 대한 direct reference이면 SyntaxError exception이 throw됩니다. 또한 delete operator가 strict mode code 안에 occur하고 deleted될 property가 attribute { [[Configurable]]: false }를 가지면(또는 otherwise deleted될 수 없으면), TypeError exception이 throw됩니다.
Note 2
step 4.c에서 created될 수 있는 object는 위 abstract operation과 ordinary object[[Delete]] internal method 밖에서는 accessible하지 않습니다. implementation은 그 object의 actual creation을 avoid하도록 choose할 수 있습니다.
The abstract operation InstanceofOperator takes arguments value (an ECMAScript language value) and target (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. target의 %Symbol.hasInstance% method를 consult하거나, 그것이 absent하면 target의 "prototype" property의 value가 value의 prototype chain 안에 present한지를 determine하여, value가 target의 instance인지 determine하는 generic algorithm을 implements합니다. It performs the following steps when called:
A == B는 A와 B의 evaluation order를 제외하면 B == A와 equivalent합니다.
Note 2
equality operator는 항상 transitive하지는 않습니다. 예를 들어 같은 String value를 각각 representing하는 두 distinct String object가 있을 수 있습니다; 각 String object는 == operator에 의해 String value와 equal하다고 considered되지만, 두 String object는 서로 equal하지 않습니다. 예:
new String("a") == "a"와 "a" == new String("a")는 모두 true입니다.
new String("a") == new String("a")는 false입니다.
Note 3
String의 comparison은 code unit value의 sequence에 대한 simple equality test를 사용합니다. Unicode specification에 defined된 character 또는 string equality 및 collating order의 더 complex하고 semantically oriented한 definition을 사용하려는 attempt는 없습니다. 따라서 Unicode Standard에 따라 canonically equal한 String value가 unequal로 test될 수 있습니다. 사실상 이 algorithm은 두 String이 이미 normalized form에 있다고 assume합니다.
ECMAScript에서 ConditionalExpression의 grammar는 C 및 Java의 grammar와 약간 다릅니다. C와 Java는 second subexpression을 Expression으로 allow하지만 third expression은 ConditionalExpression으로 restrict합니다. ECMAScript에서 이 차이의 motivation은 conditional의 어느 arm이든 assignment expression에 의해 governed될 수 있도록 하고, centre expression으로서 comma expression이라는 confusing하고 fairly useless한 case를 eliminate하기 위한 것입니다.
이 expression이 strict mode code 안에 occur할 때, step 1.e, 3, 2, 2, 2의 leftRef가 unresolvable reference이면 runtime error입니다. 그러한 경우 ReferenceError exception이 throw됩니다. 추가로, step 9, 6, 6, 6의 leftRef가 attribute value { [[Writable]]: false }를 가진 data property에 대한 reference이거나, attribute value { [[Set]]: undefined }를 가진 accessor property에 대한 reference이거나, IsExtensible predicate가 value false를 반환하는 object의 non-existent property에 대한 reference이면 runtime error입니다. 이러한 경우 TypeError exception이 throw됩니다.
step 1.a 및 1.b의 ToPrimitive call에는 hint가 provided되지 않습니다. Date를 제외한 모든 standard object는 hint의 absence를 number가 given된 것처럼 handle합니다; Date는 hint의 absence를 string이 given된 것처럼 handle합니다. Exotic object는 hint의 absence를 다른 manner로 handle할 수 있습니다.
Note 2
step 1.c는 logical-and operation 대신 logical-or operation을 사용한다는 점에서 IsLessThan algorithm의 step 3와 다릅니다.
The abstract operation EvaluateStringOrNumericBinaryExpression takes arguments leftOperand (a Parse Node), opText (**, *, /, %, +, -, <<, >>, >>>, &, ^, or |), and rightOperand (a Parse Node) and returns either a normal completion containing either a String, a BigInt, or a Number, or an abrupt completion. It performs the following steps when called:
undefined가 envRecord로 passed되면 initialization value를 assign하기 위해 PutValue operation이 사용되어야 함을 indicate합니다. 이는 non-strict function의 formal parameter list의 경우입니다. 그 경우 formal parameter binding은 같은 name을 가진 multiple parameter의 possibility를 deal하기 위해 preinitialized됩니다.
It is defined piecewise over the following productions:
The abstract operation LoopContinues takes arguments completion (a Completion Record) and labelSet (a List of Strings) and returns a Boolean. It performs the following steps when called:
The abstract operation CreatePerIterationEnvironment takes argument perIterationBindings (a List of Strings) and returns either a normal completion containingunused or a throw completion. It performs the following steps when called:
perIterationBindings에 요소가 있으면,
lastIterationEnv를 실행 중인 실행 컨텍스트의 LexicalEnvironment라고 하자.
The abstract operation ForIn/OfBodyEvaluation takes arguments lhs (a Parse Node), stmt (a StatementParse Node), iteratorRecord (an Iterator Record), iterationKind (enumerate or iterate), lhsKind (assignment, var-binding, or lexical-binding), and labelSet (a List of Strings) and optional argument iteratorKind (sync or async) and returns either a normal completion containing an ECMAScript language value or an abrupt completion. It performs the following steps when called:
The abstract operation EnumerateObjectProperties takes argument obj (an Object) and returns an iterator object. It performs the following steps when called:
obj의 enumerable property의 모든 String-valued key를 iterate하는 next method를 가진 iterator object를 반환한다. iterator object는 ECMAScript code에 의해 never directly accessible하지 않다. property를 enumerating하는 mechanics와 order는 specified되어 있지 않지만, 아래 specified된 rule에 conform해야 한다.
iterator의 throw 및 return method는 null이며 never invoked되지 않습니다. iterator의 next method는 property key가 iterator value로 returned되어야 하는지 determine하기 위해 object property를 process합니다. returned property key는 Symbol인 key를 include하지 않습니다. target object의 property는 enumeration 중에 deleted될 수 있습니다. iterator의 next method에 의해 processed되기 전에 deleted된 property는 ignored됩니다. enumeration 중에 target object에 새 property가 added되면, newly added property가 active enumeration에서 processed된다는 guarantee는 없습니다. property name은 어떤 enumeration에서든 iterator의 next method에 의해 at most once returned됩니다.
target object의 property를 enumerating하는 것은 그 prototype의 property, 그 prototype의 prototype 등을 recursively enumerating하는 것을 include합니다; 그러나 prototype의 property는 같은 name을 가진 property가 iterator의 next method에 의해 이미 processed되었으면 processed되지 않습니다. prototype object의 property가 이미 processed되었는지 determine할 때 [[Enumerable]] attribute의 value는 considered되지 않습니다. prototype object의 enumerable property name은 prototype object를 argument로 passing하여 EnumerateObjectProperties를 invoking함으로써 obtained되어야 합니다. EnumerateObjectProperties는 target object의 [[OwnPropertyKeys]] internal method를 calling하여 own property key를 obtain해야 합니다. target object의 Property attribute는 그 [[GetOwnProperty]] internal method를 calling하여 obtained되어야 합니다.
obj 또는 그 prototype chain 안의 object의 [[Prototype]] internal slot의 value가 changes,
obj 또는 그 prototype chain 안의 object에서 property가 removed,
obj의 prototype chain 안의 object에 property가 added, 또는
obj 또는 그 prototype chain 안의 object의 property의 [[Enumerable]] attribute value가 changes.
Note 1
ECMAScript implementation은 14.7.5.10.2.1의 algorithm을 directly implement할 필요가 없습니다. previous paragraph의 constraint 중 하나가 violated되지 않는 한 그 algorithm에서 deviate하지 않을 behaviour를 가진 어떤 implementation이라도 choose할 수 있습니다.
다음은 이러한 rule에 conform하는 ECMAScript generator function의 informative definition입니다:
function* EnumerateObjectProperties(obj) {
const visited = newSet();
for (const key ofReflect.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 ofEnumerateObjectProperties(proto)) {
if (!visited.has(protoKey)) yield protoKey;
}
}
Note 2
implementation이 CreateForInIterator와 match할 필요가 없는 exotic object의 list는, implementation이 historically those case에서 behaviour가 differed했고, all others에서는 agreed했기 때문에 chosen되었습니다.
14.7.5.10 For-In Iterator Objects
For-In Iterator는 어떤 specific object에 대한 specific iteration을 represent하는 object입니다. For-In Iterator object는 ECMAScript code에 의해 never directly accessible하지 않으며, 오직 EnumerateObjectProperties의 behaviour를 illustrate하기 위해 존재합니다.
14.7.5.10.1 CreateForInIterator ( obj )
The abstract operation CreateForInIterator takes argument obj (an Object) and returns a For-In Iterator. obj의 own 및 inherited enumerable string property를 specific order로 iterate하는 For-In Iterator object를 create하는 데 사용됩니다. It performs the following steps when called:
이 ContinueStatement가 직접 또는 간접적으로(function 또는 static initialization block boundary를 crossing하지 않고) IterationStatement 안에 nested되어 있지 않으면 Syntax Error입니다.
return statement는 function이 execution을 cease하게 하고, 대부분의 경우 caller에게 value를 return합니다. Expression이 omitted되면, return value는 undefined입니다. 그렇지 않으면 return value는 Expression의 value입니다. surrounding context에 따라 return statement가 actually caller에게 value를 return하지 않을 수도 있습니다. 예를 들어 try block 안에서, return statement의 Completion Record는 finally block의 evaluation 중에 another Completion Record로 replaced될 수 있습니다.
with statement는 computed object에 대한 Object Environment Record를 running execution context의 lexical environment에 adds합니다. 그런 다음 이 augmented lexical environment를 사용하여 statement를 executes합니다. Finally, original lexical environment를 restores합니다.
이 operation은 caseClauseNode의 StatementList(있는 경우)를 execute하지 않습니다. CaseBlock algorithm은 어떤 StatementList를 executing 시작할지 determine하기 위해 그 return value를 사용합니다.
Statement는 label로 prefixed될 수 있습니다. Labelled statement는 labelled break 및 continue statement와 conjunction에서만 사용됩니다. ECMAScript에는 goto statement가 없습니다. Statement는 LabelledStatement의 part가 될 수 있고, 그 자체가 LabelledStatement의 part가 될 수 있으며, 이런 식으로 계속될 수 있습니다. 이런 way로 introduced된 label은 individual statement의 semantics를 describing할 때 collectively “current label set”이라고 referred됩니다.
The abstract operation IsLabelledFunction takes argument stmt (a StatementParse Node) and returns a Boolean. It performs the following steps when called:
try statement는 runtime error 또는 throw statement와 같은 exceptional condition이 occur할 수 있는 code block을 encloses합니다. catch clause는 exception-handling code를 제공합니다. catch clause가 exception을 catches하면, 그 CatchParameter가 해당 exception에 bound됩니다.
DebuggerStatement를 evaluating하면 implementation이 debugger 아래에서 run될 때 breakpoint를 cause할 수 있습니다. debugger가 present하지 않거나 active하지 않으면 이 statement는 observable effect를 가지지 않습니다.
다양한 ECMAScript language element는 ECMAScript function object(10.2)의 creation을 cause합니다. 그러한 function의 Evaluation은 그 [[Call]] internal method(10.2.1)의 execution으로 시작됩니다.
The syntax-directed operation ExpectedArgumentCount takes no arguments and returns a non-negative integer. It is defined piecewise over the following productions:
FormalParameterList의 ExpectedArgumentCount는 rest parameter 또는 Initializer를 가진 first FormalParameter의 left에 있는 FormalParameters의 수입니다. initializer가 없는 FormalParameter는 initializer를 가진 first parameter 뒤에 allowed되지만, 그러한 parameter는 undefined를 default value로 하는 optional parameter로 considered됩니다.
The syntax-directed operation FunctionBodyContainsUseStrict takes no arguments and returns a Boolean. It is defined piecewise over the following productions:
The syntax-directed operation ConciseBodyContainsUseStrict takes no arguments and returns a Boolean. It is defined piecewise over the following productions:
ArrowFunction은 arguments, super, this 또는 new.target을 위한 local binding을 define하지 않습니다. ArrowFunction 안의 arguments, super, this 또는 new.target에 대한 모든 reference는 lexically enclosing environment 안의 binding으로 resolve되어야 합니다. 보통 이는 immediately enclosing function의 Function Environment입니다. ArrowFunction이 super에 대한 reference를 contain할 수 있더라도, step 5에서 created되는 function object는 MakeMethod를 수행하여 method로 만들어지지 않습니다. super를 reference하는 ArrowFunction은 항상 non-ArrowFunction 안에 contained되며, super를 implement하는 데 필요한 state는 ArrowFunction의 function object가 capture하는 envRecord를 통해 accessible합니다.
ClassElementList의 PrivateBoundIdentifiers가 duplicate entry를 contain하면 Syntax Error입니다. 단, name이 getter에 한 번, setter에 한 번 사용되고 다른 entry에는 사용되지 않으며, getter와 setter가 둘 다 static이거나 둘 다 non-static인 경우는 예외입니다.
The syntax-directed operation ClassElementKind takes no arguments and returns constructor-method, non-constructor-method, or empty. It is defined piecewise over the following productions:
The syntax-directed operation PrivateBoundIdentifiers takes no arguments and returns a List of Strings. It is defined piecewise over the following productions:
specification의 ease를 위해, private method와 accessor는 private field와 함께 class instance의 [[PrivateElements]] slot에 included됩니다. 그러나 given object는 given class에 의해 defined된 private method 및 accessor를 모두 가지거나 전혀 가지지 않습니다. 이 feature는 implementation이 각 method 또는 accessor를 individual하게 tracking할 필요가 없는 strategy를 사용하여 private method와 accessor를 implement하도록 choose할 수 있게 designed되었습니다.
예를 들어, implementation은 instance private method를 그 corresponding Private Name과 직접 associate하고, 각 object에 대해 어느 class constructor가 그 object를 this value로 사용하여 run되었는지를 track할 수 있습니다. 그러면 object에서 instance private method를 looking up하는 것은 method를 define하는 class constructor가 object를 initialize하는 데 사용되었는지 checking한 다음, Private Name과 associated된 method를 returning하는 것으로 구성됩니다.
이는 private field와 다릅니다: field initializer는 class instantiation 중에 throw할 수 있으므로, individual object는 given class의 private field의 proper subset만 가질 수 있고, 따라서 private field는 일반적으로 individual하게 tracked되어야 합니다.
It is defined piecewise over the following productions:
NOTE: 이 분기는 constructor(...args) { super(...args); }와 유사하게 동작한다. 가장 두드러진 차이점은 앞의 ECMAScript 소스 텍스트는 관찰 가능하게 %Array.prototype%의 %Symbol.iterator% 메서드를 호출하지만, 이 함수는 그렇지 않다는 점이다.
[Await] parameter가 present할 때 await는 AwaitExpression의 keyword로 parsed됩니다. [Await] parameter는 다음 context의 top level에서 present하지만, FunctionBody와 같은 nonterminal에 따라 일부 context에서는 parameter가 absent할 수 있습니다:
The syntax-directed operation AsyncConciseBodyContainsUseStrict takes no arguments and returns a Boolean. It is defined piecewise over the following productions:
The abstract operation PrepareForTailCall takes no arguments and returns unused. It performs the following steps when called:
Assert: current execution context는 이후 어떤 ECMAScript code 또는 built-in function의 evaluation에도 사용되지 않는다. 이 abstract operation의 invocation 이후 Call의 invocation은 그러한 evaluation을 수행하기 전에 new execution context를 create하고 push할 것이다.
tail position call은 target function을 invoking하기 전에 currently executing function execution context와 associated된 모든 transient internal resource를 release하거나, target function을 support하기 위해 그러한 resource를 reuse해야 합니다.
Note
예를 들어, tail position call은 target function의 activation record size가 calling function의 activation record size를 초과하는 amount만큼만 implementation의 activation record stack을 grow해야 합니다. target function의 activation record가 더 작으면, stack의 total size는 decrease해야 합니다.
이 script에 의해 imported된 specifier string에서 resolved Module Record로의 map입니다. list는 ModuleRequestsEqual(r1, r2)이 true인 두 different Recordr1 및 r2를 contain하지 않습니다.
[[HostDefined]]
anything (default value is empty)
script와 additional information을 associate해야 하는 host environment가 use하기 위해 reserved된 field입니다.
The abstract operation ParseScript takes arguments sourceText (a String or a sequence of Unicode code points), realm (a Realm Record), and hostDefined (anything) and returns a Script Record or a non-empty List of SyntaxError objects. sourceText를 Script로 parsing한 result를 기반으로 Script Record를 create합니다. It performs the following steps when called:
implementation은 해당 script source text에 대해 ParseScript를 evaluation하기 전에 script source text를 parse하고 Early Error condition에 대해 analyse할 수 있습니다. 그러나 any error의 reporting은 이 specification이 실제로 해당 source text에 대해 ParseScript를 수행하는 point까지 deferred되어야 합니다.
script를 evaluating하기 위해 execution context가 established될 때, declaration은 current global environment 안에서 instantiated됩니다. code 안에 declared된 각 global binding이 instantiated됩니다.
NOTE: 전역 객체가 ordinary object이면 이 알고리즘 단계 이후에는 abnormal termination이 발생하지 않는다. 하지만 전역 객체가 Proxy exotic object이면 다음 단계 중 일부에서 abnormal termination을 유발하는 동작을 보일 수 있다.
16.1.1에 specified된 early error는 single Script 안에 contained된 declaration에 대해 function/var declaration과 let/const/class declaration 사이의 name conflict 및 let/const/class binding의 redeclaration을 prevent합니다. 그러나 둘 이상의 Script에 걸친 such conflict와 redeclaration은 GlobalDeclarationInstantiation 동안 runtime error로 detected됩니다. 그러한 error가 detected되면, script에 대해 어떤 binding도 instantiated되지 않습니다. 그러나 global object가 Proxy exotic object를 사용하여 defined된 경우 conflicting declaration에 대한 runtime test가 unreliable할 수 있으며, 그 결과 abrupt completion과 some global declaration이 instantiated되지 않을 수 있습니다. 이것이 occur하면 Script의 code는 evaluated되지 않습니다.
explicit var 또는 function declaration과 달리, global object에 directly created된 property는 let/const/class declaration에 의해 shadowed될 수 있는 global binding을 result합니다.
The abstract operation ImportedLocalNames takes argument importEntries (a List of ImportEntry Records) and returns a List of Strings. importEntries에 의해 defined된 모든 local name binding의 List를 create합니다. It performs the following steps when called:
Module Record는 single module의 import와 export에 대한 structural information을 encapsulate합니다. 이 information은 connected module의 set의 import와 export를 link하는 데 사용됩니다. Module Record는 module을 evaluating할 때만 사용되는 네 개의 field를 include합니다.
specification 목적상 Module Record value는 Record specification type의 value이며, Module Record가 abstract 및 concrete subclass를 모두 가진 abstract class인 simple object-oriented hierarchy 안에 existing한다고 생각할 수 있습니다. 이 specification은 Cyclic Module Record라는 abstract subclass와 그 concrete subclass인 Source Text Module Record를 define합니다. 다른 specification 및 implementation은 자신이 defined한 alternative module definition facility에 corresponding하는 additional Module Record subclass를 define할 수 있습니다.
Module Record는 Table 39에 listed된 field를 define합니다. 모든 Module Definition subclass는 적어도 those field를 include합니다. Module Record는 또한 Table 40의 abstract method list를 define합니다. 모든 Module definition subclass는 these abstract method의 concrete implementation을 provide해야 합니다.
The abstract method ResolveExport takes argument exportName (a String) and optional argument resolveSet (a List of Records with fields [[Module]] (a Module Record) and [[ExportName]] (a String)) and returns a ResolvedBinding Record, null, or ambiguous.
이 module이 exported한 name의 binding을 반환합니다. Binding은 { [[Module]]: Module Record, [[BindingName]]: String | namespace } form의 ResolvedBinding Record로 represented됩니다. export가 any module 안의 direct binding 없이 Module Namespace Object인 경우, [[BindingName]]은 namespace로 set됩니다. name이 resolved될 수 없으면 null을 반환하고, multiple binding이 found되면 ambiguous를 반환합니다.
이 operation이 specific exportName, resolveSet pair를 argument로 하여 called될 때마다 same result를 반환해야 합니다.
The abstract method Evaluate takes no arguments and returns a Promise.
이 module 및 그 dependency의 evaluation을 위한 promise를 반환하며, successful evaluation 또는 이미 successfully evaluated된 경우 resolve하고, evaluation error 또는 이미 unsuccessfully evaluated된 경우 reject합니다. promise가 rejected되면, host는 promise rejection을 handle하고 evaluation error를 rethrow할 것으로 expected됩니다. 이 module이 Cyclic Module Record가 아닌 한, returned promise는 already settled되어야 합니다.
이 method를 invoking하기 전에 Link는 successfully completed되어야 합니다.
이 specification 안에서는 다음 type에 definition이 있습니다; host는 own definition을 가진 additional type을 provide할 수 있습니다:
The abstract operation EvaluateModuleSync takes argument module (a Module Record) and returns either a normal completion containingunused or a throw completion. caller가 module의 evaluation이 already settled promise를 return할 것임을 guarantee하는 경우, module을 synchronously evaluate합니다. It performs the following steps when called:
Link와 Evaluate 중에만 사용되는 auxiliary field입니다. [[Status]]가 linking 또는 evaluating 중 하나이면, 이것은 module의 depth-first traversal index이거나 same strongly connected component 안의 “earlier” module의 것입니다.
이 record가 represented하는 module이 relative import attribute와 함께 module importation을 request하기 위해 사용한 specifier string에서 resolved Module Record로의 map입니다. list는 ModuleRequestsEqual(r1, r2)이 true인 두 different Recordr1 및 r2를 contain하지 않습니다.
cycle의 first visited module, strongly connected component의 root DFS ancestor입니다. cycle 안에 있지 않은 module의 경우, 이는 module 자체일 것입니다. Evaluate가 completed되면, module의 [[DFSAncestorIndex]]는 그 [[CycleRoot]]의 depth-first traversal index입니다.
[[HasTLA]]
a Boolean
이 module이 individually asynchronous인지 여부입니다(예를 들어 top-level await를 contain하는 Source Text Module Record인 경우). asynchronous dependency를 가진다는 것이 이 field가 true임을 의미하지는 않습니다. 이 field는 module이 parsed된 후 change되어서는 안 됩니다.
이 module이 어떤 cycle의 [[CycleRoot]]이고, Evaluate()가 그 cycle 안의 어떤 module에 대해 called된 경우, 이 field는 entire evaluation에 대한 PromiseCapability Record를 contain합니다. 이는 Evaluate() abstract method에서 returned되는 Promise object를 settle하는 데 사용됩니다. 이 field는 그 module의 dependency에 대해서는 empty일 것이며, 단 those dependency 중 일부에 대해 top-level Evaluate()가 initiated된 경우는 제외합니다.
이 module 또는 dependency가 [[HasTLA]]true를 가지고 execution이 in progress이면, top-level execution job에 대해 이 module의 parent importer를 track합니다. 이러한 parent module은 이 module이 successfully completed execution하기 전에 executing을 start하지 않습니다.
이 module이 asynchronous dependency를 가진 경우, 이 module을 위해 execute될 remaining asynchronous dependency module의 수를 track합니다. asynchronous dependency를 가진 module은 이 field가 0에 reach하고 execution error가 없을 때 executed됩니다.
module의 execution context 안에서 module의 code를 evaluate합니다. 이 module이 [[HasTLA]] 안에 true를 가지면, PromiseCapability Record가 argument로 passed되고, method는 given capability를 resolve하거나 reject할 것으로 expected됩니다. 이 경우 method는 exception을 throw해서는 안 되고, 필요하면 PromiseCapability Record를 reject해야 합니다.
이 specification 안에서는 다음 type에 definition이 있습니다; host는 own definition을 가진 additional type을 provide할 수 있습니다:
The LoadRequestedModules concrete method of a Cyclic Module Recordmodule takes optional argument hostDefined (anything) and returns a Promise. module의 dependency graph 안의 모든 Module Record의 [[LoadedModules]]를 populate합니다(work의 대부분은 auxiliary function InnerModuleLoading에 의해 done됩니다). HostLoadImportedModule hook에 passed되는 optional hostDefined parameter를 받습니다. It performs the following steps when called:
hostDefined parameter는 imported module을 fetch하는 데 necessary한 additional information을 pass하는 데 사용될 수 있습니다. 예를 들어 HTML에서는 <link rel="preload" as="..."> tag에 대한 correct fetch destination을 set하는 데 사용됩니다.
import() expression은 hostDefined parameter를 never set하지 않습니다.
The abstract operation InnerModuleLoading takes arguments state (a GraphLoadingState Record) and module (a Module Record) and returns unused. LoadRequestedModules가 module의 dependency graph에 대한 actual loading process를 recursively 수행하는 데 사용됩니다. It performs the following steps when called:
! Call(state.[[PromiseCapability]].[[Reject]], undefined, « moduleCompletion.[[Value]] »)를 수행한다.
unused를 반환한다.
16.2.1.6.1.2 Link ( )
The Link concrete method of a Cyclic Module Recordmodule takes no arguments and returns either a normal completion containingunused or a throw completion. success 시, Link는 이 module의 [[Status]]를 unlinked에서 linked로 transition합니다. failure 시, exception이 thrown되고 이 module의 [[Status]]는 unlinked로 remain합니다. (work의 대부분은 auxiliary function InnerModuleLinking에 의해 done됩니다.) It performs the following steps when called:
Assert: module.[[Status]]는 unlinked, linked, evaluating-async 또는 evaluated 중 하나이다.
16.2.1.6.1.2.1 InnerModuleLinking ( module, stack, index )
The abstract operation InnerModuleLinking takes arguments module (a Module Record), stack (a List of Cyclic Module Records), and index (a non-negative integer) and returns either a normal completion containing a non-negative integer or a throw completion. Link가 module에 대한 actual linking process를 수행하고, dependency graph 안의 모든 다른 module에 대해 recursively 수행하는 데 사용됩니다. stack 및 index parameter와 module의 [[DFSAncestorIndex]] field는 depth-first search (DFS) traversal을 keep track합니다. 특히 [[DFSAncestorIndex]]는 strongly connected component (SCC)를 discover하는 데 사용되어, SCC 안의 모든 module이 together linked로 transition하도록 합니다. It performs the following steps when called:
requiredModule과 module이 same Module Record이면, done을 true로 설정한다.
index를 반환한다.
16.2.1.6.1.3 Evaluate ( )
The Evaluate concrete method of a Cyclic Module Recordmodule takes no arguments and returns a Promise. Evaluate는 이 module의 [[Status]]를 linked에서 evaluating-async 또는 evaluated로 transition합니다. given strongly connected component 안의 module에서 first time called되면, Evaluate는 module이 evaluating을 finished할 때 resolve되는 Promise를 create하고 반환합니다. 이 Promise는 component의 [[CycleRoot]]의 [[TopLevelCapability]] field에 stored됩니다. component 안의 any module에 대한 future invocation of Evaluate는 same Promise를 반환합니다. (work의 대부분은 auxiliary function InnerModuleEvaluation에 의해 done됩니다.) It performs the following steps when called:
16.2.1.6.1.3.1 InnerModuleEvaluation ( module, stack, index )
The abstract operation InnerModuleEvaluation takes arguments module (a Module Record), stack (a List of Cyclic Module Records), and index (a non-negative integer) and returns either a normal completion containing a non-negative integer or a throw completion. Evaluate가 module에 대한 actual evaluation process를 수행하고, dependency graph 안의 모든 다른 module에 대해 recursively 수행하는 데 사용됩니다. stack 및 index parameter와 module의 [[DFSAncestorIndex]] field는 InnerModuleLinking에서와 same way로 사용됩니다. It performs the following steps when called:
그렇지 않으면, requiredModule.[[Status]]를 evaluating-async로 설정한다.
requiredModule과 module이 same Module Record이면, done을 true로 설정한다.
requiredModule.[[CycleRoot]]를 module로 설정한다.
index를 반환한다.
Note 1
module은 InnerModuleEvaluation에 의해 traversed되는 동안 evaluating입니다. module은 execution completion 시 evaluated가 되거나, [[HasTLA]] field가 true이거나 asynchronous dependency를 가진 경우 execution 중 evaluating-async가 됩니다.
Note 2
asynchronous cycle의 module에 depending하는 any module은 that cycle이 evaluating이 아닐 때, 대신 [[CycleRoot]]를 통해 cycle root의 execution에 depend합니다. 이는 cycle state가 root module state를 통해 single strongly connected component로 treated될 수 있음을 ensure합니다.
16.2.1.6.1.3.2 ExecuteAsyncModule ( module )
The abstract operation ExecuteAsyncModule takes argument module (a Cyclic Module Record) and returns unused. It performs the following steps when called:
Assert: module.[[Status]]는 evaluating 또는 evaluating-async 중 하나이다.
The abstract operation GatherAvailableAncestors takes arguments module (a Cyclic Module Record) and execList (a List of Cyclic Module Records) and returns unused. It performs the following steps when called:
module.[[AsyncParentModules]]의 각 Cyclic Module RecordancestorModule에 대해, 다음을 수행한다.
execList가 ancestorModule을 contain하지 않고 ancestorModule.[[CycleRoot]].[[EvaluationError]]가 empty이면, 다음을 수행한다.
root module에 대한 asynchronous execution이 fulfilled될 때, 이 function은 이 completion에서 synchronously execute together할 수 있는 module의 list를 determine하여 execList에 populate합니다.
The abstract operation AsyncModuleExecutionFulfilled takes argument module (a Cyclic Module Record) and returns unused. It performs the following steps when called:
The abstract operation AsyncModuleExecutionRejected takes arguments module (a Cyclic Module Record) and error (an ECMAScript language value) and returns unused. It performs the following steps when called:
이 non-normative section은 몇 가지 common module graph의 linking 및 evaluation 예제를, error가 어떻게 occur할 수 있는지에 specific focus를 두고 제공합니다.
먼저 다음 simple module graph를 consider하십시오:
Figure 2: A simple module graph
먼저 error condition이 없다고 assume합시다. host가 first A.LoadRequestedModules()를 call하면, 이는 assumption에 따라 successfully complete하고, B와 C의 dependency도 respectively recursively load하며(각각 C와 none), 그런 다음 A.[[Status]] = B.[[Status]] = C.[[Status]] = unlinked로 set합니다. 그 다음 host가 A.Link()를 call하면, 이는 (again by assumption) successfully complete하여 A.[[Status]] = B.[[Status]] = C.[[Status]] = linked가 됩니다. 이러한 preparatory step은 any time에 performed될 수 있습니다. Later, host가 module의 any possible side effect를 incur할 준비가 되면 A.Evaluate()를 call할 수 있으며, 이는 successfully complete하고 undefined로 resolving되는 Promise를 반환하며(again by assumption), recursively first C then B를 evaluated하게 됩니다. 이 point에서 각 module의 [[Status]]는 evaluated가 됩니다.
그 다음 A.LoadRequestedModules()의 successful call 이후 linking error가 involving된 case를 consider하십시오. C의 InnerModuleLinking이 succeeds하지만, thereafter B에 대해 fails하면, 예를 들어 C가 provide하지 않는 something을 import하기 때문이면, original A.Link()는 fail하고 A와 B의 [[Status]]는 unlinked로 remain합니다. 그러나 C의 [[Status]]는 linked가 되었습니다.
Finally, Link()의 successful call 이후 evaluation error가 involving된 case를 consider하십시오. C의 InnerModuleEvaluation이 succeeds하지만, thereafter B에 대해 fails하면, 예를 들어 B가 exception을 throw하는 code를 contain하기 때문이면, original A.Evaluate()는 fail하고 rejected Promise를 return합니다. resulting exception은 A와 B의 [[EvaluationError]] field 둘 다에 recorded되고, 그 [[Status]]는 evaluated가 됩니다. C 역시 evaluated가 되지만, A와 B와 달리 evaluation을 successfully completed했으므로 [[EvaluationError]] 없이 remain합니다. exception을 storing하면 host가 their Evaluate() method를 calling하여 A 또는 B를 reuse하려 할 때마다 same exception을 encounter하도록 ensure합니다. (Host는 Cyclic Module Record를 reuse할 필요가 없습니다; similarly, host는 이러한 method에 의해 thrown된 exception object를 expose할 필요도 없습니다. 그러나 specification은 such use를 enable합니다.)
이제 다른 type의 error condition을 consider하십시오:
Figure 3: A module graph with an unresolvable module
이 scenario에서 module A는 어떤 다른 module에 대한 dependency를 declare하지만, 그 module에 대한 Module Record가 존재하지 않습니다. 즉, HostLoadImportedModule은 그것을 요청받았을 때 exception과 함께 FinishLoadingImportedModule을 call합니다. 이는 corresponding resource가 존재하지 않거나, resource는 존재하지만 resulting source text를 parse하려고 할 때 ParseModule이 some errors를 return하는 등 다양한 reason으로 occur할 수 있습니다. Host는 FinishLoadingImportedModule에 pass하는 completion을 통해 failure의 cause를 expose하도록 choose할 수 있습니다. 어떤 경우든, 이 exception은 loading failure를 cause하고, 그 결과 A의 [[Status]]는 new로 remain합니다.
여기서 loading, linking 및 evaluation error 사이의 difference는 다음 characteristic 때문입니다:
Evaluation은 side effect를 cause할 수 있으므로 only once performed되어야 합니다; 따라서 evaluation이 already performed되었는지, even unsuccessfully라도 remember하는 것이 important합니다. (error case에서는 subsequent Evaluate() call이 new one을 synthesize해야 하지 않도록 exception도 remember하는 것이 makes sense합니다.)
반면 Linking은 side-effect-free이므로, fail하더라도 later time에 issue 없이 retried될 수 있습니다.
Loading은 host와 closely interact하며, 일부 host는 failed load를 retry하도록 users에게 allow하는 것이 desirable할 수 있습니다(예를 들어 failure가 temporarily bad network condition에 의해 caused된 경우).
이제 cycle을 가진 module graph를 consider하십시오:
Figure 4: A cyclic module graph
여기서는 entry point가 module A라고 assume하므로, host는 A.LoadRequestedModules()를 calling하여 proceed하고, 이는 A에 대해 InnerModuleLoading을 수행합니다. 이것은 다시 B와 C에 대해 InnerModuleLoading을 call합니다. cycle 때문에, 이는 다시 A에 대해 InnerModuleLoading을 trigger하지만, 이 point에서는 A의 dependency loading이 이 LoadRequestedModules process 중에 already triggered되었으므로 no-op입니다. graph 안의 모든 module이 successfully loaded되면, their [[Status]]는 same time에 new에서 unlinked로 transition합니다.
Then host는 A.Link()를 calling하여 proceed하고, 이는 A에 대해 InnerModuleLinking을 수행합니다. 이것은 다시 B에 대해 InnerModuleLinking을 call합니다. cycle 때문에, 이는 다시 A에 대해 InnerModuleLinking을 trigger하지만, 이 point에서는 A.[[Status]]가 already linking이므로 no-op입니다. control이 A로 돌아오고 InnerModuleLinking이 C에 대해 triggered될 때 B.[[Status]] 자체는 linking으로 remain합니다. 이것이 return하여 C.[[Status]]가 linked가 된 후, A와 B는 together linking에서 linked로 transition합니다; 이것은 by design이며, they form a strongly connected component이기 때문입니다. 이 phase 중에는 module graph가 depth-first search로 traversed되므로 same SCC 안의 module status를 same time에 transition하는 것이 possible합니다.
이제 A에 linking error가 있는 case를 consider하십시오; 예를 들어, it tries to import a binding from C that does not exist. 이 경우, above step은 still occur하며, InnerModuleLinking on A의 second call로부터 early return도 include합니다. 그러나 original InnerModuleLinking on A로 unwind back하면, InitializeEnvironment 중에, namely C.ResolveExport() right after에 fail합니다. thrown SyntaxError exception은 A.Link로 propagate되고, 이는 currently its stack에 있는 모든 module을 reset합니다(these are always exactly the modules that are still linking). 따라서 A와 B 둘 다 unlinked가 됩니다. C는 linked로 left됨에 note하십시오.
Alternatively, A에 evaluation error가 있는 case를 consider하십시오; 예를 들어, 그 source code가 exception을 throw합니다. 이 경우, evaluation-time analogue of the above step은 still occur하며, InnerModuleEvaluation on A의 second call로부터 early return도 include합니다. 그러나 original InnerModuleEvaluation on A로 unwind back하면, assumption에 따라 fail합니다. thrown exception은 A.Evaluate()로 propagate되고, 이는 currently its stack에 있는 모든 module(즉, still evaluating인 module)에 error를 record할 뿐 아니라, top-level await를 contain하거나 depend하는 module을 위해 whole dependency graph를 통해 chain을 form하는 [[AsyncParentModules]]를 통해서도 record합니다. 이는 AsyncModuleExecutionRejected algorithm을 통해 이루어집니다. 따라서 A와 B 둘 다 evaluated가 되고 exception은 A와 B의 [[EvaluationError]] field 둘 다에 recorded되며, C는 [[EvaluationError]] 없이 evaluated로 left됩니다.
마지막으로, 모든 module이 asynchronously complete하는 cycle을 가진 module graph를 consider하십시오:
Figure 5: An asynchronous cyclic module graph
Loading 및 linking은 before와 같이 happen하며, 모든 module은 [[Status]]가 linked로 set되어 end up합니다.
A.Evaluate()를 calling하면 A, B, 및 D에 대해 InnerModuleEvaluation을 call하며, 이들은 모두 evaluating으로 transition합니다. Then InnerModuleEvaluation이 A에 대해 다시 called되며, it is already evaluating이므로 no-op입니다. 이 point에서 D.[[PendingAsyncDependencies]]는 0이므로 ExecuteAsyncModule(D)가 called되고, D의 asynchronous execution을 tracking하는 new PromiseCapability와 함께 D.ExecuteModule을 call합니다. B에 대한 InnerModuleEvaluation으로 unwind back하여 B.[[PendingAsyncDependencies]]를 1로 set하고 B.[[AsyncEvaluationOrder]]를 1로 set합니다. original InnerModuleEvaluation on A로 unwind back하여 A.[[PendingAsyncDependencies]]를 1로 set합니다. A의 dependency에 대한 loop의 next iteration에서, C 그리고 thus D(again no-op)와 E에 대해 InnerModuleEvaluation을 call합니다. E는 dependency가 없고 cycle의 part가 아니므로, D와 same manner로 ExecuteAsyncModule(E)을 call하고 E는 immediately stack에서 removed됩니다. 다시 한 번 C에 대한 InnerModuleEvaluation으로 unwind하여 C.[[AsyncEvaluationOrder]]를 3으로 set합니다. 이제 A의 dependency에 대한 loop를 finish하고, A.[[AsyncEvaluationOrder]]를 4로 set하며, entire strongly connected component를 stack에서 remove하여 모든 module을 at once evaluating-async로 transition합니다. 이 point에서 module의 field는 Table 44에 given된 것과 같습니다.
Table 44: Module fields after the initial Evaluate() call
Field
Module
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가 first로 executing을 finish한다고 assume합시다. 그것이 happen하면, AsyncModuleExecutionFulfilled가 called되고, E.[[Status]]는 evaluated로 set되며 C.[[PendingAsyncDependencies]]는 decremented되어 1이 됩니다. updated module의 field는 Table 45에 given된 것과 같습니다.
Table 45: Module fields after module E finishes executing
Field
Module
C
E
[[DFSAncestorIndex]]
0
4
[[Status]]
evaluating-async
evaluated
[[AsyncEvaluationOrder]]
3
done
[[AsyncParentModules]]
« A »
« C »
[[PendingAsyncDependencies]]
1 (D)
0
D가 next로 finish합니다(아직 executing 중인 only module이었으므로). 그것이 happen하면, AsyncModuleExecutionFulfilled가 again called되고 D.[[Status]]는 evaluated로 set됩니다. execution에 available한 its ancestor는 B([[AsyncEvaluationOrder]]가 1)와 C([[AsyncEvaluationOrder]]가 3)이므로, B가 first handled됩니다: B.[[PendingAsyncDependencies]]는 decremented되어 0이 되고, ExecuteAsyncModule이 B에 대해 called되며, it starts executing. C.[[PendingAsyncDependencies]]도 decremented되어 0이 되고, C가 executing을 start합니다(B가 await를 contain하면 potentially in parallel to B). updated module의 field는 Table 46에 given된 것과 같습니다.
Table 46: Module fields after module D finishes executing
Field
Module
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가 next로 executing을 finish한다고 assume합시다. 그것이 happen하면, AsyncModuleExecutionFulfilled가 again called되고, C.[[Status]]는 evaluated로 set되며 A.[[PendingAsyncDependencies]]는 decremented되어 1이 됩니다. updated module의 field는 Table 47에 given된 것과 같습니다.
Table 47: Module fields after module C finishes executing
Field
Module
A
C
[[DFSAncestorIndex]]
0
0
[[Status]]
evaluating-async
evaluated
[[AsyncEvaluationOrder]]
4
done
[[AsyncParentModules]]
« »
« A »
[[PendingAsyncDependencies]]
1 (B)
0
Then, B가 executing을 finish합니다. 그것이 happen하면, AsyncModuleExecutionFulfilled가 again called되고 B.[[Status]]는 evaluated로 set됩니다. A.[[PendingAsyncDependencies]]는 decremented되어 0이 되므로, ExecuteAsyncModule이 called되고 it starts executing. updated module의 field는 Table 48에 given된 것과 같습니다.
Table 48: Module fields after module B finishes executing
Field
Module
A
B
[[DFSAncestorIndex]]
0
0
[[Status]]
evaluating-async
evaluated
[[AsyncEvaluationOrder]]
4
done
[[AsyncParentModules]]
« »
« A »
[[PendingAsyncDependencies]]
0
0
Finally, A가 executing을 finish합니다. 그것이 happen하면, AsyncModuleExecutionFulfilled가 again called되고 A.[[Status]]는 evaluated로 set됩니다. 이 point에서 A.[[TopLevelCapability]] 안의 Promise(A.Evaluate()에서 returned된 것)가 resolved되고, 이것으로 이 module graph의 handling이 conclude됩니다. updated module의 field는 Table 49에 given된 것과 같습니다.
Table 49: Module fields after module A finishes executing
Field
Module
A
[[DFSAncestorIndex]]
0
[[Status]]
evaluated
[[AsyncEvaluationOrder]]
done
[[AsyncParentModules]]
« »
[[PendingAsyncDependencies]]
0
Alternatively, C가 B가 executing을 finished하기 전에 execution에 fail하고 error를 return하는 failure case를 consider하십시오. 그것이 happen하면, AsyncModuleExecutionRejected가 called되고, 이는 C.[[Status]]를 evaluated로 set하고 C.[[EvaluationError]]를 error로 set합니다. 그런 다음 각 AsyncParentModules에 대해 AsyncModuleExecutionRejected를 수행하여 이 error를 all AsyncParentModules에 propagate합니다. updated module의 field는 Table 50에 given된 것과 같습니다.
Table 50: Module fields after module C finishes with an error
Field
Module
A
C
[[DFSAncestorIndex]]
0
0
[[Status]]
evaluated
evaluated
[[AsyncEvaluationOrder]]
done
done
[[AsyncParentModules]]
« »
« A »
[[PendingAsyncDependencies]]
1 (B)
0
[[EvaluationError]]
empty
C의 evaluation error
C가 C의 error와 함께 A에 대해 AsyncModuleExecutionRejected를 call하므로, A는 C와 same error로 rejected될 것입니다. A.[[Status]]는 evaluated로 set됩니다. 이 point에서 A.[[TopLevelCapability]] 안의 Promise(A.Evaluate()에서 returned된 것)가 rejected됩니다. updated module의 field는 Table 51에 given된 것과 같습니다.
Table 51: Module fields after module A is rejected
Then, B가 error 없이 executing을 finish합니다. 그것이 happen하면, AsyncModuleExecutionFulfilled가 again called되고 B.[[Status]]는 evaluated로 set됩니다. GatherAvailableAncestors가 B에 대해 called됩니다. 그러나 A.[[CycleRoot]]는 evaluation error를 가진 A이므로, returned sortedExecList에 added되지 않고 AsyncModuleExecutionFulfilled는 further processing 없이 return합니다. B의 any future importer는 cycle root A에 set된 C의 evaluation error에서 B.[[CycleRoot]].[[EvaluationError]]의 rejection을 resolve할 것입니다. updated module의 field는 Table 52에 given된 것과 같습니다.
Table 52: Module fields after module B finishes executing in an erroring graph
Source Text Module Record는 goal symbolModule을 사용하여 parsed된 ECMAScript source text(11)에서 defined된 module에 대한 information을 represent하는 데 사용됩니다. 그 field는 module에 의해 imported 및 exported되는 name에 대한 digested information을 contain하며, 그 concrete method는 these digest를 사용하여 module을 link하고 evaluate합니다.
module 안에서 occur하는 reexported import 또는 export * as namespace declaration에서의 export에 corresponding하는, 이 module의 code에서 derived된 ExportEntry record의 List입니다.
[[ModuleRequest]]가 identified하는 module에 의해 desired binding이 exported되는 name입니다. value namespace는 import request가 target module의 namespace object에 대한 것임을 indicate합니다.
[[LocalName]]
a String
importing module 안에서 imported value에 locally access하는 데 사용되는 name입니다.
Note 1
Table 55는 syntactic import form을 represent하는 데 사용되는 ImportEntry record field의 example을 제공합니다:
[[ModuleRequest]]가 identified하는 module에 의해 desired binding이 exported되는 name입니다. ExportDeclaration이 ModuleSpecifier를 가지지 않으면 null입니다. namespace는 export * as ns from "mod" declaration에 사용됩니다. all-but-default는 export * from "mod" declaration에 사용됩니다.
[[LocalName]]
a String or null
importing module 안에서 exported value에 locally access하는 데 사용되는 name입니다. exported value가 module 안에서 locally accessible하지 않으면 null입니다.
Note 2
Table 57는 syntactic export form을 represent하는 데 사용되는 ExportEntry record field의 example을 제공합니다:
The abstract operation ParseModule takes arguments sourceText (a String or a sequence of Unicode code points), realm (a Realm Record), and hostDefined (anything) and returns a Source Text Module Record or a non-empty List of SyntaxError objects. sourceText를 Module로 parsing한 result를 기반으로 Source Text Module Record를 create합니다. It performs the following steps when called:
NOTE: 원래 다른 모듈에서 가져온 바인딩 또는 namespace 객체를 내보낼 때, ExportEntry Record는 바인딩 또는 namespace 객체가 가져온 뒤 내보내진 것이 아니라 원래 모듈에서 직접 다시 내보내졌다면 가졌을 형식과 일치하도록 다시 작성된다. 이를 통해 export * from을 통해 같은 이름으로 같은 바인딩 또는 namespace를 두 번 내보내면서 발생하는 충돌이 Source Text Module Records의 ResolveExport 구체 메서드의 9.e.iii 단계에서 모호한 것으로 처리되지 않고 무시될 수 있다.
importEntry를 [[LocalName]]이 exportEntry.[[LocalName]]인 importEntries의 요소라고 하자.
implementation은 해당 module source text에 대한 ParseModule의 evaluation 전에 module source text를 parse하고 Early Error condition에 대해 analyse할 수 있습니다. 그러나 any error의 reporting은 이 specification이 실제로 해당 source text에 대해 ParseModule을 수행하는 point까지 deferred되어야 합니다.
16.2.1.7.2 Implementation of Module Record Abstract Methods
ResolveExport는 imported binding을 actual defining module 및 local binding name으로 resolve하려 시도합니다. defining module은 이 method가 invoked된 Module Record가 represented하는 module일 수도 있고, 그 module에 의해 imported된 다른 module일 수도 있습니다. parameter resolveSet은 unresolved circular import/export path를 detect하는 데 사용됩니다. specific Module Record와 exportName으로 구성된 pair가 resolveSet 안에 already 있으면, import circularity가 encountered된 것입니다. ResolveExport를 recursively calling하기 전에, module과 exportName으로 구성된 pair가 resolveSet에 added됩니다.
defining module이 found되면, ResolvedBinding Record { [[Module]], [[BindingName]] }이 returned됩니다. 이 record는 originally requested export의 resolved binding을 identify합니다. 단, this is the export of a namespace with no local binding인 경우 [[BindingName]]은 namespace로 set됩니다. definition이 found되지 않았거나 request가 circular로 found되면 null이 returned됩니다. request가 ambiguous로 found되면 ambiguous가 returned됩니다.
AsyncBlockStart(capability, module.[[ECMAScriptCode]], moduleContext)를 수행한다.
unused를 반환한다.
16.2.1.8 Synthetic Module Records
Synthetic Module Record는 specification에 의해 defined된 module에 대한 information을 represent하는 데 사용됩니다. 그 exported name은 creation 시 statically defined되며, 그 corresponding value는 SetSyntheticModuleExport를 사용하여 시간이 지나며 change될 수 있습니다. import나 dependency는 없습니다.
Note
Synthetic Module Record는 다양한 module type을 defining하는 데 사용될 수 있습니다: 예를 들어 JSON modules 또는 CSS modules.
module의 evaluation 시 수행할 initialization logic이며, Synthetic Module Record를 its sole argument로 받습니다. 이는 [[ExportNames]]를 modify해서는 안 됩니다. abrupt completion을 return할 수 있습니다.
The abstract operation SetSyntheticModuleExport takes arguments module (a Synthetic Module Record), exportName (a String), and exportValue (an ECMAScript language value) and returns unused. Synthetic Module Record의 existing export에 대한 exported value를 set하거나 change하는 데 사용될 수 있습니다. It performs the following steps when called:
The LoadRequestedModules concrete method of a Synthetic Module Recordmodule takes optional argument hostDefined (anything) and returns a Promise. It performs the following steps when called:
The ResolveExport concrete method of a Synthetic Module Recordmodule takes argument exportName (a String) and optional argument resolveSet (a List of Records with fields [[Module]] (a Module Record) and [[ExportName]] (a String)) and returns a ResolvedBinding Record, null, or ambiguous. It performs the following steps when called:
import() expression이 run되는 time에는 active script 또는 module이 없을 것입니다. More generally, 이는 host가 null ScriptOrModule component를 가진 execution context를 execution context stack에 push하는 any situation에서 happen할 수 있습니다.
HostLoadImportedModule의 implementation은 다음 requirements에 conform해야 합니다:
performed되는 actual process는 host-defined이지만, typically appropriate Module Record를 load하는 데 necessary한 whatever I/O operation을 performing하는 것으로 구성됩니다. Multiple different (referrer, moduleRequest.[[Specifier]], moduleRequest.[[Attributes]]) triple이 same Module Record instance에 map될 수 있습니다. actual mapping semantics는 host-defined이지만 typically normalization process가 mapping process의 part로 specifier에 applied됩니다. typical normalization process는 relative 및 abbreviated path specifier의 expansion과 같은 action을 include할 것입니다.
Note 2
above text는 host가 type: "json"으로 imported된 JSON module을 support할 것을 require하지만(그리고 HostLoadImportedModule이 normally complete하는 경우), type: "json" 없이 imported된 JSON module을 host가 supporting하는 것을 prohibit하지 않습니다.
16.2.1.11 FinishLoadingImportedModule ( referrer, moduleRequest, payload, result )
The abstract operation AllImportAttributesSupported takes argument attrs (a List of ImportAttribute Records) and returns a Boolean. It performs the following steps when called:
The host-defined abstract operation HostGetSupportedImportAttributes takes no arguments and returns a List of Strings. host environment가 support하는 import attribute를 specify할 수 있게 합니다. supported key를 가진 attribute만 host에 provided됩니다.
HostGetSupportedImportAttributes의 implementation은 다음 requirements에 conform해야 합니다:
supported attribute를 각각 indicate하는 String의 List를 반환해야 합니다.
이 operation이 called될 때마다, same contents를 same order로 가진 same List를 반환해야 합니다.
HostGetSupportedImportAttributes의 default implementation은 새 empty List를 반환하는 것입니다.
Note
host가 support하는 import attribute를 specify하도록 require하는 목적은, 모든 attribute를 host에 pass하고 host가 then 처리하려는 것을 choose하게 하는 대신, unsupported attribute가 different host across consistent way로 handled되도록 ensure하기 위한 것입니다.
16.2.1.13 GetModuleNamespace ( module )
The abstract operation GetModuleNamespace takes argument module (an instance of a concrete subclass of Module Record) and returns a Module Namespace Object. module의 export를 represent하는 Module Namespace Object를 retrieve하며, first time requested되었을 때 lazily creating하고 future retrieval을 위해 module.[[Namespace]]에 storing합니다. It performs the following steps when called:
GetModuleNamespace는 never throws. 대신 unresolvable name은 이 point에서 simply namespace에서 excluded됩니다. 그것들이 explicitly requested되지 않는 ambiguous star export뿐인 경우가 아니면, later에 real linking error로 이어질 것입니다.
attrs를 각 such field의 value를 UTF-16 code unit value의 sequence로 treating하여 그 [[Key]] field의 lexicographic order에 따라 sort한다. NOTE: 이 sorting은 host가 attribute가 enumerated되는 order에 따라 behaviour를 changing하는 것이 prohibited된다는 점에서만 observable하다.
implementation은 대부분의 error를 relevant ECMAScript language construct가 evaluated되는 time에 report해야 합니다. early error는 error를 contain하는 Script 안의 어떤 construct도 evaluation되기 전에 detect 및 report될 수 있는 error입니다. early error가 존재하면 construct의 evaluation은 prevented됩니다. implementation은 Script 안의 early error를 ParseScript에서 해당 Script를 parsing하는 part로 report해야 합니다. Module 안의 early error는 Module이 evaluated될 point에서 report되며 Module은 never initialized됩니다. eval code 안의 early error는 eval이 called되는 time에 report되고 eval code의 evaluation을 prevent합니다. early error가 아닌 모든 error는 runtime error입니다.
implementation은 이 specification의 “Static Semantics: Early Errors” subclause에 listed된 condition의 occurrence를 early error로 report해야 합니다.
compiler가 construct가 어떤 circumstance에서도 error 없이 execute될 수 없음을 prove할 수 있더라도, implementation은 other kinds of errors를 early error로 treat해서는 안 됩니다. implementation은 such case에 early warning을 issue할 수 있지만, relevant construct가 actually executed될 때까지 error를 report해서는 안 됩니다.
implementation은 다음을 제외하고 specified된 대로 모든 error를 report해야 합니다:
17.1에서 restricted된 경우를 제외하고, host 또는 implementation은 Script syntax, Module syntax 및 regular expression pattern 또는 flag syntax를 extend할 수 있습니다. 이를 permit하기 위해, SyntaxError를 throw하도록 allowed된 모든 operation(eval calling, regular expression literal 사용, 또는 Function 또는 RegExp constructor 사용 등)은 script syntax 또는 regular expression pattern 또는 flag syntax에 대한 host-defined extension을 encounter할 때 SyntaxError를 throw하는 대신 host-defined behaviour를 exhibit하는 것이 permitted됩니다.
17.1에서 restricted된 경우를 제외하고, host 또는 implementation은 이 specification에 described된 것 외의 additional type, value, object, property 및 function을 provide할 수 있습니다. 이는 construct(예: global scope에서 variable lookup)가 error(예: ReferenceError)를 throwing하는 대신 host-defined behaviour를 가지게 할 수 있습니다.
17.1 Forbidden Extensions
implementation은 다음 ways로 이 specification을 extend해서는 안 됩니다:
implementation이 어떤 function object를 "caller"라는 own property로 extend하는 경우, [[Get]] 또는 [[GetOwnProperty]]를 사용하여 observed되는 그 property의 value는 strict function object여서는 안 됩니다. 그것이 accessor property이면, property의 [[Get]] attribute의 value인 function은 called될 때 strict function을 never return해야 합니다.
mapped arguments object도 unmapped arguments object도 "caller"라는 own property를 가진 채 created되어서는 안 됩니다.
toLocaleString이라는 이름을 가진 것과 같이 ECMA-402에 specified된 built-in method의 behaviour는 ECMA-402에 specified된 경우를 제외하고 extend되어서는 안 됩니다.
22.2.1 및 B.1.2의 RegExp pattern grammar는 [UnicodeMode] grammar parameter가 present할 때 source character A-Z 또는 a-z 중 어느 것도 IdentityEscape[+UnicodeMode]로 recognize하도록 extend되어서는 안 됩니다.
Syntactic Grammar는 token :가 BindingIdentifier nonterminal symbol에 matched된 source text 바로 뒤에 follow하도록 allow하는 어떤 manner로도 extend되어서는 안 됩니다.
ECMAScript Script 또는 Module이 execution을 begin할 때마다 사용할 수 있는 certain built-in object가 있습니다. 하나인 global object는 executing program의 global environment의 part입니다. 다른 것들은 global object의 initial property로, 또는 accessible built-in object의 property로 indirect하게 accessible합니다.
달리 specified되지 않는 한, function으로 callable한 built-in object는 10.3에 described된 characteristic을 가진 built-in function object입니다. 달리 specified되지 않는 한, built-in object의 [[Extensible]] internal slot은 initially value true를 가집니다. 모든 built-in function object는 object가 initially created된 realm의 Realm Record를 value로 가지는 [[Realm]] internal slot을 가집니다.
많은 built-in object는 function입니다: arguments와 함께 invoked될 수 있습니다. 그중 일부는 further constructor입니다: new operator와 함께 사용되도록 intended된 function입니다. 각 built-in function에 대해, 이 specification은 해당 function에 required되는 arguments와 그 function object의 property를 describe합니다. 각 built-in constructor에 대해, 이 specification은 further 해당 constructor의 prototype object의 property와 그 constructor를 invoke하는 new expression에 의해 returned되는 specific object instance의 property를 describe합니다.
particular function의 description에 달리 specified되지 않는 한, built-in function 또는 constructor에 specified된 require 수보다 fewer arguments가 given되면, function 또는 constructor는 sufficient additional arguments가 given된 것과 exactly 같이 behave해야 하며, each such argument는 undefined value입니다. such missing arguments는 “not present”로 considered되고 specification algorithm에서 that manner로 identified될 수 있습니다. particular function의 description에서 “this value” 및 “NewTarget”이라는 term은 10.3에 given된 meaning을 가집니다.
particular function의 description에 달리 specified되지 않는 한, described built-in function 또는 constructor에 function이 allow하도록 specified된 것보다 more arguments가 given되면, extra arguments는 call에 의해 evaluated된 다음 function에 의해 ignored됩니다. 그러나 implementation은 such arguments와 관련한 implementation specific behaviour를 define할 수 있으며, 단 그 behaviour가 단순히 extra argument의 presence에 predicated된 TypeError exception의 throwing이어서는 안 됩니다.
Note 1
built-in function의 set에 additional capability를 add하는 implementation은 existing function에 new parameter를 add하는 것보다 new function을 add하는 방식으로 doing so할 것이 encouraged됩니다.
달리 specified되지 않는 한 모든 built-in function 및 모든 built-in constructor는 Function prototype object, 즉 expression Function.prototype(20.2.3)의 initial value를 그 [[Prototype]] internal slot의 value로 가집니다.
달리 specified되지 않는 한 모든 built-in prototype object는 Object prototype object, 즉 expression Object.prototype(20.1.3)의 initial value를 그 [[Prototype]] internal slot의 value로 가집니다. 단 Object prototype object itself는 제외합니다.
이 specification이 algorithm step을 통해 built-in constructor의 behaviour를 define하는 경우, 그것이 [[Call]] 및 [[Construct]] 둘 다의 purposes에 대한 behaviour입니다. such algorithm이 두 case를 distinguish할 필요가 있으면, NewTarget이 undefined인지 check하며, 이는 [[Call]] invocation을 indicate합니다.
constructor로 identified되지 않은 built-in function object는 particular function의 description에 달리 specified되지 않는 한 [[Construct]] internal method를 implement하지 않습니다.
constructor가 아닌 built-in function object는 particular function의 description에 달리 specified되지 않는 한 "prototype" property를 가지지 않습니다.
이 specification에 defined된 각 built-in function은 CreateBuiltinFunction abstract operation(10.3.4)을 calling하여 created됩니다. length 및 name parameter의 value는 below에서 discussed되는 "length" 및 "name" property의 initial value입니다. prefix parameter의 value도 similarly below에서 discussed됩니다.
constructor를 include한 모든 built-in function object는 non-negative integral Number인 value를 가진 "length" property를 가집니다. 달리 specified되지 않는 한, 이 value는 function description의 subclause heading에 shown된 required parameter의 수입니다. Optional parameter와 rest parameter는 parameter count에 included되지 않습니다.
Note 2
예를 들어, Array prototype object의 "map" property의 initial value인 function object는 subclause heading «Array.prototype.map (callback [ , thisArg])» 아래에 described되며, 여기에는 named argument callback과 thisArg 두 개가 shown되고 latter는 optional입니다; 따라서 그 function object의 "length" property의 value는 1𝔽입니다.
달리 specified되지 않는 한, built-in function object의 "length" property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }를 가집니다.
constructor를 include한 모든 built-in function object는 String인 value를 가진 "name" property를 가집니다. 달리 specified되지 않는 한, 이 value는 이 specification에서 function에 given되는 name입니다. anonymous function으로 identified되는 function은 "name" property의 value로 empty String을 사용합니다. object의 property로 specified되는 function의 경우, name value는 function에 access하는 데 사용되는 property name string입니다. built-in property의 get 또는 set accessor function으로 specified되는 function은 CreateBuiltinFunction을 calling할 때 prefix parameter에 "get" 또는 "set"(respectively)이 passed됩니다.
"name" property의 value는 property key가 Symbol value인 각 built-in function에 대해 explicitly specified됩니다. such explicitly specified된 value가 prefix "get " 또는 "set "으로 start하고 그것이 specified되는 function이 built-in property의 get 또는 set accessor function인 경우, prefix 없는 value가 name parameter에 passed되고, value "get" 또는 "set"(respectively)이 CreateBuiltinFunction을 calling할 때 prefix parameter에 passed됩니다.
달리 specified되지 않는 한, built-in function object의 "name" property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }를 가집니다.
clause 19부터 28까지 및 Annex B.2에 described된 every other data property는 달리 specified되지 않는 한 attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }를 가집니다.
clause 19부터 28까지 및 Annex B.2에 described된 every accessor property는 달리 specified되지 않는 한 attributes { [[Enumerable]]: false, [[Configurable]]: true }를 가집니다. get accessor function만 described된 경우, set accessor function은 default value인 undefined입니다. set accessor만 described된 경우 get accessor는 default value인 undefined입니다.
eval code는 calling context의 code나 eval code 중 하나가 strict mode code인 경우 eval을 invoked한 calling context의 variable environment 안에 variable 또는 function binding을 instantiate할 수 없습니다. 대신 such binding은 eval code에만 accessible한 새 VariableEnvironment 안에 instantiated됩니다. let, const, 또는 class declaration에 의해 introduced된 binding은 항상 새 LexicalEnvironment 안에 instantiated됩니다.
19.2.1.2 HostEnsureCanCompileStrings ( calleeRealm, paramStrings, bodyString, direct )
The host-defined abstract operation HostEnsureCanCompileStrings takes arguments calleeRealm (a Realm Record), paramStrings (a List of Strings), bodyString (a String), and direct (a Boolean) and returns either a normal completion containingunused or a throw completion. 개발자가 string을 ECMAScript code로 interpret하고 evaluate할 수 있게 하는 certain ECMAScript function을 host environment가 block할 수 있게 합니다.
paramStrings는 function constructor 중 하나를 사용할 때 parameters list를 build하기 위해 together concatenated될 string들을 represent합니다. bodyString은 function body 또는 eval call에 passed된 string을 represent합니다.
direct는 evaluation이 direct eval인지 여부를 signifies합니다.
이 function은 string의 leading portion만 Number value로 interpret할 수 있습니다; decimal literal의 notation의 part로 interpret될 수 없는 any code unit은 ignored되며, such code unit이 ignored되었다는 indication은 given되지 않습니다.
19.2.5 parseInt ( string, radix )
이 function은 specified된 radix에 따라 string의 contents를 interpretation하여 dictated되는 integral Number를 produce합니다. string 안의 leading white space는 ignored됩니다. radix가 0으로 coerces되면(undefined인 경우 등), number representation이 "0x" 또는 "0X"로 begins하는 경우를 제외하고 10으로 assumed되며, 그런 경우에는 16으로 assumed됩니다. radix가 16이면, number representation은 optionally "0x" 또는 "0X"로 begin할 수 있습니다.
trimmedString을 ! TrimString(inputString, start)로 둔다.
sign을 1로 둔다.
trimmedString이 empty가 아니고 trimmedString의 first code unit이 code unit 0x002D (HYPHEN-MINUS)이면, sign을 -1로 설정한다.
trimmedString이 empty가 아니고 trimmedString의 first code unit이 code unit 0x002B (PLUS SIGN) 또는 code unit 0x002D (HYPHEN-MINUS) 중 하나이면, trimmedString을 index 1부터의 trimmedString의 substring으로 설정한다.
trimmedString의 length가 ≥ 2이고 trimmedString의 first two code unit이 "0x" 또는 "0X" 중 하나이면, 다음을 수행한다.
trimmedString을 index 2부터의 trimmedString의 substring으로 설정한다.
radixMV를 16으로 설정한다.
trimmedString이 radix-radixMV digit이 아닌 code unit을 contain하면, end를 trimmedString 안에서 first such code unit의 index로 둔다; 그렇지 않으면 end를 trimmedString의 length로 둔다.
numberString을 0부터 end까지의 trimmedString의 substring으로 둔다.
numberString이 empty이면, NaN을 반환한다.
mathInt를 radix-radixMV notation으로 numberString에 의해 represented되는 integer value로 둔다. 여기서 A부터 Z까지와 a부터 z까지의 letters는 values 10 through 35를 가진 digits로 사용된다. (그러나 radixMV = 10이고 numberString이 20개보다 많은 significant digits를 contain하면, 20번째 이후의 every significant digit은 implementation의 option에 따라 0 digit으로 replaced될 수 있다; 그리고 radixMV가 2, 4, 8, 10, 16, 또는 32 중 하나가 아니면, mathInt는 radix-radixMV notation에서 numberString이 denoted하는 integer value를 representing하는 implementation-approximatedinteger일 수 있다.)
이 function은 string의 leading portion만 integer value로 interpret할 수 있습니다; integer의 notation의 part로 interpret될 수 없는 any code unit은 ignored되며, such code unit이 ignored되었다는 indication은 given되지 않습니다.
19.2.6 URI Handling Functions
Uniform Resource Identifier, 즉 URI는 Internet에서 resource(예: web page 또는 file)와 그것에 access하기 위한 transport protocol(예: HTTP 또는 FTP)을 identify하는 String입니다. ECMAScript language 자체는 이 section에 described된 것처럼 URI를 encode 및 decode하는 function을 제외하고 URI 사용을 위한 어떤 support도 provide하지 않습니다. encodeURI와 decodeURI는 complete URI와 함께 work하도록 intended됩니다; 이들은 any reserved character가 special meaning(예: delimiter)을 가지도록 intended된다고 assume하므로 encoded되지 않습니다. encodeURIComponent와 decodeURIComponent는 URI의 individual component와 함께 work하도록 intended됩니다; 이들은 any reserved character가 text를 represent하며 component가 complete URI의 part일 때 special meaning을 avoid하기 위해 encoded되어야 한다고 assume합니다.
Note 1
reserved character의 set은 RFC 2396에 based하며, 더 recent한 RFC 3986에 의해 introduced된 change를 reflect하지 않습니다.
Note 2
ECMAScript의 많은 implementation은 web page를 manipulate하는 additional function 및 method를 provide합니다; 이러한 function은 이 standard의 scope 밖입니다.
19.2.6.1 decodeURI ( encodedURI )
이 function은 encodeURI function에 의해 introduced될 수 있는 sort의 각 escape sequence와 UTF-8 encoding이 그것이 represent하는 code point의 UTF-16 encoding으로 replaced된 URI의 new version을 computes합니다. encodeURI에 의해 introduced될 수 없었던 escape sequence는 replaced되지 않습니다.
이 function은 encodeURIComponent function에 의해 introduced될 수 있는 sort의 각 escape sequence와 UTF-8 encoding이 그것이 represent하는 code point의 UTF-16 encoding으로 replaced된 URI의 new version을 computes합니다.
이는 %decodeURIComponent% intrinsic object입니다.
called될 때 다음 step을 수행합니다:
componentString을 ? ToString(encodedURIComponent)으로 둔다.
이 function은 certain code point의 각 instance가 code point의 UTF-8 encoding을 represent하는 one, two, three, or four escape sequence로 replaced된 UTF-16 encoded(6.1.4) URI의 new version을 computes합니다.
이 function은 certain code point의 각 instance가 code point의 UTF-8 encoding을 represent하는 one, two, three, or four escape sequence로 replaced된 UTF-16 encoded(6.1.4) URI의 new version을 computes합니다.
The abstract operation Encode takes arguments string (a String) and extraUnescaped (a String) and returns either a normal completion containing a String or a throw completion. 6.1.4에 described된 것처럼 string을 UTF-16 encoded code point의 sequence로 interpreting하여 URI encoding과 escaping을 수행합니다. character가 RFC 2396에서 unreserved로 identified되거나 extraUnescaped 안에 appear하면, escaped되지 않습니다. It performs the following steps when called:
percent-encoding은 individual octet을 represent하는 데 사용되므로, single code point는 multiple consecutive escape sequence(그 8-bit UTF-8 code unit 각각에 대해 하나)로 expressed될 수 있습니다.
19.2.6.6 Decode ( string, preserveEscapeSet )
The abstract operation Decode takes arguments string (a String) and preserveEscapeSet (a String) and returns either a normal completion containing a String or a throw completion. preserveEscapeSet 안의 Basic Latin character에 corresponding하는 any escape sequence를 preserving하면서 URI unescaping 및 decoding을 수행합니다. It performs the following steps when called:
length를 string의 length로 둔다.
result를 empty String으로 둔다.
k를 0으로 둔다.
Repeat, k < length인 동안,
codeUnit을 string 안의 index k에 있는 code unit으로 둔다.
segment를 codeUnit으로 둔다.
codeUnit이 code unit 0x0025 (PERCENT SIGN)이면, 다음을 수행한다.
RFC 3629는 invalid UTF-8 octet sequence의 decoding을 prohibit합니다. 예를 들어 invalid sequence 0xC0 0x80은 code unit 0x0000으로 decode되어서는 안 됩니다. Decode algorithm의 implementation은 such invalid sequence를 encounter할 때 URIError를 throw해야 합니다.
19.2.6.7 ParseHexOctet ( string, position )
The abstract operation ParseHexOctet takes arguments string (a String) and position (a non-negative integer) and returns either a non-negative integer or a non-empty List of SyntaxError objects. string 안의 specified position에서 두 hexadecimal character의 sequence를 unsigned 8-bit integer로 parse합니다. It performs the following steps when called:
callback은 two arguments를 accept하는 function이어야 합니다. groupBy는 items의 각 element에 대해 ascending order로 callback을 once call하고, new object를 construct합니다. callback에 의해 returned된 각 value는 property key로 coerced됩니다. such 각 property key에 대해, result object는 key가 해당 property key이고 value가 callback return value가 그 key로 coerced된 모든 element를 contain하는 array인 property를 가집니다.
callback은 two arguments, 즉 element의 value와 element의 index로 called됩니다.
step 1와 2의 ordering은, this value가 undefined 또는 null인 경우에도 이 specification의 previous edition에서 step 1에 의해 thrown되었을 any exception이 계속 thrown되도록 ensure하기 위해 chosen되었습니다.
propertyDesc를 ? obj.[[GetOwnProperty]](propertyKey)로 둔다.
propertyDesc가 undefined이면, false를 반환한다.
propertyDesc.[[Enumerable]]을 반환한다.
Note 1
이 method는 prototype chain 안의 object를 consider하지 않습니다.
Note 2
step 1와 2의 ordering은, this value가 undefined 또는 null인 경우에도 이 specification의 previous edition에서 step 1에 의해 thrown되었을 any exception이 계속 thrown되도록 ensure하기 위해 chosen되었습니다.
이 method의 optional parameter는 사용되지 않지만, ECMA-402 toLocaleString method에서 사용되는 parameter pattern에 correspond하도록 intended됩니다. ECMA-402 support를 include하지 않는 implementation은 those parameter position을 other purpose에 사용해서는 안 됩니다.
Note 1
이 method는 locale-sensitive toString behaviour를 가지지 않는 object를 위한 generic toLocaleString implementation을 제공합니다. Array, Number, Date, 및 %TypedArray%는 own locale-sensitive toLocaleString method를 provide합니다.
Note 2
ECMA-402는 intentionally 이 default implementation에 대한 alternative를 provide하지 않습니다.
20.1.3.6 Object.prototype.toString ( )
이 method는 called될 때 다음 step을 수행합니다:
this value가 undefined이면, "[object Undefined]"를 반환한다.
Historically, 이 method는 this specification의 previous edition에서 various built-in object를 위한 nominal type tag로 사용되었던 [[Class]] internal slot의 String value에 access하기 위해 occasionally 사용되었습니다. toString의 above definition은 those specific kind of built-in object를 test하기 위해 toString을 사용하는 legacy code에 대한 compatibility를 preserves합니다. 이는 other kind의 built-in 또는 program defined object에 대한 reliable type testing mechanism을 provide하지 않습니다. In addition, program은 such legacy type test의 reliability를 invalidate할 ways로 %Symbol.toStringTag%를 사용할 수 있습니다.
Object.prototype.__proto__는 attributes { [[Enumerable]]: false, [[Configurable]]: true }를 가진 accessor property입니다. [[Get]] 및 [[Set]] attribute는 다음과 같이 defined됩니다:
20.1.3.8.1 get Object.prototype.__proto__
[[Get]] attribute의 value는 argument를 require하지 않는 built-in function입니다. called될 때 다음 step을 수행합니다:
global object의 "Function" property의 initial value입니다.
constructor가 아니라 function으로 called될 때 new function object를 create하고 initialize합니다. 따라서 function call Function(…)은 same arguments를 가진 object creation expression new Function(…)과 equivalent합니다.
class definition의 extends clause의 value로 사용될 수 있습니다. specified Function behaviour를 inherit하려는 subclass constructor는 built-in function behaviour에 necessary한 internal slot을 가진 subclass instance를 create하고 initialize하기 위해 Function constructor에 대한 super call을 include해야 합니다. function object를 defining하기 위한 모든 ECMAScript syntactic form은 Function의 instance를 create합니다. built-in GeneratorFunction, AsyncFunction, 및 AsyncGeneratorFunction subclass를 제외하고 Function subclass의 instance를 create하는 syntactic means는 없습니다.
NOTE: parameter와 body는 각각 alone valid함을 ensure하기 위해 separately parsed된다. 예를 들어 new Function("/*", "*/ ) {")는 function으로 evaluate되지 않는다.
NOTE: 이 step에 reached했다면, sourceText는 exprGrammar의 syntax를 가져야 한다(although reverse implication does not hold). 다음 두 step의 purpose는 exprGrammar에 directly apply되는 any Early Error rule을 enforce하는 것이다.
thisArg value는 modification 없이 this value로 passed됩니다. 이는 Edition 3에서 undefined 또는 nullthisArg가 global object로 replaced되고, all other value에 ToObject가 applied되며 그 result가 this value로 passed되었던 것과 달라진 change입니다. thisArg가 modification 없이 passed되더라도, non-strict function은 function entry 시 여전히 these transformation을 수행합니다.
thisArg value는 modification 없이 this value로 passed됩니다. 이는 Edition 3에서 undefined 또는 nullthisArg가 global object로 replaced되고, all other value에 ToObject가 applied되며 그 result가 this value로 passed되었던 것과 달라진 change입니다. thisArg가 modification 없이 passed되더라도, non-strict function은 function entry 시 여전히 these transformation을 수행합니다.
이는 대부분의 function이 inherit하는 %Symbol.hasInstance%의 default implementation입니다. %Symbol.hasInstance%는 value가 specific constructor의 instance인지 determine하기 위해 instanceof operator에 의해 called됩니다. 다음과 같은 expression은
v instanceof F
다음처럼 evaluates됩니다
F[%Symbol.hasInstance%](v)
constructor function은 function에 different %Symbol.hasInstance% method를 exposing함으로써 instanceof에 의해 어떤 object가 its instance로 recognized되는지 control할 수 있습니다.
이 property는 bound function의 target function을 globally expose하는 데 used될 수 있는 tampering을 prevent하기 위해 non-writable 및 non-configurable입니다.
이 method의 "name" property의 value는 "[Symbol.hasInstance]"입니다.
"length" property의 value는 function에 expected되는 typical number of arguments를 indicate하는 integral Number입니다. 그러나 language는 function이 some other number of arguments와 함께 invoked되는 것을 permit합니다. "length" property에 의해 specified된 number가 아닌 number of arguments로 invoked될 때의 function behaviour는 function에 depend합니다. 이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }를 가집니다.
20.2.4.2 name
"name" property의 value는 function을 descriptive하는 String입니다. name은 semantic significance를 가지지 않지만, typically ECMAScript source text 안에서 definition point에서 function을 refer하기 위해 사용되는 variable 또는 property name입니다. 이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }를 가집니다.
이 specification에 의해 contextual name이 associated되지 않은 Anonymous function object는 "name" property의 value로 empty String을 사용합니다.
20.2.4.3 prototype
constructor로 사용될 수 있는 Function instance는 "prototype" property를 가집니다. such Function instance가 created될 때마다 another ordinary object도 created되고 function의 "prototype" property의 initial value가 됩니다. 달리 specified되지 않는 한, "prototype" property의 value는 해당 function이 constructor로 invoked될 때 created되는 object의 [[Prototype]] internal slot을 initialize하는 데 사용됩니다.
The host-defined abstract operation HostHasSourceTextAvailable takes argument func (a function object) and returns a Boolean. host environment가 func에 대한 source text가 provided되는 것을 prevent할 수 있게 합니다.
HostHasSourceTextAvailable의 implementation은 다음 requirement에 conform해야 합니다:
parameter에 대해 deterministic이어야 합니다. 특정 func를 argument로 하여 called될 때마다, same result를 반환해야 합니다.
global object의 "Boolean" property의 initial value입니다.
constructor로 called될 때 new Boolean object를 create하고 initialize합니다.
constructor가 아니라 function으로 called될 때 type conversion을 수행합니다.
class definition의 extends clause의 value로 사용될 수 있습니다. specified Boolean behaviour를 inherit하려는 subclass constructor는 [[BooleanData]] internal slot을 가진 subclass instance를 create하고 initialize하기 위해 Boolean constructor에 대한 super call을 include해야 합니다.
Symbol instance는 Symbol prototype object에서 property를 inherit하는 ordinary object입니다. Symbol instance는 [[SymbolData]] internal slot을 가집니다. [[SymbolData]] internal slot은 이 Symbol object가 represented하는 Symbol value입니다.
20.4.5 Abstract Operations for Symbols
20.4.5.1 GlobalSymbolRegistry 레코드
GlobalSymbolRegistry Record는 Symbol.for를 통해 등록된 Symbol 값과 String 키를 연결하는 데 사용되는 Record 값이다.
GlobalSymbolRegistry Records에는 Table 59에 나열된 필드가 있다.
The abstract operation KeyForSymbol takes argument symbol (a Symbol) and returns a String or undefined. symbol이 둘러싸는 에이전트의 [[GlobalSymbolRegistry]]List 안에 있으면, symbol을 등록하는 데 사용된 String이 반환된다. It performs the following steps when called:
단언: globalSymbolRegistry는 현재 symbol에 대한 항목을 포함하지 않는다.
undefined를 반환한다.
20.5 Error Objects
Error object의 instance는 runtime error가 occur할 때 exception으로 thrown됩니다. Error object는 user-defined exception class를 위한 base object로도 serve할 수 있습니다.
ECMAScript 구현이 런타임 오류를 감지하면, 20.5.5에 정의된 NativeError 객체 중 하나의 새 인스턴스, 또는 20.5.7에 정의된 AggregateError 객체나 20.5.8에 정의된 SuppressedError 객체 중 하나의 새 인스턴스를 던진다. 이러한 각 객체는 아래에 설명된 구조를 가지며, NativeError 대신 생성자 이름으로 사용되는 이름, 프로토타입 객체의 "name" 속성, 프로토타입 객체의 구현 정의 "message" 속성, 그리고 %AggregateError% 전용 "errors" 속성 또는 %SuppressedError% 전용 "error" 및 "suppressed" 속성의 존재 여부에서만 다르다.
constructor가 아니라 function으로 called될 때 new Error object를 create하고 initialize합니다. 따라서 function call Error(…)은 same arguments를 가진 object creation expression new Error(…)과 equivalent합니다.
class definition의 extends clause의 value로 사용될 수 있습니다. specified Error behaviour를 inherit하려는 subclass constructor는 [[ErrorData]] internal slot을 가진 subclass instance를 create하고 initialize하기 위해 Error constructor에 대한 super call을 include해야 합니다.
20.5.1.1 Error ( message [ , options ] )
이 function은 called될 때 다음 step을 수행합니다:
NewTarget이 undefined이면, newTarget을 active function object로 둔다; 그렇지 않으면 newTarget을 NewTarget으로 둔다.
message가 undefined이면, message를 empty String으로 설정한다; 그렇지 않으면 message를 ? ToString(message)로 설정한다.
name이 empty String이면, message를 반환한다.
message가 empty String이면, name을 반환한다.
name, code unit 0x003A (COLON), code unit 0x0020 (SPACE), 및 message의 string-concatenation을 반환한다.
20.5.4 Properties of Error Instances
Error 인스턴스는 Error 프로토타입 객체에서 속성을 상속하고 값이 undefined인 [[ErrorData]] 내부 슬롯을 갖는 일반 객체이다. [[ErrorData]]의 유일하게 명세된 용도는 Object.prototype.toString 및 Error.isError 안에서 Error, AggregateError, SuppressedError 및 NativeError 인스턴스를 Error 객체로 식별하는 것이다.
20.5.5 Native Error Types Used in This Standard
아래의 NativeError 객체 중 하나, 또는 AggregateError 객체나 SuppressedError 객체 중 하나의 새 인스턴스는 런타임 오류가 감지될 때 던져진다. 모든 NativeError 객체는 20.5.6에 설명된 것처럼 동일한 구조를 공유한다.
constructor가 아니라 function으로 called될 때 new NativeError object를 create하고 initialize합니다. object를 function으로 call하는 것은 same arguments를 가지고 constructor로 call하는 것과 equivalent합니다. 따라서 function call NativeError(…)는 same arguments를 가진 object creation expression new NativeError(…)과 equivalent합니다.
class definition의 extends clause의 value로 사용될 수 있습니다. specified NativeError behaviour를 inherit하려는 subclass constructor는 [[ErrorData]] internal slot을 가진 subclass instance를 create하고 initialize하기 위해 NativeErrorconstructor에 대한 super call을 include해야 합니다.
20.5.6.1.1NativeError ( message [ , options ] )
각 NativeError function은 called될 때 다음 step을 수행합니다:
NewTarget이 undefined이면, newTarget을 active function object로 둔다; 그렇지 않으면 newTarget을 NewTarget으로 둔다.
step 2에 passed되는 string의 actual value는 which NativeErrorconstructor가 defined되는지에 corresponding하여 "%EvalError.prototype%", "%RangeError.prototype%", "%ReferenceError.prototype%", "%SyntaxError.prototype%", "%TypeError.prototype%", 또는 "%URIError.prototype%" 중 하나입니다.
20.5.6.2 Properties of the NativeError Constructors
given NativeErrorconstructor에 대한 prototype의 "constructor" property의 initial value는 constructor itself입니다.
20.5.6.3.2NativeError.prototype.message
given NativeErrorconstructor에 대한 prototype의 "message" property의 initial value는 empty String입니다.
20.5.6.3.3NativeError.prototype.name
given NativeErrorconstructor에 대한 prototype의 "name" property의 initial value는 constructor의 name(NativeError 대신 사용된 name)으로 구성되는 String value입니다.
20.5.6.4 Properties of NativeError Instances
NativeError 인스턴스는 해당 NativeError 프로토타입 객체에서 속성을 상속하고 값이 undefined인 [[ErrorData]] 내부 슬롯을 갖는 일반 객체이다. [[ErrorData]]의 유일하게 명세된 용도는 Object.prototype.toString(20.1.3.6) 및 Error.isError(20.5.2.1)가 Error, AggregateError, SuppressedError 또는 NativeError 인스턴스를 식별하는 것이다.
global object의 "AggregateError" property의 initial value입니다.
constructor가 아니라 function으로 called될 때 new AggregateError object를 create하고 initialize합니다. 따라서 function call AggregateError(…)은 same arguments를 가진 object creation expression new AggregateError(…)과 equivalent합니다.
class definition의 extends clause의 value로 사용될 수 있습니다. specified AggregateError behaviour를 inherit하려는 subclass constructor는 [[ErrorData]] internal slot을 가진 subclass instance를 create하고 initialize하기 위해 AggregateError constructor에 대한 super call을 include해야 합니다.
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 호출을 포함해야 한다.
SuppressedError 인스턴스는 해당 SuppressedError 프로토타입 객체에서 속성을 상속하고 값이 undefined인 [[ErrorData]] 내부 슬롯을 갖는 일반 객체이다. [[ErrorData]]의 유일하게 명세된 용도는 Object.prototype.toString 및 Error.isError 안에서 Error, AggregateError, SuppressedError 및 NativeError 인스턴스를 Error 객체로 식별하는 것이다.
20.5.9 Abstract Operations for Error Objects
20.5.9.1 InstallErrorCause ( obj, options )
The abstract operation InstallErrorCause takes arguments obj (an Object) and options (an ECMAScript language value) and returns either a normal completion containingunused or a throw completion. options에 "cause" property가 present할 때 obj에 "cause" property를 create하는 데 사용됩니다. It performs the following steps when called:
options가 Object이고 ? HasProperty(options, "cause")가 true이면, 다음을 수행한다.
constructor로 called될 때 new Number object를 create하고 initialize합니다.
constructor가 아니라 function으로 called될 때 type conversion을 수행합니다.
class definition의 extends clause의 value로 사용될 수 있습니다. specified Number behaviour를 inherit하려는 subclass constructor는 [[NumberData]] internal slot을 가진 subclass instance를 create하고 initialize하기 위해 Number constructor에 대한 super call을 include해야 합니다.
Number.EPSILON의 value는 Number value로 represent 가능한 1보다 큰 smallest value와 1 사이의 difference의 magnitude에 대한 Number value이며, 이는 approximately 2.2204460492503130808472633361816 × 10-16입니다.
IEEE 754-2019의 precision limitation 때문에 necessary한 rounding behaviour로 인해, Number.MAX_SAFE_INTEGER보다 큰 every integer에 대한 Number value는 at least one other integer와 shared됩니다. 따라서 such large-magnitude integer는 safe하지 않으며, Number value로 exactly represent 가능하거나 서로 distinguish 가능하다고 guaranteed되지 않습니다. 예를 들어, 9007199254740992와 9007199254740993 둘 다 Number value 9007199254740992𝔽로 evaluate됩니다.
IEEE 754-2019의 precision limitation 때문에 necessary한 rounding behaviour로 인해, Number.MIN_SAFE_INTEGER보다 작은 every integer에 대한 Number value는 at least one other integer와 shared됩니다. 따라서 such large-magnitude integer는 safe하지 않으며, Number value로 exactly represent 가능하거나 서로 distinguish 가능하다고 guaranteed되지 않습니다. 예를 들어, -9007199254740992와 -9007199254740993 둘 다 Number value -9007199254740992𝔽로 evaluate됩니다.
explicitly 달리 stated되지 않는 한, 아래에 defined된 Number prototype object의 method는 generic하지 않고, 이들에게 passed되는 this value는 Number value이거나 Number value로 initialized된 [[NumberData]] internal slot을 가진 object여야 합니다.
method specification 안의 phrase “this Number value”는 method invocation의 this value를 argument로 pass하여 abstract operation ThisNumberValue를 calling한 result를 refer합니다.
이 method는 significand의 decimal point 앞에 one digit, significand의 decimal point 뒤에 fractionDigits digits를 가진 decimal exponential notation으로 represented된 this Number value를 contain하는 String을 반환합니다. fractionDigits가 undefined이면, Number를 uniquely specify하는 데 necessary한 만큼의 significand digit을 include합니다(ToString에서와 같지만, 이 경우 Number는 always exponential notation으로 output됩니다).
significand를 code unit 0x0030 (DIGIT ZERO)가 fractionCount + 1번 occurrence하는 것으로 구성된 String value로 둔다.
exponent를 0으로 둔다.
그렇지 않으면,
fractionDigits가 undefined가 아니면, 다음을 수행한다.
exponent와 intSignificand를 10fractionCount ≤ intSignificand < 10fractionCount + 1이고 intSignificand × 10exponent - fractionCount - number가 가능한 한 zero에 close한 integers로 둔다. such exponent와 intSignificand의 set이 two이면, intSignificand × 10exponent - fractionCount가 larger인 exponent와 intSignificand를 pick한다.
그렇지 않으면,
exponent, intSignificand, 및 ff를 ff ≥ 0, 10ff ≤ intSignificand < 10ff + 1, 𝔽(intSignificand × 10exponent - ff) is 𝔽(number), 그리고 ff가 가능한 한 small인 integers로 둔다. intSignificand의 decimal representation은 ff + 1 digits를 가지고, intSignificand는 10으로 divisible하지 않으며, intSignificand의 least significant digit이 these criteria에 의해 necessarily uniquely determined되는 것은 아님에 note한다.
fractionCount를 ff로 설정한다.
significand를 intSignificand의 decimal representation의 digits로 구성된 String value로 둔다(in order, with no leading zeroes).
fractionCount ≠ 0이면, 다음을 수행한다.
intPart를 significand의 first code unit으로 둔다.
fractionalPart를 significand의 other fractionCount code unit으로 둔다.
above rules에 의해 required되는 것보다 more accurate conversion을 provide하는 implementation의 경우, step 10.b.i의 다음 alternative version을 guideline으로 사용할 것이 recommended됩니다:
exponent, intSignificand, 및 ff를 ff ≥ 0, 10ff ≤ intSignificand < 10ff + 1, 𝔽(intSignificand × 10exponent - ff) is 𝔽(number), 그리고 ff가 가능한 한 small인 integers로 둔다. intSignificand에 대해 multiple possibility가 있으면, 𝔽(intSignificand × 10exponent - ff)가 𝔽(number)에 closest한 intSignificand를 choose한다. such possible value of intSignificand가 two이면, even인 것을 choose한다.
이 method는 decimal point 뒤에 fractionDigits digits를 가진 decimal fixed-point notation으로 represented된 this Number value를 contain하는 String을 반환합니다. fractionDigits가 undefined이면, 0이 assumed됩니다.
intValue를 intValue / 10fractionCount - number가 가능한 한 zero에 close한 integer로 둔다. such intValue가 two이면, larger intValue를 pick한다.
intValue = 0이면, digitString을 "0"으로 둔다; 그렇지 않으면 digitString을 intValue의 decimal representation의 digits로 구성된 String value로 둔다(in order, with no leading zeroes).
fractionCount ≠ 0이면, 다음을 수행한다.
digitCount를 digitString의 length로 둔다.
digitCount ≤ fractionCount이면, 다음을 수행한다.
zeroPad를 code unit 0x0030 (DIGIT ZERO)가 fractionCount + 1 - digitCount번 occurrence하는 것으로 구성된 String value로 둔다.
toString은 adjacent Number value와 number를 distinguish하기에 enough significant digits만 print하므로, some value에 대해 toFixed의 output은 toString보다 more precise할 수 있습니다. 예를 들어,
(1000000000000000128).toString()은 "1000000000000000100"을 반환하는 반면, (1000000000000000128).toFixed(0)은 "1000000000000000128"을 반환합니다.
ECMA-402 Internationalization API를 include하는 ECMAScript implementation은 ECMA-402 specification에 specified된 대로 이 method를 implement해야 합니다. ECMAScript implementation이 ECMA-402 API를 include하지 않으면 이 method의 다음 specification이 사용됩니다:
이 method는 host environment의 current locale의 convention에 따라 formatted된 this Number value를 represent하는 String value를 produce합니다. 이 method는 implementation-defined이며, toString과 same thing을 return하는 것이 permissible하지만 encouraged되지는 않습니다.
이 method의 optional parameter의 meaning은 ECMA-402 specification에 defined되어 있습니다; ECMA-402 support를 include하지 않는 implementation은 those parameter position을 anything else에 사용해서는 안 됩니다.
이 method는 significand의 decimal point 앞에 one digit, significand의 decimal point 뒤에 precision - 1 digits를 가진 decimal exponential notation 또는 precision significant digits를 가진 decimal fixed notation 중 하나로 represented된 this Number value를 contain하는 String을 반환합니다. precision이 undefined이면, 대신 ToString을 call합니다.
이 method는 generic하지 않습니다; this value가 Number 또는 Number object가 아니면 TypeError exception을 throw합니다. 따라서 method로 사용하기 위해 다른 kind의 object로 transferred될 수 없습니다.
Number instance는 Number prototype object에서 property를 inherit하는 ordinary object입니다. Number instance는 또한 [[NumberData]] internal slot을 가집니다. [[NumberData]] internal slot은 이 Number object가 represented하는 Number value입니다.
constructor가 아니라 function으로 called될 때 type conversion을 수행합니다.
new operator와 함께 사용되거나 subclassed되도록 intended되지 않습니다. class definition의 extends clause의 value로 사용될 수 있지만 BigInt constructor에 대한 super call은 exception을 cause합니다.
The abstract operation NumberToBigInt takes argument number (a Number) and returns either a normal completion containing a BigInt or a throw completion. It performs the following steps when called:
number가 integral Number가 아니면, RangeError exception을 throw한다.
ECMA-402 Internationalization API를 include하는 ECMAScript implementation은 ECMA-402 specification에 specified된 대로 이 method를 implement해야 합니다. ECMAScript implementation이 ECMA-402 API를 include하지 않으면 이 method의 다음 specification이 사용됩니다:
이 method는 host environment의 current locale의 convention에 따라 formatted된 this BigInt value를 represent하는 String value를 produce합니다. 이 method는 implementation-defined이며, toString과 same thing을 return하는 것이 permissible하지만 encouraged되지는 않습니다.
이 method의 optional parameter의 meaning은 ECMA-402 specification에 defined되어 있습니다; ECMA-402 support를 include하지 않는 implementation은 those parameter position을 anything else에 사용해서는 안 됩니다.
이 method는 generic하지 않습니다; this value가 BigInt 또는 BigInt object가 아니면 TypeError exception을 throw합니다. 따라서 method로 사용하기 위해 다른 kind의 object로 transferred될 수 없습니다.
acos, acosh, asin, asinh, atan, atanh, atan2, cbrt, cos, cosh, exp, expm1, hypot, log, log1p, log2, log10, pow, random, sin, sinh, tan, 및 tanh function의 behaviour는 interest의 boundary case를 represent하는 certain argument value에 대해 specific result를 require하는 것 외에는 여기에서 precisely specified되지 않습니다. other argument value에 대해, these function은 familiar mathematical function의 result에 대한 approximation을 compute하도록 intended되지만, approximation algorithm 선택에는 some latitude가 allowed됩니다. general intent는 implementer가 given hardware platform에서 C programmer에게 available한 same mathematical library를 ECMAScript에 사용할 수 있게 하는 것입니다.
algorithm 선택은 implementation에 left되지만, implementation은 Sun Microsystems의 freely distributable mathematical library인 fdlibm(http://www.netlib.org/fdlibm)에 contained된 IEEE 754-2019 arithmetic을 위한 approximation algorithm을 사용할 것이 recommended됩니다(이 standard에 의해 specified되지는 않음).
21.3.2.1 Math.abs ( x )
이 function은 x의 absolute value를 반환합니다; result는 x와 same magnitude를 가지지만 positive sign을 가집니다.
이 function은 x의 exponential function(e raised to the power of x, 여기서 e는 natural logarithm의 base)에서 1을 subtract한 result를 반환합니다. result는 x의 value가 0에 close한 경우에도 accurate한 way로 computed됩니다.
n16을 roundTiesToEven mode를 사용하여 n을 IEEE 754-2019 binary16 format으로 converting한 result로 둔다.
n64를 n16을 IEEE 754-2019 binary64 format으로 converting한 result로 둔다.
n64에 corresponding하는 ECMAScript Number value를 반환한다.
Note
이 operation은 double-rounding 가능성 때문에 binary32로 cast한 다음 binary16으로 cast하는 것과 same하지 않습니다: 예를 들어 number k = 1.00048828125000022204𝔽를 consider하면, Math.f16round(k)는 1.0009765625𝔽이지만, Math.f16round(Math.fround(k))는 1𝔽입니다.
모든 platform이 binary64에서 binary16으로 casting하는 native support를 provide하는 것은 아닙니다. 이를 provide할 수 있는 다양한 library가 있으며, 여기에는 MIT-licensed half library가 include됩니다. Alternatively, roundTiesToEven 하에서 binary64에서 binary32로 first cast한 다음 result가 incorrect double-rounding으로 이어질 수 있는지 check할 수 있습니다. such case는 binary32 value의 mantissa를 initial cast를 roundTiesToOdd 하에서 수행했을 때 produced될 value가 되도록 adjusting함으로써 explicitly handled될 수 있습니다. adjusted value를 roundTiesToEven 하에서 binary16으로 casting하면 correct value가 produced됩니다.
21.3.2.19 Math.hypot ( ...args )
zero or more arguments가 given되면, 이 function은 그 arguments의 squares의 sum의 square root를 반환합니다.
implementation은 이 function이 two or more arguments와 함께 called될 때 naive implementation에서 발생하기 쉬운 overflow 및 underflow로 인한 precision loss를 avoid하도록 care해야 합니다.
이 function은 positive sign을 가지고, +0𝔽보다 크거나 같지만 1𝔽보다 strictly less한 Number value를 반환하며, 이는 implementation-defined algorithm 또는 strategy를 사용하여 해당 range에서 approximately uniform distribution으로 randomly 또는 pseudo randomly chosen됩니다.
distinct realm을 위해 created된 각 Math.random function은 successive call에서 distinct sequence of values를 produce해야 합니다.
21.3.2.29 Math.round ( x )
이 function은 x에 closest하고 integral인 Number value를 반환합니다. two integral Numbers가 x에 equally close하면, result는 +∞에 closer한 Number value입니다. x가 already integral이면, result는 x입니다.
NOTE: 이 step은 practice에서 reached될 것으로 expected되지 않으며, implementation이 이 specification을 violating하지 않고 input이 “reasonably sized”라고 rely할 수 있도록 하기 위해서만 included된다.
error를 ThrowCompletion(newly created RangeError object)로 둔다.
sum의 value는 다양한 algorithm을 통해 arbitrary-precision arithmetic 없이 computed될 수 있습니다. 그중 하나는 Jonathan Richard Shewchuk의 Adaptive Precision Floating-Point Arithmetic and Fast Robust Geometric Predicates에 given된 “Grow-Expansion” algorithm입니다. 더 recent한 algorithm은 “Fast exact summation using small and large superaccumulators”에 given되어 있으며, 그 code는 https://gitlab.com/radfordneal/xsum에서 available합니다.
21.3.2.35 Math.tan ( x )
이 function은 x의 tangent를 반환합니다. argument는 radians로 expressed됩니다.
21.4.1 Overview of Date Objects and Definitions of Abstract Operations
다음 abstract operation은 time value(21.4.1.1에서 defined됨)에 대해 operate합니다. 모든 경우에, 이러한 function 중 하나에 대한 any argument가 NaN이면 result는 NaN이 된다는 점에 note하십시오.
21.4.1.1 Time Values and Time Range
ECMAScript의 time measurement는 POSIX의 time measurement와 analogous하며, 특히 proleptic Gregorian calendar, 1970년 1월 1일 UTC 시작 시점의 midnight인 epoch, 그리고 every day가 정확히 86,400초(각각 1000 milliseconds 길이)로 구성된다는 accounting을 공유합니다.
ECMAScript time value는 Number이며, millisecond precision으로 time 안의 instant를 represent하는 finiteintegral Number이거나 specific instant가 없음을 represent하는 NaN입니다. 24 × 60 × 60 × 1000 = 86,400,000의 multiple인 time value(즉 어떤 integerd에 대해 86,400,000 × d)는 epoch 뒤에 d whole UTC days만큼 따르는 UTC day의 start instant를 represent합니다(negative d의 경우 epoch 앞). every other finite time value tv는 그러한 multiple인 greatest preceding time value s를 기준으로 defined되며, s와 same UTC day 안에서 occur하지만 (tv - s) milliseconds만큼 뒤따르는 instant를 represent합니다.
Time value는 UTC leap second를 account하지 않습니다—positive leap second 안의 instant를 represent하는 time value는 없고, negative leap second에 의해 UTC timeline에서 removed된 instant를 represent하는 time value가 있습니다. 그러나 time value의 definition은 nonetheless UTC와 piecewise alignment를 yield하며, discontinuity는 leap second boundary에서만 존재하고 leap second 밖에서는 zero difference입니다.
Number는 -9,007,199,254,740,992부터 9,007,199,254,740,992까지의 모든 integer를 exactly represent할 수 있습니다(21.1.2.8 및 21.1.2.6). time value는 -8,640,000,000,000,000부터 8,640,000,000,000,000 milliseconds까지의 slightly smaller range를 support합니다. 이는 1970년 1월 1일 UTC 시작 시점의 midnight를 기준으로 exactly -100,000,000 days부터 100,000,000 days까지의 supported time value range를 yield합니다.
1970년 1월 1일 UTC 시작 시점의 midnight의 exact moment는 time value +0𝔽로 represented됩니다.
Note
proleptic Gregorian calendar에서 leap year는 4로 divisible하면서 400으로 divisible하거나 100으로 divisible하지 않는 year입니다.
proleptic Gregorian calendar의 400 year cycle은 97 leap years를 contain합니다. 이는 year당 average 365.2425 days를 yield하며, 이는 31,556,952,000 milliseconds입니다. 따라서 Number가 millisecond precision으로 exactly represent할 수 있는 maximum range는 1970을 기준으로 approximately -285,426부터 285,426 years까지입니다. 이 section에 specified된 time value가 support하는 smaller range는 1970을 기준으로 approximately -273,790부터 273,790 years까지입니다.
21.4.1.2 Time-related Constants
이러한 constant는 following sections의 algorithm에서 referenced됩니다.
The abstract operation Day takes argument tv (a finitetime value) and returns an integral Number. tv가 fall하는 day의 day number를 반환합니다. It performs the following steps when called:
The abstract operation TimeWithinDay takes argument tv (a finitetime value) and returns an integral Number in the interval from +0𝔽 (inclusive) to msPerDay (exclusive). tv가 fall하는 day의 start 이후 milliseconds 수를 반환합니다. It performs the following steps when called:
The abstract operation DaysInYear takes argument y (an integral Number) and returns 365𝔽 or 366𝔽. year y 안의 days 수를 반환합니다. Leap year는 366 days를 가지고, all other years는 365를 가집니다. It performs the following steps when called:
The abstract operation DayFromYear takes argument y (an integral Number) and returns an integral Number. year y의 first day의 day number를 반환합니다. It performs the following steps when called:
NOTE: following steps에서 numberYears1, numberYears4, numberYears100, 및 numberYears400은 각각 1, 4, 100, 및 400으로 divisible한 years의 number이며, epoch와 year y의 start 사이에 occur합니다. y가 epoch보다 before이면 number는 negative입니다.
The abstract operation TimeFromYear takes argument y (an integral Number) and returns a time value. year y의 start의 time value를 반환합니다. It performs the following steps when called:
The abstract operation YearFromTime takes argument tv (a finitetime value) and returns an integral Number. tv가 fall하는 year를 반환합니다. It performs the following steps when called:
The abstract operation InLeapYear takes argument tv (a finitetime value) and returns +0𝔽 or 1𝔽. tv가 leap year 안에 있으면 1𝔽를 반환하고 otherwise +0𝔽를 반환합니다. It performs the following steps when called:
The abstract operation MonthFromTime takes argument tv (a finitetime value) and returns an integral Number in the inclusive interval from +0𝔽 to 11𝔽. tv가 fall하는 month를 identifying하는 Number를 반환합니다. month value +0𝔽는 January를 specify합니다; 1𝔽는 February를 specify합니다; 2𝔽는 March를 specify합니다; 3𝔽는 April을 specify합니다; 4𝔽는 May를 specify합니다; 5𝔽는 June을 specify합니다; 6𝔽는 July를 specify합니다; 7𝔽는 August를 specify합니다; 8𝔽는 September를 specify합니다; 9𝔽는 October를 specify합니다; 10𝔽는 November를 specify합니다; 그리고 11𝔽는 December를 specify합니다. MonthFromTime(+0𝔽) = +0𝔽이며, 이는 1970년 1월 1일 목요일에 corresponding함에 note하십시오. It performs the following steps when called:
The abstract operation DateFromTime takes argument tv (a finitetime value) and returns an integral Number in the inclusive interval from 1𝔽 to 31𝔽. tv가 fall하는 month의 day를 반환합니다. It performs the following steps when called:
The abstract operation WeekDay takes argument tv (a finitetime value) and returns an integral Number in the inclusive interval from +0𝔽 to 6𝔽. tv가 fall하는 week의 day를 identifying하는 Number를 반환합니다. weekday value +0𝔽는 Sunday를 specify합니다; 1𝔽는 Monday를 specify합니다; 2𝔽는 Tuesday를 specify합니다; 3𝔽는 Wednesday를 specify합니다; 4𝔽는 Thursday를 specify합니다; 5𝔽는 Friday를 specify합니다; 그리고 6𝔽는 Saturday를 specify합니다. WeekDay(+0𝔽) = 4𝔽이며, 이는 1970년 1월 1일 목요일에 corresponding함에 note하십시오. It performs the following steps when called:
The abstract operation HourFromTime takes argument tv (a finitetime value) and returns an integral Number in the inclusive interval from +0𝔽 to 23𝔽. tv가 fall하는 day의 hour를 반환합니다. It performs the following steps when called:
The abstract operation MinFromTime takes argument tv (a finitetime value) and returns an integral Number in the inclusive interval from +0𝔽 to 59𝔽. tv가 fall하는 hour의 minute를 반환합니다. It performs the following steps when called:
The abstract operation SecFromTime takes argument tv (a finitetime value) and returns an integral Number in the inclusive interval from +0𝔽 to 59𝔽. tv가 fall하는 minute의 second를 반환합니다. It performs the following steps when called:
The abstract operation msFromTime takes argument tv (a finitetime value) and returns an integral Number in the inclusive interval from +0𝔽 to 999𝔽. tv가 fall하는 second의 millisecond를 반환합니다. It performs the following steps when called:
ECMAScript의 시간대는 시간대 식별자로 표현되며, 이는 0x0000부터 0x007F까지의 닫힌 구간에 있는 코드 유닛으로만 구성된 String이다.
ECMAScript 구현체가 지원하는 시간대는 AvailableNamedTimeZoneIdentifiers가 반환하는 시간대 식별자 레코드의 [[Identifier]] 필드로 표현되는 사용 가능한 이름 있는 시간대이거나, IsTimeZoneOffsetString이 true를 반환하는 String으로 표현되는 오프셋 시간대일 수 있다.
주 시간대 식별자는 사용 가능한 이름 있는 시간대에 대한 선호 식별자이다.
비주 시간대 식별자는 주 시간대 식별자가 아닌, 사용 가능한 이름 있는 시간대에 대한 식별자이다.
사용 가능한 이름 있는 시간대 식별자는 주 시간대 식별자 또는 비주 시간대 식별자 중 하나이다.
각 사용 가능한 이름 있는 시간대 식별자는 정확히 하나의 사용 가능한 이름 있는 시간대와 연관된다.
각 사용 가능한 이름 있는 시간대는 정확히 하나의 주 시간대 식별자와 0개 이상의 비주 시간대 식별자와 연관된다.
ECMAScript 구현체는 식별자 "UTC"를 가지는 사용 가능한 이름 있는 시간대를 지원해야 하며, 이는 UTC 시간대의 주 시간대 식별자여야 한다.
또한, 구현체는 임의 개수의 다른 사용 가능한 이름 있는 시간대를 지원할 수 있다.
ECMA-402 국제화 API 명세에 설명된 시간대 요구사항을 따르는 구현체를 시간대 인식이라고 한다.
시간대 인식 구현체는 IANA Time Zone Database의 Zone 및 Link 이름에 해당하는 사용 가능한 이름 있는 시간대를 지원해야 하며, 그러한 이름만 지원해야 한다.
시간대 인식 구현체에서, ECMA-402 명세에 명시된 AvailableNamedTimeZoneIdentifiers에 의해 특별히 재정의된 경우를 제외하고, 주 시간대 식별자는 IANA Time Zone Database의 Zone 이름이고, 비주 시간대 식별자는 각각 Link 이름이다.
전체 IANA Time Zone Database를 지원하지 않는 구현체도 시간대를 표현하는 식별자로 IANA Time Zone Database 이름을 사용하는 것이 권장된다.
input이 negative time zone transition 때문에 more than once occur하는 local time을 represent할 때(예: daylight saving time이 끝나거나 time zone rule change 때문에 time zone offset이 decreased되는 경우), returned List는 more than one element를 가지며 ascending numerical value로 sorted됩니다.
input이 positive time zone transition 때문에 skipped된 local time을 represent할 때(예: daylight saving time이 시작되거나 time zone rule change 때문에 time zone offset이 increased되는 경우), returned List는 empty입니다.
Otherwise, returned List는 one element를 가집니다.
any time zone에 대한 local political rules를 include하지 않는 ECMAScript implementation에 사용될 GetNamedTimeZoneEpochNanoseconds의 default implementation은 called될 때 following steps를 수행합니다:
time zone aware implementation에 대해 required되고(all others에도 recommended됨), IANA Time Zone Database https://www.iana.org/time-zones/의 time zone information을 사용해야 합니다.
America/New_York에서 2017년 11월 5일 1:30 AM은 twice repeated되므로, GetNamedTimeZoneEpochNanoseconds("America/New_York", 2017, 11, 5, 1, 30, 0, 0, 0, 0)는 length 2의 List를 반환할 것이며, first element는 05:30 UTC(UTC offset -04:00에서 01:30 US Eastern Daylight Time에 corresponding)를 represent하고 second element는 06:30 UTC(UTC offset -05:00에서 01:30 US Eastern Standard Time에 corresponding)를 represent합니다.
The implementation-defined abstract operation GetNamedTimeZoneOffsetNanoseconds takes arguments timeZoneIdentifier (a String) and epochNanoseconds (a BigInt) and returns an integer.
returned integer는 epoch를 기준으로 epochNanoseconds와 corresponding하는 instant에서 timeZoneIdentifier로 identified되는 named time zone의 UTC로부터의 offset을 nanoseconds 단위로 represent합니다.
any time zone에 대한 local political rules를 include하지 않는 ECMAScript implementation에 사용될 GetNamedTimeZoneOffsetNanoseconds의 default implementation은 called될 때 following steps를 수행합니다:
ECMA-402 Internationalization API를 implement하는 all implementation을 포함하여 time zone aware implementation은 ECMA-402 specification에 specified된 대로 AvailableNamedTimeZoneIdentifiers abstract operation을 implement해야 합니다.
time zone aware가 아닌 implementation의 경우, AvailableNamedTimeZoneIdentifiers는 called될 때 following steps를 수행합니다:
implementation이 any time zone에 대한 local political rules를 include하지 않으면, 다음을 수행한다.
The implementation-defined abstract operation SystemTimeZoneIdentifier takes no arguments and returns a String.
host environment의 current time zone을 represent하는 String을 반환합니다. 이는 IsTimeZoneOffsetString이 true를 반환하는 UTC offset을 represent하는 String이거나 primary time zone identifier입니다.
It performs the following steps when called:
implementation이 UTC time zone만 support하면, "UTC"를 반환한다.
Date object의 method에서 implementation이 commonly provide하는 functionality level을 ensure하기 위해, such thing이 exist한다면 SystemTimeZoneIdentifier가 host environment의 time zone setting에 corresponding하는 IANA time zone name을 return하는 것이 recommended됩니다.
GetNamedTimeZoneEpochNanoseconds와 GetNamedTimeZoneOffsetNanoseconds는 such rules가 exist한다면 해당 time zone의 standard time 및 daylight saving time에 대한 local political rules를 reflect해야 합니다.
예를 들어 host environment가 user가 time zone으로 US Eastern Time을 chosen한 system의 browser라면, SystemTimeZoneIdentifier는 "America/New_York"를 반환합니다.
21.4.1.25 LocalTime ( tv )
The abstract operation LocalTime takes argument tv (a finitetime value) and returns an integral Number.
tv를 UTC에서 local time으로 convert합니다.
tv에서 effect 중인 standard time 및 daylight saving time에 대한 local political rules를 사용하여 이 section에 specified된 way로 result를 determine해야 합니다.
It performs the following steps when called:
time zone aware implementation에 대해 required되고(all others에도 recommended됨), IANA Time Zone Database https://www.iana.org/time-zones/의 time zone information을 사용해야 합니다.
Note 3
negative time zone transition에서 repeated time이 있을 때(예: daylight saving time이 끝나거나 time zone adjustment가 decreased되는 경우) two different input time valuetvUTC가 same local time tlocal로 converted됩니다.
The abstract operation UTC takes argument t (a Number) and returns a time value.
t를 local time에서 UTC time value로 convert합니다.
t에서 effect 중인 standard time 및 daylight saving time에 대한 local political rules를 사용하여 이 section에 specified된 way로 result를 determine해야 합니다.
It performs the following steps when called:
NOTE: 다음 steps는 t가 negative time zone transition에서 multiple times repeating되는 local time(예: daylight saving time이 끝나거나 time zone rule change 때문에 time zone offset이 decreased되는 경우) 또는 positive time zone transition에서 skipped local time(예: daylight saving time이 시작되거나 time zone rule change 때문에 time zone offset이 increased되는 경우)을 represent할 때, t가 transition before의 time zone offset을 사용하여 interpreted되도록 ensure한다.
possibleInstants가 empty가 아니면, 다음을 수행한다.
disambiguatedInstant를 possibleInstants[0]으로 둔다.
그렇지 않으면,
NOTE: t는 positive time zone transition에서 skipped된 local time을 represent한다(예: daylight saving time starting 또는 time zone rule change가 UTC offset을 increasing하기 때문).
input t는 nominally time value이지만 any Number value일 수 있습니다.
algorithm은 t를 time value range로 limit해서는 안 됩니다. 그러면 local UTC offset에 관계없이 time value range의 boundary와 corresponding하는 input이 support될 수 있습니다.
예를 들어 maximum time value는 8.64 × 1015이며, 이는 "+275760-09-13T00:00:00Z"에 corresponding합니다.
local time zone offset이 해당 instant에서 UTC보다 1 hour ahead인 environment에서는, 더 큰 input인 8.64 × 1015 + 3.6 × 106로 represented되며, 이는 "+275760-09-13T01:00:00+01:00"에 corresponding합니다.
time zone aware implementation에 대해 required되고(all others에도 recommended됨), IANA Time Zone Database https://www.iana.org/time-zones/의 time zone information을 사용해야 합니다.
America/New_York에서 2017년 11월 5일 1:30 AM은 twice repeated됩니다(fall backward). 하지만 이는 1:30 AM UTC-05가 아니라 1:30 AM UTC-04로 interpreted되어야 합니다.
UTC(TimeClip(MakeDate(MakeDay(2017, 10, 5), MakeTime(1, 30, 0, 0))))에서 offsetMs의 value는 -4 × msPerHour입니다.
America/New_York에서 2017년 3월 12일 2:30 AM은 exist하지 않지만, 2:30 AM UTC-05(3:30 AM UTC-04와 equivalent)로 interpreted되어야 합니다.
UTC(TimeClip(MakeDate(MakeDay(2017, 2, 12), MakeTime(2, 30, 0, 0))))에서 offsetMs의 value는 -5 × msPerHour입니다.
The abstract operation MakeTime takes arguments hour (a Number), min (a Number), sec (a Number), and ms (a Number) and returns a Number. milliseconds 수를 calculate합니다. It performs the following steps when called:
The abstract operation MakeDay takes arguments year (a Number), month (a Number), and date (a Number) and returns a finite Number or NaN. days 수를 calculate합니다. It performs the following steps when called:
The abstract operation MakeDate takes arguments day (a Number) and time (a Number) and returns a finite Number or NaN. milliseconds 수를 calculate합니다. It performs the following steps when called:
The abstract operation MakeFullYear takes argument year (a Number) and returns an integral Number or NaN. year의 integer part와 associated된 full year를 반환하며, 0부터 99까지의 inclusive interval 안의 any value를 1900 start 이후 years count로 interpret합니다. proleptic Gregorian calendar와 alignment하기 위해, “full year”는 year 0(1 B.C.) start 이후 complete years의 signed count로 defined됩니다. It performs the following steps when called:
The abstract operation TimeClip takes argument time (a Number) and returns a time value. milliseconds 수를 calculate합니다. It performs the following steps when called:
ECMAScript는 ISO 8601 calendar date extended format의 simplification을 기반으로 date-times를 위한 string interchange format을 define합니다. format은 다음과 같습니다: YYYY-MM-DDTHH:mm:ss.sssZ
elements는 다음과 같습니다:
YYYY
proleptic Gregorian calendar에서 0000부터 9999까지의 four decimal digits로 된 year이거나, "+" 또는 "-" 뒤에 six decimal digits가 followed되는 expanded year입니다.
-
"-" (hyphen)가 string 안에 literally twice appear합니다.
MM
01 (January)부터 12 (December)까지의 two decimal digits로 된 year의 month입니다.
DD
01부터 31까지의 two decimal digits로 된 month의 day입니다.
T
time element의 beginning을 indicate하기 위해 "T"가 string 안에 literally appear합니다.
HH
midnight 이후 passed한 complete hours 수이며, 00부터 24까지의 two decimal digits입니다.
:
":" (colon)가 string 안에 literally twice appear합니다.
mm
hour의 start 이후 complete minutes 수이며, 00부터 59까지의 two decimal digits입니다.
ss
minute의 start 이후 complete seconds 수이며, 00부터 59까지의 two decimal digits입니다.
.
"." (dot)가 string 안에 literally appear합니다.
sss
second의 start 이후 complete milliseconds 수이며, three decimal digits입니다.
Z
UTC offset representation이며, "Z" (offset 없는 UTC)로 specified되거나, local time이 UTC보다 ahead 또는 behind임을 indicate하기 위해 "+" 또는 "-" 뒤에 time expression HH:mm가 followed되는 형식(time zone offset string format의 subset)입니다.
이 format은 date-only form을 include합니다:
YYYY
YYYY-MM
YYYY-MM-DD
또한 above date-only form 중 하나 바로 뒤에 following time form 중 하나가 followed되고 optional UTC offset representation이 appended되는 “date-time” form도 include합니다:
THH:mm
THH:mm:ss
THH:mm:ss.sss
out-of-bounds 또는 nonconforming element를 contain하는 string은 이 format의 valid instance가 아닙니다.
Note 1
every day는 midnight로 start하고 end하므로, two notations 00:00 및 24:00는 one date와 associated될 수 있는 two midnights를 distinguish하기 위해 available합니다. 이는 following two notations가 exactly same point in time을 refer함을 의미합니다: 1995-02-04T24:00 및 1995-02-05T00:00. latter form을 “calendar day의 end”로 해석하는 것은 ISO 8601과 consistent합니다. 그 specification이 이를 time interval을 describing하는 데 reserve하고 single point in time의 representation 안에서는 permit하지 않더라도 그렇습니다.
Note 2
CET, EST 등과 같은 civil time zone의 abbreviation을 specify하는 international standard는 존재하지 않으며, sometimes same abbreviation이 even two very different time zones에 사용됩니다. 이러한 이유로 ISO 8601과 이 format 모두 time zone offset의 numeric representation을 specify합니다.
21.4.1.32.1 Expanded Years
1970년 1월 1일을 기준으로 forward 또는 backward approximately 273,790 years의 full time value range를 cover하려면(21.4.1.1), 0 before 또는 9999 after의 years를 represent해야 합니다. ISO 8601은 year representation의 expansion을 permit하지만, information interchange의 partners 간 mutual agreement에 의해서만 permit합니다. simplified ECMAScript format에서 such expanded year representation은 6 digits를 가져야 하며 항상 + 또는 - sign이 prefixed됩니다. year 0은 positive로 considered되며 + sign으로 prefixed되어야 합니다. year 0을 -000000으로 represent하는 것은 invalid입니다. expanded years를 가진 Date Time String Format과 match하는 String이 time value range outside의 instant를 represent하면, Date.parse에 의해 unrecognizable로 treated되고 implementation-specific behaviour 또는 heuristics로 fallback하지 않고 그 function이 NaN을 return하게 합니다.
Note
expanded years를 가진 date-time values의 examples:
-271821-04-20T00:00:00Z
271822 B.C.
-000001-01-01T00:00:00Z
2 B.C.
+000000-01-01T00:00:00Z
1 B.C.
+000001-01-01T00:00:00Z
1 A.D.
+001970-01-01T00:00:00Z
1970 A.D.
+002009-12-15T00:00:00Z
2009 A.D.
+275760-09-13T00:00:00Z
275760 A.D.
21.4.1.33 Time Zone Offset String Format
ECMAScript는 ISO 8601에서 derived된 UTC offsets를 위한 string interchange format을 define합니다.
format은 following grammar로 described됩니다.
The abstract operation IsTimeZoneOffsetString takes argument offsetString (a String) and returns a Boolean. return value는 offsetString이 UTCOffset에 의해 given된 grammar에 conform하는지 여부를 indicate합니다. It performs the following steps when called:
The abstract operation ParseTimeZoneOffsetString takes argument offsetString (a String) and returns an integer. return value는 String offsetString에 corresponding하는 UTC offset이며, nanoseconds 수입니다. It performs the following steps when called:
constructor로 called될 때 new Date를 create하고 initialize합니다.
constructor가 아니라 function으로 called될 때 current time(UTC)을 represent하는 String을 반환합니다.
argument의 number 및 type에 따라 behaviour가 differ하는 function입니다.
class definition의 extends clause의 value로 사용될 수 있습니다. specified Date behaviour를 inherit하려는 subclass constructor는 [[DateValue]] internal slot을 가진 subclass instance를 create하고 initialize하기 위해 Date constructor에 대한 super call을 include해야 합니다.
21.4.2.1 Date ( ...values )
이 function은 called될 때 following steps를 수행합니다:
NewTarget이 undefined이면, 다음을 수행한다.
now를 current time을 identifying하는 time value (UTC)로 둔다.
이 function은 call이 occur한 UTC date 및 time을 designating하는 time value를 반환합니다.
21.4.3.2 Date.parse ( string )
이 function은 argument에 ToString operator를 apply합니다. ToString이 abrupt completion을 result하면 Completion Record가 immediately returned됩니다. Otherwise, 이 function은 resulting String을 date 및 time으로 interpret합니다; date 및 time에 corresponding하는 UTC time value인 Number를 반환합니다. String은 contents에 따라 local time, UTC time, 또는 어떤 other time zone의 time으로 interpreted될 수 있습니다. function은 first로 expanded years를 포함하여 Date Time String Format(21.4.1.32)에 described된 format에 따라 String을 parse하려고 attempt합니다. String이 that format에 conform하지 않으면 function은 any implementation-specific heuristics 또는 implementation-specific date format으로 fallback할 수 있습니다. unrecognizable하거나 out-of-bounds format element value를 contain하는 String은 이 function이 NaN을 return하게 해야 합니다.
String이 Date Time String Format에 conform하면, absent format element 대신 substitute value가 take됩니다. MM 또는 DD elements가 absent이면, "01"이 사용됩니다. HH, mm, 또는 ss elements가 absent이면, "00"이 사용됩니다. sss element가 absent이면, "000"이 사용됩니다. UTC offset representation이 absent이면, date-only form은 UTC time으로 interpreted되고 date-time form은 local time으로 interpreted됩니다.
x가 ECMAScript의 particular implementation 안에서 milliseconds amount가 zero인 any Date이면, all referenced properties가 their initial values를 가진다면, following expressions는 that implementation에서 same numeric value를 produce해야 합니다:
은 preceding three expressions와 same Number value를 produce할 필요가 없으며, general하게 이 function에 Date Time String Format(21.4.1.32)에 conform하지 않고 that implementation에서 toString 또는 toUTCString method에 의해 produced될 수 없는 any String value가 given될 때 produced되는 value는 implementation-defined입니다.
explicitly 달리 defined되지 않는 한, 아래에 defined된 Date prototype object의 methods는 generic하지 않으며, 이들에게 passed되는 this value는 time value로 initialized된 [[DateValue]] internal slot을 가진 object여야 합니다.
min이 present하지 않으면, 이 method는 min이 value getMinutes()로 present한 것처럼 behave합니다. sec가 present하지 않으면, sec가 value getSeconds()로 present한 것처럼 behave합니다. ms가 present하지 않으면, ms가 value getMilliseconds()로 present한 것처럼 behave합니다.
sec가 present하지 않으면, 이 method는 sec가 value getSeconds()로 present한 것처럼 behave합니다. ms가 present하지 않으면, 이는 ms가 value getMilliseconds()로 present한 것처럼 behave합니다.
21.4.4.25 Date.prototype.setMonth ( month [ , date ] )
month가 present하지 않으면, 이 method는 month가 value getUTCMonth()로 present한 것처럼 behave합니다. date가 present하지 않으면, date가 value getUTCDate()로 present한 것처럼 behave합니다.
21.4.4.30 Date.prototype.setUTCHours ( hour [ , min [ , sec [ , ms ] ] ] )
min이 present하지 않으면, 이 method는 min이 value getUTCMinutes()로 present한 것처럼 behave합니다. sec가 present하지 않으면, sec가 value getUTCSeconds()로 present한 것처럼 behave합니다. ms가 present하지 않으면, ms가 value getUTCMilliseconds()로 present한 것처럼 behave합니다.
21.4.4.31 Date.prototype.setUTCMilliseconds ( ms )
sec가 present하지 않으면, 이 method는 sec가 value getUTCSeconds()로 present한 것처럼 behave합니다. ms가 present하지 않으면, 이는 ms가 getUTCMilliseconds()에 의해 returned되는 value로 present한 것처럼 behave합니다.
21.4.4.33 Date.prototype.setUTCMonth ( month [ , date ] )
이 method는 intentionally generic입니다; this value가 Date일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다. However, any such object가 toISOString method를 가질 것을 require합니다.
ECMA-402 Internationalization API를 include하는 ECMAScript implementation은 ECMA-402 specification에 specified된 대로 이 method를 implement해야 합니다. ECMAScript implementation이 ECMA-402 API를 include하지 않으면 이 method의 following specification이 사용됩니다:
이 method는 String value를 반환합니다. String의 contents는 implementation-defined이지만, host environment의 current locale의 convention에 corresponding하는 convenient, human-readable form으로 current time zone에서 Date의 “date” portion을 represent하도록 intended됩니다.
이 method에 대한 optional parameter의 meaning은 ECMA-402 specification에 defined되어 있습니다; ECMA-402 support를 include하지 않는 implementation은 those parameter position을 anything else에 사용해서는 안 됩니다.
ECMA-402 Internationalization API를 include하는 ECMAScript implementation은 ECMA-402 specification에 specified된 대로 이 method를 implement해야 합니다. ECMAScript implementation이 ECMA-402 API를 include하지 않으면 이 method의 following specification이 사용됩니다:
이 method는 String value를 반환합니다. String의 contents는 implementation-defined이지만, host environment의 current locale의 convention에 corresponding하는 convenient, human-readable form으로 current time zone에서 Date를 represent하도록 intended됩니다.
이 method에 대한 optional parameter의 meaning은 ECMA-402 specification에 defined되어 있습니다; ECMA-402 support를 include하지 않는 implementation은 those parameter position을 anything else에 사용해서는 안 됩니다.
ECMA-402 Internationalization API를 include하는 ECMAScript implementation은 ECMA-402 specification에 specified된 대로 이 method를 implement해야 합니다. ECMAScript implementation이 ECMA-402 API를 include하지 않으면 이 method의 following specification이 사용됩니다:
이 method는 String value를 반환합니다. String의 contents는 implementation-defined이지만, host environment의 current locale의 convention에 corresponding하는 convenient, human-readable form으로 current time zone에서 Date의 “time” portion을 represent하도록 intended됩니다.
이 method에 대한 optional parameter의 meaning은 ECMA-402 specification에 defined되어 있습니다; ECMA-402 support를 include하지 않는 implementation은 those parameter position을 anything else에 사용해서는 안 됩니다.
이 method는 this value에 corresponding하는 instant in time을 represent하는 String value를 반환합니다. String의 format은 RFC 7231의 HTTP-date를 기반으로 하며, ECMAScript Dates가 support하는 full range of times를 support하도록 generalized됩니다.
21.4.4.45 Date.prototype [ %Symbol.toPrimitive% ] ( hint )
이 method는 ECMAScript language operator가 Date를 primitive value로 convert하기 위해 called합니다. hint에 allowed되는 values는 "default", "number", 및 "string"입니다. Date는 "default"를 "string"과 equivalent하게 treat한다는 점에서 built-in ECMAScript object 중 unique합니다. all other built-in ECMAScript objects는 "default"를 "number"와 equivalent하게 treat합니다.
이 method의 "name" property의 value는 "[Symbol.toPrimitive]"입니다.
21.4.5 Properties of Date Instances
Date instance는 Date prototype object에서 property를 inherit하는 ordinary object입니다. Date instance는 또한 [[DateValue]] internal slot을 가집니다. [[DateValue]] internal slot은 이 Date가 represented하는 time value입니다.
constructor로 called될 때 new String object를 create하고 initialize합니다.
constructor가 아니라 function으로 called될 때 type conversion을 수행합니다.
class definition의 extends clause의 value로 사용될 수 있습니다. specified String behaviour를 inherit하려는 subclass constructor는 [[StringData]] internal slot을 가진 subclass instance를 create하고 initialize하기 위해 String constructor에 대한 super call을 include해야 합니다.
이 function은 Tagged Template(13.3.11)의 tag function으로 use되도록 intended됩니다. 그렇게 called될 때, first argument는 well formed template object이고 rest parameter는 substitution values를 contain합니다.
explicitly 달리 stated되지 않는 한, 아래에 defined된 String prototype object의 methods는 generic하지 않으며, 이들에게 passed되는 this value는 String value 또는 String value로 initialized된 [[StringData]] internal slot을 가진 object여야 합니다.
이 method는 this object를 String으로 converting한 result인 String value 안에서 index position의 code unit을 contain하는 single element String을 반환합니다. 해당 index에 element가 없으면 result는 empty String입니다. result는 String value이며, String object가 아닙니다.
position < 0 또는 position ≥ size이면, empty String을 반환한다.
string의 position부터 position + 1까지의 substring을 반환한다.
Note 2
이 method는 intentionally generic입니다; this value가 String object일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.
22.1.3.3 String.prototype.charCodeAt ( position )
Note 1
이 method는 this object를 String으로 converting한 result인 String 안에서 index position의 code unit의 numeric value인 Number(216보다 작은 non-negative integral Number)를 반환합니다. 해당 index에 element가 없으면 result는 NaN입니다.
start를 positionInt를 0과 length 사이로 clamping한 result로 둔다.
index를 StringIndexOf(string, searchString, start)로 둔다.
index가 not-found이면, false를 반환한다.
true를 반환한다.
Note 1
searchString이 this object를 String으로 converting한 result의 substring으로, position 이상인 one or more indices에 appear하면 이 function은 true를 반환합니다; otherwise false를 반환합니다. position이 undefined이면 String 전체를 search하도록 0이 assumed됩니다.
Note 2
first argument가 RegExp이면 exception을 throw하는 것은, future editions가 such argument values를 allow하는 extensions를 define할 수 있도록 specified되었습니다.
Note 3
이 method는 intentionally generic입니다; this value가 String object일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.
22.1.3.9 String.prototype.indexOf ( searchString [ , position ] )
Note 1
searchString이 this object를 String으로 converting한 result의 substring으로, position 이상인 one or more indices에 appear하면, smallest such index가 returned됩니다; otherwise -1𝔽가 returned됩니다. position이 undefined이면 String 전체를 search하도록 +0𝔽가 assumed됩니다.
22.1.3.11 String.prototype.lastIndexOf ( searchString [ , position ] )
Note 1
searchString이 this object를 String으로 converting한 result의 substring으로 position 이하인 one or more indices에 appear하면, greatest such index가 returned됩니다; otherwise -1𝔽가 returned됩니다. position이 undefined이면, String value의 length가 assumed되어 String 전체를 search합니다.
ECMA-402 Internationalization API를 include하는 ECMAScript implementation은 ECMA-402 specification에 specified된 대로 이 method를 implement해야 합니다. ECMAScript implementation이 ECMA-402 API를 include하지 않으면 이 method의 following specification이 사용됩니다:
이 method는 this value(String string으로 converted됨)를 that(String thatValue로 converted됨)과 implementation-defined locale-sensitive String comparison한 result를 representing하는 NaN이 아닌 Number를 반환합니다. result는 host environment의 current locale의 conventions에 따른 String values의 sort order와 corresponding하도록 intended되며, string이 thatValue보다 before로 ordered되면 negative, string이 thatValue보다 after로 ordered되면 positive, 그리고 all other cases에서는 zero(string과 thatValue 사이에 relative ordering이 없음을 representing)입니다.
comparisons를 수행하기 before, 이 method는 Strings를 prepare하기 위해 following steps를 수행합니다:
이 method에 대한 optional second 및 third parameters의 meaning은 ECMA-402 specification에 defined되어 있습니다; ECMA-402 support를 include하지 않는 implementations는 those parameter positions에 any other interpretation을 assign해서는 안 됩니다.
actual return values는 additional information을 encode할 수 있도록 implementation-defined이지만, 이 method는 two arguments의 method로 considered될 때 all Strings의 set에 total ordering을 defining하는 consistent comparator일 것이 required됩니다. 또한 이 method는 Unicode Standard에 따른 canonical equivalence를 recognize하고 honour해야 하며, distinguishable Strings가 canonically equivalent인 경우 comparing할 때 +0𝔽를 return하는 것도 include합니다.
Note 1
이 method 자체는 Array.prototype.sort의 argument로 직접 suitable하지 않습니다. latter는 two arguments의 function을 require하기 때문입니다.
Note 2
이 method는 ECMAScript environment가 host environment로부터 사용할 수 있는 whatever language- and/or locale-sensitive comparison functionality에 rely할 수 있으며, host environment의 current locale의 conventions에 따라 compare하도록 intended됩니다. However, comparison capabilities와 관계없이, 이 method는 Unicode Standard에 따른 canonical equivalence를 recognize하고 honour해야 합니다—예를 들어, following comparisons는 모두 +0𝔽를 반환해야 합니다:
// Å ANGSTROM SIGN vs.// Å LATIN CAPITAL LETTER A + COMBINING RING ABOVE"\u212B".localeCompare("A\u030A")
// Ω OHM SIGN vs.// Ω GREEK CAPITAL LETTER OMEGA"\u2126".localeCompare("\u03A9")
// ṩ LATIN SMALL LETTER S WITH DOT BELOW AND DOT ABOVE vs.// ṩ LATIN SMALL LETTER S + COMBINING DOT ABOVE + COMBINING DOT BELOW"\u1E69".localeCompare("s\u0307\u0323")
// ḍ̇ LATIN SMALL LETTER D WITH DOT ABOVE + COMBINING DOT BELOW vs.// ḍ̇ LATIN SMALL LETTER D WITH DOT BELOW + COMBINING DOT ABOVE"\u1E0B\u0323".localeCompare("\u1E0D\u0307")
// 가 HANGUL CHOSEONG KIYEOK + HANGUL JUNGSEONG A vs.// 가 HANGUL SYLLABLE GA"\u1100\u1161".localeCompare("\uAC00")
이 method는 Unicode Standard chapter 3, section 3.7에 defined된 Unicode compatibility equivalents 또는 compatibility decompositions를 honour하지 않는 것이 recommended됩니다.
Note 3
이 method는 intentionally generic입니다; this value가 String object일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.
이 method는 this value를 representing하는 String에 대해 regexpOrPattern과 regular expression match를 수행하고 match results를 yield하는 iterator를 반환합니다. 각 match result는 String의 matched portion을 first element로 contain하고, 그 뒤에 any capturing groups에 의해 matched된 portions가 followed되는 Array입니다. regular expression이 never matches하면, returned iterator는 any match results도 yield하지 않습니다.
The abstract operation StringPad takes arguments string (a String), maxLength (a non-negative integer), fillString (a String), and placement (start or end) and returns a String. It performs the following steps when called:
argument maxLength는 string의 length보다 작아질 수 없도록 clamped됩니다.
Note 2
argument fillString은 " " (code unit 0x0020 SPACE로 구성된 String value)가 default입니다.
22.1.3.17.3 ToZeroPaddedDecimalString ( n, minLength )
The abstract operation ToZeroPaddedDecimalString takes arguments n (a non-negative integer) and minLength (a non-negative integer) and returns a String. It performs the following steps when called:
string을 decimal number로 formatted된 n의 String representation으로 둔다.
The abstract operation GetSubstitution takes arguments matched (a String), string (a String), position (a non-negative integer), captures (a List of either Strings or undefined), namedCaptures (an Object or undefined), and replacementTemplate (a String) and returns either a normal completion containing a String or a throw completion. 이 abstract operation의 purposes를 위해, decimal digit은 0x0030 (DIGIT ZERO)부터 0x0039 (DIGIT NINE)까지의 inclusive interval 안의 code unit입니다. It performs the following steps when called:
이 method는 this object를 String으로 converting한 result의 substrings가 stored된 Array를 반환합니다. substrings는 separator의 occurrences를 left to right로 searching하여 determined됩니다; 이러한 occurrences는 returned array 안의 any String의 part가 아니지만, String value를 divide up하는 역할을 합니다. separator의 value는 any length의 String일 수 있고, %Symbol.split% method를 가진 object(예: RegExp)일 수도 있습니다.
separator의 value는 empty String일 수 있습니다. 이 경우, separator는 input String의 beginning 또는 end에 있는 empty substring과 match하지 않으며, previous separator match의 end에 있는 empty substring과도 match하지 않습니다. separator가 empty String이면, String은 individual code unit elements로 split up됩니다; result array의 length는 String의 length와 equal하고, 각 substring은 one code unit을 contain합니다.
this value가 empty String이거나 empty String으로 converts되면, result는 separator가 empty String과 match할 수 있는지 여부에 depends합니다. match할 수 있으면, result array는 no elements를 contain합니다. Otherwise, result array는 one element를 contain하며, 이는 empty String입니다.
separator가 undefined이면, result array는 just one String을 contain하며, 이는 this value(String으로 converted됨)입니다. limit이 undefined가 아니면, output array는 no more than limit elements를 contain하도록 truncated됩니다.
Note 2
이 method는 intentionally generic입니다; this value가 String object일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.
22.1.3.24 String.prototype.startsWith ( searchString [ , position ] )
ECMA-402 Internationalization API를 include하는 ECMAScript implementation은 ECMA-402 specification에 specified된 대로 이 method를 implement해야 합니다. ECMAScript implementation이 ECMA-402 API를 include하지 않으면 이 method의 following specification이 사용됩니다:
이 method는 6.1.4에 described된 대로 String value를 UTF-16 encoded code points의 sequence로 interpret합니다.
toLowerCase와 exactly same하게 works하지만, host environment의 current locale의 conventions와 corresponding하는 locale-sensitive result를 yield하도록 intended된다는 점이 다릅니다. regular Unicode case mappings와 해당 language의 rules가 conflict하는 few cases(예: Turkish)에서만 difference가 있을 것입니다.
이 method에 대한 optional parameters의 meaning은 ECMA-402 specification에 defined되어 있습니다; ECMA-402 support를 include하지 않는 implementations는 those parameter positions를 anything else에 사용해서는 안 됩니다.
Note
이 method는 intentionally generic입니다; this value가 String object일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.
ECMA-402 Internationalization API를 include하는 ECMAScript implementation은 ECMA-402 specification에 specified된 대로 이 method를 implement해야 합니다. ECMAScript implementation이 ECMA-402 API를 include하지 않으면 이 method의 following specification이 사용됩니다:
이 method는 6.1.4에 described된 대로 String value를 UTF-16 encoded code points의 sequence로 interpret합니다.
toUpperCase와 exactly same하게 works하지만, host environment의 current locale의 conventions와 corresponding하는 locale-sensitive result를 yield하도록 intended된다는 점이 다릅니다. regular Unicode case mappings와 해당 language의 rules가 conflict하는 few cases(예: Turkish)에서만 difference가 있을 것입니다.
이 method에 대한 optional parameters의 meaning은 ECMA-402 specification에 defined되어 있습니다; ECMA-402 support를 include하지 않는 implementations는 those parameter positions를 anything else에 사용해서는 안 됩니다.
Note
이 method는 intentionally generic입니다; this value가 String object일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.
22.1.3.28 String.prototype.toLowerCase ( )
이 method는 6.1.4에 described된 대로 String value를 UTF-16 encoded code points의 sequence로 interpret합니다.
result는 Unicode Character Database의 locale-insensitive case mappings에 따라 derived되어야 합니다(이는 file UnicodeData.txt뿐만 아니라 accompanying file SpecialCasing.txt 안의 모든 locale-insensitive mappings도 explicitly include합니다).
Note 1
some code points의 case mapping은 multiple code points를 produce할 수 있습니다. 이 경우 result String은 source String과 same length가 아닐 수 있습니다. toUpperCase와 toLowerCase 모두 context-sensitive behaviour를 가지므로, methods는 symmetrical하지 않습니다. In other words, s.toUpperCase().toLowerCase()는 necessarily s.toLowerCase()와 equal하지 않습니다.
Note 2
이 method는 intentionally generic입니다; this value가 String object일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.
이 method는 intentionally generic입니다; this value가 String object일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.
22.1.3.32.1 TrimString ( arg, where )
The abstract operation TrimString takes arguments arg (an ECMAScript language value) and where (start, end, or start+end) and returns either a normal completion containing a String or a throw completion. 6.1.4에 described된 대로 arg를 UTF-16 encoded code points의 sequence로 interpret합니다. It performs the following steps when called:
trimmedString을 leading 및 trailing white space가 모두 removed된 string의 copy인 String value로 둔다.
trimmedString을 반환한다.
white space의 definition은 WhiteSpace와 LineTerminator의 union입니다. Unicode code point가 Unicode general category “Space_Separator” (“Zs”) 안에 있는지 determining할 때, code unit sequences는 6.1.4에 specified된 대로 UTF-16 encoded code point sequences로 interpreted됩니다.
22.1.3.33 String.prototype.trimEnd ( )
이 method는 6.1.4에 described된 대로 String value를 UTF-16 encoded code points의 sequence로 interpret합니다.
이 String object가 represented하는 String value 안의 elements 수입니다.
String object가 initialized되면, 이 property는 unchanging입니다. 이는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }를 가집니다.
22.1.5 String Iterator Objects
String Iterator는 some specific String instance object에 대한 specific iteration을 represent하는 object입니다. String Iterator objects를 위한 named constructor는 없습니다. 대신, String Iterator objects는 String instance objects의 certain methods를 calling하여 created됩니다.
UnicodePropertyName이 match한 source text가 Table 65의 “Property name and aliases” column에 listed된 Unicode property name 또는 property alias가 아니면 Syntax Error입니다.
LoneUnicodePropertyNameOrValue가 match한 source text가 PropertyValueAliases.txt에 listed된 General_Category (gc) property의 Unicode property value 또는 property value alias가 아니고, Table 66의 “Property name and aliases” column에 listed된 binary property 또는 binary property alias도 아니며, Table 67의 “Property name” column에 listed된 binary property of strings도 아니면 Syntax Error입니다.
enclosing Pattern이 [UnicodeSetsMode] parameter를 가지지 않고 LoneUnicodePropertyNameOrValue가 match한 source text가 Table 67의 “Property name” column에 listed된 binary property of strings이면 Syntax Error입니다.
The abstract operation CountLeftCapturingParensWithin takes argument parseNode (a Parse Node) and returns a non-negative integer. parseNode 안의 left-capturing parentheses 수를 반환합니다. left-capturing parenthesis는 Atom::(GroupSpecifieroptDisjunction) production의 ( terminal에 의해 matched되는 any ( pattern character입니다.
The abstract operation CountLeftCapturingParensBefore takes argument parseNode (a Parse Node) and returns a non-negative integer. enclosing pattern 안에서 parseNode의 left에 occur하는 left-capturing parentheses 수를 반환합니다.
22.2.1.4 Static Semantics: MightBothParticipate ( x, y )
The abstract operation MightBothParticipate takes arguments x (a Parse Node) and y (a Parse Node) and returns a Boolean. It performs the following steps when called:
The abstract operation GroupSpecifiersThatMatch takes argument thisGroupName (a GroupNameParse Node) and returns a List of GroupSpecifierParse Nodes. It performs the following steps when called:
The syntax-directed operation RegExpIdentifierCodePoints takes no arguments and returns a List of code points. It is defined piecewise over the following productions:
The syntax-directed operation RegExpIdentifierCodePoint takes no arguments and returns a code point. It is defined piecewise over the following productions:
regular expression pattern은 아래에 described된 process를 사용하여 Abstract Closure로 converted됩니다. implementation은 results가 same인 한, below에 listed된 것보다 more efficient algorithms를 use할 것이 encouraged됩니다. Abstract Closure는 RegExp object의 [[RegExpMatcher]] internal slot의 value로 사용됩니다.
Pattern은 its associated flags가 u도 v도 contain하지 않으면 BMP pattern입니다. Otherwise, Unicode pattern입니다. BMP pattern은 Basic Multilingual Plane의 range 안의 Unicode code points인 16-bit values의 sequence로 구성된 것으로 interpreted되는 String에 대해 match합니다. Unicode pattern은 UTF-16을 사용하여 encoded된 Unicode code points로 구성된 것으로 interpreted되는 String에 대해 match합니다. BMP pattern의 behaviour를 describing하는 context에서 “character”는 single 16-bit Unicode BMP code point를 의미합니다. Unicode pattern의 behaviour를 describing하는 context에서 “character”는 UTF-16 encoded code point(6.1.4)를 의미합니다. 어느 context에서든, “character value”는 corresponding non-encoded code point의 numeric value를 의미합니다.
Pattern의 syntax 및 semantics는 Pattern의 source text가 SourceCharacter values의 List였던 것처럼 defined되며, 각 SourceCharacter는 Unicode code point에 corresponding합니다. BMP pattern이 non-BMP SourceCharacter를 contain하면 전체 pattern은 UTF-16을 사용하여 encoded되고, 그 encoding의 individual code units가 List의 elements로 사용됩니다.
Note
예를 들어, source text에서 single non-BMP character U+1D11E (MUSICAL SYMBOL G CLEF)로 expressed된 pattern을 consider하십시오. Unicode pattern으로 interpreted되면, 이는 single code point U+1D11E로 구성된 single element(character) List가 됩니다. However, BMP pattern으로 interpreted되면, 먼저 UTF-16 encoded되어 code units 0xD834 및 0xDD1E로 구성된 two element List를 produce합니다.
Patterns는 ECMAScript String values로 RegExp constructor에 passed되며, 그 안에서 non-BMP characters는 UTF-16 encoded됩니다. 예를 들어, String value로 expressed된 single character MUSICAL SYMBOL G CLEF pattern은 elements가 code units 0xD834 및 0xDD1E인 length 2의 String입니다. 따라서 이를 two pattern characters로 구성된 BMP pattern으로 process하기 위해서는 string의 further translation이 필요하지 않습니다. However, Unicode pattern으로 process하기 위해서는 sole element가 single pattern character, 즉 code point U+1D11E인 List를 producing하는 데 UTF16SurrogatePairToCodePoint를 사용해야 합니다.
implementation은 such translations를 실제로 UTF-16으로 또는 UTF-16으로부터 perform하지 않을 수 있지만, 이 specification의 semantics는 pattern matching의 result가 such translations가 performed된 것과 같아야 함을 require합니다.
22.2.2.1 Notation
아래 descriptions는 다음 internal data structures를 사용합니다:
CharSetElement는 following two entities 중 하나입니다:
regexpRecord.[[UnicodeSets]]가 false이면, CharSetElement는 위 Pattern Semantics의 sense에서 character입니다.
regexpRecord.[[UnicodeSets]]가 true이면, CharSetElement는 elements가 위 Pattern Semantics의 sense에서 characters인 sequence입니다. 이는 empty sequence, one character의 sequences, 및 more than one character의 sequences를 include합니다. convenience를 위해, 이러한 kind의 CharSetElements로 작업할 때 individual character는 one character의 sequence와 interchangeably treated됩니다.
CharSet은 CharSetElements의 mathematical set입니다.
CaptureRange는 capture에 included된 characters의 range를 represent하는 Record { [[StartIndex]], [[EndIndex]] }이며, 여기서 [[StartIndex]]는 input 안의 range의 start index(inclusive)를 representing하는 integer이고, [[EndIndex]]는 input 안의 range의 end index(exclusive)를 representing하는 integer입니다. any CaptureRange에 대해, these indices는 [[StartIndex]] ≤ [[EndIndex]]라는 invariant를 satisfy해야 합니다.
MatchState는 Record { [[Input]], [[EndIndex]], [[Captures]] }이며, 여기서 [[Input]]은 matched되는 String을 representing하는 characters의 List이고, [[EndIndex]]는 integer이며, [[Captures]]는 pattern 안의 각 left-capturing parenthesis에 대해 하나씩 values의 List입니다. MatchStates는 regular expression matching algorithms에서 partial match states를 represent하는 데 사용됩니다. [[EndIndex]]는 지금까지 pattern에 의해 matched된 last input character의 index plus one이며, [[Captures]]는 capturing parentheses의 results를 hold합니다. [[Captures]]의 nth element는 nth set of capturing parentheses에 의해 captured된 characters의 range를 representing하는 CaptureRange이거나, nth set of capturing parentheses가 아직 reached되지 않은 경우 undefined입니다. backtracking 때문에, matching process 동안 many MatchStates가 언제든 use 중일 수 있습니다.
Pattern은 Abstract Closure value로 compiles됩니다. RegExpBuiltinExec는 then 이 procedure를 characters의 List와 그 List 안의 offset에 apply하여 pattern이 그 List 안의 exactly that offset에서 starting하여 match할지, 그리고 match한다면 capturing parentheses의 values가 무엇인지 determine할 수 있습니다. 22.2.2의 algorithms는 pattern을 compiling하는 것이 SyntaxError exception을 throw할 수 있도록 designed되어 있습니다; 반면 pattern이 successfully compiled된 후, resulting Abstract Closure를 apply하여 characters의 List에서 match를 find하는 것은 exception을 throw할 수 없습니다(out-of-memory처럼 anywhere에서 occur할 수 있는 any implementation-defined exceptions는 제외).
| regular expression operator는 two alternatives를 separates합니다. pattern은 first left Alternative를 match하려고 tries합니다(regular expression의 sequel이 followed됨); if it fails, right Disjunction을 match하려고 tries합니다(regular expression의 sequel이 followed됨). left Alternative, right Disjunction, 그리고 sequel이 모두 choice points를 가지면, left Alternative의 next choice로 moving하기 전에 sequel 안의 all choices가 tried됩니다. left Alternative의 choices가 exhausted되면, left Alternative 대신 right Disjunction이 tried됩니다. |에 의해 skipped된 pattern portion 안의 any capturing parentheses는 Strings 대신 undefined values를 produce합니다. 따라서, 예를 들어,
Consecutive Terms는 input의 consecutive portions를 simultaneously match하려고 try합니다. direction이 forward이면, left Alternative, right Term, 그리고 regular expression의 sequel이 모두 choice points를 가지는 경우, right Term의 next choice로 moving하기 전에 sequel 안의 all choices가 tried되고, left Alternative의 next choice로 moving하기 전에 right Term 안의 all choices가 tried됩니다. direction이 backward이면, Alternative와 Term의 evaluation order가 reversed됩니다.
The abstract operation RepeatMatcher takes arguments m (a Matcher), min (a non-negative integer), max (a non-negative integer or +∞), greedy (a Boolean), matchState (a MatchState), continue (a MatcherContinuation), parenIndex (a non-negative integer), and parenCount (a non-negative integer) and returns either a MatchState or failure. It performs the following steps when called:
max = 0이면, continue(matchState)를 반환한다.
m, min, max, greedy, matchState, continue, parenIndex, 및 parenCount를 capture하고 called될 때 following steps를 수행하는, parameters (y)를 가진 새 MatcherContinuationd를 둔다:
min = 0이고 y.[[EndIndex]] = matchState.[[EndIndex]]이면, failure를 반환한다.
min = 0이면 min2를 0으로 둔다; else min2를 min - 1로 둔다.
max = +∞이면 max2를 +∞로 둔다; else max2를 max - 1로 둔다.
RepeatMatcher(m, min2, max2, greedy, y, continue, parenIndex, parenCount)를 반환한다.
capability를 matchState.[[Captures]]의 copy로 둔다.
parenIndex + 1부터 parenIndex + parenCount까지의 inclusive interval 안의 각 integerk에 대해, 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)를 반환한다.
Note 1
Atom 뒤에 Quantifier가 followed되면 Quantifier가 specified한 number of times만큼 repeated됩니다. Quantifier는 non-greedy일 수 있으며, 이 경우 Atom pattern은 sequel을 still matching하면서 possible한 few times만 repeated됩니다. 또는 greedy일 수 있으며, 이 경우 Atom pattern은 sequel을 still matching하면서 possible한 many times만 repeated됩니다. Atom pattern은 그것이 match하는 input character sequence가 아니라 pattern itself가 repeated되므로, Atom의 different repetitions는 different input substrings를 match할 수 있습니다.
Note 2
Atom과 regular expression의 sequel이 모두 choice points를 가지면, Atom은 first possible한 many times(or non-greedy이면 possible한 few times)만큼 matched됩니다. last repetition of Atom의 next choice로 moving하기 전에 sequel 안의 all choices가 tried됩니다. Atom의 last (nth) repetition 안의 all choices는 Atom의 next-to-last (n - 1)st repetition 안의 next choice로 moving하기 전에 tried됩니다; at which point Atom의 more or fewer repetitions가 now possible한 것으로 turn out될 수 있습니다; these are exhausted됩니다(again, 가능한 few 또는 many 것으로 starting) before moving on to the next choice in the (n - 1)st repetition of Atom and so on.
Compare
/a[a-z]{2,4}/.exec("abcdefghi")
which returns "abcde" with
/a[a-z]{2,4}?/.exec("abcdefghi")
which returns "abc".
Consider also
/(aa|aabaac|ba|b|c)*/.exec("aabaac")
which, by the choice point ordering above, returns the array
["aaba", "ba"]
and not any of:
["aabaac", "aabaac"]
["aabaac", "c"]
위 choice points의 ordering은 two numbers(unary notation으로 represented됨)의 greatest common divisor를 calculate하는 regular expression을 writing하는 데 사용될 수 있습니다. following example은 10과 15의 gcd를 calculates합니다:
RepeatMatcher의 step 4는 Atom이 repeated될 때마다 Atom의 captures를 clears합니다. 우리는 regular expression
/(z)((a+)?(b+)?(c))*/.exec("zaacbbbcac")
에서 its behaviour를 볼 수 있으며, 이는 array
["zaacbbbcac", "z", "ac", "a", undefined, "c"]
를 반환하고, 다음을 반환하지 않습니다
["zaacbbbcac", "z", "ac", "a", "bbb", "c"]
because outermost *의 each iteration은 quantified Atom 안에 contained된 all captured Strings를 clears하고, 이 case에서는 capture Strings numbered 2, 3, 4, 및 5를 include하기 때문입니다.
Note 4
RepeatMatcher의 step 2.b는 minimum number of repetitions가 satisfied되면, empty character sequence를 match하는 Atom의 any more expansions는 further repetitions에 considered되지 않는다고 states합니다. 이는 regular expression engine이 다음과 같은 patterns에서 infinite loop에 빠지는 것을 prevents합니다:
/(a*)*/.exec("b")
or the slightly more complicated:
/(a*)b\1+/.exec("baaaac")
which returns the array
["b", ""]
22.2.2.3.2 EmptyMatcher ( )
The abstract operation EmptyMatcher takes no arguments and returns a Matcher. It performs the following steps when called:
아무것도 capture하지 않고 called될 때 following steps를 수행하는, parameters (matchState, continue)를 가진 새 Matcher를 반환한다:
The abstract operation MatchTwoAlternatives takes arguments m1 (a Matcher) and m2 (a Matcher) and returns a Matcher. It performs the following steps when called:
m1 및 m2를 capture하고 called될 때 following steps를 수행하는, parameters (matchState, continue)를 가진 새 Matcher를 반환한다:
The abstract operation MatchSequence takes arguments m1 (a Matcher), m2 (a Matcher), and direction (forward or backward) and returns a Matcher. It performs the following steps when called:
direction이 forward이면, 다음을 수행한다.
m1 및 m2를 capture하고 called될 때 following steps를 수행하는, parameters (matchState, continue)를 가진 새 Matcher를 반환한다:
form (?=Disjunction)는 zero-width positive lookahead를 specifies합니다. 이것이 succeed하려면, Disjunction 안의 pattern이 current position에서 match해야 하지만, sequel을 matching하기 전에 current position은 advanced되지 않습니다. Disjunction이 current position에서 several ways로 match할 수 있으면, only first one이 tried됩니다. other regular expression operators와 달리, (?= form 안으로의 backtracking은 없습니다(this unusual behaviour는 Perl로부터 inherited되었습니다). 이는 Disjunction이 capturing parentheses를 contain하고 pattern의 sequel이 those captures에 대한 backreferences를 contain할 때만 matters합니다.
예를 들어,
/(?=(a+))/.exec("baaabac")
는 first b 바로 뒤의 empty String을 matches하므로 array를 반환합니다:
["", "aaa"]
lookahead 안으로 backtracking이 없는 것을 illustrate하기 위해 다음을 consider하십시오:
form (?!Disjunction)는 zero-width negative lookahead를 specifies합니다. 이것이 succeed하려면, Disjunction 안의 pattern이 current position에서 match하지 못해야 합니다. sequel을 matching하기 전에 current position은 advanced되지 않습니다. Disjunction은 capturing parentheses를 contain할 수 있지만, them에 대한 backreferences는 Disjunction itself 안에서만 sense를 가집니다. pattern의 elsewhere에서 these capturing parentheses에 대한 Backreferences는 negative lookahead가 pattern이 succeed하기 위해 fail해야 하므로 always undefined를 return합니다. 예를 들어,
/(.*?)a(?!(a+)b\2c)\2(.*)/.exec("baaabaac")
는 positive number n of a's, b, another n a's(first \2로 specified됨), 그리고 c가 immediately followed하지 않는 a를 looks for합니다. second \2는 negative lookahead outside에 있으므로, undefined에 대해 matches하고 따라서 always succeeds합니다. whole expression은 array를 반환합니다:
The abstract operation IsWordChar takes arguments regexpRecord (a RegExp Record), input (a List of characters), and e (an integer) and returns a Boolean. It performs the following steps when called:
The syntax-directed operation CompileQuantifier takes no arguments and returns a Record with fields [[Min]] (a non-negative integer), [[Max]] (a non-negative integer or +∞), and [[Greedy]] (a Boolean). It is defined piecewise over the following productions:
The syntax-directed operation CompileQuantifierPrefix takes no arguments and returns a Record with fields [[Min]] (a non-negative integer) and [[Max]] (a non-negative integer or +∞). It is defined piecewise over the following productions:
r을 CaptureRange { [[StartIndex]]: ye, [[EndIndex]]: xe }로 둔다.
capability[parenIndex + 1]을 r로 설정한다.
z를 MatchState { [[Input]]: input, [[EndIndex]]: ye, [[Captures]]: capability }로 둔다.
c(z)를 반환한다.
m(x, d)를 반환한다.
Note 2
form (Disjunction)의 Parentheses는 Disjunction pattern의 components를 together group하고 match result를 save하는 two roles를 serve합니다. result는 backreference(\ followed by a non-zero decimal number), replace String 안에서 referenced, 또는 regular expression matching Abstract Closure로부터 array의 part로 returned되는 데 사용될 수 있습니다. parentheses의 capturing behaviour를 inhibit하려면 form (?:Disjunction)를 사용하십시오.
form \ followed by a non-zero decimal number n의 escape sequence는 nth set of capturing parentheses의 result(22.2.2.1)를 matches합니다. regular expression이 n보다 fewer capturing parentheses를 가지면 error입니다. regular expression이 n 또는 more capturing parentheses를 가지지만 nth one이 아무것도 capture하지 않았기 때문에 undefined이면, backreference는 always succeeds합니다.
22.2.2.7.1 CharacterSetMatcher ( regexpRecord, charSet, invert, direction )
The abstract operation CharacterSetMatcher takes arguments regexpRecord (a RegExp Record), charSet (a CharSet), invert (a Boolean), and direction (forward or backward) and returns a Matcher. It performs the following steps when called:
22.2.2.7.2 BackreferenceMatcher ( regexpRecord, ns, direction )
The abstract operation BackreferenceMatcher takes arguments regexpRecord (a RegExp Record), ns (a List of positive integers), and direction (forward or backward) and returns a Matcher. It performs the following steps when called:
regexpRecord, ns, 및 direction을 capture하고 called될 때 following steps를 수행하는, parameters (x, c)를 가진 새 Matcher를 반환한다:
The abstract operation Canonicalize takes arguments regexpRecord (a RegExp Record) and char (a character) and returns a character. It performs the following steps when called:
HasEitherUnicodeFlag(regexpRecord)가 true이고 regexpRecord.[[IgnoreCase]]가 true이면, 다음을 수행한다.
Unicode Character Database의 file CaseFolding.txt가 char에 대한 simple 또는 common case folding mapping을 provide하면, 그 mapping을 char에 apply한 result를 반환한다.
char의 numeric value ≥ 128이고 codeUnit의 numeric value < 128이면, char를 반환한다.
codeUnit을 반환한다.
Note
HasEitherUnicodeFlag(regexpRecord)가 true인 case-insignificant matches에서, all characters는 compared되기 immediately before Unicode Standard가 provided하는 simple mapping을 사용하여 implicitly case-folded됩니다. simple mapping은 always single code point로 maps하므로, 예를 들어 ß (U+00DF LATIN SMALL LETTER SHARP S)를 ss 또는 SS로 map하지 않습니다. 그러나 Basic Latin block 밖의 code points를 그 안의 code points로 map할 수 있습니다 — 예를 들어, ſ (U+017F LATIN SMALL LETTER LONG S)는 s (U+0073 LATIN SMALL LETTER S)로 case-fold되고 K (U+212A KELVIN SIGN)는 k (U+006B LATIN SMALL LETTER K)로 case-fold됩니다. those code points를 contain하는 Strings는 /[a-z]/ui와 같은 regular expressions에 의해 matched됩니다.
HasEitherUnicodeFlag(regexpRecord)가 false인 case-insignificant matches에서, mapping은 toCasefold가 아니라 Unicode Default Case Conversion algorithm toUppercase에 based하며, 이는 some subtle differences를 result합니다. 예를 들어, Ω (U+2126 OHM SIGN)는 toUppercase에 의해 itself로 mapped되지만 toCasefold에 의해 Ω (U+03A9 GREEK CAPITAL LETTER OMEGA)와 함께 ω (U+03C9 GREEK SMALL LETTER OMEGA)로 mapped되므로, "\u2126"는 /[ω]/ui 및 /[\u03A9]/ui에 의해 matched되지만 /[ω]/i 또는 /[\u03A9]/i에 의해 matched되지 않습니다. 또한 Basic Latin block 밖의 code point는 그 안의 code point로 mapped되지 않으므로, "\u017F ſ" 및 "\u212A K"와 같은 strings는 /[a-z]/i에 의해 matched되지 않습니다.
The abstract operation UpdateModifiers takes arguments regexpRecord (a RegExp Record), add (a String), and remove (a String) and returns a RegExp Record. It performs the following steps when called:
The syntax-directed operation CompileCharacterClass takes argument regexpRecord (a RegExp Record) and returns a Record with fields [[CharSet]] (a CharSet) and [[Invert]] (a Boolean). It is defined piecewise over the following productions:
ClassContents는 single ClassAtom 및/또는 dashes로 separated된 two ClassAtom의 ranges로 expand될 수 있습니다. latter case에서 ClassContents는 first ClassAtom과 second ClassAtom 사이의 all characters를 inclusive로 include합니다; either ClassAtom이 single character를 represent하지 않으면(예: one이 \w인 경우) 또는 first ClassAtom의 character value가 second ClassAtom의 character value보다 strictly greater이면 error가 occurs합니다.
Note 3
pattern이 case를 ignores하더라도, range의 two ends의 case는 어떤 characters가 range에 belong하는지 determining하는 데 significant합니다. 따라서 예를 들어, pattern /[E-F]/i는 letters E, F, e, 및 f만 matches하는 반면, pattern /[E-f]/i는 Unicode Basic Latin block 안의 all uppercase and lowercase letters 및 symbols [, \, ], ^, _, 그리고 `를 matches합니다.
Note 4
- character는 literally treated될 수 있고 range를 denote할 수도 있습니다. It is treated literally if it is the first or last character of ClassContents, the beginning or end limit of a range specification, or immediately follows a range specification.
ClassAtom은 regular expression의 rest에서 allowed되는 any escape sequences를 사용할 수 있지만, \b, \B, 및 backreferences는 제외합니다. CharacterClass 안에서 \b는 backspace character를 의미하는 반면, \B 및 backreferences는 errors를 raise합니다. ClassAtom 안에서 backreference를 사용하면 error가 causes됩니다.
result는 often two or more ranges로 구성됩니다. UnicodeSets가 true이고 IgnoreCase가 true이면, MaybeSimpleCaseFolding(regexpRecord, [Ā-č])는 그 range의 odd-numbered code points만 include합니다.
single character U+0008 (BACKSPACE)를 contain하는 CharSet을 반환한다.
22.2.2.9.1 CharacterRange ( charSet, otherSet )
The abstract operation CharacterRange takes arguments charSet (a CharSet) and otherSet (a CharSet) and returns a CharSet. It performs the following steps when called:
Assert: charSet 및 otherSet은 각각 exactly one character를 contain한다.
The abstract operation HasEitherUnicodeFlag takes argument regexpRecord (a RegExp Record) and returns a Boolean. It performs the following steps when called:
The abstract operation WordCharacters takes argument regexpRecord (a RegExp Record) and returns a CharSet. \b, \B, \w, 및 \W의 purposes를 위해 “word characters”로 considered되는 characters를 contain하는 CharSet을 반환합니다. It performs the following steps when called:
extraWordChars를 c가 basicWordChars 안에 없지만 Canonicalize(regexpRecord, c)가 basicWordChars 안에 있는 all characters c를 contain하는 CharSet으로 둔다.
Assert: HasEitherUnicodeFlag(regexpRecord)가 true이고 regexpRecord.[[IgnoreCase]]가 true인 경우가 아니면 extraWordChars는 empty이다.
basicWordChars와 extraWordChars의 union을 반환한다.
22.2.2.9.4 AllCharacters ( regexpRecord )
The abstract operation AllCharacters takes argument regexpRecord (a RegExp Record) and returns a CharSet. regular expression flags에 따른 “all characters”의 set을 반환합니다. It performs the following steps when called:
regexpRecord.[[UnicodeSets]]가 true이고 regexpRecord.[[IgnoreCase]]가 true이면, 다음을 수행한다.
The abstract operation MaybeSimpleCaseFolding takes arguments regexpRecord (a RegExp Record) and charSet (a CharSet) and returns a CharSet. regexpRecord.[[UnicodeSets]]가 false이거나 regexpRecord.[[IgnoreCase]]가 false이면, charSet을 반환합니다. Otherwise, Unicode Character Database의 file CaseFolding.txt 안의 Simple Case Folding (scf(codePoint)) definitions(each maps a single code point to another single code point)를 사용하여 charSet의 각 CharSetElement를 character-by-character로 canonical form에 map하고 resulting CharSet을 반환합니다. It performs the following steps when called:
The abstract operation CharacterComplement takes arguments regexpRecord (a RegExp Record) and complement (a CharSet) and returns a CharSet. It performs the following steps when called:
complement의 CharSetElements도 아닌 charSet의 CharSetElements를 contain하는 CharSet을 반환한다.
22.2.2.9.7 UnicodeMatchProperty ( regexpRecord, p )
The abstract operation UnicodeMatchProperty takes arguments regexpRecord (a RegExp Record) and p (ECMAScript source text) and returns a Unicode property name. It performs the following steps when called:
regexpRecord.[[UnicodeSets]]가 true이고 p가 Table 67의 “Property name” column에 listed된 Unicode property name이면, 다음을 수행한다.
Implementations는 Table 65, Table 66, 및 Table 67에 listed된 Unicode property names 및 aliases를 support해야 합니다. interoperability를 ensure하기 위해, implementations는 any other property names 또는 aliases를 support해서는 안 됩니다.
Note 1
예를 들어, Script_Extensions(property name) 및 scx(property alias)는 valid이지만, script_extensions 또는 Scx는 그렇지 않습니다.
Note 2
listed properties는 UTS18 RL1.2가 require하는 것의 superset을 form합니다.
Note 3
these tables의 entries의 spellings(casing 포함)는 Unicode Character Database의 file PropertyAliases.txt에서 used되는 spellings와 match합니다. that file의 precise spellings는 stable하다고 guaranteed됩니다.
Table 65: Non-binary Unicode property aliases and their canonical property names
The abstract operation UnicodeMatchPropertyValue takes arguments p (ECMAScript source text) and v (ECMAScript source text) and returns a Unicode property value. It performs the following steps when called:
Implementations는 Table 65에 listed된 properties에 대해 PropertyValueAliases.txt에 listed된 Unicode property values 및 property value aliases를 support해야 합니다. interoperability를 ensure하기 위해, implementations는 any other property values 또는 property value aliases를 support해서는 안 됩니다.
Note 1
예를 들어, Xpeo 및 Old_Persian은 valid Script_Extensions values이지만, xpeo 및 Old Persian은 그렇지 않습니다.
The syntax-directed operation CompileClassSetString takes argument regexpRecord (a RegExp Record) and returns a sequence of characters. It is defined piecewise over the following productions:
regexpRecord를 RegExp Record { [[IgnoreCase]]: i, [[Multiline]]: m, [[DotAll]]: s, [[Unicode]]: u, [[UnicodeSets]]: v, [[CapturingGroupsCount]]: capturingGroupsCount }로 둔다.
obj.[[RegExpRecord]]를 regexpRecord로 설정한다.
obj.[[RegExpMatcher]]를 argument regexpRecord와 함께 parseResult의 CompilePattern으로 설정한다.
22.2.3.4 Static Semantics: ParsePattern ( patternText, u, v )
The abstract operation ParsePattern takes arguments patternText (a sequence of Unicode code points), u (a Boolean), and v (a Boolean) and returns a Parse Node or a non-empty List of SyntaxError objects.
constructor로 called될 때 new RegExp object를 create하고 initialize합니다.
constructor가 아니라 function으로 called될 때, new RegExp object 또는 only argument가 RegExp object인 경우 argument itself를 반환합니다.
class definition의 extends clause의 value로 사용될 수 있습니다. specified RegExp behaviour를 inherit하려는 subclass constructors는 necessary internal slots를 가진 subclass instances를 create하고 initialize하기 위해 RegExp constructor에 대한 super call을 include해야 합니다.
pattern이 StringLiteral을 사용하여 supplied되면, String이 이 function에 의해 processed되기 전에 usual escape sequence substitutions가 performed됩니다. pattern이 이 function에 의해 recognized되기 위해 escape sequence를 contain해야 한다면, any U+005C (REVERSE SOLIDUS) code points는 StringLiteral의 contents가 formed될 때 removed되는 것을 prevent하기 위해 StringLiteral 안에서 escaped되어야 합니다.
NOTE: leading digit를 escaping하면 output이 \0 character escape 또는 \1 같은 DecimalEscape 뒤에서 사용될 수 있는 pattern text와 correspond하고, preceding escape sequence의 extension으로 interpreted되는 대신 still string을 match하게 된다. leading ASCII letter를 escaping하는 것도 \c 뒤의 context에 대해 같은 일을 한다.
similar names를 가지고 있음에도, EscapeRegExpPattern과 RegExp.escape는 similar actions를 수행하지 않습니다. former는 string으로 representation하기 위해 pattern을 escapes하는 반면, 이 function은 pattern 안에서 representation하기 위해 string을 escapes합니다.
22.2.5.1.1 EncodeForRegExpEscape ( codePoint )
The abstract operation EncodeForRegExpEscape takes argument codePoint (a code point) and returns a String. codePoint를 matching하기 위한 Pattern을 representing하는 String을 반환합니다. codePoint가 white space 또는 ASCII punctuator이면, returned value는 escape sequence입니다. Otherwise, returned value는 codePoint itself의 String representation입니다. It performs the following steps when called:
codePoint가 SyntaxCharacter에 의해 matched되거나 codePoint가 U+002F (SOLIDUS)이면, 다음을 수행한다.
RegExp[%Symbol.species%]는 set accessor function이 undefined인 accessor property입니다. Its get accessor function은 called될 때 다음 steps를 수행합니다:
this value를 반환한다.
이 function의 "name" property의 value는 "get [Symbol.species]"입니다.
Note
RegExp prototype methods는 normally their this value의 constructor를 사용하여 derived object를 create합니다. However, subclass constructor는 its %Symbol.species% property를 redefining하여 that default behaviour를 over-ride할 수 있습니다.
? Set(regexp, "lastIndex", 𝔽(nextIndex), true)를 수행한다.
matchCount를 matchCount + 1로 설정한다.
이 method의 "name" property의 value는 "[Symbol.match]"입니다.
Note
%Symbol.match% property는 regular expressions의 basic behaviour를 가진 objects를 identify하기 위해 IsRegExp abstract operation에 의해 사용됩니다. %Symbol.match% property의 absence 또는 Boolean coerce to true하지 않는 value를 가진 such property의 existence는 object가 regular expression object로 used될 intended가 아님을 indicates합니다.
NOTE: captureNumber = 1일 때, preceding step은 first element를 captures 안에 넣는다(index 0에). More generally, captureNumberth capture(captureNumberth set of capturing parentheses에 의해 captured된 characters)는 captures[captureNumber - 1]에 있다.
replacementString을 ? GetSubstitution(matched, string, position, captures, namedCaptures, replaceValue)로 둔다.
position ≥ nextSourcePosition이면, 다음을 수행한다.
NOTE: position은 normally backwards로 move해서는 안 된다. 그렇게 된다면, ill-behaving RegExp subclass 또는 global flag나 regexp의 other characteristics를 change하는 access triggered side-effect의 사용을 indication한다. such cases에서, corresponding substitution은 ignored된다.
accumulatedResult를 accumulatedResult, string의 nextSourcePosition부터 position까지의 substring, 및 replacementString의 string-concatenation으로 설정한다.
The abstract operation EscapeRegExpPattern takes arguments pattern (a String) and flags (a String) and returns a String. It performs the following steps when called:
flags가 "v"를 contain하면, 다음을 수행한다.
patternSymbol을 Pattern[+UnicodeMode, +UnicodeSetsMode]로 둔다.
Else if flags가 "u"를 contain하면, 다음을 수행한다.
patternSymbol을 Pattern[+UnicodeMode, ~UnicodeSetsMode]로 둔다.
Else,
patternSymbol을 Pattern[~UnicodeMode, ~UnicodeSetsMode]로 둔다.
escapedPattern을 UTF-16 encoded Unicode code points(6.1.4)로 interpreted된 pattern과 equivalent한 patternSymbol의 form인 String으로 두며, 그 안에서 certain code points는 below에 described된 대로 escaped된다. escapedPattern은 pattern과 differ할 수도 있고 differ하지 않을 수도 있다; however, escapedPattern을 patternSymbol로 evaluating하여 result하는 Abstract Closure는 constructed object의 [[RegExpMatcher]] internal slot이 given하는 Abstract Closure와 identically behave해야 한다. same values for pattern and flags를 사용하여 이 abstract operation을 multiple calls하면 identical results를 produce해야 한다.
pattern 안에 occurring하는 code points / 또는 any LineTerminator는 escapedPattern 안에서, "/", escapedPattern, "/", 및 flags의 string-concatenation이 constructed regular expression과 identically behave하는 RegularExpressionLiteral로(in an appropriate lexical context) parsed될 수 있도록 necessary하게 escaped되어야 한다. 예를 들어, pattern이 "/"이면 escapedPattern은 among other possibilities "\/" 또는 "\u002F"일 수 있지만, "/"일 수는 없다. 왜냐하면 flags가 followed되는 ///는 RegularExpressionLiteral이 아니라 SingleLineComment로 parsed될 것이기 때문이다. pattern이 empty String이면, 이 specification은 escapedPattern을 "(?:)"로 두어 met될 수 있다.
escapedPattern을 반환한다.
Note
similar names를 가지고 있음에도, RegExp.escape와 EscapeRegExpPattern은 similar actions를 수행하지 않습니다. former는 pattern 안에서 representation하기 위해 string을 escapes하는 반면, 이 function은 string으로 representation하기 위해 pattern을 escapes합니다.
이 method는 string을 String으로 converting한 result의 substrings가 stored된 Array를 반환합니다. substrings는 this value regular expression의 matches를 left to right로 searching하여 determined됩니다; 이러한 occurrences는 returned array 안의 any String의 part가 아니지만, String value를 divide up하는 역할을 합니다.
this value는 empty regular expression 또는 empty String을 match할 수 있는 regular expression일 수 있습니다. 이 경우, regular expression은 input String의 beginning 또는 end에 있는 empty substring과 match하지 않으며, previous separator match의 end에 있는 empty substring과도 match하지 않습니다. (예를 들어, regular expression이 empty String을 match하면, String은 individual code unit elements로 split up됩니다; result array의 length는 String의 length와 equal하고, 각 substring은 one code unit을 contain합니다.) backtracking이 해당 index에서 non-empty substring match를 yield할 수 있더라도, String의 given index에서 first match만 considered됩니다. (예를 들어, /a*?/[Symbol.split]("ab")는 array ["a", "b"]로 evaluates되는 반면, /a*/[Symbol.split]("ab")는 array ["","b"]로 evaluates됩니다.)
string이 empty String이거나 empty String으로 converts되면, result는 regular expression이 empty String을 match할 수 있는지 여부에 depends합니다. match할 수 있으면, result array는 no elements를 contain합니다. Otherwise, result array는 one element를 contain하며, 이는 empty String입니다.
regular expression이 capturing parentheses를 contain하면, separator가 matched될 때마다 capturing parentheses의 results(any undefined results 포함)가 output array에 spliced됩니다. 예를 들어,
The abstract operation RegExpExec takes arguments regexp (an Object) and string (a String) and returns either a normal completion containing either an Object or null, or a throw completion. It performs the following steps when called:
callable "exec" property가 found되지 않으면 이 algorithm은 built-in RegExp matching algorithm 사용을 attempt하는 것으로 fallback합니다. 이는 regular expressions를 사용하는 most built-in algorithms가 "exec"의 dynamic property lookup을 수행하지 않았던 prior editions용으로 written된 code에 대해 compatible behaviour를 제공합니다.
22.2.7.2 RegExpBuiltinExec ( regexp, string )
The abstract operation RegExpBuiltinExec takes arguments regexp (an initialized RegExp instance) and string (a String) and returns either a normal completion containing either an Array exotic object or null, or a throw completion. It performs the following steps when called:
length를 string의 length로 둔다.
lastIndex를 ℝ(? ToLength(! Get(regexp, "lastIndex")))로 둔다.
flags를 regexp.[[OriginalFlags]]로 둔다.
flags가 "g"를 contain하면 global을 true로 둔다; else global을 false로 둔다.
flags가 "y"를 contain하면 sticky를 true로 둔다; else sticky를 false로 둔다.
flags가 "d"를 contain하면 hasIndices를 true로 둔다; else hasIndices를 false로 둔다.
global이 false이고 sticky가 false이면, lastIndex를 0으로 설정한다.
NOTE: groupName이라고 named된 multiple groups가 있으면, groups는 이 point에서 이미 groupName property를 가지고 있을 수 있다. However, groups가 properties가 모두 writable data properties인 ordinary object이므로, CreateDataPropertyOrThrow call은 nevertheless succeed하는 것이 guaranteed된다.
The abstract operation AdvanceStringIndex takes arguments string (a String), index (a non-negative integer), and unicode (a Boolean) and returns a non-negative integer. It performs the following steps when called:
The abstract operation GetStringIndex takes arguments string (a String) and codePointIndex (a non-negative integer) and returns a non-negative integer. 6.1.4에 described된 대로 string을 UTF-16 encoded code points의 sequence로 interpret하고, such index가 exist할 때 code point index codePointIndex에 corresponding하는 code unit index를 반환합니다. Otherwise, string의 length를 반환합니다. It performs the following steps when called:
match가 end하는(exclusive) string의 start부터의 code units 수입니다.
22.2.7.6 GetMatchString ( string, match )
The abstract operation GetMatchString takes arguments string (a String) and match (a Match Record) and returns a String. It performs the following steps when called:
The abstract operation GetMatchIndexPair takes arguments string (a String) and match (a Match Record) and returns an Array. It performs the following steps when called:
The abstract operation MakeMatchIndicesIndexPairArray takes arguments string (a String), indices (a List of either Match Records or undefined), groupNames (a List of either Strings or undefined), and hasGroups (a Boolean) and returns an Array. It performs the following steps when called:
NOTE: name이라고 named된 multiple groups가 있으면, groups는 이 point에서 이미 name property를 가지고 있을 수 있다. However, groups가 properties가 모두 writable data properties인 ordinary object이므로, CreateDataPropertyOrThrow call은 nevertheless succeed하는 것이 guaranteed된다.
ECMAScript 2015 이전에는 RegExp instances가 own data properties"source", "global", "ignoreCase", 및 "multiline"을 가지는 것으로 specified되었습니다. Those properties는 now RegExp.prototype의 accessor properties로 specified됩니다.
RegExp instances는 또한 다음 property를 가집니다:
22.2.8.1 lastIndex
"lastIndex" property의 value는 next match를 start할 String index를 specifies합니다. 사용될 때 integral Number로 coerced됩니다(22.2.7.2 참조). 이 property는 attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false }를 가져야 합니다.
22.2.9 RegExp String Iterator Objects
RegExp String Iterator는 some specific String instance object에 대한 specific iteration을 represent하고, some specific RegExp instance object에 대해 matching하는 object입니다. RegExp String Iterator objects를 위한 named constructor는 없습니다. 대신, RegExp String Iterator objects는 RegExp instance objects의 certain methods를 calling하여 created됩니다.
The abstract operation CreateRegExpStringIterator takes arguments regexp (an Object), string (a String), global (a Boolean), and fullUnicode (a Boolean) and returns an Object. It performs the following steps when called:
constructor로 called될 때 new Array를 create하고 initialize합니다.
constructor가 아니라 function으로 called될 때도 new Array를 create하고 initialize합니다. 따라서 function call Array(…)는 same arguments를 가진 object creation expression new Array(…)와 equivalent합니다.
arguments의 number 및 types에 따라 behaviour가 달라지는 function입니다.
class definition의 extends clause의 value로 사용될 수 있습니다. exotic Array behaviour를 inherit하려는 subclass constructors는 Array exotic objects인 subclass instances를 initialize하기 위해 Array constructor에 대한 super call을 include해야 합니다. 그러나 Array.prototype methods의 대부분은 this value가 Array exotic object인지에 dependent하지 않은 generic methods입니다.
23.1.1.1 Array ( ...values )
이 function은 called될 때 다음 steps를 수행합니다:
NewTarget이 undefined이면 newTarget을 active function object로 둔다; else newTarget을 NewTarget으로 둔다.
이 method는 intentionally generic factory method입니다; its this value가 Array constructor일 것을 require하지 않습니다. 따라서 single numeric argument와 함께 called될 수 있는 any other constructors로 transferred되거나 inherited될 수 있습니다.
이 method는 intentionally generic factory method입니다; its this value가 Array constructor일 것을 require하지 않습니다. 따라서 single numeric argument와 함께 called될 수 있는 any other constructors로 transferred되거나 inherited될 수 있습니다.
이 method는 intentionally generic factory method입니다; its this value가 Array constructor일 것을 require하지 않습니다. 따라서 single numeric argument와 함께 called될 수 있는 other constructors로 transferred되거나 inherited될 수 있습니다.
Array[%Symbol.species%]는 set accessor function이 undefined인 accessor property입니다. Its get accessor function은 called될 때 다음 steps를 수행합니다:
this value를 반환한다.
이 function의 "name" property의 value는 "get [Symbol.species]"입니다.
Note
Array prototype methods는 normally their this value의 constructor를 사용하여 derived object를 create합니다. However, subclass constructor는 its %Symbol.species% property를 redefining하여 그 default behaviour를 over-ride할 수 있습니다.
step 6에서 "length" property를 explicitly setting하는 것은 items의 final non-empty element가 trailing holes를 가지거나 array가 built-in Array가 아닌 경우에도 length가 correct함을 ensure하기 위한 것입니다.
Note 2
이 method는 intentionally generic입니다; its this value가 Array일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.
callback은 three arguments를 accept하고 Boolean value로 coercible한 value를 return하는 function이어야 합니다. every는 callback이 false를 return하는 element를 find할 때까지 array에 present한 each element마다 ascending order로 callback을 once call합니다. such element가 found되면, every는 immediately false를 반환합니다. Otherwise, every는 true를 반환합니다. callback은 actually exist하는 array의 elements에 대해서만 called됩니다; array의 missing elements에 대해서는 called되지 않습니다.
thisArg parameter가 provided되면, callback의 each invocation에 대한 this value로 사용됩니다. provided되지 않으면, 대신 undefined가 사용됩니다.
callback은 three arguments와 함께 called됩니다: element의 value, element의 index, 그리고 traversed되는 object입니다.
every는 called된 object를 directly mutate하지 않지만, object는 callback calls에 의해 mutated될 수 있습니다.
every에 의해 processed되는 elements의 range는 callback에 대한 first call 전에 set됩니다. every call이 begin된 뒤 array에 appended되는 elements는 callback에 의해 visited되지 않습니다. array의 existing elements가 changed되면, callback에 passed되는 그 value는 every가 them을 visit하는 time의 value입니다; every call이 begin된 뒤 그리고 visited되기 전에 deleted되는 elements는 visited되지 않습니다. every는 mathematics의 “for all” quantifier처럼 acts합니다. 특히 empty array에 대해서는 true를 반환합니다.
callback은 three arguments를 accept하고 Boolean value로 coercible한 value를 return하는 function이어야 합니다. filter는 array의 each element에 대해 ascending order로 callback을 once call하고, callback이 true를 return하는 all values의 new array를 constructs합니다. callback은 actually exist하는 array의 elements에 대해서만 called됩니다; array의 missing elements에 대해서는 called되지 않습니다.
thisArg parameter가 provided되면, callback의 each invocation에 대한 this value로 사용됩니다. provided되지 않으면, 대신 undefined가 사용됩니다.
callback은 three arguments와 함께 called됩니다: element의 value, element의 index, 그리고 traversed되는 object입니다.
filter는 called된 object를 directly mutate하지 않지만, object는 callback calls에 의해 mutated될 수 있습니다.
filter에 의해 processed되는 elements의 range는 callback에 대한 first call 전에 set됩니다. filter call이 begin된 뒤 array에 appended되는 elements는 callback에 의해 visited되지 않습니다. array의 existing elements가 changed되면 callback에 passed되는 그 value는 filter가 them을 visit하는 time의 value입니다; filter call이 begin된 뒤 그리고 visited되기 전에 deleted되는 elements는 visited되지 않습니다.
이 method는 predicate가 true로 coerce되는 value를 return하는 one을 find할 때까지 array의 each element에 대해 ascending index order로 predicate를 once call합니다. such element가 found되면, find는 immediately that element value를 반환합니다. Otherwise, find는 undefined를 반환합니다.
이 method는 predicate가 true로 coerce되는 value를 return하는 one을 find할 때까지 array의 each element에 대해 ascending index order로 predicate를 once call합니다. such element가 found되면, findIndex는 immediately that element value의 index를 반환합니다. Otherwise, findIndex는 -1을 반환합니다.
이 method는 predicate가 true로 coerce되는 value를 return하는 one을 find할 때까지 array의 each element에 대해 descending index order로 predicate를 once call합니다. such element가 found되면, findLast는 immediately that element value를 반환합니다. Otherwise, findLast는 undefined를 반환합니다.
이 method는 predicate가 true로 coerce되는 value를 return하는 one을 find할 때까지 array의 each element에 대해 descending index order로 predicate를 once call합니다. such element가 found되면, findLastIndex는 immediately that element value의 index를 반환합니다. Otherwise, findLastIndex는 -1을 반환합니다.
obj는 array-like object 또는 TypedArray이어야 합니다. 이 operation은 predicate가 true로 coerce되는 value를 return하는 one을 find할 때까지 obj의 each element에 대해 ascending index order 또는 descending index order(direction에 의해 indicated됨)로 predicate를 once call합니다. 그 point에서, 이 operation은 found된 element의 index 및 value를 giving하는 Record를 반환합니다. such element가 found되지 않으면, 이 operation은 index에 -1𝔽을, value에 undefined를 specify하는 Record를 반환합니다.
predicate는 function이어야 합니다. array의 element에 대해 called될 때, three arguments가 passed됩니다: element의 value, element의 index, 그리고 traversed되는 object입니다. Its return value는 Boolean value로 coerced됩니다.
thisArg는 predicate의 each invocation에 대한 this value로 사용됩니다.
이 operation은 called된 object를 directly mutate하지 않지만, object는 predicate calls에 의해 mutated될 수 있습니다.
processed되는 elements의 range는 predicate에 대한 first call 전에, traversal이 begin되기 직전에 set됩니다. 이 뒤 array에 appended되는 elements는 predicate에 의해 visited되지 않습니다. array의 existing elements가 changed되면, predicate에 passed되는 그 value는 이 operation이 them을 visit하는 time의 value입니다. traversal이 begin된 뒤 그리고 visited되기 전에 deleted되는 elements도 still visited되며, prototype에서 looked up되거나 undefined입니다.
callback은 three arguments를 accept하는 function이어야 합니다. forEach는 array에 present한 each element마다 ascending order로 callback을 once call합니다. callback은 actually exist하는 array의 elements에 대해서만 called됩니다; array의 missing elements에 대해서는 called되지 않습니다.
thisArg parameter가 provided되면, callback의 each invocation에 대한 this value로 사용됩니다. provided되지 않으면, 대신 undefined가 사용됩니다.
callback은 three arguments와 함께 called됩니다: element의 value, element의 index, 그리고 traversed되는 object입니다.
forEach는 called된 object를 directly mutate하지 않지만, object는 callback calls에 의해 mutated될 수 있습니다.
forEach에 의해 processed되는 elements의 range는 callback에 대한 first call 전에 set됩니다. forEach call이 begin된 뒤 array에 appended되는 elements는 callback에 의해 visited되지 않습니다. array의 existing elements가 changed되면, callback에 passed되는 그 value는 forEach가 them을 visit하는 time의 value입니다; forEach call이 begin된 뒤 그리고 visited되기 전에 deleted되는 elements는 visited되지 않습니다.
이 method는 intentionally generic입니다; its this value가 Array일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.
Note 3
이 method는 similar indexOf method와 intentionally two ways에서 다릅니다. First, IsStrictlyEqual 대신 SameValueZero algorithm을 사용하여 NaN array elements를 detect할 수 있습니다. Second, missing array elements를 skip하지 않고, 대신 them을 undefined로 treating합니다.
이 method는 IsStrictlyEqual algorithm을 사용하여 searchElement를 array의 elements와 ascending order로 compare하고, one or more indices에서 found되면 smallest such index를 반환합니다; otherwise, -1𝔽를 반환합니다.
Note 1
optional second argument fromIndex의 default는 +0𝔽입니다(즉, whole array가 searched됩니다). 그것이 array의 length보다 크거나 같으면, -1𝔽가 returned됩니다, 즉 array는 searched되지 않습니다. 그것이 -0𝔽보다 작으면, array의 end로부터 offset을 compute하는 데 사용됩니다. computed index가 +0𝔽보다 작거나 같으면, whole array가 searched됩니다.
이 method는 intentionally generic입니다; its this value가 Array일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.
23.1.3.18 Array.prototype.join ( separator )
이 method는 array의 elements를 Strings로 convert한 뒤, separator의 occurrences로 separated하여 these Strings를 concatenates합니다. separator가 provided되지 않으면, single comma가 separator로 사용됩니다.
이 method는 IsStrictlyEqual algorithm을 사용하여 searchElement를 array의 elements와 descending order로 compare하고, one or more indices에서 found되면 largest such index를 반환합니다; otherwise, -1𝔽를 반환합니다.
optional second argument fromIndex의 default는 array의 length minus one입니다(즉, whole array가 searched됩니다). 그것이 array의 length보다 크거나 같으면, whole array가 searched됩니다. 그것이 -0𝔽보다 작으면, array의 end로부터 offset을 compute하는 데 사용됩니다. computed index가 -0𝔽보다 작으면, -1𝔽가 returned됩니다.
callback은 three arguments를 accept하는 function이어야 합니다. map은 array의 each element에 대해 ascending order로 callback을 once call하고, results로부터 new Array를 constructs합니다. callback은 actually exist하는 array의 elements에 대해서만 called됩니다; array의 missing elements에 대해서는 called되지 않습니다.
thisArg parameter가 provided되면, callback의 each invocation에 대한 this value로 사용됩니다. provided되지 않으면, 대신 undefined가 사용됩니다.
callback은 three arguments와 함께 called됩니다: element의 value, element의 index, 그리고 traversed되는 object입니다.
map은 called된 object를 directly mutate하지 않지만, object는 callback calls에 의해 mutated될 수 있습니다.
map에 의해 processed되는 elements의 range는 callback에 대한 first call 전에 set됩니다. map call이 begin된 뒤 array에 appended되는 elements는 callback에 의해 visited되지 않습니다. array의 existing elements가 changed되면, callback에 passed되는 그 value는 map이 them을 visit하는 time의 value입니다; map call이 begin된 뒤 그리고 visited되기 전에 deleted되는 elements는 visited되지 않습니다.
callback은 four arguments를 take하는 function이어야 합니다. reduce는 initialValue가 provided되지 않는 한 first element를 skipping하면서, array에 present한 each element에 대해 ascending order로 callback을 once call합니다.
callback은 four arguments와 함께 called됩니다: previousValue(callback에 대한 previous call로부터의 value), currentValue(current element의 value), currentIndex, 그리고 traversed되는 object입니다. callback이 처음 called될 때, previousValue와 currentValue는 two values 중 하나일 수 있습니다. reduce call에 initialValue가 supplied되었으면, previousValue는 initialValue가 되고 currentValue는 array의 first value가 됩니다. initialValue가 supplied되지 않았으면, previousValue는 array의 first value가 되고 currentValue는 second가 됩니다. array가 no elements를 contain하고 initialValue가 provided되지 않으면 TypeError입니다.
reduce는 called된 object를 directly mutate하지 않지만, object는 callback calls에 의해 mutated될 수 있습니다.
reduce에 의해 processed되는 elements의 range는 callback에 대한 first call 전에 set됩니다. reduce call이 begin된 뒤 array에 appended되는 elements는 callback에 의해 visited되지 않습니다. array의 existing elements가 changed되면, callback에 passed되는 그 value는 reduce가 them을 visit하는 time의 value입니다; reduce call이 begin된 뒤 그리고 visited되기 전에 deleted되는 elements는 visited되지 않습니다.
callback은 four arguments를 take하는 function이어야 합니다. reduceRight는 initialValue가 provided되지 않는 한 first call을 skipping하면서, array에 present한 each element에 대해 descending order로 callback을 once call합니다.
callback은 four arguments와 함께 called됩니다: previousValue(callback에 대한 previous call로부터의 value), currentValue(current element의 value), currentIndex, 그리고 traversed되는 object입니다. function이 처음 called될 때, previousValue와 currentValue는 two values 중 하나일 수 있습니다. reduceRight call에 initialValue가 supplied되었으면, previousValue는 initialValue가 되고 currentValue는 array의 last value가 됩니다. initialValue가 supplied되지 않았으면, previousValue는 array의 last value가 되고 currentValue는 second-to-last value가 됩니다. array가 no elements를 contain하고 initialValue가 provided되지 않으면 TypeError입니다.
reduceRight는 called된 object를 directly mutate하지 않지만, object는 callback calls에 의해 mutated될 수 있습니다.
reduceRight에 의해 processed되는 elements의 range는 callback에 대한 first call 전에 set됩니다. reduceRight call이 begin된 뒤 array에 appended되는 elements는 callback에 의해 visited되지 않습니다. array의 existing elements가 callback에 의해 changed되면, callback에 passed되는 그 value는 reduceRight가 them을 visit하는 time의 value입니다; reduceRight call이 begin된 뒤 그리고 visited되기 전에 deleted되는 elements는 visited되지 않습니다.
callback은 three arguments를 accept하고 Boolean value로 coercible한 value를 return하는 function이어야 합니다. some은 callback이 true를 return하는 one을 find할 때까지 array에 present한 each element에 대해 ascending order로 callback을 once call합니다. such element가 found되면, some은 immediately true를 반환합니다. Otherwise, some은 false를 반환합니다. callback은 actually exist하는 array의 elements에 대해서만 called됩니다; array의 missing elements에 대해서는 called되지 않습니다.
thisArg parameter가 provided되면, callback의 each invocation에 대한 this value로 사용됩니다. provided되지 않으면, 대신 undefined가 사용됩니다.
callback은 three arguments와 함께 called됩니다: element의 value, element의 index, 그리고 traversed되는 object입니다.
some은 called된 object를 directly mutate하지 않지만, object는 callback calls에 의해 mutated될 수 있습니다.
some에 의해 processed되는 elements의 range는 callback에 대한 first call 전에 set됩니다. some call이 begin된 뒤 array에 appended되는 elements는 callback에 의해 visited되지 않습니다. array의 existing elements가 changed되면, callback에 passed되는 그 value는 some이 them을 visit하는 time의 value입니다; some call이 begin된 뒤 그리고 visited되기 전에 deleted되는 elements는 visited되지 않습니다. some은 mathematics의 “exists” quantifier처럼 acts합니다. 특히 empty array에 대해서는 false를 반환합니다.
testResult를 ToBoolean(? Call(callback, thisArg, « kValue, 𝔽(k), obj »))로 둔다.
testResult가 true이면, true를 반환한다.
k를 k + 1로 설정한다.
false를 반환한다.
Note 2
이 method는 intentionally generic입니다; its this value가 Array일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.
23.1.3.30 Array.prototype.sort ( comparator )
이 method는 this array의 elements를 sorts합니다. comparator가 undefined가 아니면, arguments x 및 y two를 accept하고 x < y이면 negative Number, x > y이면 positive Number, otherwise zero를 return하는 function이어야 합니다.
called될 때 다음 steps를 수행합니다:
comparator가 undefined가 아니고 IsCallable(comparator)가 false이면, TypeError exception을 throw한다.
itemCount보다 작은 non-negative integers의 어떤 mathematical permutation π가 존재하여, itemCount보다 작은 every non-negative integerj에 대해 element old[j]가 exactly new[π(j)]와 same해야 합니다.
그런 다음 itemCount보다 작은 all non-negative integersj 및 k에 대해, ℝ(sortCompare(old[j], old[k])) < 0이면, π(j) < π(k)입니다.
그리고 j < k < itemCount인 all non-negative integersj 및 k에 대해, ℝ(sortCompare(old[j], old[k])) = 0이면, π(j) < π(k)입니다; 즉, sort는 stable입니다.
여기서 notation old[j]는 step 4가 executed되기 전의 items[j]를 refer하는 데 사용되고, notation new[j]는 step 4가 executed된 후의 items[j]를 refer하는 데 사용됩니다.
Abstract Closure 또는 function comparator는 set values 안의 all values a, b, 및 c(possibly same value)에 대해 below requirements가 모두 met되면 values values의 set에 대한 consistent comparator입니다: notation a <Cb는 ℝ(comparator(a, b)) < 0를 의미합니다; a =Cb는 ℝ(comparator(a, b)) = 0를 의미합니다; 그리고 a >Cb는 ℝ(comparator(a, b)) > 0를 의미합니다.
specific pair of values a 및 b가 two arguments로 given될 때 comparator(a, b)를 calling하면 always same value v를 return합니다. Furthermore, v는 Number이고, v는 NaN이 아닙니다. 이는 given pair of a and b에 대해 a <Cb, a =Cb, 및 a >Cb 중 exactly one이 true일 것을 imply함에 note하십시오.
comparator(a, b)를 calling해도 obj 또는 obj의 prototype chain에 있는 any object를 modify하지 않습니다.
a =Ca (reflexivity)
a =Cb이면, b =Ca입니다 (symmetry)
a =Cb이고 b =Cc이면, a =Cc입니다 (transitivity of =C)
a <Cb이고 b <Cc이면, a <Cc입니다 (transitivity of <C)
a >Cb이고 b >Cc이면, a >Cc입니다 (transitivity of >C)
Note
위 conditions는 comparator가 set values를 equivalence classes로 divide하고, 이러한 equivalence classes가 totally ordered되도록 ensure하는 데 necessary and sufficient합니다.
23.1.3.30.2 CompareArrayElements ( x, y, comparator )
ECMA-402 Internationalization API를 include하는 ECMAScript implementation은 ECMA-402 specification에 specified된 대로 이 method를 implement해야 합니다. ECMAScript implementation이 ECMA-402 API를 include하지 않으면 이 method의 다음 specification이 사용됩니다.
Note 1
ECMA-402의 first edition은 이 method에 대한 replacement specification을 include하지 않았습니다.
이 method의 optional parameters의 meanings는 ECMA-402 specification에 defined되어 있습니다; ECMA-402 support를 include하지 않는 implementations는 those parameter positions를 anything else에 사용해서는 안 됩니다.
이 method는 array의 elements를 their toLocaleString methods를 사용하여 Strings로 convert한 뒤, implementation-defined locale-sensitive separator String의 occurrences로 separated하여 these Strings를 concatenates합니다. 이 method는 host environment의 current locale의 conventions와 corresponding하는 locale-sensitive result를 yield하도록 intended된다는 점을 제외하면 toString과 analogous합니다.
Note 3
이 method는 intentionally generic입니다; its this value가 Array일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.
이 object의 own property names는 ECMAScript 2015 specification 이전에는 Array.prototype의 standard properties로 included되지 않았던 property names입니다. 이러한 names는 with statement binding purposes에서 ignored되어, outer scope의 binding으로 these names 중 하나를 사용하고, 그 binding이 binding object가 Array인 with statement에 의해 shadowed될 수 있는 existing code의 behaviour를 preserve합니다.
"with"가 unscopableList에 included되지 않는 reason은 그것이 이미 reserved word이기 때문입니다.
"length" property의 value를 reducing하는 것은 array index가 old length value와 new length value 사이에 있는 own array elements를 deleting하는 side-effect를 가집니다. However, non-configurable properties는 deleted될 수 없습니다. Array의 "length" property를 array의 existing non-configurable array-indexed property의 largest numeric own property name보다 numerically less than or equal인 value로 set하려고 attempt하면, length는 that non-configurable numeric own property name보다 one greater인 numeric value로 set됩니다. 10.4.2.1를 참조하십시오.
23.1.5 Array Iterator Objects
Array Iterator는 some specific Array instance object에 대한 specific iteration을 represent하는 object입니다. Array Iterator objects를 위한 named constructor는 없습니다. 대신, Array Iterator objects는 Array instance objects의 certain methods를 calling하여 created됩니다.
23.1.5.1 CreateArrayIterator ( array, kind )
The abstract operation CreateArrayIterator takes arguments array (an Object) and kind (key+value, key, or value) and returns an Object. such iterators를 return하는 Array methods를 위한 iterator objects를 create하는 데 사용됩니다. It performs the following steps when called:
iteration의 each element에 대해 return되는 것이 무엇인지 identify하는 value입니다.
23.2 TypedArray Objects
TypedArray는 underlying binary data buffer(25.1)의 array-like view를 제공합니다. TypedArray element type은 TypedArray instance의 all elements가 가지는 underlying binary scalar data type입니다. supported element types 각각에 대해 Table 71에 listed된 distinct TypedArrayconstructor가 있습니다. Table 71의 each constructor는 corresponding distinct prototype object를 가집니다.
이 method는 source에서 values를 reading하여 이 TypedArray 안에 multiple values를 sets합니다. details는 source의 type에 따라 differ합니다. optional offset value는 values가 written되는 이 TypedArray 안의 first element index를 indicates합니다. omitted되면, 0으로 assumed됩니다.
The abstract operation SetTypedArrayFromArrayLike takes arguments target (a TypedArray), targetOffset (a non-negative integer or +∞), and source (an ECMAScript language value, but not a TypedArray) and returns either a normal completion containingunused or a throw completion. source에서 values를 reading하여, index targetOffset에서 starting하여 target 안에 multiple values를 sets합니다. It performs the following steps when called:
The abstract operation SetTypedArrayFromTypedArray takes arguments target (a TypedArray), targetOffset (a non-negative integer or +∞), and source (a TypedArray) and returns either a normal completion containingunused or a throw completion. source에서 values를 reading하여, index targetOffset에서 starting하여 target 안에 multiple values를 sets합니다. It performs the following steps when called:
이는 below에 described된 경우를 제외하고 23.1.3.30에 defined된 Array.prototype.sort의 requirements와 same requirements를 implements하는 distinct method입니다. 이 method의 implementation은 this value가 fixed length를 가지며 integer-indexed properties가 sparse하지 않은 object라는 knowledge로 optimized될 수 있습니다.
이 method는 generic하지 않습니다. this value는 [[TypedArrayName]] internal slot을 가진 object여야 합니다.
called될 때 다음 steps를 수행합니다:
comparator가 undefined가 아니고 IsCallable(comparator)가 false이면, TypeError exception을 throw한다.
sortedList를 ? SortIndexedProperties(obj, length, sortCompare, read-through-holes)로 둔다.
j를 0으로 둔다.
Repeat, while j < length,
! Set(obj, ! ToString(𝔽(j)), sortedList[j], true)를 수행한다.
j를 j + 1로 설정한다.
obj를 반환한다.
Note
NaN은 always any other value보다 greater로 compare되므로(CompareTypedArrayElements 참조), comparator가 provided되지 않을 때 NaN property values는 always result의 end로 sort됩니다.
23.2.3.30 %TypedArray%.prototype.subarray ( start, end )
이 method는 element type이 this TypedArray의 element type이고 ArrayBuffer가 this TypedArray의 ArrayBuffer인 new TypedArray를 반환하며, start(inclusive)부터 end(exclusive)까지의 interval 안의 elements를 referencing합니다. start 또는 end 중 어느 하나가 negative이면, beginning에서가 아니라 array의 end로부터의 index를 refer합니다.
이는 TypedArrayLength가 "length"의 [[Get]]을 performing하는 대신 called된다는 점을 제외하고 23.1.3.32에 defined된 Array.prototype.toLocaleString과 same algorithm을 implements하는 distinct method입니다. underlying buffer가 resizable하지 않을 때 this value가 fixed length를 가지며 integer-indexed properties가 sparse하지 않다는 knowledge로 algorithm의 implementation이 optimized될 수 있습니다. However, such optimization은 algorithm의 specified behaviour에 any observable changes를 introduce해서는 안 됩니다.
이 method는 generic하지 않습니다. algorithm을 evaluating하기 전에 ValidateTypedArray가 this value와 seq-cst를 arguments로 하여 called됩니다. 그 result가 abrupt completion이면, algorithm을 evaluating하는 대신 that exception이 thrown됩니다.
Note
ECMAScript implementation이 ECMA-402 Internationalization API를 include하면, 이 method는 ECMA-402 specification 안의 Array.prototype.toLocaleString용 algorithm에 based됩니다.
23.2.3.38 get %TypedArray%.prototype [ %Symbol.toStringTag% ]
%TypedArray%.prototype[%Symbol.toStringTag%]는 set accessor function이 undefined인 accessor property입니다. Its get accessor function은 called될 때 다음 steps를 수행합니다:
obj를 this value로 둔다.
obj가 Object가 아니면, undefined를 반환한다.
obj가 [[TypedArrayName]] internal slot을 가지지 않으면, undefined를 반환한다.
The abstract operation TypedArrayElementSize takes argument obj (a TypedArray) and returns a non-negative integer. It performs the following steps when called:
obj.[[TypedArrayName]]에 대해 Table 71에 specified된 Element Size value를 반환한다.
23.2.4.6 TypedArrayElementType ( obj )
The abstract operation TypedArrayElementType takes argument obj (a TypedArray) and returns a TypedArray element type. It performs the following steps when called:
obj.[[TypedArrayName]]에 대해 Table 71에 specified된 Element Type value를 반환한다.
23.2.4.7 CompareTypedArrayElements ( x, y, comparator )
The abstract operation CompareTypedArrayElements takes arguments x (a Number or a BigInt), y (a Number or a BigInt), and comparator (a function object or undefined) and returns either a normal completion containing a Number or an abrupt completion. It performs the following steps when called:
otherwise noted된 경우를 제외하고, Table 71에서 TypedArray 대신 constructor name으로 사용되는 name만 differing하며 below에 described된 structure를 가지는 intrinsic object입니다.
arguments의 number 및 types에 따라 behaviour가 달라지는 function입니다. TypedArray call의 actual behaviour는 pass된 arguments의 number 및 kind에 depends합니다.
function으로 called되도록 intended되지 않으며, such manner로 called될 때 exception을 throw합니다.
클래스 정의의 extends 절의 값으로 사용될 수 있다. 지정된 TypedArray 동작을 상속하려는 서브클래스 생성자는 %TypedArray%.prototype의 내장 메서드를 지원하는 데 필요한 내부 상태로 서브클래스 인스턴스를 생성하고 초기화하기 위해 TypedArray 생성자에 대한 super 호출을 포함해야 한다.
23.2.5.1TypedArray ( ...args )
각 TypedArrayconstructor는 called될 때 다음 steps를 수행합니다:
The abstract operation AllocateTypedArray takes arguments ctorName (a String which is the name of a TypedArrayconstructor in Table 71), newTarget (a constructor), and defaultProto (a String) and optional argument length (a non-negative integer) and returns either a normal completion containing a TypedArray or a throw completion. TypedArrayconstructor의 instance를 validate하고 create하는 데 사용됩니다. length argument가 passed되면, that length의 ArrayBuffer도 allocated되고 new TypedArray instance와 associated됩니다. AllocateTypedArray는 TypedArray에 의해 사용되는 common semantics를 제공합니다. It performs the following steps when called:
The abstract operation InitializeTypedArrayFromArrayLike takes arguments obj (a TypedArray) and arrayLike (an Object, but not a TypedArray or an ArrayBuffer) and returns either a normal completion containingunused or a throw completion. It performs the following steps when called:
The abstract operation AllocateTypedArrayBuffer takes arguments obj (a TypedArray) and length (a non-negative integer) and returns either a normal completion containingunused or a throw completion. ArrayBuffer를 allocate하고 obj와 associate합니다. It performs the following steps when called:
given TypedArrayconstructor에 대한 prototype의 "constructor" property의 initial value는 constructor itself입니다.
23.2.8 Properties of TypedArray Instances
TypedArray instances는 TypedArrays입니다. 각 TypedArray instance는 corresponding TypedArray prototype object로부터 properties를 inherit합니다. 각 TypedArray instance는 다음 internal slots를 가집니다: [[ViewedArrayBuffer]], [[TypedArrayName]], [[ContentType]], [[ByteLength]], [[ByteOffset]], 및 [[ArrayLength]].
23.3 Uint8Array Objects
Uint8Array는 위에 described된 TypedArray의 particular kind입니다. 또한 Uint8Array constructor(23.3.1)와 Uint8Array prototype object(23.3.2)에 additional methods가 있습니다.
23.3.1 Additional Properties of the Uint8Array Constructor
The abstract operation SetUint8ArrayBytes takes arguments into (a Uint8Array) and bytes (a List of byte values) and returns unused. It performs the following steps when called:
offset을 into.[[ByteOffset]]으로 둔다.
length를 bytes 안의 elements 수로 둔다.
index를 0으로 둔다.
Repeat, while 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 )
The abstract operation SkipAsciiWhitespace takes arguments string (a String) and index (a non-negative integer) and returns a non-negative integer. It performs the following steps when called:
length를 string의 length로 둔다.
Repeat, while index < length,
char를 string 내 index index의 code unit으로 둔다.
char가 0x0009 (TAB), 0x000A (LF), 0x000C (FF), 0x000D (CR), 또는 0x0020 (SPACE) 중 하나가 아니면, 다음을 수행한다.
The abstract operation DecodeFinalBase64Chunk takes arguments chunk (a String of length 2 or 3) and throwOnExtraBits (a Boolean) and returns either a normal completion containing a List of byte values, or a throw completion. It performs the following steps when called:
The abstract operation DecodeFullLengthBase64Chunk takes argument chunk (a String of length 4) and returns a List of byte values of length 3.
standard base64 alphabet은 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"입니다. 즉, Unicode Basic Latin block 안의 every letter 및 number에 corresponding하는 code units와 "+" 및 "/"를 elements로 가지는 String입니다.
The abstract operation FromBase64 takes arguments string (a String), alphabet ("base64" or "base64url"), and lastChunkHandling ("loose", "strict", or "stop-before-partial") and optional argument maxLength (a non-negative integer) and returns a Record with fields [[Read]] (an integer), [[Bytes]] (a List of byte values), and [[Error]] (a SyntaxError object or none). It performs the following steps when called:
maxLength가 present하지 않으면, 다음을 수행한다.
maxLength를 253 - 1로 설정한다.
NOTE: input이 String이므로, Strings의 length는 253 - 1 characters로 limited되고, output은 input이 가진 characters보다 more bytes를 require하지 않으므로, 이 limit에는 never reached될 수 없다. However, maxLength에 finite value를 사용하는 것이 editorially convenient하다.
NOTE: 아래 algorithm에서 validation 및 decoding의 order는 observable하지 않다. Implementations는 validation을 decoding과 interleaving할 수도 있으며, 가장 efficient한 any order로 them을 수행하도록 encouraged된다.
Record { [[Read]]: read, [[Bytes]]: bytes, [[Error]]: none }를 반환한다.
23.3.3.8 FromHex ( string [ , maxLength ] )
The abstract operation FromHex takes argument string (a String) and optional argument maxLength (a non-negative integer) and returns a Record with fields [[Read]] (an integer), [[Bytes]] (a List of byte values), and [[Error]] (a SyntaxError object or none). It performs the following steps when called:
maxLength가 present하지 않으면, maxLength를 253 - 1로 설정한다.
Record { [[Read]]: read, [[Bytes]]: bytes, [[Error]]: error }를 반환한다.
Repeat, while read < length and the number of elements in bytes < maxLength,
hexits를 string의 read부터 read + 2까지의 substring으로 둔다.
hexits가 "0123456789abcdefABCDEF" 안에 있지 않은 any code units를 contain하면, 다음을 수행한다.
error를 newly created SyntaxError object로 둔다.
Record { [[Read]]: read, [[Bytes]]: bytes, [[Error]]: error }를 반환한다.
read를 read + 2로 설정한다.
byte를 values 10부터 15까지의 digits에 대해 letters A through F 및 a through f를 사용하여, base-16 notation에서 hexits가 represented하는 integer value로 둔다.
byte를 bytes에 append한다.
Record { [[Read]]: read, [[Bytes]]: bytes, [[Error]]: none }를 반환한다.
24 Keyed Collections
24.1 Map Objects
Maps는 keys와 values 모두 arbitrary ECMAScript language values일 수 있는 key/value pairs의 collections입니다. distinct key value는 Map의 collection 안에서 하나의 key/value pair에만 occur할 수 있습니다. Distinct key values는 SameValueZero comparison algorithm의 semantics를 사용하여 discriminated됩니다.
Maps는 collection 안의 elements 수에 대해 average로 sublinear인 access times를 제공하는 hash tables 또는 other mechanisms를 사용하여 implemented되어야 합니다. 이 specification에서 사용되는 data structure는 Maps의 required observable semantics를 describe하기 위한 것일 뿐입니다. viable implementation model로 intended되지 않습니다.
constructor로 called될 때 new Map을 create하고 initialize합니다.
function으로 called되도록 intended되지 않으며, such manner로 called될 때 exception을 throw합니다.
클래스 정의의 extends 절의 값으로 사용될 수 있다. 지정된 Map 동작을 상속하려는 서브클래스 생성자는 Map.prototype의 내장 메서드를 지원하는 데 필요한 내부 상태로 서브클래스 인스턴스를 생성하고 초기화하기 위해 Map 생성자에 대한 super 호출을 포함해야 한다.
parameter iterable이 present하면, 이는 two element array-like object를 produce하는 iterator object를 반환하는 %Symbol.iterator% method를 implement하는 object일 것으로 expected됩니다. 그 first element는 Map key로 사용될 value이고 second element는 그 key와 associate할 value입니다.
The abstract operation AddEntriesFromIterable takes arguments target (an Object), iterable (an ECMAScript language value, but not undefined or null), and adder (a function object) and returns either a normal completion containing an Object or a throw completion. adder는 target을 receiver로 하여 invoked됩니다. It performs the following steps when called:
iteratorRecord를 ? GetIterator(iterable, sync)로 둔다.
parameter iterable은 two element array-like object를 produce하는 iterator object를 반환하는 %Symbol.iterator% method를 implement하는 object일 것으로 expected됩니다. 그 first element는 Map key로 사용될 value이고 second element는 그 key와 associate할 value입니다.
callback은 two arguments를 accept하는 function이어야 합니다. groupBy는 items 안의 각 element에 대해 ascending order로 callback을 한 번씩 calls하고, new Map을 constructs합니다. callback에 의해 returned되는 each value는 Map 안의 key로 사용됩니다. such key마다, result Map은 key가 that key이고 value가 callback이 that key를 returned한 all elements를 containing하는 array인 entry를 가집니다.
callback은 two arguments, 즉 element의 value와 element의 index로 called됩니다.
groupBy의 return value는 Map입니다.
이 function은 called될 때 다음 steps를 수행합니다:
groups를 ? GroupBy(items, callback, collection)로 둔다.
map.[[MapData]]의 각 Record { [[Key]], [[Value]] } entry에 대해, 다음을 수행한다.
entry.[[Key]]가 empty가 아니고 SameValue(entry.[[Key]], key)가 true이면, 다음을 수행한다.
entry.[[Key]]를 empty로 설정한다.
entry.[[Value]]를 empty로 설정한다.
true를 반환한다.
false를 반환한다.
Note
value empty는 entry가 deleted되었음을 indicate하기 위한 specification device로 사용됩니다. Actual implementations는 internal data structures에서 entry를 physically removing하는 것과 같은 other actions를 취할 수 있습니다.
? Call(callback, thisArg, « entry.[[Value]], entry.[[Key]], map »)를 수행한다.
NOTE: entries 안의 elements 수는 callback의 execution 동안 increased되었을 수 있다.
entriesCount를 entries 안의 elements 수로 설정한다.
undefined를 반환한다.
Note
callback은 three arguments를 accept하는 function이어야 합니다. forEach는 Map 안에 present한 each key/value pair에 대해 key insertion order로 callback을 한 번씩 calls합니다. callback은 actually exist하는 Map의 keys에 대해서만 called되며, Map에서 deleted된 keys에 대해서는 called되지 않습니다.
thisArg parameter가 provided되면, callback의 each invocation에서 this value로 사용됩니다. provided되지 않으면, 대신 undefined가 사용됩니다.
callback은 three arguments, 즉 item의 value, item의 key, 그리고 traversed되는 Map으로 called됩니다.
forEach는 called된 object를 directly mutate하지 않지만, object는 callback calls에 의해 mutated될 수 있습니다. map의 [[MapData]]의 each entry는 한 번만 visited됩니다. forEach call이 begins된 후 added된 new keys는 visited됩니다. key가 visited된 후 deleted되고 forEach call이 completes되기 전에 re-added되면 key는 revisited됩니다. forEach call이 begins된 후 visited되기 전에 deleted된 keys는, forEach call이 completes되기 전에 key가 again added되지 않는 한 visited되지 않습니다.
Map Iterator는 some specific Map instance object에 대한 specific iteration을 represents하는 object입니다. Map Iterator objects에 대한 named constructor는 없습니다. Instead, Map Iterator objects는 Map instance objects의 certain methods를 calling하여 created됩니다.
Set objects는 ECMAScript language values의 collections입니다. Set은 each distinct value를 at most once contain할 수 있습니다. Distinct values는 SameValueZero comparison algorithm의 semantics를 사용하여 discriminated됩니다.
Set objects는 collection 안의 elements 수에 대해 average로 sublinear인 access times를 제공하는 hash tables 또는 other mechanisms를 사용하여 implemented되어야 합니다. 이 specification에서 사용되는 data structure는 Set objects의 required observable semantics를 describe하기 위한 것일 뿐입니다. viable implementation model로 intended되지 않습니다.
24.2.1 Abstract Operations For Set Objects
24.2.1.1 Set Records
Set Record는 Set 또는 similar object의 interface를 encapsulate하는 데 사용되는 Record value입니다.
new Set Record { [[SetObject]]: obj, [[Size]]: intSize, [[Has]]: has, [[Keys]]: keys }를 반환한다.
24.2.1.3 SetDataHas ( setData, value )
The abstract operation SetDataHas takes arguments setData (a List of either ECMAScript language values or empty) and value (an ECMAScript language value) and returns a Boolean. It performs the following steps when called:
The abstract operation SetDataIndex takes arguments setData (a List of either ECMAScript language values or empty) and value (an ECMAScript language value) and returns a non-negative integer or not-found. It performs the following steps when called:
The abstract operation SetDataSize takes argument setData (a List of either ECMAScript language values or empty) and returns a non-negative integer. It performs the following steps when called:
function으로 called되도록 intended되지 않으며, such manner로 called될 때 exception을 throw합니다.
클래스 정의의 extends 절의 값으로 사용될 수 있다. 지정된 Set 동작을 상속하려는 서브클래스 생성자는 Set.prototype의 내장 메서드를 지원하는 데 필요한 내부 상태로 서브클래스 인스턴스를 생성하고 초기화하기 위해 Set 생성자에 대한 super 호출을 포함해야 한다.
value empty는 entry가 deleted되었음을 indicate하기 위한 specification device로 사용됩니다. Actual implementations는 internal data structures에서 entry를 physically removing하는 것과 같은 other actions를 취할 수 있습니다.
? Call(callback, thisArg, « entry, entry, set »)를 수행한다.
NOTE: entries 안의 elements 수는 callback의 execution 동안 increased되었을 수 있다.
entriesCount를 entries 안의 elements 수로 설정한다.
undefined를 반환한다.
Note
callback은 three arguments를 accept하는 function이어야 합니다. forEach는 Set object 안에 present한 each value에 대해 value insertion order로 callback을 한 번씩 calls합니다. callback은 actually exist하는 Set의 values에 대해서만 called되며, set에서 deleted된 keys에 대해서는 called되지 않습니다.
thisArg parameter가 provided되면, callback의 each invocation에서 this value로 사용됩니다. provided되지 않으면, 대신 undefined가 사용됩니다.
callback은 three arguments로 called됩니다: first two arguments는 Set 안에 contained된 value입니다. same value가 both arguments로 passed됩니다. traversed되는 Set object는 third argument로 passed됩니다.
callback은 Map 및 Array용 forEach methods가 사용하는 call back functions와 consistent하기 위해 three arguments로 called됩니다. Sets에서는 each item value가 key이자 value인 것으로 considered됩니다.
forEach는 called된 object를 directly mutate하지 않지만, object는 callback calls에 의해 mutated될 수 있습니다.
Each value는 normally 한 번만 visited됩니다. However, value가 visited된 후 deleted되고 forEach call이 completes되기 전에 re-added되면 value는 revisited됩니다. forEach call이 begins된 후 visited되기 전에 deleted된 values는, forEach call이 completes되기 전에 value가 again added되지 않는 한 visited되지 않습니다. forEach call이 begins된 후 added된 new values는 visited됩니다.
Set Iterator는 below에 defined된 structure를 가진 ordinary object이며, some specific Set instance object에 대한 specific iteration을 represents합니다. Set Iterator objects에 대한 named constructor는 없습니다. Instead, Set Iterator objects는 Set instance objects의 certain methods를 calling하여 created됩니다.
WeakMaps는 keys가 objects 및/또는 symbols이고 values는 arbitrary ECMAScript language values일 수 있는 key/value pairs의 collections입니다. WeakMap은 specific key를 가진 key/value pair를 contain하는지 보기 위해 queried될 수 있지만, keys로 holding하는 values를 enumerating하기 위한 mechanism은 provided되지 않습니다. Certain conditions에서, live가 아닌 values는 9.9.3에 described된 것처럼 WeakMap keys로부터 removed됩니다.
implementation은 WeakMap의 key/value pair가 inaccessible하게 되는 time과 key/value pair가 WeakMap에서 removed되는 time 사이에 arbitrarily determined latency를 impose할 수 있습니다. 이 latency가 ECMAScript program에 observable하다면, program execution에 impact할 수 있는 indeterminacy의 source가 될 것입니다. 그 reason으로, ECMAScript implementation은 observer가 observed key를 present하도록 require하지 않는 WeakMap의 key를 observe하는 any means를 provide해서는 안 됩니다.
WeakMaps는 collection 안의 key/value pairs 수에 대해 average로 sublinear인 access times를 제공하는 hash tables 또는 other mechanisms를 사용하여 implemented되어야 합니다. 이 specification에서 사용되는 data structure는 WeakMaps의 required observable semantics를 describe하기 위한 것일 뿐입니다. viable implementation model로 intended되지 않습니다.
Note
WeakMap 및 WeakSet은 WeakMap 또는 WeakSet instance가 없었다면 object 또는 symbol이 otherwise inaccessible해지고 implementation의 garbage collection mechanisms에 의한 resource reclamation의 대상이 되었을 경우 memory resources를 “leak”하지 않는 manner로 object 또는 symbol과 state를 dynamically associating하기 위한 mechanisms를 provide하도록 intended됩니다. 이 characteristic은 WeakMap 또는 WeakSet instances에서 keys로의 inverted per-object/symbol mapping을 사용하여 achieved될 수 있습니다. Alternatively, each WeakMap 또는 WeakSet instance는 internally its key 및 value data를 store할 수 있지만, 이 approach는 WeakMap 또는 WeakSet implementation과 garbage collector 사이의 coordination을 requires합니다. following references는 WeakMap 및 WeakSet의 implementations에 useful할 수 있는 mechanism을 describe합니다:
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.
global object의 "WeakMap" property의 initial value입니다.
constructor로 called될 때 new WeakMap을 create하고 initialize합니다.
function으로 called되도록 intended되지 않으며, such manner로 called될 때 exception을 throw합니다.
클래스 정의의 extends 절의 값으로 사용될 수 있다. 지정된 WeakMap 동작을 상속하려는 서브클래스 생성자는 WeakMap.prototype의 내장 메서드를 지원하는 데 필요한 내부 상태로 서브클래스 인스턴스를 생성하고 초기화하기 위해 WeakMap 생성자에 대한 super 호출을 포함해야 한다.
parameter iterable이 present하면, 이는 two element array-like object를 produce하는 iterator object를 반환하는 %Symbol.iterator% method를 implement하는 object일 것으로 expected됩니다. 그 first element는 WeakMap key로 사용될 value이고 second element는 그 key와 associate할 value입니다.
weakMap.[[WeakMapData]]의 각 Record { [[Key]], [[Value]] } entry에 대해, 다음을 수행한다.
entry.[[Key]]가 empty가 아니고 SameValue(entry.[[Key]], key)가 true이면, 다음을 수행한다.
entry.[[Key]]를 empty로 설정한다.
entry.[[Value]]를 empty로 설정한다.
true를 반환한다.
false를 반환한다.
Note
value empty는 entry가 deleted되었음을 indicate하기 위한 specification device로 사용됩니다. Actual implementations는 internal data structures에서 entry를 physically removing하는 것과 같은 other actions를 취할 수 있습니다.
WeakSets는 objects 및/또는 symbols의 collections입니다. distinct object 또는 symbol은 WeakSet의 collection의 element로서 한 번만 occur할 수 있습니다. WeakSet은 specific value를 contain하는지 보기 위해 queried될 수 있지만, holding하는 values를 enumerating하기 위한 mechanism은 provided되지 않습니다. Certain conditions에서, live가 아닌 values는 9.9.3에 described된 것처럼 WeakSet elements로부터 removed됩니다.
implementation은 WeakSet 안에 contained된 value가 inaccessible하게 되는 time과 value가 WeakSet에서 removed되는 time 사이에 arbitrarily determined latency를 impose할 수 있습니다. 이 latency가 ECMAScript program에 observable하다면, program execution에 impact할 수 있는 indeterminacy의 source가 될 것입니다. 그 reason으로, ECMAScript implementation은 observer가 observed value를 present하도록 require하지 않는 particular value를 WeakSet이 contains하는지 determine하는 any means를 provide해서는 안 됩니다.
WeakSets는 collection 안의 elements 수에 대해 average로 sublinear인 access times를 제공하는 hash tables 또는 other mechanisms를 사용하여 implemented되어야 합니다. 이 specification에서 사용되는 data structure는 WeakSets의 required observable semantics를 describe하기 위한 것일 뿐입니다. viable implementation model로 intended되지 않습니다.
global object의 "WeakSet" property의 initial value입니다.
constructor로 called될 때 new WeakSet을 create하고 initialize합니다.
function으로 called되도록 intended되지 않으며, such manner로 called될 때 exception을 throw합니다.
클래스 정의의 extends 절의 값으로 사용될 수 있다. 지정된 WeakSet 동작을 상속하려는 서브클래스 생성자는 WeakSet.prototype의 내장 메서드를 지원하는 데 필요한 내부 상태로 서브클래스 인스턴스를 생성하고 초기화하기 위해 WeakSet 생성자에 대한 super 호출을 포함해야 한다.
value empty는 entry가 deleted되었음을 indicate하기 위한 specification device로 사용됩니다. Actual implementations는 internal data structures에서 entry를 physically removing하는 것과 같은 other actions를 취할 수 있습니다.
그들의 individual algorithm steps는 observable하지 않습니다.
Note
read-modify-write modification function의 algorithm steps가 pure, mathematical function을 constitute하는지 verifying하는 데 도움을 주기 위해, 다음 editorial conventions가 recommended됩니다:
parameters와 captured values를 제외한 any language 또는 specification values에 직접 또는 invoked abstract operations와 Abstract Closures를 통해 transitively access하지 않습니다.
The abstract operation AllocateArrayBuffer takes arguments ctor (생성자) and byteLength (음이 아닌 정수) and optional argument maxByteLength (음이 아닌 정수 또는 empty) and returns ArrayBuffer를 포함하는 정상 완료 또는 throw 완료. ArrayBuffer를 만드는 데 사용된다. It performs the following steps when called:
Let slots be « [[ArrayBufferData]], [[ArrayBufferByteLength]], [[ArrayBufferDetachKey]] ».
If maxByteLength is present and maxByteLength is not empty, let allocatingResizableBuffer be true; else let allocatingResizableBuffer be false.
If allocatingResizableBuffer is true, then
If byteLength > maxByteLength, throw a RangeError exception.
If it is not possible to create a Data Blockblock consisting of maxByteLength bytes, throw a RangeError exception.
NOTE: Resizable ArrayBuffers are designed to be implementable with in-place growth. Implementations may throw if, for example, virtual memory cannot be reserved up front.
Set obj.[[ArrayBufferMaxByteLength]] to maxByteLength.
Return obj.
25.1.3.2 ArrayBufferByteLength ( arrayBuffer, order )
The abstract operation ArrayBufferByteLength takes arguments arrayBuffer (ArrayBuffer 또는 SharedArrayBuffer) and order (seq-cst 또는 unordered) and returns 음이 아닌 정수. It performs the following steps when called:
The abstract operation ArrayBufferCopyAndDetach takes arguments arrayBuffer (ECMAScript 언어 값), newLength (ECMAScript 언어 값), and preserveResizability (preserve-resizability 또는 fixed-length) and returns ArrayBuffer를 포함하는 정상 완료 또는 throw 완료. It performs the following steps when called:
The abstract operation IsDetachedBuffer takes argument arrayBuffer (ArrayBuffer 또는 SharedArrayBuffer) and returns Boolean. It performs the following steps when called:
The abstract operation DetachArrayBuffer takes argument arrayBuffer (ArrayBuffer) and optional argument key (아무것) and returns unused를 포함하는 정상 완료 또는 throw 완료. It performs the following steps when called:
The abstract operation CloneArrayBuffer takes arguments sourceBuffer (ArrayBuffer 또는 SharedArrayBuffer), sourceByteOffset (음이 아닌 정수), and sourceLength (음이 아닌 정수) and returns ArrayBuffer를 포함하는 정상 완료 또는 throw 완료. sourceByteOffset에서 시작하여 sourceLength 바이트 동안 이어지는 범위에 걸친 sourceBuffer의 데이터 복사본을 데이터로 가지는 새 ArrayBuffer를 만든다. It performs the following steps when called:
The host-defined abstract operation HostResizeArrayBuffer takes arguments buffer (an ArrayBuffer) and newByteLength (a non-negative integer) and returns either a normal completion containing either handled or unhandled, or a throw completion. 호스트가 buffer의 구현 정의 크기 조정을 수행할 기회를 제공한다. 호스트가 buffer의 크기 조정을 처리하지 않기로 선택하면, 기본 동작을 위해 unhandled를 반환할 수 있다.
HostResizeArrayBuffer의 구현은 다음 요구사항을 준수해야 한다:
이 추상 연산은 buffer를 detach하지 않는다.
이 추상 연산이 handled로 정상 완료되면, buffer.[[ArrayBufferByteLength]]는 newByteLength이다.
HostResizeArrayBuffer의 기본 구현은 NormalCompletion(unhandled)를 반환하는 것이다.
25.1.3.9 IsFixedLengthArrayBuffer ( arrayBuffer )
The abstract operation IsFixedLengthArrayBuffer takes argument arrayBuffer (ArrayBuffer 또는 SharedArrayBuffer) and returns Boolean. It performs the following steps when called:
arrayBuffer가 [[ArrayBufferMaxByteLength]] 내부 슬롯을 가지면, false를 반환하라.
true를 반환하라.
25.1.3.10 IsUnsignedElementType ( type )
The abstract operation IsUnsignedElementType takes argument type (TypedArray 요소 타입) and returns Boolean. 인수 type이 부호 없는 TypedArray 요소 타입인지 검증한다. It performs the following steps when called:
type이 uint8, uint8clamped, uint16, uint32, 또는 biguint64 중 하나이면, true를 반환하라.
false를 반환하라.
25.1.3.11 IsUnclampedIntegerElementType ( type )
The abstract operation IsUnclampedIntegerElementType takes argument type (TypedArray 요소 타입) and returns Boolean. 인수 type이 uint8clamped를 포함하지 않는 IntegerTypedArray 요소 타입인지 검증한다. It performs the following steps when called:
type이 int8, uint8, int16, uint16, int32, 또는 uint32 중 하나이면, true를 반환하라.
false를 반환하라.
25.1.3.12 IsBigIntElementType ( type )
The abstract operation IsBigIntElementType takes argument type (TypedArray 요소 타입) and returns Boolean. 인수 type이 BigInt TypedArray 요소 타입인지 검증한다. It performs the following steps when called:
type이 biguint64 또는 bigint64이면, true를 반환하라.
false를 반환하라.
25.1.3.13 IsNoTearConfiguration ( type, order )
The abstract operation IsNoTearConfiguration takes arguments type (a TypedArray element type) and order (seq-cst, unordered, or init) and returns a Boolean. It performs the following steps when called:
The abstract operation RawBytesToNumeric takes arguments type (TypedArray 요소 타입), rawBytes (바이트 값의 List), and isLittleEndian (Boolean) and returns Number 또는 BigInt. It performs the following steps when called:
elementSize를 Element Type type에 대해 Table 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 값의 리틀 엔디언 비트 문자열 인코딩으로 해석한 것으로 하라.
25.1.3.15 GetRawBytesFromSharedBlock ( block, byteIndex, type, isTypedArray, order )
The abstract operation GetRawBytesFromSharedBlock takes arguments block (Shared Data Block), byteIndex (음이 아닌 정수), type (TypedArray 요소 타입), isTypedArray (Boolean), and order (seq-cst 또는 unordered) and returns 바이트 값의 List. It performs the following steps when called:
elementSize를 Element Type type에 대해 Table 71에 명시된 Element Size 값으로 하라.
The abstract operation GetValueFromBuffer takes arguments arrayBuffer (ArrayBuffer 또는 SharedArrayBuffer), byteIndex (음이 아닌 정수), type (TypedArray 요소 타입), isTypedArray (Boolean), and order (seq-cst 또는 unordered) and optional argument isLittleEndian (Boolean) and returns Number 또는 BigInt. It performs the following steps when called:
The abstract operation NumericToRawBytes takes arguments type (TypedArray 요소 타입), value (Number 또는 BigInt), and isLittleEndian (Boolean) and returns 바이트 값의 List. It performs the following steps when called:
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에 대해 Table 71에 명시된 Element Size 값으로 하라.
conversionOperation을 Element Type type에 대해 Table 71의 “Conversion Operation” 열에 이름이 지정된 추상 연산으로 하라.
The abstract operation SetValueInBuffer takes arguments arrayBuffer (an ArrayBuffer or SharedArrayBuffer), byteIndex (a non-negative integer), type (a TypedArray element type), value (a Number or a BigInt), isTypedArray (a Boolean), and order (seq-cst, unordered, or init) and optional argument isLittleEndian (a Boolean) and returns unused. It performs the following steps when called:
rawBytes의 개별 바이트를 block[byteIndex]에서 시작하여 block에 저장하라.
unused를 반환하라.
25.1.3.19 GetModifySetValueInBuffer ( arrayBuffer, byteIndex, type, value, op )
The abstract operation GetModifySetValueInBuffer takes arguments arrayBuffer (ArrayBuffer 또는 SharedArrayBuffer), byteIndex (음이 아닌 정수), type (TypedArray 요소 타입), value (Number 또는 BigInt), and op (읽기-수정-쓰기 수정 함수) and returns Number 또는 BigInt. It performs the following steps when called:
global object의 "ArrayBuffer" property의 initial value입니다.
constructor로 called될 때 new ArrayBuffer를 create하고 initialize합니다.
function으로 called되도록 intended되지 않으며, such manner로 called될 때 exception을 throw합니다.
클래스 정의의 extends 절의 값으로 사용될 수 있다. 지정된 ArrayBuffer 동작을 상속하려는 서브클래스 생성자는 ArrayBuffer.prototype의 내장 메서드를 지원하는 데 필요한 내부 상태로 서브클래스 인스턴스를 생성하고 초기화하기 위해 ArrayBuffer 생성자에 대한 super 호출을 포함해야 한다.
NOTE: new Data Block의 creation도 old Data Block으로부터의 copying도 observable하지 않습니다. Implementations는 이 method를 in-place growth 또는 shrinkage로 implement할 수 있습니다.
ArrayBuffer instances는 ArrayBuffer prototype object로부터 properties를 inherit합니다. ArrayBuffer instances는 각각 [[ArrayBufferData]] internal slot, [[ArrayBufferByteLength]] internal slot, 및 [[ArrayBufferDetachKey]] internal slot을 가집니다. resizable인 ArrayBuffer instances는 각각 [[ArrayBufferMaxByteLength]] internal slot을 가집니다.
[[ArrayBufferData]]가 null인 ArrayBuffer instances는 detached된 것으로 considered되며, ArrayBuffer instance 안에 contained된 data에 access하거나 modify하는 모든 operators는 fail합니다.
[[ArrayBufferDetachKey]]가 undefined가 아닌 value로 set된 ArrayBuffer instances는 all DetachArrayBuffer calls가 same “detach key”를 argument로 passing해야 하며, 그렇지 않으면 TypeError가 result됩니다. 이 internal slot은 only certain embedding environments에 의해 set되며, 이 specification의 algorithms에 의해 set되지 않습니다.
가능한 경우 programs를 그 deployment environments에서 test할 것을 recommend합니다. available physical memory의 amount는 hardware devices 사이에서 크게 differs합니다. Similarly, virtual memory subsystems 또한 hardware devices 및 operating systems 사이에서 크게 differs합니다. 64-bit desktop web browser에서 out-of-memory errors 없이 runs하는 application이 32-bit mobile web browser에서는 memory가 부족해질 수 있습니다.
resizable ArrayBuffer에 대한 "maxByteLength" option의 value를 choosing할 때, application에 대해 가능한 smallest size를 choose할 것을 recommend합니다. "maxByteLength"가 1,073,741,824 (230 bytes 또는 1GiB)를 exceed하지 않을 것을 recommend합니다.
particular maximum size에 대해 resizable ArrayBuffer를 successfully constructing하는 것이 future resizes가 succeed할 것을 guarantee하지 않는다는 점에 note하십시오.
Note 2
다음은 resizable ArrayBuffer를 implementing하는 ECMAScript implementers를 위한 guidelines입니다.
Resizable ArrayBuffer는 resize 시 copying, virtual memory를 up front로 reserving하는 in-place growth, 또는 constructor의 "maxByteLength" option의 different values에 대해 both의 combination으로 implemented될 수 있습니다.
host가 web browser처럼 multi-tenanted(즉, many ECMAScript applications를 simultaneously runs)이고, its implementations가 virtual memory를 reserving하여 in-place growth를 implement하기로 choose하는 경우, 32-bit와 64-bit implementations 모두 "maxByteLength" ≥ 1GiB to 1.5GiB인 values에 대해 throw할 것을 recommend합니다. 이는 single application이 virtual memory address space를 exhaust할 likelihood를 reduce하고 interoperability risk를 reduce하기 위한 것입니다.
host가 MMU 없이 embedded devices에서 running하는 것처럼 virtual memory를 가지지 않거나, host가 resizing을 copying으로만 implements하는 경우, "maxByteLength" option에 대한 any Number value for을 accept할 수 있습니다. However, requested size의 memory block이 never allocated될 수 없는 경우 RangeError가 thrown될 것을 recommend합니다. 예를 들어, requested size가 device에서 usable한 maximum memory amount보다 greater한 경우입니다.
25.2 SharedArrayBuffer 객체
25.2.1 Fixed-length 및 Growable SharedArrayBuffer 객체
fixed-length SharedArrayBuffer는 creation 후 byte length가 change될 수 없는 SharedArrayBuffer입니다.
The abstract operation AllocateSharedArrayBuffer takes arguments ctor (a constructor) and byteLength (a non-negative integer) and optional argument maxByteLength (a non-negative integer or empty) and returns either a normal completion containing a SharedArrayBuffer or a throw completion. SharedArrayBuffer를 create하는 데 사용됩니다. It performs the following steps when called:
Let slots be « [[ArrayBufferData]] ».
If maxByteLength is present and maxByteLength is not empty, let allocatingGrowableBuffer be true; else let allocatingGrowableBuffer be false.
If allocatingGrowableBuffer is true, then
If byteLength > maxByteLength, throw a RangeError exception.
Append [[ArrayBufferByteLengthData]] and [[ArrayBufferMaxByteLength]] to slots.
Set obj.[[ArrayBufferByteLengthData]] to byteLengthBlock.
Set obj.[[ArrayBufferMaxByteLength]] to maxByteLength.
Else,
Set obj.[[ArrayBufferByteLength]] to byteLength.
Return obj.
25.2.2.2 IsSharedArrayBuffer ( obj )
The abstract operation IsSharedArrayBuffer takes argument obj (an ArrayBuffer or a SharedArrayBuffer) and returns a Boolean. object가 SharedArrayBuffer인지 tests합니다. It performs the following steps when called:
The abstract operation IsGrowableSharedArrayBuffer takes argument obj (an ArrayBuffer or a SharedArrayBuffer) and returns a Boolean. object가 growable SharedArrayBuffer인지 tests합니다. It performs the following steps when called:
The host-defined abstract operation HostGrowSharedArrayBuffer takes arguments buffer (a SharedArrayBuffer) and newByteLength (a non-negative integer) and returns either a normal completion containing either handled or unhandled, or a throw completion. host에게 buffer의 implementation-defined growing을 수행할 opportunity를 제공합니다. host가 buffer의 growing을 handle하지 않기로 choose하면, default behaviour를 위해 unhandled를 반환할 수 있습니다.
HostGrowSharedArrayBuffer의 implementation은 다음 requirements를 conform해야 합니다:
abstract operation이 unhandled로 normally complete하지 않고, newByteLength < buffer의 current byte length이거나 newByteLength > buffer.[[ArrayBufferMaxByteLength]]이면, RangeError exception을 throw합니다.
위의 second requirement는 buffer의 current byte length가 how 또는 when read되는지에 대해 intentionally vague합니다. byte length는 underlying hardware에서 atomic read-modify-write operation을 통해 updated되어야 하므로, load-link/store-conditional 또는 load-exclusive/store-exclusive instruction pairs를 사용하는 architectures는 paired instructions를 instruction stream 안에서 close하게 유지하기를 원할 수 있습니다. 따라서 SharedArrayBuffer.prototype.grow ( newLength ) 자체는 HostGrowSharedArrayBuffer를 calling하기 전에 newByteLength에 대한 bounds checking을 수행하지 않으며, current byte length가 언제 read되는지에 대한 requirement도 없습니다.
이는 0 ≤ newByteLength ≤ buffer.[[ArrayBufferMaxByteLength]]가 guaranteed되는 HostResizeArrayBuffer와 대비됩니다.
그 property가 present한 경우, global object의 "SharedArrayBuffer" property의 initial value입니다(아래 참조).
constructor로 called될 때 new SharedArrayBuffer를 create하고 initialize합니다.
function으로 called되도록 intended되지 않으며, such manner로 called될 때 exception을 throw합니다.
클래스 정의의 extends 절의 값으로 사용될 수 있다. 지정된 SharedArrayBuffer 동작을 상속하려는 서브클래스 생성자는 SharedArrayBuffer.prototype의 내장 메서드를 지원하는 데 필요한 내부 상태로 서브클래스 인스턴스를 생성하고 초기화하기 위해 SharedArrayBuffer 생성자에 대한 super 호출을 포함해야 한다.
host가 SharedArrayBuffers에 대한 concurrent access를 provide하지 않을 때마다, global object의 "SharedArrayBuffer" property를 omit할 수 있습니다.
Note
ArrayBuffer와 달리, SharedArrayBuffer는 detached될 수 없고, its internal [[ArrayBufferData]] slot은 never null입니다.
isLittleEndian을 agentRecord.[[LittleEndian]]으로 둔다.
byteLengthBlock을 obj.[[ArrayBufferByteLengthData]]로 둔다.
currentByteLengthRawBytes를 GetRawBytesFromSharedBlock(byteLengthBlock, 0, biguint64, true, seq-cst)로 둔다.
newByteLengthRawBytes를 NumericToRawBytes(biguint64, ℤ(newByteLength), isLittleEndian)로 둔다.
반복한다.
NOTE: 이것은 same buffer의 parallel, racing grows가 totally ordered되고, lost되지 않으며, silently do nothing하지 않도록 보장하기 위한 compare-and-exchange loop입니다. loop는 uncontended로 grow를 attempt할 수 있었을 때 exits합니다.
currentByteLength를 ℝ(RawBytesToNumeric(biguint64, currentByteLengthRawBytes, isLittleEndian))로 둔다.
byteLengthDelta를 newByteLength - currentByteLength로 둔다.
byteLengthDelta bytes로 구성된 new Shared Data Block value를 create하는 것이 impossible하면, RangeError exception을 throw한다.
NOTE: 여기서는 new Shared Data Block이 constructed되고 used되지 않습니다. growable SharedArrayBuffers의 observable behaviour는 construction time에 max-sized Shared Data Block을 allocating하는 것으로 specified되며, 이 step은 memory가 부족해진 implementations가 RangeError를 throw해야 한다는 requirement를 captures합니다.
readByteLengthRawBytes를 AtomicCompareExchangeInSharedBlock(byteLengthBlock, 0, 8, currentByteLengthRawBytes, newByteLengthRawBytes)로 둔다.
length를 update하는 compare-exchange의 spurious failures는 prohibited됩니다. new length에 대한 bounds checking이 passes하고 implementation이 out of memory가 아니면, ReadModifyWriteSharedMemory event(즉 successful compare-exchange)는 always candidate execution 안에 added됩니다.
SharedArrayBuffer.prototype.grow에 대한 parallel calls는 totally ordered됩니다. 예를 들어, 두 racing calls sab.grow(10)과 sab.grow(20)을 consider하십시오. 두 calls 중 하나는 race에서 win하는 것이 guaranteed됩니다. sab.grow(20)이 먼저 happened하더라도 sab.grow(10)에 대한 call은 never sab를 shrink하지 않습니다; 그 경우 대신 RangeError를 throw합니다.
25.2.5.4 get SharedArrayBuffer.prototype.growable
SharedArrayBuffer.prototype.growable은 set accessor function이 undefined인 accessor property입니다. Its get accessor function은 called될 때 다음 steps를 수행합니다:
25.2.5.5 get SharedArrayBuffer.prototype.maxByteLength
SharedArrayBuffer.prototype.maxByteLength는 set accessor function이 undefined인 accessor property입니다. Its get accessor function은 called될 때 다음 steps를 수행합니다:
가능한 경우 programs를 그 deployment environments에서 test할 것을 recommend합니다. available physical memory의 amount는 hardware devices 사이에서 greatly differ합니다. Similarly, virtual memory subsystems 또한 hardware devices 및 operating systems 사이에서 greatly differ합니다. 64-bit desktop web browser에서 out-of-memory errors 없이 runs하는 application이 32-bit mobile web browser에서는 memory가 부족해질 수 있습니다.
growable SharedArrayBuffer에 대한 "maxByteLength" option의 value를 choosing할 때, application에 대해 가능한 smallest size를 choose할 것을 recommend합니다. "maxByteLength"가 1073741824, 또는 1GiB를 exceed하지 않을 것을 recommend합니다.
particular maximum size에 대해 growable SharedArrayBuffer를 successfully constructing하는 것이 future grows가 succeed할 것을 guarantee하지 않는다는 점에 note하십시오.
growable SharedArrayBuffer's length의 모든 loads가 synchronizing seq-cst loads인 것은 아닙니다. integer-indexed property access의 bounds-checking을 위한 length의 loads, 예를 들어 u8[idx],는 synchronizing하지 않습니다. 일반적으로 explicit synchronization이 없을 때, one property access가 in-bound라는 것이 same agent 안의 subsequent property access도 in-bound라는 것을 imply하지 않습니다. 이와 contrast하여, SharedArrayBuffer, %TypedArray%.prototype, 및 DataView.prototype의 length와 byteLength getters를 통한 length의 explicit loads는 synchronizing합니다. TypedArray가 entirely out-of-bounds인지 check하기 위해 built-in methods에 의해 performed되는 length의 loads도 synchronizing합니다.
growable SharedArrayBuffer는 virtual memory를 up front로 reserving하는 in-place growth로 implemented될 것을 recommend합니다.
grow operations는 growable SharedArrayBuffer에 대한 memory accesses와 parallel하게 happen할 수 있으므로, memory model의 constraints는 unordered accesses조차도 “tear”하지 않을 것(그 values의 bits가 mixed되지 않을 것)을 require합니다. In practice, 이는 growable SharedArrayBuffer의 underlying data block이 stopping the world 없이 copied되어 grown될 수 없음을 의미합니다. 우리는 stopping the world를 implementation strategy로 recommend하지 않습니다. 이는 serialization point를 introduce하고 느리기 때문입니다.
Grown memory는 creation 순간부터 zeroed된 것으로 appear해야 하며, parallel한 any racy accesses에도 포함됩니다. 이는 zero-filled-on-demand virtual memory pages를 통해 또는 manually zeroing memory하는 경우 careful synchronization을 통해 accomplished될 수 있습니다.
growable SharedArrayBuffers의 TypedArray views에 대한 Integer-indexed property access는 non-growable SharedArrayBuffers의 TypedArray views에 대한 access와 similarly optimizable되도록 intended됩니다. 이는 integer-indexed property loads가 underlying buffer's length에 대해 synchronizing하지 않기 때문입니다(위 programmer guidelines 참조). 예를 들어, property accesses를 위한 bounds checks는 still loops 밖으로 hoisted될 수 있습니다.
In practice, virtual memory가 없는 hosts, 예를 들어 MMU 없이 embedded devices에서 running하는 hosts에서 growable SharedArrayBuffer를 copying으로 implement하는 것은 어렵습니다. 이러한 hosts에서 growable SharedArrayBuffers의 memory usage behaviour는 virtual memory가 있는 hosts와 significantly differ할 수 있습니다. Such hosts는 memory usage expectations를 users에게 clearly communicate해야 합니다.
25.3 DataView 객체
25.3.1 DataView 객체를 위한 Abstract Operations
25.3.1.1 DataView With Buffer Witness Records
DataView With Buffer Witness Record는 viewed buffer의 cached byte length와 함께 DataView를 encapsulate하는 데 사용되는 Record value입니다. viewed buffer가 growable SharedArrayBuffer일 때 byte length data block의 single ReadSharedMemory event가 있음을 ensure하는 데 도움을 주기 위해 사용됩니다.
DataView With Buffer Witness Records는 Table 73에 listed된 fields를 가집니다.
Record가 created되었을 때 object's [[ViewedArrayBuffer]]의 byte length입니다.
25.3.1.2 MakeDataViewWithBufferWitnessRecord ( obj, order )
The abstract operation MakeDataViewWithBufferWitnessRecord takes arguments obj (a DataView) and order (seq-cst or unordered) and returns a DataView With Buffer Witness Record. It performs the following steps when called:
The abstract operation GetViewByteLength takes argument viewRecord (a DataView With Buffer Witness Record) and returns a non-negative integer. It performs the following steps when called:
The abstract operation IsViewOutOfBounds takes argument viewRecord (a DataView With Buffer Witness Record) and returns a Boolean. It performs the following steps when called:
view를 viewRecord.[[Object]]로 둔다.
bufferByteLength를 viewRecord.[[CachedBufferByteLength]]로 둔다.
global object의 "DataView" property의 initial value입니다.
constructor로 called될 때 new DataView를 create하고 initialize합니다.
function으로 called되도록 intended되지 않으며, such manner로 called될 때 exception을 throw합니다.
클래스 정의의 extends 절의 값으로 사용될 수 있다. 지정된 DataView 동작을 상속하려는 서브클래스 생성자는 DataView.prototype의 내장 메서드를 지원하는 데 필요한 내부 상태로 서브클래스 인스턴스를 생성하고 초기화하기 위해 DataView 생성자에 대한 super 호출을 포함해야 한다.
DataView instances는 DataView prototype object로부터 properties를 inherit하는 ordinary objects입니다. DataView instances는 각각 [[DataView]], [[ViewedArrayBuffer]], [[ByteLength]], 및 [[ByteOffset]] internal slots를 가집니다.
Note
[[DataView]] internal slot의 value는 이 specification 안에서 사용되지 않습니다. 그 internal slot의 simple presence는 DataView constructor를 사용하여 created된 objects를 identify하기 위해 specification 안에서 사용됩니다.
25.4 Atomics 객체
Atomics object는:
%Atomics%입니다.
global object의 "Atomics" property의 initial value입니다.
[[Construct]] internal method를 가지지 않습니다; new operator와 함께 constructor로 사용될 수 없습니다.
[[Call]] internal method를 가지지 않습니다; function으로 invoked될 수 없습니다.
Atomics object는 shared memory array cells에 대해 indivisibly(atomically) operate하는 functions뿐 아니라 agents가 primitive events를 wait하고 dispatch할 수 있게 하는 functions를 제공합니다. disciplined하게 사용될 때, Atomics functions는 shared memory를 통해 communicate하는 multi-agent programs가 parallel CPUs에서도 well-understood order로 execute되도록 합니다. shared-memory communication을 govern하는 rules는 아래에 defined된 memory model에 의해 제공됩니다.
Note
ECMAScript에서 shared memory를 programming하고 implementing하기 위한 informative guidelines는 memory model section의 끝에 있는 notes를 참조하십시오.
25.4.1 Waiter Record
Waiter Record는 Atomics.wait 또는 Atomics.waitAsync에 대한 particular call을 denote하는 데 사용되는 Record value입니다.
agent cluster는 WaiterList Records의 store를 가집니다; store는 (block, i)로 indexed되며, 여기서 block은 Shared Data Block이고 i는 block의 memory 안으로의 byte offset입니다. WaiterList Records는 agent-independent입니다: any agent in the agent cluster에서 (block, i)로 WaiterList Records의 store를 lookup하면 same WaiterList Record가 result됩니다.
Each WaiterList Record는 evaluation 동안 that WaiterList Record에 대한 exclusive access를 control하는 critical section을 가집니다. 한 번에 단일 agent만 WaiterList Record's critical section에 enter할 수 있습니다. WaiterList Record's critical section에 entering하고 leaving하는 것은 EnterCriticalSection 및 LeaveCriticalSectionabstract operations에 의해 controlled됩니다. WaiterList Record에 대한 operations—waiting agents를 adding 및 removing하기, agents의 list를 traversing하기, list의 agents를 suspending 및 notifying하기, Synchronize event를 setting 및 retrieving하기—는 WaiterList Record's critical section에 entered한 agents에 의해서만 performed될 수 있습니다.
25.4.3 Atomics를 위한 Abstract Operations
25.4.3.1 ValidateIntegerTypedArray ( ta, waitable )
25.4.3.4 RevalidateAtomicAccess ( ta, byteIndexInBuffer )
The abstract operation RevalidateAtomicAccess takes arguments ta (a TypedArray) and byteIndexInBuffer (a non-negative integer) and returns either a normal completion containingunused or a throw completion. 이 operation은 Atomics methods에서 모든 argument coercions가 performed된 후 atomic operations를 위한 backing buffer 안의 index를 revalidates합니다. argument coercions는 arbitrary side effects를 가질 수 있고, 이는 buffer가 out of bounds가 되도록 cause할 수 있기 때문입니다. 이 operation은 ta's backing buffer가 SharedArrayBuffer일 때 throw하지 않습니다. It performs the following steps when called:
The abstract operation GetWaiterList takes arguments block (a Shared Data Block) and i (a non-negative integer that is evenly divisible by 4) and returns a WaiterList Record. It performs the following steps when called:
Assert: i와 i + 3은 block의 memory 안에서 valid byte offsets이다.
The abstract operation EnterCriticalSection takes argument waiterList (a WaiterList Record) and returns unused. It performs the following steps when called:
EnterCriticalSection은 critical section에 enter하려는 agent가 another agent가 leave할 때까지 wait해야 할 때 contention을 가집니다. contention이 없을 때, EnterCriticalSection calls의 FIFO order는 observable입니다. contention이 있을 때, implementation은 arbitrary order를 choose할 수 있지만 agent가 indefinitely wait하도록 cause해서는 안 됩니다.
25.4.3.7 LeaveCriticalSection ( waiterList )
The abstract operation LeaveCriticalSection takes argument waiterList (a WaiterList Record) and returns unused. It performs the following steps when called:
The abstract operation AddWaiter takes arguments waiterList (a WaiterList Record) and waiterRecord (a Waiter Record) and returns unused. It performs the following steps when called:
The abstract operation RemoveWaiter takes arguments waiterList (a WaiterList Record) and waiterRecord (a Waiter Record) and returns unused. It performs the following steps when called:
The abstract operation RemoveWaiters takes arguments waiterList (a WaiterList Record) and count (a non-negative integer or +∞) and returns a List of Waiter Records. It performs the following steps when called:
The abstract operation SuspendThisAgent takes arguments waiterList (a WaiterList Record) and waiterRecord (a Waiter Record) and returns unused. It performs the following steps when called:
LeaveCriticalSection(waiterList)를 수행하고 time이 waiterRecord.[[TimeoutTime]]이 될 때까지 surrounding agent를 suspend하되, critical section이 exited된 후 suspension이 effect를 가지기 전에 arriving하는 notification이 lost되지 않는 방식으로 combined operation을 수행한다. surrounding agent는 timeout 때문이거나 another agent가 arguments waiterList와 thisAgent로 NotifyWaiter를 calling하는 것(즉 Atomics.notify에 대한 call을 통해) 때문에만 suspension에서 wake할 수 있다.
The abstract operation NotifyWaiter takes arguments waiterList (a WaiterList Record) and waiterRecord (a Waiter Record) and returns unused. It performs the following steps when called:
The abstract operation EnqueueResolveInAgentJob takes arguments agentSignifier (an agent signifier), promiseCapability (a PromiseCapability Record), and resolution ("ok" or "timed-out") and returns unused. It performs the following steps when called:
resolveJob을 parameters가 없고 agentSignifier, promiseCapability, 및 resolution을 captures하며 called될 때 다음 steps를 수행하는 new JobAbstract Closure로 둔다:
waiterRecord를 new Waiter Record { [[AgentSignifier]]: thisAgent, [[PromiseCapability]]: promiseCapability, [[TimeoutTime]]: timeoutTime, [[Result]]: "ok" }로 둔다.
additionalTimeout은 power consumption을 reducing하거나 timing attacks를 mitigate하기 위해 timer resolution을 coarsening하는 것처럼, implementations가 necessary하게 timeouts를 pad할 수 있게 합니다. 이 value는 DoWait의 call마다 differ할 수 있습니다.
The abstract operation EnqueueAtomicsWaitAsyncTimeoutJob takes arguments waiterList (a WaiterList Record) and waiterRecord (a Waiter Record) and returns unused. It performs the following steps when called:
timeoutJob을 parameters가 없고 waiterList와 waiterRecord를 captures하며 called될 때 다음 steps를 수행하는 new JobAbstract Closure로 둔다:
The abstract operation AtomicCompareExchangeInSharedBlock takes arguments block (a Shared Data Block), byteIndexInBuffer (an integer), elementSize (a non-negative integer), expectedBytes (a List of byte values), and replacementBytes (a List of byte values) and returns a List of byte values. It performs the following steps when called:
rawBytesRead를 elements가 nondeterministically chosen byte values인 length elementSize의 List로 둔다.
NOTE: implementations에서 rawBytesRead는 underlying hardware의 load-link, load-exclusive, 또는 read-modify-write instruction의 operand의 result입니다. nondeterminism은 weak consistency를 가진 hardware의 observable behaviour를 describe하기 위한 memory model의 semantic prescription입니다.
NOTE: expected value와 read value의 comparison은 expected value가 read value와 equal하지 않을 때 needlessly strong synchronization을 avoid하기 위해 read-modify-write modification function 밖에서 performed됩니다.
ByteListEqual(rawBytesRead, expectedBytes)가 true이면, 다음을 수행한다.
The abstract operation ByteListBitwiseOp takes arguments op (&, ^, or |), xBytes (a List of byte values), and yBytes (a List of byte values) and returns a List of byte values. 이 operation은 arguments의 모든 byte values에 대해 bitwise operation을 atomically performs하고 byte values의 List를 returns합니다. It performs the following steps when called:
Assert: xBytes와 yBytes는 same number of elements를 가진다.
resultByte를 xByte와 yByte에 bitwise inclusive OR operation을 applying한 result로 둔다.
i를 i + 1로 설정한다.
resultByte를 result에 append한다.
result를 반환한다.
25.4.3.19 ByteListEqual ( xBytes, yBytes )
The abstract operation ByteListEqual takes arguments xBytes (a List of byte values) and yBytes (a List of byte values) and returns a Boolean. It performs the following steps when called:
xBytes와 yBytes가 same number of elements를 가지지 않으면, false를 반환한다.
이 function은 optimization primitive입니다. intuition은 size n bytes인 datum에 대한 atomic primitive(compareExchange, load, store, add, sub, and, or, xor, 또는 exchange)의 atomic step이 datum을 comprising하는 n bytes outside의 lock을 surrounding agent가 acquiring하지 않고 performed될 것이라면, Atomics.isLockFree(n)가 true를 반환한다는 것입니다. High-performance algorithms는 critical sections에서 locks를 사용할지 atomic operations를 사용할지 determine하기 위해 이 function을 사용할 것입니다. atomic primitive가 lock-free가 아니면 algorithm이 its own locking을 provide하는 것이 often more efficient합니다.
Atomics.isLockFree(4)는 all known relevant hardware에서 supported될 수 있으므로 always true를 반환합니다. 이를 assume할 수 있음은 generally programs를 simplify할 것입니다.
이 function이 반환하는 value와 관계없이, all atomic operations는 atomic하다고 guaranteed됩니다. 예를 들어, operation 중간에 visible operation이 take place하는 일은 never 없습니다(예: “tearing”).
[[Construct]] internal method를 가지지 않습니다; new operator와 함께 constructor로 사용될 수 없습니다.
[[Call]] internal method를 가지지 않습니다; function으로 invoked될 수 없습니다.
JSON Data Interchange Format은 ECMA-404에 defined되어 있습니다. 이 specification에서 사용되는 JSON interchange format은 ECMA-404에 의해 described된 것과 exactly 같습니다. JSON.parse와 JSON.stringify의 conforming implementations는 ECMA-404 specification에 described된 exact interchange format을, format에 대한 deletions나 extensions 없이 support해야 합니다.
이 function은 JSON text(JSON-formatted String)를 parses하고 ECMAScript language value를 produces합니다. JSON format은 literals, arrays, 및 objects를 ECMAScript literals, Array Initializers, 및 Object Initializers에 대한 syntax와 similar한 syntax로 represents합니다. parsing 후, JSON objects는 ECMAScript objects로 realized됩니다. JSON arrays는 ECMAScript Array instances로 realized됩니다. JSON strings, numbers, booleans, 및 null은 ECMAScript Strings, Numbers, Booleans, 및 null로 realized됩니다.
optional reviver parameter는 results를 filter하고 transform할 수 있는 function입니다. parse에 의해 produced된 each value에 대해, reviver는 three arguments(associated property key, value, 및 context object)와 함께 called됩니다. property가 unmodified이고 그 value가 primitive이면, provided context object는 corresponding Parse Node의 source text를 containing하는 "source" property를 가집니다. call이 undefined를 반환하면 property는 deleted됩니다. 그렇지 않으면 property는 return value를 사용하도록 redefined됩니다.
Record { [[ParseNode]]: script, [[Value]]: result }를 반환한다.
JSON.parse의 conforming implementation이 JSON grammars를 extend하는 것은 permitted되지 않습니다. implementation이 modified 또는 extended JSON interchange format을 support하려면, different parse function을 defining하여 그렇게 해야 합니다.
그러나 13.2.5.6가 ParseJSON 동안 differently behaves하기 때문에, same source text는 JSON이 아니라 PrimaryExpression으로 evaluated될 때 different results를 produce할 수 있습니다. Furthermore, object literals 안의 duplicate "__proto__" properties에 대한 Early Error도 likewise ParseJSON 동안 apply되지 않으므로, grammar와 matching함에도 불구하고 ParseJSON이 accepted하는 모든 texts가 PrimaryExpression으로 valid인 것은 아닙니다.
Note 2
object 안에 duplicate name Strings가 있는 경우, same key에 대해 lexically preceding values는 overwritten되어야 합니다.
25.5.2.2 JSON Parse Record
JSON Parse Record는 JSON text에서 parsed된 value의 initial state를 describe하는 데 사용되는 Record value입니다.
[[Value]]가 non-Array Object이면, 이는 [[Value]]의 entries에 corresponding하는 JSON Parse Records를 contains합니다. 그렇지 않으면, 이는 empty List입니다.
25.5.2.3 CreateJSONParseRecord ( parseNode, key, value )
The abstract operation CreateJSONParseRecord takes arguments parseNode (a Parse Node), key (a property name), and value (an ECMAScript language value) and returns a JSON Parse Record. JSON text에서 parsed된 parseNode와 그 evaluation에 의해 produced된 value를 recursively combines합니다. It performs the following steps when called:
NOTE: single object에 대해 same name을 가진 multiple name/value pairs를 specifying하는 JSON text의 경우(예: {"a":"lost","a":"kept"}), resulting ECMAScript object의 corresponding property에 대한 value는 that name을 가진 last pair로 specified됩니다.
propertyDefinition을 empty로 둔다.
propertyNodes의 each Parse NodepropertyNode에 대해, 다음을 수행한다.
The abstract operation ShallowestContainedJSONValue takes argument root (a Parse Node) and returns a Parse Node or empty. root에 rooted된 parse tree의 breadth-first search를 performs하고, JSON value에 corresponding하는 nonterminal의 instance인 first node를 returns하거나, such node가 없으면 empty를 returns합니다. It performs the following steps when called:
NOTE: JSON grammar에서 number token은 negative value를 represent할 수 있습니다. ECMAScript에서 negation은 UnaryExpression이 - 뒤에 derived UnaryExpression이 오는 것으로 parses되는 unary operation으로 represented됩니다.
The syntax-directed operation JSONArrayLiteralContentNodes takes no arguments and returns a List of Parse Nodes. It is defined piecewise over the following productions:
jsonString의 first code unit이 ASCII lowercase letter code unit(0x0061부터 0x007A까지, inclusive), ASCII digit code unit(0x0030부터 0x0039까지, inclusive), 0x0022 (QUOTATION MARK), 또는 0x002D (HYPHEN-MINUS) 중 어느 것도 아니면, SyntaxError exception을 throw한다.
jsonString의 last code unit이 ASCII lowercase letter code unit(0x0061부터 0x007A까지, inclusive), ASCII digit code unit(0x0030부터 0x0039까지, inclusive), 또는 0x0022 (QUOTATION MARK) 중 어느 것도 아니면, SyntaxError exception을 throw한다.
25.5.4 JSON.stringify ( value [ , replacer [ , space ] ] )
이 function은 ECMAScript language value를 representing하는 UTF-16 encoded JSON format의 String 또는 undefined를 반환합니다. 세 parameters를 받을 수 있습니다. value parameter는 ECMAScript language value로, usually object 또는 array이지만 String, Boolean, Number 또는 null일 수도 있습니다. optional replacer parameter는 objects와 arrays가 stringified되는 방식을 alters하는 function이거나, stringified될 object properties를 selecting하기 위한 inclusion list로 acts하는 Strings 및 Numbers의 array입니다. optional space parameter는 result에 human readability를 improve하기 위한 white space가 injected되도록 하는 String 또는 Number입니다.
JSON structures는 any depth로 nested될 수 있지만, acyclic이어야 합니다. value가 cyclic structure이거나 cyclic structure를 contains하면, 이 function은 TypeError exception을 throw해야 합니다. 다음은 stringified될 수 없는 value의 예입니다:
a = [];
a[0] = a;
my_text = JSON.stringify(a); // This must throw a TypeError.
Note 2
Symbolic primitive values는 다음과 같이 rendered됩니다:
null value는 JSON text에서 String value "null"로 rendered됩니다.
undefined value는 rendered되지 않습니다.
true value는 JSON text에서 String value "true"로 rendered됩니다.
false value는 JSON text에서 String value "false"로 rendered됩니다.
Note 3
String values는 QUOTATION MARK (") code units로 wrapped됩니다. code units "와 \는 \ prefixes로 escaped됩니다. Control characters code units는 escape sequences \uHHHH 또는 shorter forms인 \b (BACKSPACE), \f (FORM FEED), \n (LINE FEED), \r (CARRIAGE RETURN), \t (CHARACTER TABULATION)로 replaced됩니다.
Note 4
Finite numbers는 ToString(number)를 calling한 것처럼 stringified됩니다. sign과 관계없이 NaN과 Infinity는 String value "null"로 represented됩니다.
Note 5
JSON representation을 가지지 않는 values(예: undefined 및 functions)는 String을 produce하지 않습니다. 대신 undefined value를 produce합니다. arrays 안에서 these values는 String value "null"로 represented됩니다. objects 안에서는 unrepresentable value가 property를 stringification에서 excluded되도록 causes합니다.
Note 6
object는 U+007B (LEFT CURLY BRACKET) 뒤에 zero or more properties가 오고, U+002C (COMMA)로 separated되며, U+007D (RIGHT CURLY BRACKET)로 closed되는 것으로 rendered됩니다. property는 property name을 representing하는 quoted String, U+003A (COLON), 그리고 stringified property value입니다. array는 opening U+005B (LEFT SQUARE BRACKET) 뒤에 zero or more values가 오고, U+002C (COMMA)로 separated되며, U+005D (RIGHT SQUARE BRACKET)로 closed되는 것으로 rendered됩니다.
25.5.4.1 JSON Serialization Record
JSON Serialization Record는 JSON format으로의 serialization을 enable하는 데 사용되는 Record value입니다.
The abstract operation SerializeJSONProperty takes arguments state (a JSON Serialization Record), key (a String), and holder (an Object) and returns either a normal completion containing either a String or undefined, or a throw completion. It performs the following steps when called:
The abstract operation QuoteJSONString takes argument value (a String) and returns a String. value를 0x0022 (QUOTATION MARK) code units로 wraps하고, 그 안의 certain other code units를 escapes합니다. 이 operation은 6.1.4에 described된 것처럼 value를 UTF-16 encoded code points의 sequence로 interprets합니다. It performs the following steps when called:
product를 code unit 0x0022 (QUOTATION MARK) solely로 consisting하는 String value로 둔다.
그렇지 않고 codePoint가 0x0020 (SPACE)보다 less than인 numeric value를 가지거나 codePoint가 leading surrogate 또는 trailing surrogate와 same numeric value를 가지면, 다음을 수행한다.
unit을 numeric value가 codePoint의 numeric value인 code unit으로 둔다.
product를 product와 code unit 0x0022 (QUOTATION MARK)의 string-concatenation으로 설정한다.
product를 반환한다.
Table 78: JSON Single Character Escape Sequences
Code Point
Unicode Character Name
Escape Sequence
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 )
The abstract operation UnicodeEscape takes argument codeUnit (a code unit) and returns a String. codeUnit을 Unicode escape sequence로 represents합니다. It performs the following steps when called:
properties를 partial의 모든 element Strings를 code unit 0x002C (COMMA)로 separated된 each adjacent pair of Strings와 함께 concatenating하여 formed된 String value로 둔다. comma는 first String before나 last String after에 inserted되지 않는다.
separator를 code unit 0x002C (COMMA), code unit 0x000A (LINE FEED), 및 state.[[Indent]]의 string-concatenation으로 둔다.
properties를 partial의 모든 element Strings를 separator로 separated된 each adjacent pair of Strings와 함께 concatenating하여 formed된 String value로 둔다. separator String은 first String before나 last String after에 inserted되지 않는다.
final을 "{", code unit 0x000A (LINE FEED), state.[[Indent]], properties, code unit 0x000A (LINE FEED), stepBack, 및 "}"의 string-concatenation으로 둔다.
properties를 partial의 모든 element Strings를 code unit 0x002C (COMMA)로 separated된 each adjacent pair of Strings와 함께 concatenating하여 formed된 String value로 둔다. comma는 first String before나 last String after에 inserted되지 않는다.
separator를 code unit 0x002C (COMMA), code unit 0x000A (LINE FEED), 및 state.[[Indent]]의 string-concatenation으로 둔다.
properties를 partial의 모든 element Strings를 separator로 separated된 each adjacent pair of Strings와 함께 concatenating하여 formed된 String value로 둔다. separator String은 first String before나 last String after에 inserted되지 않는다.
final을 "[", code unit 0x000A (LINE FEED), state.[[Indent]], properties, code unit 0x000A (LINE FEED), stepBack, 및 "]"의 string-concatenation으로 둔다.
state.[[Stack]]의 last element를 remove한다.
state.[[Indent]]를 stepBack으로 설정한다.
final을 반환한다.
Note
arrays의 representation은 +0𝔽 (inclusive)부터 array.length (exclusive)까지의 interval 안의 elements만 includes합니다. keys가 array indices가 아닌 properties는 stringification에서 excluded됩니다. array는 opening LEFT SQUARE BRACKET, COMMA로 separated된 elements, 그리고 closing RIGHT SQUARE BRACKET으로 stringified됩니다.
WeakRef는 garbage collection으로부터 target object 또는 symbol을 preserving하지 않고 그것을 refer하는 데 사용되는 object입니다. target이 garbage collection에 의해 reclaimed되지 않았다면, target value에 대한 access를 allow하기 위해 WeakRefs는 dereferenced될 수 있습니다.
global object의 "WeakRef" property의 initial value입니다.
constructor로 called될 때 new WeakRef를 create하고 initialize합니다.
function으로 called되도록 intended되지 않았으며, 그러한 방식으로 called되면 exception을 throw합니다.
클래스 정의의 extends 절의 값으로 사용될 수 있다. 지정된 WeakRef 동작을 상속하려는 서브클래스 생성자는 WeakRef.prototype의 내장 메서드를 지원하는 데 필요한 내부 상태로 서브클래스 인스턴스를 생성하고 초기화하기 위해 WeakRef 생성자에 대한 super 호출을 포함해야 한다.
WeakRef가 undefined가 아닌 target value를 반환하면, 이 target value는 ECMAScript code의 current execution이 completed될 때까지 garbage collected되어서는 안 됩니다. AddToKeptObjects operation은 read consistency가 maintained되도록 보장합니다.
let target = { foo() {} };
let weakRef = newWeakRef(target);
// ... later ...if (weakRef.deref()) {
weakRef.deref().foo();
}
위 example에서 first deref가 undefined로 evaluate되지 않으면 second deref도 그럴 수 없습니다.
The abstract operation WeakRefDeref takes argument weakRef (a WeakRef) and returns an ECMAScript language value. It performs the following steps when called:
global object의 "FinalizationRegistry" property의 initial value입니다.
constructor로 called될 때 new FinalizationRegistry를 create하고 initialize합니다.
function으로 called되도록 intended되지 않았으며, 그러한 방식으로 called되면 exception을 throw합니다.
클래스 정의의 extends 절의 값으로 사용될 수 있다. 지정된 FinalizationRegistry 동작을 상속하려는 서브클래스 생성자는 FinalizationRegistry.prototype의 내장 메서드를 지원하는 데 필요한 내부 상태로 서브클래스 인스턴스를 생성하고 초기화하기 위해 FinalizationRegistry 생성자에 대한 super 호출을 포함해야 한다.
cell을 Record { [[WeakRefTarget]]: target, [[HeldValue]]: heldValue, [[UnregisterToken]]: unregisterToken }로 둔다.
cell을 finalizationRegistry.[[Cells]]에 append한다.
undefined를 반환한다.
Note
이 specification의 algorithms와 definitions에 기반하면, finalizationRegistry.[[Cells]]가 cell을 contains할 때 cell.[[HeldValue]]는 live입니다; 그러나 이는 반드시 cell.[[UnregisterToken]] 또는 cell.[[Target]]이 live임을 의미하지는 않습니다. 예를 들어, object를 itself를 unregister token으로 하여 registering해도 그 object가 forever alive로 유지되지는 않습니다.
interface는 associated values가 specific specification과 match하는 property keys의 set입니다. interface의 specification에 의해 described된 모든 properties를 제공하는 any object는 그 interface에 conform합니다. interface는 distinct object로 represented되지 않습니다. 어떤 interface에도 conform하는 separately implemented objects가 많이 있을 수 있습니다. individual object는 multiple interfaces에 conform할 수 있습니다.
arguments는 next function에 passed될 수 있지만, 그 interpretation과 validity는 target iterator에 dependent합니다. for-of statement와 iterators의 other common users는 어떤 arguments도 pass하지 않으므로, 그러한 방식으로 사용될 것으로 expect되는 iterator objects는 arguments 없이 called되는 것을 deal할 준비가 되어 있어야 합니다.
반환된 object는 IteratorResult interface에 conform해야 합니다. 이 method를 invoking하면 caller가 iterator에 대해 더 이상 next method calls를 make할 intention이 없음을 iterator object에 notifies합니다. 반환된 IteratorResult object는 typically value가 true인 "done" property와 return method의 argument로 passed된 value를 가진 "value" property를 가집니다. 그러나 이 requirement는 enforced되지 않습니다.
반환된 object는 IteratorResult interface에 conform해야 합니다. 이 method를 invoking하면 caller가 error condition을 detected했음을 iterator object에 notifies합니다. argument는 error condition을 identify하는 데 사용될 수 있으며 typically exception object입니다. typical response는 argument로 passed된 value를 throw하는 것입니다. method가 throw하지 않으면, 반환된 IteratorResult object는 typically value가 true인 "done" property를 가집니다.
Note 2
Typically 이 methods의 callers는 invoking하기 전에 their existence를 check해야 합니다. for-of, yield*, 및 array destructuring을 포함한 certain ECMAScript language features는 existence check를 수행한 후 이 methods를 call합니다. iterable objects를 arguments로 accept하는 most ECMAScript library functions도 conditionally 이들을 call합니다.
반환된 promise는 fulfilled될 때 IteratorResult interface에 conform하는 object로 fulfill해야 합니다. async iterator의 next method에 대한 previous call이 "done" property가 true인 IteratorResult object에 대한 promise를 반환했다면, 그 object의 next method에 대한 모든 subsequent calls도 "done" property가 true인 IteratorResult object에 대한 promise를 반환해야 합니다. 그러나 이 requirement는 enforced되지 않습니다.
Additionally, fulfillment value로 serves하는 IteratorResult object는 value가 promise(또는 “thenable”)가 아닌 "value" property를 가져야 합니다. 그러나 이 requirement도 enforced되지 않습니다.
Note 1
arguments는 next function에 passed될 수 있지만, 그 interpretation과 validity는 target async iterator에 dependent합니다. for-await-of statement와 async iterators의 other common users는 어떤 arguments도 pass하지 않으므로, 그러한 방식으로 사용될 것으로 expect되는 async iterator objects는 arguments 없이 called되는 것을 deal할 준비가 되어 있어야 합니다.
반환된 promise는 fulfilled될 때 IteratorResult interface에 conform하는 object로 fulfill해야 합니다. 이 method를 invoking하면 caller가 async iterator에 대해 더 이상 next method calls를 make할 intention이 없음을 async iterator object에 notifies합니다. 반환된 promise는 typically value가 true인 "done" property와 return method의 argument로 passed된 value를 가진 "value" property를 가지는 IteratorResult object로 fulfill합니다. 그러나 이 requirement는 enforced되지 않습니다.
Additionally, fulfillment value로 serves하는 IteratorResult object는 value가 promise(또는 “thenable”)가 아닌 "value" property를 가져야 합니다. argument value가 typical manner로 used되면, 그것이 rejected promise인 경우 same reason으로 rejected된 promise가 returned되어야 합니다; fulfilled promise인 경우 그 fulfillment value가 returned promise의 IteratorResult object fulfillment value의 "value" property로 used되어야 합니다. 그러나 이러한 requirements도 enforced되지 않습니다.
반환된 promise는 fulfilled될 때 IteratorResult interface에 conform하는 object로 fulfill해야 합니다. 이 method를 invoking하면 caller가 error condition을 detected했음을 async iterator object에 notifies합니다. argument는 error condition을 identify하는 데 사용될 수 있으며 typically exception object입니다. typical response는 argument로 passed된 value로 reject하는 rejected promise를 반환하는 것입니다.
반환된 promise가 fulfilled되면, IteratorResult object fulfillment value는 typically value가 true인 "done" property를 가집니다. Additionally, value가 promise(또는 “thenable”)가 아닌 "value" property를 가져야 하지만, 이 requirement는 enforced되지 않습니다.
Note 2
Typically 이 methods의 callers는 invoking하기 전에 their existence를 check해야 합니다. for-await-of와 yield*를 포함한 certain ECMAScript language features는 existence check를 수행한 후 이 methods를 call합니다.
이는 iteratornext method call의 result status입니다. iterator의 end에 reached했다면 "done"은 true입니다. end에 reached하지 않았다면 "done"은 false이고 value가 available합니다. "done" property(own 또는 inherited)가 exist하지 않으면, value false를 가지는 것으로 considered됩니다.
done이 false이면, 이는 current iteration element value입니다. done이 true이면, 이는 iterator의 return value입니다(제공한 경우). iterator가 return value를 가지지 않으면, "value"는 undefined입니다. 그 경우 conforming object가 explicit "value" property를 inherit하지 않는다면 "value" property는 absent일 수 있습니다.
27.1.2 Iterator Helper 객체
Iterator Helper object는 some specific source iterator object의 lazy transformation을 represent하는 ordinary object입니다. Iterator Helper objects를 위한 named constructor는 없습니다. 대신, Iterator Helper objects는 Iterator instance objects의 certain methods를 calling하여 created됩니다.
Assert: obj는 [[GeneratorState]] internal slot을 가진다.
obj.[[GeneratorState]]가 suspended-start이면, 다음을 수행한다.
obj.[[GeneratorState]]를 completed로 설정한다.
NOTE: generator가 completed state에 들어가면 결코 그 state를 떠나지 않으며 its associated execution context는 결코 resumed되지 않는다. obj와 associated된 any execution state는 이 point에서 discarded될 수 있다.
이 specification에서 iterator interface를 implement하도록 defined된 모든 objects는 또한 %Iterator.prototype%으로부터 inherit합니다. ECMAScript code도 %Iterator.prototype%으로부터 inherit하는 objects를 define할 수 있습니다. %Iterator.prototype%은 all iterator objects에 applicable한 additional methods가 added될 수 있는 place를 제공합니다.
다음 expression은 ECMAScript code가 %Iterator.prototype% object에 access할 수 있는 one way입니다:
Iterator.prototype.constructor는 attributes { [[Enumerable]]: false, [[Configurable]]: true }를 가진 accessor property입니다. [[Get]] 및 [[Set]] attributes는 다음과 같이 defined됩니다:
27.1.3.3.1.1 get Iterator.prototype.constructor
[[Get]] attribute의 value는 arguments를 require하지 않는 built-in function입니다. called될 때 다음 steps를 수행합니다:
Iterator.prototype[%Symbol.toStringTag%]는 attributes { [[Enumerable]]: false, [[Configurable]]: true }를 가진 accessor property입니다. [[Get]] 및 [[Set]] attributes는 다음과 같이 defined됩니다:
27.1.3.3.15.1 get Iterator.prototype [ %Symbol.toStringTag% ]
[[Get]] attribute의 value는 arguments를 require하지 않는 built-in function입니다. called될 때 다음 steps를 수행합니다:
"Iterator"를 반환한다.
27.1.3.3.15.2 set Iterator.prototype [ %Symbol.toStringTag% ]
[[Set]] attribute의 value는 argument v를 takes하는 built-in function입니다. called될 때 다음 steps를 수행합니다:
이 specification에서 async iterator interface를 implement하도록 defined된 모든 objects는 또한 %AsyncIteratorPrototype%으로부터 inherit합니다. ECMAScript code도 %AsyncIteratorPrototype%으로부터 inherit하는 objects를 define할 수 있습니다. %AsyncIteratorPrototype% object는 all async iterator objects에 applicable한 additional methods가 added될 수 있는 place를 제공합니다.
이 function의 "name" property의 value는 "[Symbol.asyncIterator]"입니다.
27.1.5 Async-from-Sync Iterator 객체
Async-from-Sync Iterator object는 specific synchronous iterator를 adapts하는 async iterator입니다. Async-from-Sync Iterator objects는 ECMAScript code에 직접 accessible하지 않습니다. Async-from-Sync Iterator objects를 위한 named constructor는 없습니다. 대신, Async-from-Sync Iterator objects는 needed에 따라 CreateAsyncFromSyncIterator abstract operation에 의해 created됩니다.
The abstract operation CreateAsyncFromSyncIterator takes argument syncIteratorRecord (an Iterator Record) and returns an Iterator Record. synchronous Iterator Record로부터 async Iterator Record를 create하는 데 사용됩니다. It performs the following steps when called:
The abstract operation AsyncFromSyncIteratorContinuation takes arguments result (an Object), promiseCapability (a PromiseCapability Record for an intrinsic %Promise%), syncIteratorRecord (an Iterator Record), and closeOnRejection (a Boolean) and returns a Promise. It performs the following steps when called:
NOTE: promiseCapability가 intrinsic %Promise%에서 derived되므로, 아래 IfAbruptRejectPromise의 use에 entailed되는 promiseCapability.[[Reject]]에 대한 calls는 throw하지 않음이 guaranteed된다.
이 메서드를 호출하면 호출자가 이 객체를 계속 사용할 의도가 없음을 Disposable 객체에 알린다. 이 메서드는 파일 시스템 핸들, 스트림, 호스트 객체 등을 포함하되 이에 국한되지 않는 리소스의 명시적 정리를 수행하는 데 필요한 모든 로직을 수행해야 한다. 이 메서드에서 예외가 던져지면, 일반적으로 리소스를 명시적으로 해제할 수 없었음을 의미한다.
같은 객체에 대해 이 메서드를 두 번 이상 호출하는 경우, 이미 폐기된 리소스에 대해 정리 로직을 반복하지 않아야 하며, 첫 번째 호출에서 예외가 던져졌더라도 예외를 던지지 않아야 한다. 그러나 이 요구사항은 강제되지 않는다.
Disposable 객체를 using 또는 await using 선언과 함께 사용할 때, 리소스는 해당 선언을 바로 포함하는 Block 또는 Module이 평가된 후 자동으로 폐기된다.
이 메서드를 호출하면 호출자가 이 객체를 계속 사용할 의도가 없음을 AsyncDisposable 객체에 알린다. 이 메서드는 파일 시스템 핸들, 스트림, 호스트 객체 등을 포함하되 이에 국한되지 않는 리소스의 명시적 정리를 수행하는 데 필요한 모든 로직을 수행해야 한다. 이 메서드가 반환한 promise가 거부되면, 일반적으로 리소스를 명시적으로 해제할 수 없었음을 의미한다. AsyncDisposable 객체는 결과 Promise가 이행될 때까지 "disposed"된 것으로 간주되지 않는다.
같은 객체에 대해 이 메서드를 두 번 이상 호출하는 경우, 이미 폐기된 리소스에 대해 정리 로직을 반복하지 않아야 하며, 첫 번째 호출에서 예외가 던져졌거나 거부된 promise가 반환되었더라도 예외를 던지거나 거부된 promise를 반환하지 않아야 한다. 그러나 이 요구사항은 강제되지 않는다.
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]] »)로 둔다.
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]] »)로 둔다.
disposable stack이 폐기될 때 폐기될 리소스. 리소스는 초기화된 순서대로 추가되고, 역순으로 폐기된다.
27.5 Promise 객체
Promise는 deferred된(그리고 possibly asynchronous인) computation의 eventual results에 대한 placeholder로 사용되는 object입니다.
모든 Promise는 mutually exclusive한 세 states 중 하나입니다: fulfilled, rejected, 그리고 pending:
promise p는 p.then(f, r)가 function f를 call하는 Job을 immediately enqueue할 경우 fulfilled입니다.
promise p는 p.then(f, r)가 function r를 call하는 Job을 immediately enqueue할 경우 rejected입니다.
promise는 fulfilled도 rejected도 아니면 pending입니다.
promise는 pending이 아니면, 즉 fulfilled 또는 rejected이면 settled라고 합니다.
promise는 settled되었거나 다른 promise의 state와 match하도록 “locked in”된 경우 resolved입니다. resolved promise를 resolve 또는 reject하려는 시도는 effect가 없습니다. promise는 resolved가 아니면 unresolved입니다. unresolved promise는 항상 pending state입니다. resolved promise는 pending, fulfilled 또는 rejected일 수 있습니다.
27.5.1 Promise Abstract Operations
27.5.1.1 PromiseCapability Records
PromiseCapability Record는 Promise 또는 promise-like object를 그 promise를 resolve하거나 reject할 수 있는 functions와 함께 encapsulate하는 데 사용되는 Record value입니다. PromiseCapability Records는 NewPromiseCapability abstract operation에 의해 produced됩니다.
? Call(capability.[[Reject]], undefined, « value.[[Value]] »)를 수행한다.
capability.[[Promise]]를 반환한다.
value를 ! value로 설정한다.
27.5.1.2 PromiseReaction Records
PromiseReaction Record는 promise가 주어진 value로 resolved 또는 rejected될 때 어떻게 react해야 하는지에 대한 information을 store하는 데 사용되는 Record value입니다. PromiseReaction Records는 PerformPromiseThen abstract operation에 의해 created되며, NewPromiseReactionJob이 반환하는 Abstract Closure에 의해 used됩니다.
incoming value에 applied되어야 하는 function이며, 그 return value가 derived promise에 무슨 일이 일어나는지를 govern합니다. [[Handler]]가 empty이면, [[Type]]의 value에 dependent한 function이 대신 사용됩니다.
27.5.1.3 CreateResolvingFunctions ( toResolve )
The abstract operation CreateResolvingFunctions takes argument toResolve (a Promise) and returns a Record with fields [[Resolve]] (a function object) and [[Reject]] (a function object). It performs the following steps when called:
promiseOrEmpty를 Record { [[Value]]: toResolve }로 둔다.
resolveSteps를 parameters (resolution)를 가지고 promiseOrEmpty를 captures하며 called될 때 다음 steps를 수행하는 new Abstract Closure로 둔다:
Record { [[Resolve]]: resolve, [[Reject]]: reject }를 반환한다.
27.5.1.4 FulfillPromise ( promise, value )
The abstract operation FulfillPromise takes arguments promise (a Promise) and value (an ECMAScript language value) and returns unused. It performs the following steps when called:
이 abstract operation은 Promise subclassing을 support합니다. 이는 Promise constructor와 same way로 passed executor function argument를 call하는 any constructor에 대해 generic하기 때문입니다. Promise constructor의 static methods를 any subclass로 generalize하는 데 사용됩니다.
27.5.1.6 IsPromise ( arg )
The abstract operation IsPromise takes argument arg (an ECMAScript language value) and returns a Boolean. object에서 promise brand를 checks합니다. It performs the following steps when called:
arg가 Object가 아니면, false를 반환한다.
arg가 [[PromiseState]] internal slot을 가지지 않으면, false를 반환한다.
true를 반환한다.
27.5.1.7 RejectPromise ( promise, reason )
The abstract operation RejectPromise takes arguments promise (a Promise) and reason (an ECMAScript language value) and returns unused. It performs the following steps when called:
The abstract operation TriggerPromiseReactions takes arguments reactions (a List of PromiseReaction Records) and arg (an ECMAScript language value) and returns unused. reactions 안의 각 record에 대해 new Job을 enqueue합니다. Such Job 각각은 PromiseReaction Record의 [[Type]] 및 [[Handler]]를 process하며, [[Handler]]가 empty가 아니면 주어진 argument를 passing하여 it을 calls합니다. [[Handler]]가 empty이면, behaviour는 [[Type]]에 의해 determined됩니다. It performs the following steps when called:
The host-defined abstract operation HostPromiseRejectionTracker takes arguments promise (a Promise) and operation ("reject" or "handle") and returns unused. host environments가 promise rejections를 track할 수 있게 합니다.
HostPromiseRejectionTracker는 두 scenarios에서 called됩니다:
promise가 any handlers 없이 rejected될 때, operation argument가 "reject"로 set되어 called됩니다.
rejected promise에 handler가 first time added될 때, operation argument가 "handle"로 set되어 called됩니다.
HostPromiseRejectionTracker의 typical implementation은 unhandled rejections를 developers에게 notify하려고 시도할 수 있으며, 그러한 previous notifications가 later new handlers being attached에 의해 invalidated되면 also notify하도록 careful할 수 있습니다.
Note 2
operation이 "handle"이면, implementation은 garbage collection을 interfere하는 way로 promise에 대한 reference를 hold해서는 안 됩니다. operation이 "reject"이면, rejections는 rare하고 hot code paths에 있지 않을 것으로 expected되므로 implementation은 promise에 대한 reference를 hold할 수 있습니다.
27.5.2 Promise Jobs
27.5.2.1 NewPromiseReactionJob ( reaction, arg )
The abstract operation NewPromiseReactionJob takes arguments reaction (a PromiseReaction Record) and arg (an ECMAScript language value) and returns a Record with fields [[Job]] (a JobAbstract Closure) and [[Realm]] (a Realm Record or null). incoming value에 appropriate handler를 apply하고, handler의 return value를 사용하여 that handler와 associated된 derived promise를 resolve 또는 reject하는 new JobAbstract Closure를 반환합니다. It performs the following steps when called:
job을 reaction과 arg를 captures하며 called될 때 다음 steps를 수행하는, parameters가 없는 new JobAbstract Closure로 둔다:
NOTE: handler가 undefined가 아닌 한 handlerRealm은 never null이다. handler가 revoked Proxy이고 ECMAScript code가 실행되지 않을 때, handlerRealm은 error objects를 create하는 데 사용된다.
Record { [[Job]]: job, [[Realm]]: handlerRealm }를 반환한다.
27.5.2.2 NewPromiseResolveThenableJob ( promiseToResolve, thenable, then )
The abstract operation NewPromiseResolveThenableJob takes arguments promiseToResolve (a Promise), thenable (an Object), and then (a JobCallback Record) and returns a Record with fields [[Job]] (a JobAbstract Closure) and [[Realm]] (a Realm Record). It performs the following steps when called:
job을 promiseToResolve, thenable, 및 then을 captures하며 called될 때 다음 steps를 수행하는, parameters가 없는 new JobAbstract Closure로 둔다:
NOTE: thenRealm은 never null이다. then.[[Callback]]이 revoked Proxy이고 code가 실행되지 않을 때, thenRealm은 error objects를 create하는 데 사용된다.
Record { [[Job]]: job, [[Realm]]: thenRealm }를 반환한다.
Note
이 Job은 supplied thenable과 its then method를 사용하여 given promise를 resolve합니다. 이 process는 then method의 evaluation이 any surrounding code의 evaluation이 completed된 후 occur하도록 보장하기 위해 Job으로 일어나야 합니다.
global object의 "Promise" property의 initial value입니다.
constructor로 called될 때 new Promise를 create하고 initialize합니다.
function으로 called되도록 intended되지 않으며, 그런 방식으로 called되면 exception을 throw합니다.
클래스 정의의 extends 절의 값으로 사용될 수 있다. 지정된 Promise 동작을 상속하려는 서브클래스 생성자는 Promise 및 Promise.prototype의 내장 메서드를 지원하는 데 필요한 내부 상태로 서브클래스 인스턴스를 생성하고 초기화하기 위해 Promise 생성자에 대한 super 호출을 포함해야 한다.
? Call(resolvingFuncs.[[Reject]], undefined, « completion.[[Value]] »)를 수행한다.
promise를 반환한다.
Note
executor argument는 function object여야 합니다. 이는 이 Promise에 의해 represented되는 possibly deferred action의 initiating 및 reporting completion을 위해 called됩니다. executor는 두 arguments, resolve와 reject로 called됩니다. 이들은 executor function이 deferred computation의 eventual completion 또는 failure를 report하는 데 사용할 수 있는 functions입니다. executor function에서 returning하는 것은 deferred action이 completed되었음을 의미하지 않고, eventual deferred action 수행 request가 accepted되었음을 의미할 뿐입니다.
executor function에 passed되는 resolve function은 single argument를 accepts합니다. executor code는 eventually associated Promise를 resolve하기 원함을 indicate하기 위해 resolve function을 call할 수 있습니다. resolve function에 passed되는 argument는 deferred action의 eventual value를 represent하며, actual fulfillment value 또는 fulfilled될 경우 value를 provide할 another promise일 수 있습니다.
executor function에 passed되는 reject function은 single argument를 accepts합니다. executor code는 associated Promise가 rejected되며 결코 fulfilled되지 않음을 indicate하기 위해 reject function을 eventually call할 수 있습니다. reject function에 passed되는 argument는 promise의 rejection value로 used됩니다. Typically Error object입니다.
Promise constructor가 executor function에 passed하는 resolve 및 reject functions는 associated promise를 actually resolve하고 reject할 capability를 가집니다. Subclasses는 resolve와 reject에 대해 customized values를 pass하는 different constructor behaviour를 가질 수 있습니다.
NOTE: remainingElementsCount는 0 대신 1에서 시작하여, passed callback이 input iterator가 exhausted되기 전에 misbehaving "then"에 의해 called되는 경우에도 resultCapability.[[Resolve]]가 only once called되도록 ensure한다.
remainingElementsCount를 Record { [[Value]]: 1 }로 둔다.
? Call(resultCapability.[[Resolve]], undefined, « valuesArray »)를 수행한다.
resultCapability.[[Promise]]를 반환한다.
undefined를 values에 append한다.
nextPromise를 ? Call(promiseResolve, ctor, « next »)로 둔다.
fulfilledSteps를 parameters (value)를 가지고 values, resultCapability, 및 remainingElementsCount를 captures하며 called될 때 다음 steps를 수행하는 new Abstract Closure로 둔다:
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 )
이 function은 original promises가 모두 settled될 때, 즉 fulfilled 또는 rejected 중 하나가 될 때만 promise state snapshots의 array로 fulfilled되는 promise를 반환합니다. 이 algorithm을 run하면서 passed iterable의 모든 elements를 promises로 resolves합니다.
NOTE: remainingElementsCount는 0 대신 1에서 시작하여, passed callbacks 중 하나가 input iterator가 exhausted되기 전에 misbehaving "then"에 의해 called되는 경우에도 resultCapability.[[Resolve]]가 only once called되도록 ensure한다.
remainingElementsCount를 Record { [[Value]]: 1 }로 둔다.
fulfilledSteps를 parameters (value)를 가지고 values, resultCapability, 및 remainingElementsCount를 captures하며 called될 때 다음 steps를 수행하는 new Abstract Closure로 둔다:
rejectedSteps를 parameters (error)를 가지고 values, resultCapability, 및 remainingElementsCount를 captures하며 called될 때 다음 steps를 수행하는 new Abstract Closure로 둔다:
remainingElementsCount.[[Value]]를 remainingElementsCount.[[Value]] + 1로 설정한다.
? Invoke(nextPromise, "then", « onFulfilled, onRejected »)를 수행한다.
27.5.4.3 Promise.any ( iterable )
이 function은 fulfilled되는 first given promise에 의해 fulfilled되거나, given promises가 모두 rejected되면 rejection reasons를 holding하는 AggregateError로 rejected되는 promise를 반환합니다. 이 algorithm을 run하면서 passed iterable의 모든 elements를 promises로 resolves합니다.
NOTE: remainingElementsCount는 0 대신 1에서 시작하여, passed callback이 input iterator가 exhausted되기 전에 misbehaving "then"에 의해 called되는 경우에도 resultCapability.[[Reject]]가 only once called되도록 ensure한다.
remainingElementsCount를 Record { [[Value]]: 1 }로 둔다.
? Call(resultCapability.[[Reject]], undefined, « aggregateError »)를 수행한다.
resultCapability.[[Promise]]를 반환한다.
undefined를 errors에 append한다.
nextPromise를 ? Call(promiseResolve, ctor, « next »)로 둔다.
rejectedSteps를 parameters (error)를 가지고 errors, resultCapability, 및 remainingElementsCount를 captures하며 called될 때 다음 steps를 수행하는 new Abstract Closure로 둔다:
이 function은 settle되는 first passed promise와 same way로 settled되는 new promise를 반환합니다. 이 algorithm을 run하면서 passed iterable의 모든 elements를 promises로 resolves합니다.
iterable argument가 no values를 yield하거나 iterable에 의해 yielded된 promises 중 none이 ever settle하지 않으면, 이 method가 반환하는 pending promise는 never settled됩니다.
Note 2
이 function은 its this value가 Promise constructor의 parameter conventions를 support하는 constructor function일 것을 expects합니다. 또한 its this value가 resolve method를 provide할 것을 expects합니다.
이 function은 its this value가 Promise constructor의 parameter conventions를 support하는 constructor function일 것을 expects합니다.
27.5.4.7.1 PromiseResolve ( ctor, resolution )
The abstract operation PromiseResolve takes arguments ctor (an Object) and resolution (an ECMAScript language value) and returns either a normal completion containing an Object or a throw completion. resolution으로 resolved된 new promise를 반환합니다. It performs the following steps when called:
Promise[%Symbol.species%]는 set accessor function이 undefined인 accessor property입니다. Its get accessor function은 called될 때 다음 steps를 수행합니다:
this value를 반환한다.
이 function의 "name" property의 value는 "get [Symbol.species]"입니다.
Note
Promise prototype methods는 normally derived object를 create하기 위해 their this value's constructor를 사용합니다. 그러나 subclass constructor는 its %Symbol.species% property를 redefining하여 that default behaviour를 over-ride할 수 있습니다.
The abstract operation PerformPromiseThen takes arguments promise (a Promise), onFulfilled (an ECMAScript language value), and onRejected (an ECMAScript language value) and optional argument resultCapability (a PromiseCapability Record) and returns an Object or undefined. onFulfilled와 onRejected를 settlement actions로 사용하여 promise에 “then” operation을 수행합니다. resultCapability가 passed되면, result는 resultCapability의 promise를 updating하여 stored됩니다. passed되지 않으면, PerformPromiseThen은 result가 matter하지 않는 specification-internal operation에 의해 called되고 있는 것입니다. It performs the following steps when called:
constructor가 아니라 function으로 호출될 때 새 GeneratorFunction을 생성하고 초기화합니다. 따라서 function call GeneratorFunction (…)은 같은 arguments를 가진 object creation expression new GeneratorFunction (…)과 동등합니다.
class definition의 extends clause의 value로 사용될 수 있습니다. 지정된 GeneratorFunction behaviour를 상속하려는 subclass constructors는 built-in GeneratorFunction behaviour에 필요한 internal slots를 가진 subclass instances를 생성하고 초기화하기 위해 GeneratorFunction constructor에 대한 super call을 포함해야 합니다. generator function objects를 정의하는 모든 ECMAScript syntactic forms는 GeneratorFunction의 direct instances를 생성합니다. GeneratorFunction subclasses의 instances를 생성하는 syntactic means는 없습니다.
모든 GeneratorFunction instance는 ECMAScript function object이며 Table 26에 listed된 internal slots를 가집니다. 그러한 모든 instances의 [[IsClassConstructor]] internal slot의 value는 false입니다.
각 GeneratorFunction instance는 다음 own properties를 가집니다:
27.6.4.1 length
20.2.4.1에 given된 Function instances의 "length" property에 대한 specification은 GeneratorFunction instances에도 적용됩니다.
27.6.4.2 name
20.2.4.2에 given된 Function instances의 "name" property에 대한 specification은 GeneratorFunction instances에도 적용됩니다.
27.6.4.3 prototype
GeneratorFunction instance가 생성될 때마다 또 다른 ordinary object도 생성되며, 이는 generator function의 "prototype" property의 initial value입니다. prototype property의 value는 generator function object가 [[Call]]을 사용해 invoked될 때 newly created Generator의 [[Prototype]] internal slot을 initialize하는 데 사용됩니다.
constructor가 아니라 function으로 호출될 때 새 AsyncGeneratorFunction을 생성하고 초기화합니다. 따라서 function call AsyncGeneratorFunction (...)은 같은 arguments를 가진 object creation expression new AsyncGeneratorFunction (...)과 동등합니다.
class definition의 extends clause의 value로 사용될 수 있습니다. 지정된 AsyncGeneratorFunction behaviour를 상속하려는 subclass constructors는 built-in AsyncGeneratorFunction behaviour에 필요한 internal slots를 가진 subclass instances를 생성하고 초기화하기 위해 AsyncGeneratorFunction constructor에 대한 super call을 포함해야 합니다. async generator function objects를 정의하는 모든 ECMAScript syntactic forms는 AsyncGeneratorFunction의 direct instances를 생성합니다. AsyncGeneratorFunction subclasses의 instances를 생성하는 syntactic means는 없습니다.
모든 AsyncGeneratorFunction instance는 ECMAScript function object이며 Table 26에 listed된 internal slots를 가집니다. 그러한 모든 instances의 [[IsClassConstructor]] internal slot의 value는 false입니다.
각 AsyncGeneratorFunction instance는 다음 own properties를 가집니다:
27.7.4.1 length
"length" property의 value는 AsyncGeneratorFunction이 expected하는 typical number of arguments를 나타내는 integral Number입니다. 그러나 language는 function이 다른 number of arguments로 invoked되는 것을 permits합니다. "length" property가 specified한 number가 아닌 number of arguments로 invoked될 때 AsyncGeneratorFunction의 behaviour는 function에 depends합니다.
20.2.4.2에 given된 Function instances의 "name" property에 대한 specification은 AsyncGeneratorFunction instances에도 적용됩니다.
27.7.4.3 prototype
AsyncGeneratorFunction instance가 생성될 때마다 또 다른 ordinary object도 생성되며, 이는 async generator function의 "prototype" property의 initial value입니다. prototype property의 value는 generator function object가 [[Call]]을 사용해 invoked될 때 newly created AsyncGenerator의 [[Prototype]] internal slot을 initialize하는 데 사용됩니다.
function instances와 달리, AsyncGeneratorFunction의 "prototype" property의 value인 object는 value가 AsyncGeneratorFunction instance인 "constructor" property를 가지지 않습니다.
different kinds of generators를 distinguish하기 위해 사용되는 brand. ECMAScript source text로 declared된 generators의 [[GeneratorBrand]]는 항상 empty입니다.
27.8.3 Generator Abstract Operations
27.8.3.1 GeneratorStart ( gen, genBody )
The abstract operation GeneratorStart takes arguments gen (a Generator) and genBody (a FunctionBodyParse Node or an Abstract Closure with no parameters) and returns unused. It performs the following steps when called:
NOTE: generator가 completed state에 들어가면 결코 이를 떠나지 않으며, its associated execution context는 결코 resumed되지 않는다. acGen과 associated된 any execution state는 이 시점에서 discarded될 수 있다.
genContext의 code evaluation state를, 그 execution context에 대해 evaluation이 resumed될 때 closure가 no arguments로 called되도록 설정한다.
gen.[[GeneratorContext]]를 genContext로 설정한다.
unused를 반환한다.
27.8.3.2 GeneratorValidate ( gen, genBrand )
The abstract operation GeneratorValidate takes arguments gen (an ECMAScript language value) and genBrand (a String or empty) and returns either a normal completion containing one of suspended-start, suspended-yield, or completed, or a throw completion. It performs the following steps when called:
NOTE: generator가 completed state에 들어가면 결코 이를 떠나지 않으며, its associated execution context는 결코 resumed되지 않는다. gen과 associated된 any execution state는 이 시점에서 discarded될 수 있다.
The abstract operation CreateIteratorFromClosure takes arguments closure (an Abstract Closure with no parameters), genBrand (a String or empty), and genProto (an Object) and optional argument extraSlots (a List of names of internal slots) and returns a Generator. It performs the following steps when called:
async generator를 resume하기 위한 requests를 represent하는 Records. state transitions 동안을 제외하고, [[AsyncGeneratorState]]가 executing 또는 draining-queue 중 하나인 경우에만 non-empty입니다.
[[GeneratorBrand]]
String 또는 empty
different kinds of async generators를 distinguish하기 위해 사용되는 brand. ECMAScript source text로 declared된 async generators의 [[GeneratorBrand]]는 항상 empty입니다.
27.9.3 AsyncGenerator Abstract Operations
27.9.3.1 AsyncGeneratorRequest Records
AsyncGeneratorRequest는 async generator가 어떻게 resumed되어야 하는지에 대한 information을 store하고, corresponding promise를 fulfilling하거나 rejecting하기 위한 capabilities를 contain하는 데 사용되는 Record value입니다.
The abstract operation AsyncGeneratorStart takes arguments gen (an AsyncGenerator) and genBody (a FunctionBodyParse Node or an Abstract Closure with no parameters) and returns unused. It performs the following steps when called:
The abstract operation AsyncGeneratorEnqueue takes arguments gen (an AsyncGenerator), completion (a Completion Record), and promiseCapability (a PromiseCapability Record) and returns unused. It performs the following steps when called:
request를 AsyncGeneratorRequest { [[Completion]]: completion, [[Capability]]: promiseCapability }로 둔다.
The abstract operation AsyncGeneratorCompleteStep takes arguments gen (an AsyncGenerator), completion (a Completion Record), and done (a Boolean) and optional argument realm (a Realm Record) and returns unused. It performs the following steps when called:
! Call(promiseCapability.[[Resolve]], undefined, « iteratorResult »)를 수행한다.
unused를 반환한다.
27.9.3.6 AsyncGeneratorResume ( gen, completion )
The abstract operation AsyncGeneratorResume takes arguments gen (an AsyncGenerator) and completion (a Completion Record) and returns unused. It performs the following steps when called:
Assert: gen.[[AsyncGeneratorState]]는 suspended-start 또는 suspended-yield 중 하나이다.
The abstract operation AsyncGeneratorAwaitReturn takes argument gen (an AsyncGenerator) and returns unused. It performs the following steps when called:
The abstract operation AsyncGeneratorDrainQueue takes argument gen (an AsyncGenerator) and returns unused. generator의 AsyncGeneratorQueue를 return completion을 holding하는 AsyncGeneratorRequest를 encounters할 때까지 drains합니다. It performs the following steps when called:
constructor가 아니라 function으로 호출될 때 새 AsyncFunction을 생성하고 초기화합니다. 따라서 function call AsyncFunction(…)은 같은 arguments를 가진 object creation expression new AsyncFunction(…)과 동등합니다.
class definition의 extends clause의 value로 사용될 수 있습니다. 지정된 AsyncFunction behaviour를 상속하려는 subclass constructors는 built-in async function behaviour에 필요한 internal slots를 가진 subclass instance를 생성하고 초기화하기 위해 AsyncFunction constructor에 대한 super call을 포함해야 합니다. async function objects를 정의하는 모든 ECMAScript syntactic forms는 AsyncFunction의 direct instances를 생성합니다. AsyncFunction subclasses의 instances를 생성하는 syntactic means는 없습니다.
The abstract operation AsyncBlockStart takes arguments promiseCapability (a PromiseCapability Record), asyncBody (a Parse Node or an Abstract Closure with no parameters), and asyncContext (an execution context) and returns unused. It performs the following steps when called:
closure를 parameters가 없고 promiseCapability와 asyncBody를 captures하며 호출될 때 다음 steps를 수행하는 new Abstract Closure로 둔다:
memory consistency model, 즉 memory model은 SharedArrayBuffer로 backed된 TypedArray instances에 accessing하여, 그리고 Atomics object의 methods를 통해 발생하는 Shared Data Block events의 possible orderings를 specifies합니다. program에 data races(아래에 defined됨)가 없을 때, events의 ordering은 sequentially consistent하게, 즉 각 agent의 actions가 interleaving된 것처럼 나타납니다. program에 data races가 있을 때, shared memory operations는 sequentially inconsistent하게 나타날 수 있습니다. 예를 들어, programs는 causality-violating behaviour 및 기타 astonishments를 보일 수 있습니다. 이러한 astonishments는 compiler transforms 및 CPUs의 design(예: out-of-order execution 및 speculation)에서 발생합니다. memory model은 program이 sequentially consistent behaviour를 보이는 precise conditions와 data races에서 read될 수 있는 possible values 둘 다를 정의합니다. 즉, undefined behaviour는 없습니다.
memory model은 SharedArrayBuffer에 대한 abstract operations 또는 evaluation 중 Atomics object의 methods에 의해 introduced되는 Memory events에 대한 relational constraints로 defined됩니다.
Note
이 section은 SharedArrayBuffers에 대한 abstract operations가 introduced하는 Memory events에 관한 axiomatic model을 제공합니다. 이 model은 이 specification의 나머지와 달리 algorithmically expressible하지 않다는 점을 강조할 필요가 있습니다. abstract operations에 의한 events의 nondeterministic introduction은 ECMAScript evaluation의 operational semantics와 memory model의 axiomatic semantics 사이의 interface입니다. 이러한 events의 semantics는 evaluation의 모든 events graphs를 considering하여 defined됩니다. 이것들은 Static Semantics도 Runtime Semantics도 아닙니다. demonstrated algorithmic implementation은 없고, 대신 particular event graph가 allowed 또는 disallowed되는지를 determine하는 constraints의 set이 있습니다.
29.1 Memory Model Fundamentals
Shared memory accesses(reads와 writes)는 아래에 defined된 atomic accesses와 data accesses라는 두 groups로 divided됩니다. Atomic accesses는 sequentially consistent합니다. 즉, agent cluster의 모든 agents가 agreed upon하는 events의 strict total ordering이 있습니다. Non-atomic accesses에는 모든 agents가 agreed upon하는 strict total ordering이 없습니다. 즉, unordered입니다.
Note 1
release-acquire와 같이 sequentially consistent보다 약하고 unordered보다 강한 orderings는 supported되지 않습니다.
Shared Data Block event는 ReadSharedMemory, WriteSharedMemory, 또는 ReadModifyWriteSharedMemory Record 중 하나입니다. read event는 ReadSharedMemory 또는 ReadModifyWriteSharedMemory입니다. write event는 WriteSharedMemory 또는 ReadModifyWriteSharedMemory입니다.
Shared Data Block events는 abstract operations 또는 Atomics object의 methods에 의해 candidate executionAgent Events Records에 introduced됩니다. 일부 operations는 또한 fields가 없고 other events의 permitted orderings를 직접 constrain하기 위해서만 존재하는 Synchronize events를 introduce합니다. 그리고 마지막으로 host-specific events가 있습니다. Memory event는 Shared Data Block event, Synchronize event, 또는 그러한 host-specific event 중 하나입니다.
Shared Data Block event e의 memory range를 e.[[ByteIndex]](inclusive)에서 e.[[ByteIndex]] + e.[[ElementSize]](exclusive)까지 interval의 all integers의 Set으로 둔다. 두 events가 같은 [[Block]], [[ByteIndex]], 및 [[ElementSize]]를 가질 때 두 events의 memory ranges는 equal입니다. 두 events가 같은 [[Block]]을 가지고, ranges가 equal이 아니며, 그 intersection이 non-empty일 때 두 events의 memory ranges는 overlapping합니다. 두 events가 같은 [[Block]]을 가지지 않거나 그 ranges가 equal도 overlapping도 아닐 때 두 events의 memory ranges는 disjoint입니다.
Note 2
accounted for되어야 하는 host-specific synchronizing events의 examples는 다음과 같습니다: 한 agent에서 다른 agent로 SharedArrayBuffer를 sending하는 것(예: browser에서 postMessage), agents를 starting 및 stopping하는 것, 그리고 shared memory 이외의 channels를 통해 agent cluster 내에서 communicating하는 것. particular execution execution에 대해, 이러한 events는 host가 host-synchronizes-withstrict partial order를 통해 제공합니다. 또한 hosts는 is-agent-order-beforeRelation에 participate하기 위해 host-specific synchronizing events를 execution.[[EventList]]에 add할 수 있습니다.
The abstract operation EventSet takes argument execution (a candidate execution) and returns a Set of Memory events. It performs the following steps when called:
events를 empty Set으로 둔다.
execution.[[EventsRecords]]의 각 Agent Events RecordeventsRecord에 대해, 다음을 수행한다.
eventsRecord.[[EventList]]의 각 Memory eventevent에 대해, 다음을 수행한다.
event를 events에 Add한다.
events를 반환한다.
29.5.2 SharedDataBlockEventSet ( execution )
The abstract operation SharedDataBlockEventSet takes argument execution (a candidate execution) and returns a Set of Shared Data Block events. It performs the following steps when called:
The abstract operation HostEventSet takes argument execution (a candidate execution) and returns a Set of Memory events. It performs the following steps when called:
이벤트 eventA와 eventB에 대해, execution.[[EventsRecords]] 안에 어떤 Agent Events RecordeventsRecord가 있어서 eventsRecord.[[EventList]]가 eventA와 eventB를 모두 포함하고, eventA가 eventsRecord.[[EventList]]의 List 순서에서 eventB보다 앞에 있으면, eventA는 execution에서 eventB보다 is-agent-order-before이다.
events readEvent 및 writeEvent에 대해, SharedDataBlockEventSet(execution)이 readEvent와 writeEvent 둘 다를 contain하고 execution 안의 reads-bytes-from(readEvent)이 writeEvent를 contain하면, readEvent는 execution에서 writeEvent로부터 reads-from합니다.
candidate executionexecution 안의 두 host-specific events eventA 및 eventB에 대해, eventA가 execution에서 eventB와 host-synchronizes-with이면 eventA가 execution에서 eventB보다 happens-before임을 implies합니다.
Note 2
이 Relation은 host가 HTML workers 사이의 postMessage와 같은 additional synchronization mechanisms를 제공할 수 있게 합니다.
candidate executionexecution에서 reads-from에 의해 related된 모든 seq-cst events가 synchronizes-with에 의해 related되는 것은 아닙니다. equal memory ranges도 가지는 events만 synchronizes-with에 의해 related됩니다.
이 clause는 agents에 대한 forward progress guarantee와 함께, seq-cstwrites가 finite time 안에 equal memory range를 가진 seq-cstreads에게 visible해지는 liveness condition을 ensure합니다.
is-memory-order-before가 EventSet(execution) 안의 모든 events를 포함하지만, execution에서 happens-before 또는 synchronizes-with에 의해 constrained되지 않는 것들은 order 안의 anywhere에서 occur하는 것이 allowed됩니다.
29.7.5 Valid Executions
candidate executionexecution은 다음 모두가 true이면 valid execution(또는 simply execution)입니다.
eventA가 execution에서 eventB로부터 reads-from하거나 eventB가 execution에서 eventA로부터 reads-from하면, 다음을 수행한다.
true를 반환한다.
false를 반환한다.
29.9 Data Races
execution execution과 SharedDataBlockEventSet(execution)에 contained된 events eventA 및 eventB에 대해, 다음 algorithm이 true를 반환하면 eventA와 eventB는 data race 안에 있습니다.
eventA와 eventB가 execution에서 race 안에 있으면, 다음을 수행한다.
eventA.[[Order]]가 seq-cst가 아니거나 eventB.[[Order]]가 seq-cst가 아니면, 다음을 수행한다.
true를 반환한다.
eventA와 eventB가 overlapping memory ranges를 가지면, 다음을 수행한다.
program은 all its executions가 data race free이면 data race free입니다.
memory model은 data race free programs에 대해 all events의 sequential consistency를 guarantee합니다.
29.11 Shared Memory Guidelines
Note 1
다음은 shared memory로 작업하는 ECMAScript programmers를 위한 guidelines입니다.
programs는 data race free로 유지하는 것을 recommend합니다. 즉, 같은 memory location에 concurrent non-atomic operations가 존재할 수 없도록 만듭니다. Data race free programs는 각 agent의 evaluation semantics 안의 각 step이 서로 interleaved되는 interleaving semantics를 가집니다. data race free programs에 대해서는 memory model의 details를 이해할 필요가 없습니다. details는 ECMAScript를 더 잘 작성하는 데 도움이 되는 intuition을 build할 가능성이 낮습니다.
더 일반적으로, program이 data race free가 아니더라도 atomic operations가 any data races에 involved되지 않고 race하는 operations가 모두 같은 access size를 가지는 한 predictable behaviour를 가질 수 있습니다. atomics가 races에 involved되지 않도록 arrange하는 simplest way는 atomic 및 non-atomic operations에 different memory cells가 사용되도록 ensure하고, different sizes의 atomic accesses가 동시에 같은 cells에 access하는 데 사용되지 않도록 하는 것입니다. Effectively, program은 shared memory를 가능한 한 strongly typed로 treat해야 합니다. 여전히 race하는 non-atomic accesses의 ordering과 timing에 depend할 수는 없지만, memory가 strongly typed로 treated되면 racing accesses는 “tear”되지 않습니다(bits of their values will not be mixed).
Note 2
다음은 shared memory를 사용하는 programs에 대한 compiler transformations를 작성하는 ECMAScript implementers를 위한 guidelines입니다.
multi-agent setting에서 각 agent의 performance가 single-agent setting에서와 as good as it would be 되도록, single-agent setting에서 valid한 대부분의 program transformations를 multi-agent setting에서도 allow하는 것이 desirable합니다. 이러한 transformations는 often judge하기 어렵습니다. 우리는 normative로 taken되도록 intended된(즉 memory model에 의해 implied되거나 memory model이 implies하는 것보다 stronger인) program transformations에 관한 몇 가지 rules를 outline하지만, 이는 exhaustive하지 않을 가능성이 큽니다. 이러한 rules는 is-agent-order-beforeRelation을 구성하는 Memory events의 introductions에 precede하는 program transformations에 apply되도록 intended됩니다.
read event의 possible read values를 모든 valid executions 전반에서 그 event에 대한 ValueOfReadEvent의 모든 values의 set으로 둔다.
shared memory가 없는 경우 valid한 agent-order slice의 any transformation은 shared memory가 있는 경우에도 valid하며, 다음 exceptions가 있습니다.
Atomics are carved in stone: Program transformations는 [[Order]]가 seq-cst인 any Shared Data Block events가 is-agent-order-beforeRelation에서 removed되게 하거나, 서로에 대해 reordered되게 하거나, [[Order]]가 unordered인 events에 대해 agent-order slice 안에서 reordered되게 해서는 안 됩니다.
(In practice, reorderings에 대한 prohibition은 compiler가 inter-agent program analysis가 없는 경우 어차피 보통 assume해야 하는 것처럼, every seq-cst operation이 synchronization이고 final is-memory-order-beforeRelation에 included된다고 assume하도록 force합니다. 또한 memory-order에 대한 callee의 effects가 unknown인 every call이 seq-cst operations를 contain할 수 있다고 compiler가 assume하도록 force합니다.)
Reads must be stable: Any given shared memory read는 execution 안에서 single value만 observe해야 합니다.
(예를 들어, program에서 semantically single read인 것이 multiple times executed되면, program은 subsequently read된 values 중 하나만 observe하도록 allowed됩니다. rematerialization으로 known된 transformation은 이 rule을 violate할 수 있습니다.)
Writes must be stable: shared memory에 대한 모든 observable writes는 execution 안의 program semantics로부터 follow해야 합니다.
(예를 들어, transformation은 larger location에 대한 read-modify-write operations를 사용해 smaller datum을 write하거나, program이 write할 수 없었던 value를 memory에 write하거나, read한 location이 read 후 다른 agent에 의해 overwritten될 수 있었다면 그 just-read value를 그 location에 다시 write하는 것과 같은 certain observable writes를 introduce해서는 안 됩니다.)
Possible read values must be non-empty: Program transformations는 shared memory read의 possible read values가 empty가 되도록 할 수 없습니다.
(Counterintuitively, 이 rule은 effect적으로 writes에 대한 transformations를 restrict합니다. 왜냐하면 writes는 read events에 의해 read되는 한에서 memory model 안에서 force를 가지기 때문입니다. 예를 들어, writes는 두 seq-cst operations 사이에서 moved 및 coalesced되고 sometimes reordered될 수 있지만, transformation은 location을 updates하는 모든 write를 remove해서는 안 됩니다; some write는 preserved되어야 합니다.)
valid로 remain하는 transformations의 examples는 다음과 같습니다: 같은 location으로부터 multiple non-atomic reads를 merging하는 것, non-atomic reads를 reordering하는 것, speculative non-atomic reads를 introducing하는 것, 같은 location에 대한 multiple non-atomic writes를 merging하는 것, different locations에 대한 non-atomic writes를 reordering하는 것, 그리고 termination에 영향을 미치더라도 non-atomic reads를 loops 밖으로 hoisting하는 것. 일반적으로 aliased TypedArrays는 locations가 different임을 prove하기 어렵게 만든다는 점에 유의하십시오.
Note 3
다음은 shared memory accesses에 대한 machine code를 generating하는 ECMAScript implementers를 위한 guidelines입니다.
ARM 또는 Power의 memory models보다 no weaker인 memory models를 가진 architectures에서는, non-atomic stores와 loads가 target architecture의 bare stores와 loads로 compiled될 수 있습니다. Atomic stores와 loads는 sequential consistency를 guarantee하는 instructions로 compiled down될 수 있습니다. such instructions가 없으면, bare store 또는 load의 양쪽에 barriers를 placing하는 것과 같은 memory barriers가 employed되어야 합니다. Read-modify-write operations는 x86의 LOCK-prefixed instructions, ARM의 load-exclusive/store-exclusive instructions, Power의 load-link/store-conditional instructions와 같은 target architecture의 read-modify-write instructions로 compiled될 수 있습니다.
Specifically, memory model은 다음과 같은 code generation을 allow하도록 intended됩니다.
program 안의 every atomic operation은 necessary하다고 assumed됩니다.
Atomic operations는 서로 또는 non-atomic operations와 never rearranged됩니다.
Functions는 항상 atomic operations를 perform한다고 assumed됩니다.
Atomic operations는 larger data에 대한 read-modify-write operations로 implemented되지 않고, platform이 appropriate size의 atomic operations를 가지지 않는 경우 non-lock-free atomics로 implemented됩니다. (우리는 already every platform이 every interesting size의 normal memory access operations를 가진다고 assume합니다.)
Naive code generation은 다음 patterns를 사용합니다:
Regular loads와 stores는 single load 및 store instructions로 compile됩니다.
Lock-free atomic loads와 stores는 full(sequentially consistent) fence, regular load 또는 store, 그리고 full fence로 compile됩니다.
Lock-free atomic read-modify-write accesses는 full fence, atomic read-modify-write instruction sequence, 그리고 full fence로 compile됩니다.
Non-lock-free atomics는 spinlock acquire, full fence, 일련의 non-atomic load 및 store instructions, full fence, 그리고 spinlock release로 compile됩니다.
그 mapping은 memory range에 대한 atomic operation이 non-atomic write 또는 different size의 atomic operation과 race하지 않는 한 correct합니다. 그러나 그것이 all we need입니다: memory model은 race에 involved된 atomic operations를 effect적으로 non-atomic status로 demotes합니다. 반면 naive mapping은 꽤 strong합니다: 이는 atomic operations가 sequentially consistent fences로 사용되는 것을 allow하지만, memory model은 실제로 이를 guarantee하지 않습니다.
those basic patterns에 대한 local improvements도 memory model의 constraints에 subject하여 allowed됩니다. 예를 들어:
redundant fences를 remove하는 obvious platform-dependent improvements가 있습니다. 예를 들어, x86에서는 lock-free atomic loads와 stores 주변의 fences를 store 뒤에 following하는 fence를 제외하고 항상 omitted할 수 있으며, lock-free read-modify-write instructions에는 fence가 필요하지 않습니다. 이것들은 모두 LOCK-prefixed instructions를 사용하기 때문입니다. many platforms에는 several strengths의 fences가 있고, certain contexts에서는 sequential consistency를 destroying하지 않고 weaker fences가 사용될 수 있습니다.
대부분의 modern platforms는 ECMAScript atomics가 required하는 모든 data sizes에 대해 lock-free atomics를 support합니다. Non-lock-free atomics가 needed되면, atomic operation의 body를 surrounding하는 fences는 보통 lock 및 unlock steps에 folded될 수 있습니다. non-lock-free atomics에 대한 simplest solution은 SharedArrayBuffer마다 single lock word를 가지는 것입니다.
또한 더 complicated platform-dependent local improvements가 있으며, 이는 some code analysis를 require합니다. 예를 들어, two back-to-back fences는 often single fence와 같은 effect를 가지므로, code가 two atomic operations in sequence에 대해 generated되면 single fence만 them 사이를 separate하면 됩니다. x86에서는 atomic stores를 separating하는 single fence조차 omitted될 수 있습니다. store 뒤에 following하는 fence는 store를 subsequent load와 separate하는 데만 needed되기 때문입니다.
이 annex에서 정의되는 ECMAScript language syntax와 semantics는 ECMAScript host가 web browser일 때 요구됩니다. 이 annex의 내용은 normative이지만 ECMAScript host가 web browser가 아닌 경우 optional입니다.
이 annex에서 정의되는 일부 기능은 이 annex에 specified되며, 일부는 이 문서의 main body에 specified됩니다.
기능이 main body에 specified되는 경우, 그것이 문서에 영향을 주는 각 지점은 coloured box 안의 “Normative Optional”이라는 단어로 표시됩니다. 또한 그 기능이 algorithm이나 early error rule에서 특정 wording을 수반하는 경우, 이는 relevant feature를 “the host supports”한다는 condition으로 guarded됩니다. Web browsers는 이러한 모든 기능을 support해야 합니다.
Note
이 annex는 web browser ECMAScript hosts의 다양한 legacy features와 기타 characteristics를 설명합니다. 이 annex에 specified된 모든 language features와 behaviours는 하나 이상의 바람직하지 않은 characteristics를 가지고 있으며 legacy usage가 없다면 이 specification에서 제거될 것입니다. 그러나 많은 기존 web pages가 이러한 features를 사용하기 때문에 web browsers는 계속 이를 support해야 합니다. 이 annex의 specifications는 이러한 legacy features의 interoperable implementations에 대한 requirements를 정의합니다.
이러한 features는 core ECMAScript language의 일부로 간주되지 않습니다. Programmers는 새로운 ECMAScript code를 작성할 때 이러한 features와 behaviours의 존재를 사용하거나 가정해서는 안 됩니다. ECMAScript implementations는 implementation이 web browser의 일부이거나 web browsers가 마주치는 동일한 legacy ECMAScript code를 실행해야 하는 경우가 아니면 이러한 features를 implement하지 않는 것이 권장됩니다.
B.1 추가 구문
B.1.1 HTML-like Comments
12.4의 syntax와 semantics는 다음과 같이 extended됩니다. 단, 이 extension은 goal symbolModule을 사용하여 source text를 parsing할 때는 allowed되지 않습니다:
22.2.1의 syntax는 다음과 같이 modified되고 extended됩니다. 이러한 changes는 grammar productions의 ordering과 contextual information에 의해 resolved되는 ambiguities를 도입합니다. 다음 grammar를 사용하여 parsing할 때, 각 alternative는 previous production alternatives가 match하지 않는 경우에만 considered됩니다.
이 alternative pattern grammar와 semantics는 BMP patterns의 syntax와 semantics만 변경합니다. 다음 grammar extensions는 [UnicodeMode] parameter로 parameterized된 productions를 포함합니다. 그러나 이러한 extensions 중 어느 것도 [UnicodeMode] parameter가 goal symbol에 present한 상태로 parsing할 때 recognized되는 Unicode patterns의 syntax를 변경하지 않습니다.
The abstract operation CharacterRangeOrUnion takes arguments regexpRecord (a RegExp Record), charSet (a CharSet), and otherSet (a CharSet) and returns a CharSet. It performs the following steps when called:
abstract operation ParsePattern은 arguments patternText (Unicode code points의 sequence), u (a Boolean), 및 v (a Boolean)를 받습니다. called될 때 다음 steps를 수행합니다:
v가 true이고 u가 true이면, 다음을 수행한다.
parseResult를 하나 이상의 SyntaxError objects를 포함하는 List로 둔다.
Else if v가 true이면, 다음을 수행한다.
parseResult를 ParseText(patternText, Pattern[+UnicodeMode, +UnicodeSetsMode, +NamedCaptureGroups])로 둔다.
Else if u가 true이면, 다음을 수행한다.
parseResult를 ParseText(patternText, Pattern[+UnicodeMode, ~UnicodeSetsMode, +NamedCaptureGroups])로 둔다.
Else,
parseResult를 ParseText(patternText, Pattern[~UnicodeMode, ~UnicodeSetsMode, ~NamedCaptureGroups])로 둔다.
encoding은 RFC 1738에 described된 encoding에 부분적으로 based되지만, 이 standard에 specified된 전체 encoding은 RFC 1738의 contents와 무관하게 위에 described되어 있습니다. 이 encoding은 RFC 3986에 의해 RFC 1738에 이루어진 changes를 reflect하지 않습니다.
B.2.1.2 unescape ( string )
이 function은 global object의 property입니다. escape function에 의해 introduced될 수 있는 sort의 각 escape sequence가 그것이 represents하는 code unit으로 replaced된 String value의 새 version을 computes합니다.
이 method는 this value를 String으로 converting한 결과의 substring을 반환하며, index start에서 시작하여 length code units만큼 이어집니다(length가 undefined이면 String의 end까지). start가 negative이면, sourceLength가 String의 length일 때 sourceLength + start로 treated됩니다. 결과는 String object가 아니라 String value입니다.
escapedAttrValue를 attrValueString과 같지만 attrValueString 내 code unit 0x0022 (QUOTATION MARK)의 각 occurrence가 six code unit sequence """로 replaced된 String value로 둔다.
property "trimStart"가 preferred됩니다. "trimLeft" property는 principally old code와의 compatibility를 위해 provided됩니다. 새로운 ECMAScript code에서는 "trimStart" property를 사용하는 것이 recommended됩니다.
property "trimEnd"가 preferred됩니다. "trimRight" property는 principally old code와의 compatibility를 위해 provided됩니다. 새로운 ECMAScript code에서는 "trimEnd" property를 사용하는 것이 recommended됩니다.
이 method는 this value RegExp를 새로운 pattern과 flags로 완전히 reinitializes합니다. implementation은 이 method의 use를 resulting RegExp object가 multiple times 사용될 것이며 따라서 extra optimization의 candidate라는 assertion으로 interpret할 수 있습니다.
B.3.2 Block-Level Function Declarations Web Legacy Compatibility Semantics
ECMAScript 2015 이전에는 ECMAScript specification이 Block statement의 StatementList의 element로서 FunctionDeclaration의 occurrence를 define하지 않았습니다. 그러나 그러한 form의 FunctionDeclaration에 대한 support는 allowable extension이었고 대부분의 browser-hosted ECMAScript implementations가 이를 permitted했습니다. 불행히도 그러한 declarations의 semantics는 implementations마다 다릅니다. 이러한 semantic differences 때문에 Block level function declarations를 사용하는 기존 web ECMAScript source text는 그 usage가 그러한 declarations에 대한 모든 browser implementations의 semantic intersection에만 depends하는 경우에만 browser implementations 간에 portable합니다. 다음은 그 intersection semantics에 속하는 use cases입니다:
function이 declared되고 single block 내에서만 referenced됩니다.
f의 declaration을 containing하는 Block을 lexically follows하는 g의 function code 내에 IdentifierReference로서 f의 occurrence가 적어도 하나 있습니다.
첫 번째 use case는 ECMAScript 2015가 provided하는 Block level function declarations의 semantics와 interoperable합니다. 그 use case를 employing하는 pre-existing ECMAScript source text는 clauses 10, 14, 및 15에 의해 defined된 Block level function declarations semantics를 사용하여 operate할 것입니다.
두 번째 및 세 번째 use cases에 대한 ECMAScript 2015 interoperability는 clause 10, clause 15, clause 19.2.1 및 clause 16.1.7 semantics에 대한 다음 extensions를 requires합니다.
ECMAScript implementation이 diagnostic warning messages를 reporting하는 mechanism을 가지고 있으면, code가 이러한 compatibility semantics가 applied되고 non-compatibility semantics와 observable differences를 introduce하는 FunctionDeclaration을 contains할 때 warning이 produced되어야 합니다. 예를 들어 var binding이 early error를 create하기 때문에 introduced되지 않는 경우 warning message는 produced되지 않아야 합니다.
이 feature는 다음 points에서 special semantics를 involves합니다:
이 production은 non-strict code를 parsing할 때만 applies됩니다. 이 production에 의해 matched된 source text는, FunctionDeclaration[?Yield, ?Await, ~Default]의 각 matching occurrence가 source text에서 그 position을 occupying하는 BlockStatement의 sole StatementListItem인 것처럼 processed됩니다. 그러한 synthetic BlockStatement의 semantics는 B.3.2에 specified된 web legacy compatibility semantics를 포함합니다.
At runtime, 그러한 bindings는 VariableDeclarationEnvironment에서 instantiated됩니다. 그것들은 CatchParameter에 의해 introduced된 same-named bindings를 shadow하지 않으므로, 그러한 var declarations에 대한 Initializer는 var binding이 아니라 corresponding catch parameter에 assign됩니다.
[[IsHTMLDDA]] internal slot을 가진 objects는 이 specification에 의해 created되지 않습니다. 그러나 web browsers의 document.all object는 web compatibility purposes를 위해 존재하는 이 slot을 가진 host-definedexotic object입니다. 이 type의 object에 대한 다른 known examples는 없으며 implementations는 document.all을 제외하고 이를 create하지 않아야 합니다.
이 feature는 다음 points에서 special semantics를 involves합니다:
B.3.9 Function Call Assignment Targets에 대한 Runtime Errors
function call (13.3.6)이 non-strict code에서 assignment target으로 사용될 때, early error를 producing하는 대신 assignment의 evaluation 중에 ReferenceError exception이 thrown됩니다.
undeclared identifier나 otherwise unresolvable reference에 대한 Assignment는 global object에 property를 create하지 않습니다. simple assignment가 strict mode code 내에서 occurs할 때, 그 LeftHandSideExpression은 unresolvable Reference로 evaluate되어서는 안 됩니다. 그렇다면 ReferenceError exception이 thrown됩니다(6.2.5.6). LeftHandSideExpression은 또한 attribute value { [[Writable]]: false }를 가진 data property에 대한 reference, attribute value { [[Set]]: undefined }를 가진 accessor property에 대한 reference, 또는 [[Extensible]] internal slot이 false인 object의 non-existent property에 대한 reference일 수도 없습니다. 이러한 경우에는 TypeError exception이 thrown됩니다(13.15).
strict functions에 대한 Arguments objects는 자신의 array-indexed property values를 their functions의 corresponding formal parameter bindings와 dynamically share하지 않습니다. (10.4.4).
strict functions의 경우, arguments object가 created되면 local identifier arguments의 arguments object에 대한 binding은 immutable이므로 assignment expression의 target이 될 수 없습니다. (10.2.11).
Strict mode eval code는 caller to eval의 variable environment에서 variables나 functions를 instantiate할 수 없습니다. 대신 새로운 variable environment가 created되고 그 environment가 eval code의 declaration binding instantiation에 사용됩니다(19.2.1).
strict mode code 내에서 this가 evaluated되면, this value는 object로 coerced되지 않습니다. undefined 또는 null인 this value는 global object로 converted되지 않으며 primitive values는 wrapper objects로 converted되지 않습니다. function call을 통해 passed된 this value(Function.prototype.apply 및 Function.prototype.call을 사용해 이루어진 calls 포함)는 passed this value를 object로 coerce하지 않습니다(10.2.1.2, 20.2.3.1, 20.2.3.3).
delete operator가 strict mode code 내에서 occurs할 때, 그 UnaryExpression이 variable, function argument, 또는 function name에 대한 direct reference이면 SyntaxError가 thrown됩니다(13.5.1.1).
delete operator가 strict mode code 내에서 occurs할 때, deleted될 property가 attribute { [[Configurable]]: false }를 가지거나 otherwise deleted될 수 없으면 TypeError가 thrown됩니다(13.5.1.2).
implementation은 function instances의 "caller" 또는 "arguments"라는 이름의 properties에 대해 strict functions 내의 meanings를 이 specification에서 defined된 것 이상으로 extend해서는 안 됩니다.
이 specification 내에 specified되지 않은 모든 exotic object에 대한 Table 4의 essential internal methods 중 임의의 것.
D.6 Built-in Objects and Methods
17.1에서 restricted된 경우를 제외하고, 이 specification 내에 defined되지 않은 모든 built-in objects와 methods.
Annex E (informative) Possible Compatibility Impact가 있는 ECMAScript 2015의 Corrections and Clarifications
9.1.1.4.14-9.1.1.4.17 Edition 5 및 5.1은 new global declaration에 corresponding하는 global object property가 already existed하는지를 determine하기 위해 property existence test를 사용했습니다. ECMAScript 2015는 own property existence test를 사용합니다. 이는 web browsers에서 가장 commonly implemented된 것과 corresponds합니다.
10.4.2.1: 5th Edition은 array index 또는 new length value의 integer conversion보다 current array length의 capture를 prior로 moved했습니다. 그러나 conversion process가 array length를 changing하는 side-effect를 가지면 captured length value가 invalid해질 수 있었습니다. ECMAScript 2015는 current array length가 그러한 side-effects의 possible occurrence 이후에 captured되어야 한다고 specifies합니다.
21.4.1.31: Previous editions는 TimeClip abstract operation이 0 time value의 representation으로 +0𝔽 또는 -0𝔽를 반환하는 것을 permitted했습니다. ECMAScript 2015는 +0𝔽가 always returned된다고 specifies합니다. 이는 ECMAScript 2015에서 Date의 time value가 never observably -0𝔽이고 time values를 반환하는 methods가 never -0𝔽를 반환하지 않음을 의미합니다.
21.4.1.32: UTC offset representation이 present하지 않으면 local time zone이 사용됩니다. Edition 5.1은 missing time zone이 "z"로 interpreted되어야 한다고 incorrectly stated했습니다.
21.4.4.36: year가 21.4.1.32에 specified된 Date Time String Format을 사용해 represented될 수 없으면 RangeError exception이 thrown됩니다. Previous editions는 그 case에 대한 behaviour를 specify하지 않았습니다.
21.4.4.41: Previous editions는 time value가 NaN일 때 Date.prototype.toString이 returned하는 value를 specify하지 않았습니다. ECMAScript 2015는 result를 String value "Invalid Date"로 specifies합니다.
22.2.4.1, 22.2.6.13.1: RegExp instance의 "source" property의 value 내 모든 LineTerminator code points는 escape sequence를 사용하여 expressed되어야 합니다. Edition 5.1은 /의 escaping만 required했습니다.
22.2.6.8, 22.2.6.11: previous editions에서 String.prototype.match와 String.prototype.replace에 대한 specifications는 pattern argument가 global flag가 set된 RegExp value인 cases에 대해 incorrect했습니다. previous specifications는 pattern을 match하려는 각 attempt에서 lastIndex가 change하지 않으면 1만큼 increment되어야 한다고 stated했습니다. correct behaviour는 pattern이 empty String을 matched한 경우에만 lastIndex가 1만큼 increment되어야 한다는 것입니다.
23.1.3.30: Previous editions는 comparator가 returned한 NaN value가 Array.prototype.sort에 의해 어떻게 interpreted되는지 specify하지 않았습니다. ECMAScript 2015는 그러한 value가 comparator로부터 +0𝔽가 returned된 것처럼 treated된다고 specifies합니다. ECMAScript 2015는 또한 comparator가 returned한 result에 ToNumber가 applied된다고 specifies합니다. previous editions에서는 Number value가 아닌 comparator result의 effect가 implementation-defined였습니다. 실제로 implementations는 ToNumber를 call합니다.
Annex F (informative) Prior Editions와 Incompatibilities를 Introduce하는 Additions and Changes
6.2.5: ECMAScript 2015에서 Function calls는 Reference Record를 return하는 것이 allowed되지 않습니다.
9.3: ECMAScript 2018에서 Template objects는 previous editions처럼 Realm 내의 해당 template literal 또는 tagged template의 모든 occurrences across가 아니라 Parse Node(source location)를 기반으로 canonicalized됩니다.
12.2: ECMAScript 2016에서는 ECMAScript 2015가 Unicode 5.1을 mandated한 것과 달리 Unicode 8.0.0 이상이 mandated됩니다. 특히 이는 ECMAScript 2015에서 Space_Separator (Zs) category에 있어 whitespace로 treated되었던 U+180E MONGOLIAN VOWEL SEPARATOR가 Unicode 6.3.0부터 Format (Cf) category로 moved되도록 했습니다. 이는 whitespace-sensitive methods가 differently behave하게 합니다. 예를 들어, "\u180E".trim().length는 previous editions에서는 0이었지만 ECMAScript 2016 이후에는 1입니다. Additionally, ECMAScript 2017은 항상 Unicode Standard의 latest version을 사용할 것을 mandated했습니다.
12.7: ECMAScript 2015에서 IdentifierName에 대한 valid code points는 Unicode properties “ID_Start” 및 “ID_Continue”의 terms로 specified됩니다. previous editions에서는 valid IdentifierName 또는 Identifier code points가 다양한 Unicode code point categories를 enumerating하여 specified되었습니다.
12.10.1: ECMAScript 2015에서 Automatic Semicolon Insertion은 do-while statement의 semicolon이 missing이면 그 end에 semicolon을 adds합니다. 이 change는 specification을 대부분의 existing implementations의 actual behaviour와 aligns합니다.
14.7: ECMAScript 2015 이전에는 initialization expression이 inkeyword를 precedes하는 VariableDeclaration의 일부로 appear할 수 있었습니다. ECMAScript 2015에서 같은 position의 ForBinding은 그러한 initializer의 occurrence를 allow하지 않습니다. ECMAScript 2017에서는 그러한 initializer가 non-strict code에서만 permitted됩니다.
14.15: ECMAScript 2015에서 Catch clause가 Catch clause parameter로 appears하는 동일한 Identifier에 대한 var declaration을 contain하는 것은 early error입니다. previous editions에서는 그러한 variable declaration이 enclosing variable environment에서 instantiated되었지만 declaration의 Initializer value는 Catch parameter에 assigned되었을 것입니다.
14.15, 19.2.1.3: ECMAScript 2015에서, Catch clause가 Catch clause parameter로 appears하는 동일한 Identifier를 binds하는 var 또는 FunctionDeclaration declaration을 포함하는 eval code를 가진 non-strict direct eval을 evaluates하면 runtime SyntaxError가 thrown됩니다.
21.4.4 ECMAScript 2015에서 Date prototype object는 Date instance가 아닙니다. previous editions에서는 TimeValue가 NaN인 Date instance였습니다.
22.1.3.12 ECMAScript 2015에서 String.prototype.localeCompare function은 Unicode Standard에 따라 canonically equivalent한 Strings를 identical한 것으로 treat해야 합니다. previous editions에서는 implementations가 canonical equivalence를 ignore하고 대신 bit-wise comparison을 사용할 수 있었습니다.
22.1.3.28 및 22.1.3.30 ECMAScript 2015에서 lowercase/upper conversion processing은 code points에 대해 operates합니다. previous editions에서는 such conversion processing이 individual code units에만 applied되었습니다. affected되는 유일한 code points는 Unicode의 Deseret block에 있는 것들입니다.
22.1.3.32 ECMAScript 2015에서 String.prototype.trim method는 Unicode BMP 밖에 존재할 수 있는 white space code points를 recognize하도록 defined됩니다. 그러나 Unicode 7 기준으로 그러한 code points는 defined되어 있지 않습니다. previous editions에서는 그러한 code points가 white space로 recognized되지 않았을 것입니다.
25.4.10: ECMAScript 2019에서 Atomics.wake는 Atomics.wait와의 confusion을 prevent하기 위해 Atomics.notify로 renamed되었습니다.
27.1.5.4, 27.9.3.6: ECMAScript 2019에서 await에 의해 enqueued되는 Jobs의 수가 reduced되었으며, 이는 then() call과 await expression 사이의 resolution order에 observable difference를 create할 수 있었습니다.
Bibliography
IEEE 754-2019: IEEE Standard for Floating-Point Arithmetic. Institute of Electrical and Electronic Engineers, New York (2019)
Note
이 specification은 GitHub에서 Ecmarkup이라는 plaintext source format으로 authored됩니다. Ecmarkup은 plaintext로 Ecma specifications를 authoring하고, 이 문서의 editorial conventions를 따르는 full-featured HTML rendering으로 specification을 processing하기 위한 framework와 toolset을 제공하는 HTML 및 Markdown dialect입니다. Ecmarkup은 syntax를 defining하기 위한 Grammarkdown 및 algorithm steps를 authoring하기 위한 Ecmarkdown을 포함한 여러 다른 formats와 technologies를 builds on하고 integrates합니다. 이 specification의 PDF renderings는 CSS Paged Media specification을 활용하는 print stylesheet를 사용하여 produced되며 PrinceXML을 사용해 converted됩니다.
이 specification의 prior editions는 Word를 사용하여 authored되었습니다. 이 edition의 basis를 formed한 Ecmarkup source text는 automated conversion tool을 사용하여 ECMAScript 2015 Word document를 Ecmarkup으로 converting하여 produced되었습니다.
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.
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.
Software License
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.