CINXE.COM
Infra Standard
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport"> <meta content="#3c790a" name="theme-color"> <meta content="light dark" name="color-scheme"> <title>Infra Standard</title> <link crossorigin href="https://resources.whatwg.org/standard-shared-with-dev.css" rel="stylesheet"> <link crossorigin href="https://resources.whatwg.org/standard.css" rel="stylesheet"> <link crossorigin href="https://resources.whatwg.org/spec.css" rel="stylesheet"> <link crossorigin href="https://resources.whatwg.org/logo-infra.svg" rel="icon"> <script crossorigin defer src="https://resources.whatwg.org/commit-snapshot-shortcut-key.js"></script> <meta content="Bikeshed version 742f3d674, updated Mon Nov 4 14:56:54 2024 -0800" name="generator"> <meta content="2e8f05adfdcd3fdd06c35458479e48285a4fb542" name="revision"> <style> /* Used for normative exemplars of how to write algorithms, as distinct from .example */ .exemplary-prose { margin-left: 2em; } </style> <style>/* Boilerplate: style-dfn-panel */ :root { --dfnpanel-bg: #ddd; --dfnpanel-text: var(--text); --dfnpanel-target-bg: #ffc; --dfnpanel-target-outline: orange; } @media (prefers-color-scheme: dark) { :root { --dfnpanel-bg: #222; --dfnpanel-text: var(--text); --dfnpanel-target-bg: #333; --dfnpanel-target-outline: silver; } } .dfn-panel { position: absolute; z-index: 35; width: 20em; width: 300px; height: auto; max-height: 500px; overflow: auto; padding: 0.5em 0.75em; font: small Helvetica Neue, sans-serif, Droid Sans Fallback; background: var(--dfnpanel-bg); color: var(--dfnpanel-text); border: outset 0.2em; white-space: normal; /* in case it's moved into a pre */ } .dfn-panel:not(.on) { display: none; } .dfn-panel * { margin: 0; padding: 0; text-indent: 0; } .dfn-panel > b { display: block; } .dfn-panel a { color: var(--dfnpanel-text); } .dfn-panel a:not(:hover) { text-decoration: none !important; border-bottom: none !important; } .dfn-panel a:focus { outline: 5px auto Highlight; outline: 5px auto -webkit-focus-ring-color; } .dfn-panel > b + b { margin-top: 0.25em; } .dfn-panel ul { padding: 0 0 0 1em; list-style: none; } .dfn-panel li a { max-width: calc(300px - 1.5em - 1em); overflow: hidden; text-overflow: ellipsis; } .dfn-panel.activated { display: inline-block; position: fixed; left: 8px; bottom: 2em; margin: 0 auto; max-width: calc(100vw - 1.5em - .4em - .5em); max-height: 30vh; transition: left 1s ease-out, bottom 1s ease-out; } .dfn-panel .link-item:hover { text-decoration: underline; } .dfn-panel .link-item .copy-icon { opacity: 0; } .dfn-panel .link-item:hover .copy-icon, .dfn-panel .link-item .copy-icon:focus { opacity: 1; } .dfn-panel .copy-icon { display: inline-block; margin-right: 0.5em; width: 0.85em; height: 1em; border-radius: 3px; background-color: #ccc; cursor: pointer; } .dfn-panel .copy-icon .icon { width: 100%; height: 100%; background-color: #fff; display: flex; justify-content: center; align-items: center; position: relative; } .dfn-panel .copy-icon .icon::before { content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 1px solid black; background-color: #ccc; opacity: 0.25; transform: translate(3px, -3px); } .dfn-panel .copy-icon:active .icon::before { opacity: 1; } .dfn-paneled[role="button"] { cursor: help; } .highlighted { animation: target-fade 3s; } @keyframes target-fade { from { background-color: var(--dfnpanel-target-bg); outline: 5px solid var(--dfnpanel-target-outline); } to { color: var(--a-normal-text); background-color: transparent; outline: transparent; } } </style> <style>/* Boilerplate: style-ref-hints */ :root { --ref-hint-bg: #ddd; --ref-hint-text: var(--text); } @media (prefers-color-scheme: dark) { :root { --ref-hint-bg: #222; --ref-hint-text: var(--text); } } .ref-hint { display: inline-block; position: absolute; z-index: 35; width: 20em; width: 300px; height: auto; max-height: 500px; overflow: auto; padding: 0.5em 0.5em; font: small Helvetica Neue, sans-serif, Droid Sans Fallback; background: var(--ref-hint-bg); color: var(--ref-hint-text); border: outset 0.2em; white-space: normal; /* in case it's moved into a pre */ } .ref-hint * { margin: 0; padding: 0; text-indent: 0; } .ref-hint ul { padding: 0 0 0 1em; list-style: none; } </style> <style>/* Boilerplate: style-var-click-highlighting */ /* Colors were chosen in Lab using https://nixsensor.com/free-color-converter/ D50 2deg illuminant, L in [0,100], a and b in [-128, 128] 0 = lab(85,0,85) 1 = lab(85,80,30) 2 = lab(85,-40,40) 3 = lab(85,-50,0) 4 = lab(85,5,15) 5 = lab(85,-10,-50) 6 = lab(85,35,-15) For darkmode: 0 = oklab(50% 0% 108%) 1 = oklab(50% -51% 51%) 2 = oklab(50% -64% -20%) 3 = oklab(50% 6% 19%) 4 = oklab(50% -12% -64%) 5 = oklab(50% 44% -19%) 6 = oklab(50% 102% 38%) */ [data-algorithm] var { cursor: pointer; } var[data-var-color] { background-color: var(--var-bg); box-shadow: 0 0 0 2px var(--var-bg); } var[data-var-color] { --var-bg: #F4D200; } var[data-var-color="1"] { --var-bg: #FF87A2; } var[data-var-color="2"] { --var-bg: #96E885; } var[data-var-color="3"] { --var-bg: #3EEED2; } var[data-var-color="4"] { --var-bg: #EACFB6; } var[data-var-color="5"] { --var-bg: #82DDFF; } var[data-var-color="6"] { --var-vg: #FFBCF2; } @media (prefers-color-scheme: dark) { var[data-var-color] { --var-bg: #bc1a00; } var[data-var-color="1"] { --var-bg: #007f00; } var[data-var-color="2"] { --var-bg: #008698; } var[data-var-color="3"] { --var-bg: #7f5b2b; } var[data-var-color="4"] { --var-bg: #004df3; } var[data-var-color="5"] { --var-bg: #a1248a; } var[data-var-color="6"] { --var-vg: #ff0000; } } </style> <body class="h-entry status-LS"> <div class="head"> <a class="logo" href="https://whatwg.org/"> <img alt="WHATWG" class="darkmode-aware" crossorigin height="100" src="https://resources.whatwg.org/logo-infra.svg"> </a> <hgroup> <h1 class="p-name no-ref" id="title">Infra</h1> <p id="subtitle">Living Standard — Last Updated <time class="dt-updated" datetime="2024-11-25">25 November 2024</time> </p> </hgroup> <div data-fill-with="spec-metadata"> <dl> <dt>Participate: <dd><a href="https://github.com/whatwg/infra">GitHub whatwg/infra</a> (<a href="https://github.com/whatwg/infra/issues/new/choose">new issue</a>, <a href="https://github.com/whatwg/infra/issues">open issues</a>) <dd><a href="https://whatwg.org/chat">Chat on Matrix</a> <dt>Commits: <dd><a href="https://github.com/whatwg/infra/commits">GitHub whatwg/infra/commits</a> <dd><a href="/commit-snapshots/2e8f05adfdcd3fdd06c35458479e48285a4fb542/" id="commit-snapshot-link">Snapshot as of this commit</a> <dd><a href="https://twitter.com/infrastandard">@infrastandard</a> <dt>Tests: <dd><a href="https://github.com/web-platform-tests/wpt/tree/master/infra">web-platform-tests infra/</a> (<a href="https://github.com/web-platform-tests/wpt/labels/infra">ongoing work</a>) <dt>Translations <small>(non-normative)</small>: <dd><span title="Japanese"><a href="https://triple-underscore.github.io/infra-ja.html" hreflang="ja" lang="ja" rel="alternate">日本語</a></span> </dl> </div> <div data-fill-with="warning"></div> </div> <div class="p-summary" data-fill-with="abstract"> <h2 class="no-num no-toc no-ref heading settled" id="abstract"><span class="content">Abstract</span></h2> <p>The Infra Standard aims to define the fundamental concepts upon which standards are built.</p> </div> <nav data-fill-with="table-of-contents" id="toc"> <h2 class="no-num no-toc no-ref" id="contents">Table of Contents</h2> <ol class="toc" role="directory"> <li><a href="#goals"><span class="secno"></span> <span class="content">Goals</span></a> <li><a href="#usage"><span class="secno">1</span> <span class="content">Usage</span></a> <li> <a href="#conventions"><span class="secno">2</span> <span class="content">Conventions</span></a> <ol class="toc"> <li><a href="#conformance"><span class="secno">2.1</span> <span class="content">Conformance</span></a> <li><a href="#other-specs"><span class="secno">2.2</span> <span class="content">Compliance with other specifications</span></a> <li><a href="#terminology"><span class="secno">2.3</span> <span class="content">Terminology</span></a> <li><a href="#privacy"><span class="secno">2.4</span> <span class="content">Privacy concerns</span></a> </ol> <li> <a href="#algorithms"><span class="secno">3</span> <span class="content">Algorithms</span></a> <ol class="toc"> <li><a href="#algorithm-conformance"><span class="secno">3.1</span> <span class="content">Conformance</span></a> <li><a href="#algorithm-limits"><span class="secno">3.2</span> <span class="content">Avoid limits on algorithm inputs</span></a> <li><a href="#algorithm-declaration"><span class="secno">3.3</span> <span class="content">Declaration</span></a> <li><a href="#algorithm-params"><span class="secno">3.4</span> <span class="content">Parameters</span></a> <li><a href="#variables"><span class="secno">3.5</span> <span class="content">Variables</span></a> <li><a href="#algorithm-control-flow"><span class="secno">3.6</span> <span class="content">Control flow</span></a> <li><a href="#algorithm-conditional-abort"><span class="secno">3.7</span> <span class="content">Conditional abort</span></a> <li><a href="#algorithm-conditional-statements"><span class="secno">3.8</span> <span class="content">Conditional statements</span></a> <li><a href="#algorithm-iteration"><span class="secno">3.9</span> <span class="content">Iteration</span></a> <li><a href="#assertions"><span class="secno">3.10</span> <span class="content">Assertions</span></a> </ol> <li> <a href="#primitive-data-types"><span class="secno">4</span> <span class="content">Primitive data types</span></a> <ol class="toc"> <li><a href="#nulls"><span class="secno">4.1</span> <span class="content">Nulls</span></a> <li><a href="#booleans"><span class="secno">4.2</span> <span class="content">Booleans</span></a> <li><a href="#numbers"><span class="secno">4.3</span> <span class="content">Numbers</span></a> <li><a href="#bytes"><span class="secno">4.4</span> <span class="content">Bytes</span></a> <li><a href="#byte-sequences"><span class="secno">4.5</span> <span class="content">Byte sequences</span></a> <li><a href="#code-points"><span class="secno">4.6</span> <span class="content">Code points</span></a> <li><a href="#strings"><span class="secno">4.7</span> <span class="content">Strings</span></a> <li><a href="#time"><span class="secno">4.8</span> <span class="content">Time</span></a> </ol> <li> <a href="#data-structures"><span class="secno">5</span> <span class="content">Data structures</span></a> <ol class="toc"> <li> <a href="#lists"><span class="secno">5.1</span> <span class="content">Lists</span></a> <ol class="toc"> <li><a href="#stacks"><span class="secno">5.1.1</span> <span class="content">Stacks</span></a> <li><a href="#queues"><span class="secno">5.1.2</span> <span class="content">Queues</span></a> <li><a href="#sets"><span class="secno">5.1.3</span> <span class="content">Sets</span></a> </ol> <li><a href="#maps"><span class="secno">5.2</span> <span class="content">Maps</span></a> <li> <a href="#structs"><span class="secno">5.3</span> <span class="content">Structs</span></a> <ol class="toc"> <li><a href="#tuples"><span class="secno">5.3.1</span> <span class="content">Tuples</span></a> </ol> </ol> <li><a href="#json"><span class="secno">6</span> <span class="content">JSON</span></a> <li><a href="#forgiving-base64"><span class="secno">7</span> <span class="content">Forgiving base64</span></a> <li><a href="#namespaces"><span class="secno">8</span> <span class="content">Namespaces</span></a> <li><a href="#acknowledgments"><span class="secno"></span> <span class="content">Acknowledgments</span></a> <li><a href="#ipr"><span class="secno"></span> <span class="content">Intellectual property rights</span></a> <li> <a href="#index"><span class="secno"></span> <span class="content">Index</span></a> <ol class="toc"> <li><a href="#index-defined-here"><span class="secno"></span> <span class="content">Terms defined by this specification</span></a> <li><a href="#index-defined-elsewhere"><span class="secno"></span> <span class="content">Terms defined by reference</span></a> </ol> <li> <a href="#references"><span class="secno"></span> <span class="content">References</span></a> <ol class="toc"> <li><a href="#normative"><span class="secno"></span> <span class="content">Normative References</span></a> <li><a href="#informative"><span class="secno"></span> <span class="content">Informative References</span></a> </ol> </ol> </nav> <main> <h2 class="no-num heading settled" id="goals"><span class="content">Goals</span></h2> <ul> <li> <p>Deduplicate boilerplate in standards. </p> <li> <p>Align standards on conventions, terminology, and data structures. </p> <li> <p>Be a place for concepts used by multiple standards without a good home. </p> <li> <p>Help write clear and readable algorithmic prose by clarifying otherwise ambiguous concepts. </p> </ul> <p>Suggestions for more goals welcome.</p> <h2 class="heading settled" data-level="1" id="usage"><span class="secno">1. </span><span class="content">Usage</span><a class="self-link" href="#usage"></a></h2> <p>To make use of this standard in a document titled <var>X</var>, use: </p> <p><samp><var>X</var> depends on <cite>Infra</cite>. <a data-link-type="biblio" href="#biblio-infra" title="Infra Standard">[Infra]</a></samp> </p> <p>Additionally, cross-referencing all terminology is strongly encouraged to avoid ambiguity. </p> <h2 class="heading settled" data-level="2" id="conventions"><span class="secno">2. </span><span class="content">Conventions</span><a class="self-link" href="#conventions"></a></h2> <h3 class="heading settled" data-level="2.1" id="conformance"><span class="secno">2.1. </span><span class="content">Conformance</span><a class="self-link" href="#conformance"></a></h3> <p>All assertions, diagrams, examples, and notes are non-normative, as are all sections explicitly marked non-normative. Everything else is normative. </p> <p>The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" are to be interpreted as described in RFC 2119. <a data-link-type="biblio" href="#biblio-rfc2119" title="Key words for use in RFCs to Indicate Requirement Levels">[RFC2119]</a> </p> <p>These keywords have equivalent meaning when written in lowercase and cannot appear in non-normative content. </p> <p class="note" role="note">This is a <a data-link-type="dfn" href="#willful-violation" id="ref-for-willful-violation">willful violation</a> of RFC 8174, motivated by legibility and a desire to preserve long-standing practice in many non-IETF-published pre-RFC 8174 documents. <a data-link-type="biblio" href="#biblio-rfc8174" title="Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words">[RFC8174]</a> </p> <p>All of the above is applicable to both this standard and any document that uses this standard. Documents using this standard are encouraged to limit themselves to "must", "must not", "should", and "may", and to use these in their lowercase form as that is generally considered to be more readable. </p> <p>For non-normative content "strongly encouraged", "strongly discouraged", "encouraged", "discouraged", "can", "cannot", "could", "could not", "might", and "might not" can be used instead. </p> <h3 class="heading settled" data-level="2.2" id="other-specs"><span class="secno">2.2. </span><span class="content">Compliance with other specifications</span><a class="self-link" href="#other-specs"></a></h3> <p>In general, specifications interact with and rely on a wide variety of other specifications. In certain circumstances, unfortunately, conflicting needs require a specification to violate the requirements of other specifications. When this occurs, a document using the Infra Standard should denote such transgressions as a <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="willful-violation">willful violation</dfn>, and note the reason for that violation. </p> <p class="example" id="example-willful-violation"><a class="self-link" href="#example-willful-violation"></a>The previous section, <a href="#conformance">§ 2.1 Conformance</a>, documents a <a data-link-type="dfn" href="#willful-violation" id="ref-for-willful-violation①">willful violation</a> of RFC 8174 committed by <cite>Infra</cite>. </p> <h3 class="heading settled" data-level="2.3" id="terminology"><span class="secno">2.3. </span><span class="content">Terminology</span><a class="self-link" href="#terminology"></a></h3> <p>The word "or", in cases where both inclusive "or" and exclusive "or" are possible (e.g., "if either width or height is zero"), means an inclusive "or" (implying "or both"), unless it is called out as being exclusive (with "but not both"). </p> <hr> <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="user-agent">user agent</dfn> is any software entity that acts on behalf of a user, for example by retrieving and rendering web content and facilitating end user interaction with it. In specifications using the Infra Standard, the user agent is generally an instance of the client software that implements the specification. The client software itself is known as an <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="implementation">implementation</dfn>. A person can use many different <a data-link-type="dfn" href="#user-agent" id="ref-for-user-agent">user agents</a> in their day-to-day life, including by configuring an <a data-link-type="dfn" href="#implementation" id="ref-for-implementation">implementation</a> to act as several <a data-link-type="dfn" href="#user-agent" id="ref-for-user-agent①">user agents</a> at once, for example by using multiple profiles or the implementation’s private browsing mode. </p> <p>If something is said to be <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="implementation-defined">implementation-defined</dfn>, the particulars of what is said to be <a data-link-type="dfn" href="#implementation-defined" id="ref-for-implementation-defined">implementation-defined</a> are up to the <a data-link-type="dfn" href="#implementation" id="ref-for-implementation①">implementation</a>. In the absence of such language, the reverse holds: <a data-link-type="dfn" href="#implementation" id="ref-for-implementation②">implementations</a> have to follow the rules laid out in documents using this standard. </p> <p class="example" id="example-implementation-defined"><a class="self-link" href="#example-implementation-defined"></a>Insert U+000A (LF) code points into <var>input</var> in an <a data-link-type="dfn" href="#implementation-defined" id="ref-for-implementation-defined①">implementation-defined</a> manner such that each resulting line has no more than <var>width</var> code points. For the purposes of this requirement, lines are delimited by the start of <var>input</var>, the end of <var>input</var>, and U+000A (LF). </p> <h3 class="heading settled" data-level="2.4" id="privacy"><span class="secno">2.4. </span><span class="content">Privacy concerns</span><a class="self-link" href="#privacy"></a></h3> <p>Some features that are defined in documents using the Infra Standard might trade user convenience for a measure of user privacy. </p> <p>In general, due to the internet’s architecture, a user can be distinguished from another by the user’s IP address. IP addresses do not perfectly match to a user; as a user moves from device to device, or from network to network, their IP address will change; similarly, NAT routing, proxy servers, and shared computers enable packets that appear to all come from a single IP address to actually map to multiple users. Technologies such as onion routing can be used to further anonymize requests so that requests from a single user at one node on the internet appear to come from many disparate parts of the network. <a data-link-type="biblio" href="#biblio-rfc791" title="Internet Protocol">[RFC791]</a> </p> <p>However, the IP address used for a user’s requests is not the only mechanism by which a user’s requests could be related to each other. Cookies, for example, are designed specifically to enable this, and are the basis of most of the web’s session features that enable you to log into a site with which you have an account. More generally, any kind of cache mechanism or shared state, including but not limited to HSTS, the HTTP cache, grouping of connections, storage APIs, can and ought to be expected to be abused. <a data-link-type="biblio" href="#biblio-cookies" title="HTTP State Management Mechanism">[COOKIES]</a> <a data-link-type="biblio" href="#biblio-rfc6797" title="HTTP Strict Transport Security (HSTS)">[RFC6797]</a> <a data-link-type="biblio" href="#biblio-storage" title="Storage Standard">[STORAGE]</a> </p> <p>There are other mechanisms that are more subtle. Certain characteristics of a user’s system can be used to distinguish groups of users from each other. By collecting enough such information, an individual user’s browser’s "digital fingerprint" can be computed, which can be better than an IP address in ascertaining which requests are from the same user. </p> <p>Grouping requests in this manner, especially across multiple sites, can be used for malevolent purposes, e.g., governments combining information such as the person’s home address (determined from the addresses they use when getting driving directions on one site) with their apparent political affiliations (determined by examining the forum sites that they participate in) to determine whether the person should be prevented from voting in an election. </p> <p>Since the malevolent purposes can be remarkably evil, user agent implementors and specification authors are strongly encouraged to minimize leaking information that could be used to fingerprint or track a user. </p> <p>Unfortunately, as the first paragraph in this section implies, sometimes there is great benefit to be derived from exposing APIs that can also be abused for fingerprinting and tracking purposes, so it’s not as easy as blocking all possible leaks. For instance, the ability to log into a site to post under a specific identity requires that the user’s requests be identifiable as all being from the same user, more or less by definition. More subtly, though, information such as how wide text is, which is necessary for many effects that involve drawing text onto a canvas (e.g., any effect that involves drawing a border around the text) also leaks information that can be used to group a user’s requests. (In this case, by potentially exposing, via a brute force search, which fonts a user has installed, information which can vary considerably from user to user.) </p> <p><a class="tracking-vector" href="https://infra.spec.whatwg.org/#tracking-vector" style="color: currentcolor"><img alt="(This is a tracking vector.)" class="darkmode-aware" crossorigin height="64" src="https://resources.whatwg.org/tracking-vector.svg" title="There is a tracking vector here." width="46"></a> Features that are defined in documents using the Infra Standard that can be used as a <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="tracking-vector">tracking vector</dfn> are marked as this paragraph is. </p> <p>Other features in the platform can be used for the same purpose, including, but not limited to: </p> <ul> <li>The exact list of which features a user agents supports. <li>The maximum allowed stack depth for recursion in script. <li>Features that describe the user’s environment. <li>The user’s time zone. <li>HTTP request headers. </ul> <h2 class="heading settled" data-level="3" id="algorithms"><span class="secno">3. </span><span class="content">Algorithms</span><a class="self-link" href="#algorithms"></a></h2> <h3 class="heading settled" data-level="3.1" id="algorithm-conformance"><span class="secno">3.1. </span><span class="content">Conformance</span><a class="self-link" href="#algorithm-conformance"></a></h3> <p>Algorithms, and requirements phrased in the imperative as part of algorithms (such as "strip any leading spaces" or "return false") are to be interpreted with the meaning of the keyword (e.g., "must") used in introducing the algorithm or step. If no such keyword is used, must is implied. </p> <div class="example" id="example-algorithms"> <a class="self-link" href="#example-algorithms"></a> <p>For example, were the spec to say:</p> <div class="exemplary-prose"> <p class="allow-2119">To <dfn data-var-ignore>eat an orange</dfn>, the user must: </p> <ol class="brief"> <li>Peel the orange. <li>Separate each slice of the orange. <li>Eat the orange slices. </ol> </div> <p>it would be equivalent to the following:</p> <div class="exemplary-prose"> <p>To <dfn data-var-ignore>eat an orange</dfn>: </p> <ol class="brief"> <li class="allow-2119">The user must peel the orange. <li class="allow-2119">The user must separate each slice of the orange. <li class="allow-2119">The user must eat the orange slices. </ol> </div> <p class="allow-2119">Here the key word is "must".</p> <p class="allow-2119">Modifying the above example, if the algorithm was introduced only with "To eat an orange:", it would still have the same meaning, as "must" is implied. </p> </div> <p>Conformance requirements phrased as algorithms or specific steps may be implemented in any manner, so long as the end result is equivalent. (In particular, the algorithms are intended to be easy to follow, and not intended to be performant.) </p> <p class="note" role="note">Performance is tricky to get correct as it is influenced by user perception, computer architectures, and different types of input that can change over time in how common they are. For instance, a JavaScript engine likely has many different code paths for what is standardized as a single algorithm, in order to optimize for speed or memory consumption. Standardizing all those code paths would be an insurmountable task and not productive as they would not stand the test of time as well as the single algorithm would. Therefore performance is best left as a field to compete over. </p> <h3 class="heading settled" data-level="3.2" id="algorithm-limits"><span class="secno">3.2. </span><span class="content">Avoid limits on algorithm inputs</span><a class="self-link" href="#algorithm-limits"></a></h3> <p>A document using the Infra Standard generally should not enforce specific limits on algorithm inputs with regards to their size, resource usage, or equivalent. This allows for competition among user agents and avoids constraining the potential computing needs of the future. </p> <p><a class="tracking-vector" href="https://infra.spec.whatwg.org/#tracking-vector" style="color: currentcolor"><img alt="(This is a tracking vector.)" class="darkmode-aware" crossorigin height="64" src="https://resources.whatwg.org/tracking-vector.svg" title="There is a tracking vector here." width="46"></a> Nevertheless, user agents may impose <a data-link-type="dfn" href="#implementation-defined" id="ref-for-implementation-defined②">implementation-defined</a> limits on otherwise unconstrained inputs. E.g., to prevent denial of service attacks, to guard against running out of memory, or to work around platform-specific limitations. </p> <p class="note" role="note">Global resource limits can be used as side channels through a variant on a resource exhaustion attack, whereby the attacker can observe whether a victim application reaches the global limit. Limits could also be used to fingerprint the user agent, but only if they make the user agent more unique in some manner, e.g., if they are specific to the underlying hardware. </p> <p class="example" id="example-algorithm-limits"><a class="self-link" href="#example-algorithm-limits"></a>An API that allows creating an in-memory bitmap might be specified to allow any dimensions, or any dimensions up to some large limit like JavaScript’s <code>Number.MAX_SAFE_INTEGER</code>. However, implementations can choose to impose some <a data-link-type="dfn" href="#implementation-defined" id="ref-for-implementation-defined③">implementation-defined</a> (and thus not specified) limit on the dimensions, instead of attempting to allocate huge amounts of memory. </p> <p class="example" id="example-algorithm-limits-language"><a class="self-link" href="#example-algorithm-limits-language"></a>A programming language might not have a maximum call stack size specified. However, implementations could choose to impose one for practical reasons. </p> <p>As code can end up depending on a particular limit, it can be useful to define a limit for interoperability. Sometimes, embracing that is not problematic for the future, and can make the code run in more user agents. </p> <p>It can also be useful to constrain an <a data-link-type="dfn" href="#implementation-defined" id="ref-for-implementation-defined④">implementation-defined</a> limit with a lower limit. I.e., ensuring all implementations can handle inputs of a given minimum size. </p> <h3 class="heading settled" data-level="3.3" id="algorithm-declaration"><span class="secno">3.3. </span><span class="content">Declaration</span><a class="self-link" href="#algorithm-declaration"></a></h3> <p>Algorithm names are usually verb phrases, but sometimes are given names that emphasize their standalone existence, so that standards and readers can refer to the algorithm more idiomatically. </p> <p class="example" id="example-algorithm-declaration-names"><a class="self-link" href="#example-algorithm-declaration-names"></a>Some algorithm names in the latter category include "attribute change steps", "internal module script graph fetching procedure", and "overload resolution algorithm". </p> <p>Declare algorithms by stating their name, parameters, and return type, in the following form: </p> <p class="exemplary-prose">To <dfn data-var-ignore>[algorithm name]</dfn>, given a [type1] <var>[parameter1]</var>, a [type2] <var>[parameter2]</var>, …, perform the following steps. They return a [return type].</p> <p>(For non-verb phrase algorithm names, use "To perform the <dfn data-var-ignore>[algorithm name]</dfn>…". See also <a href="#algorithm-params">§ 3.4 Parameters</a> for more complicated parameter-declaration forms.) </p> <p class="example" id="example-algorithm-declaration"><a class="self-link" href="#example-algorithm-declaration"></a>To <dfn data-var-ignore>parse an awesome format</dfn> given a <a data-link-type="dfn" href="#byte-sequence" id="ref-for-byte-sequence">byte sequence</a> <var>bytes</var>, perform the following steps. They return a <a data-link-type="dfn" href="#string" id="ref-for-string">string</a> or null. </p> <p>Algorithms which do not return a value use a shorter form. This same shorter form can be used even for algorithms that do return a value if the return type is relatively easy to infer from the algorithm steps: </p> <p class="exemplary-prose">To <dfn data-var-ignore>[algorithm name]</dfn>, given a [type1] <var>[parameter1]</var>, a [type2] <var>[parameter2]</var>, …:</p> <p class="example" id="example-algorithm-declaration-no-return"><a class="self-link" href="#example-algorithm-declaration-no-return"></a>To <dfn data-var-ignore>parse an awesome format</dfn> given a <a data-link-type="dfn" href="#byte-sequence" id="ref-for-byte-sequence①">byte sequence</a> <var>bytes</var>: </p> <p>Very short algorithms can be declared and specified using a single sentence: </p> <p class="example" id="example-algorithm-declaration-short"><a class="self-link" href="#example-algorithm-declaration-short"></a>To <dfn data-var-ignore>parse an awesome format</dfn> given a <a data-link-type="dfn" href="#byte-sequence" id="ref-for-byte-sequence②">byte sequence</a> <var>bytes</var>, return the result of <a data-link-type="dfn" href="#ascii-uppercase" id="ref-for-ascii-uppercase">ASCII uppercasing</a> the <a data-link-type="dfn" href="#isomorphic-decode" id="ref-for-isomorphic-decode">isomorphic decoding</a> of <var>bytes</var>. </p> <p>Types should be included in algorithm declarations, but may be omitted if the parameter name is clear enough, or if they are otherwise clear from context. (For example, because the algorithm is a simple wrapper around another one.) </p> <p class="example" id="example-algorithm-declaration-no-types"><a class="self-link" href="#example-algorithm-declaration-no-types"></a>To <dfn data-var-ignore>load a classic script</dfn> given <var>url</var>, return the result of performing the internal script-loading algorithm given <var>url</var> and "<code>classic</code>". </p> <h3 class="heading settled" data-level="3.4" id="algorithm-params"><span class="secno">3.4. </span><span class="content">Parameters</span><a class="self-link" href="#algorithm-params"></a></h3> <p>Algorithm parameters are usually listed sequentially, in the fashion described in <a href="#algorithm-declaration">§ 3.3 Declaration</a>. However, there are some more complicated cases.</p> <p>Algorithm parameters can be optional, in which case the algorithm declaration must list them as such, and list them after any non-optional parameters. They can either be given a default value, or the algorithm body can check whether or not the argument was given. Concretely, use the following forms: </p> <p class="exemplary-prose">… an optional [type] <var>[parameter]</var> … </p> <p class="exemplary-prose">… an optional [type] <var>[parameter]</var> (default [default value]) … </p> <p>Optional <a data-link-type="dfn" href="#boolean" id="ref-for-boolean">boolean</a> parameters must have a default value specified, and that default must be false. </p> <div class="example" id="example-algorithm-optional-positional-params"> <a class="self-link" href="#example-algorithm-optional-positional-params"></a> <p class="allow-2119">To <dfn data-var-ignore id="example-navigate-algo-positional">navigate</dfn> to a resource <var>resource</var>, with an optional string <var>navigationType</var> and an optional boolean <var>exceptionsEnabled</var> (default false): </p> <ol class="brief"> <li>… <li>If <var>navigationType</var> was given, then do something with <var>navigationType</var>. <li>… </ol> </div> <p>To call algorithms with such optional positional parameters, the optional argument values can be omitted, but only the trailing ones. </p> <div class="example" id="example-algorithm-optional-positional-params-calling"> <a class="self-link" href="#example-algorithm-optional-positional-params-calling"></a> <p>Call sites to the previous example’s algorithm would look like one of: </p> <ul class="brief"> <li><a href="#example-navigate-algo-positional">Navigate</a> to <var>resource</var>. <li><a href="#example-navigate-algo-positional">Navigate</a> to <var>resource</var> with "<code>form submission</code>". <li><a href="#example-navigate-algo-positional">Navigate</a> to <var>resource</var> with "<code>form submission</code>" and true. </ul> <p>But, there would be no way to supply a non-default value for the third (<var>exceptionsEnabled</var>) argument, while leaving the second (<var>navigationType</var>) argument as not-given. Additionally, the last of these calls is fairly unclear for readers, as the fact that "true" means "exceptions enabled" requires going back to the algorithm’s declaration and counting parameters. Read on for how to fix these issues! </p> </div> <p>Optional named parameters, instead of positional ones, can be used to increase clarity and flexibility at the call site. Such parameters are marked up as both variables and definitions, and linked to from their call sites. </p> <div class="example" id="example-algorithm-optional-named-params"> <a class="self-link" href="#example-algorithm-optional-named-params"></a> <p class="allow-2119">To <dfn data-var-ignore id="example-navigate-algo-named">navigate</dfn> to a resource <var>resource</var>, with an optional string <dfn data-var-ignore id="example-navigate-algo-navigationType"><var>navigationType</var></dfn> and an optional boolean <dfn data-var-ignore id="example-navigate-algo-exceptionsEnabled"><var>exceptionsEnabled</var></dfn> (default false): </p> <ol class="brief"> <li>… <li>If <var>navigationType</var> was given, then do something with <var>navigationType</var>. <li>… </ol> <p>Call sites would then look like one of: </p> <ul class="brief"> <li><a href="#example-navigate-algo-named">Navigate</a> to <var>resource</var>. <li><a href="#example-navigate-algo-named">Navigate</a> to <var>resource</var> with <a href="#example-navigate-algo-navigationType"><i>navigationType</i></a> set to "<code>form-submission</code>". <li><a href="#example-navigate-algo-named">Navigate</a> to <var>resource</var> with <a href="#example-navigate-algo-exceptionsEnabled"><i>exceptionsEnabled</i></a> set to true. <li><a href="#example-navigate-algo-named">Navigate</a> to <var>resource</var> with <a href="#example-navigate-algo-navigationType"><i>navigationType</i></a> set to "<code>form-submission</code>" and <a href="#example-navigate-algo-exceptionsEnabled"><i>exceptionsEnabled</i></a> set to true. </ul> </div> <p class="note" role="note">Note how within the algorithm steps, the argument value is not linked to the parameter declaration; it remains just a variable reference. Linking to the parameter declaration is done only at the call sites. </p> <p>Non-optional named parameters may also be used, using the same convention of marking them up as both variables and definitions, and linking to them from call sites. This can improve clarity at the call sites. </p> <p class="example allow-2119" id="example-algorithm-non-optional-named-params"><a class="self-link" href="#example-algorithm-non-optional-named-params"></a><a data-link-type="dfn" href="#boolean" id="ref-for-boolean①">Boolean</a> parameters are a case where naming the parameter can be significantly clearer than leaving it as positional, regardless of optionality. See <a href="https://ariya.io/2011/08/hall-of-api-shame-boolean-trap"><cite>The Pitfalls of Boolean Trap</cite></a> for discussion of this in the context of programming languages. </p> <p>Another complementary technique for improving clarity is to package up related values into a <a data-link-type="dfn" href="#struct" id="ref-for-struct">struct</a>, and pass that struct as a parameter. This is especially applicable when the same set of related values is used as the input to multiple algorithms. </p> <h3 class="heading settled" data-level="3.5" id="variables"><span class="secno">3.5. </span><span class="content">Variables</span><a class="self-link" href="#variables"></a></h3> <p>A variable is declared with "let" and changed with "set". </p> <p class="example" id="example-variable"><a class="self-link" href="#example-variable"></a>Let <var>list</var> be a new <a data-link-type="dfn" href="#list" id="ref-for-list">list</a>.</p> <div class="example" id="example-variable-null"> <a class="self-link" href="#example-variable-null"></a> <ol> <li> <p>Let <var>value</var> be null. </p> <li> <p>If <var>input</var> is a <a data-link-type="dfn" href="#string" id="ref-for-string①">string</a>, then set <var>value</var> to <var>input</var>. </p> <li> <p>Otherwise, set <var>value</var> to <var>input</var>, <a data-link-type="dfn" href="https://encoding.spec.whatwg.org/#utf-8-decode" id="ref-for-utf-8-decode">UTF-8 decoded</a>. </p> <li> <p><a data-link-type="dfn" href="#assert" id="ref-for-assert">Assert</a>: <var>value</var> is a <a data-link-type="dfn" href="#string" id="ref-for-string②">string</a>. </p> </ol> </div> <p class="example" id="example-variable-ternary"><a class="self-link" href="#example-variable-ternary"></a>Let <var>activationTarget</var> be <var>target</var> if <var>isActivationEvent</var> is true and <var>target</var> has activation behavior; otherwise null. </p> <p>Variables must not be used before they are declared. Variables are <a href="https://en.wikipedia.org/wiki/Scope_(computer_science)#Block_scope">block scoped</a>. Variables must not be declared more than once per algorithm. </p> <p>A multiple assignment syntax can be used to assign multiple variables to the <a data-link-type="dfn" href="#tuple" id="ref-for-tuple">tuple</a>’s <a data-link-type="dfn" href="#struct-item" id="ref-for-struct-item">items</a>, by surrounding the variable names with parenthesis and separating each variable name by a comma. The number of variables assigned cannot differ from the number of <a data-link-type="dfn" href="#struct-item" id="ref-for-struct-item①">items</a> in the <a data-link-type="dfn" href="#tuple" id="ref-for-tuple①">tuple</a>. </p> <div class="example" id="example-tuple-multiple-assignment"> <a class="self-link" href="#example-tuple-multiple-assignment"></a> <ol> <li> <p>Let <var>statusInstance</var> be the status (200, `<code>OK</code>`). </p> <li> <p>Let (<var>status</var>, <var>statusMessage</var>) be <var>statusInstance</var>. </p> </ol> <p>Assigning <var>status</var> and <var>statusMessage</var> could be written as two separate steps that use an index or <a data-link-type="dfn" href="#struct-name" id="ref-for-struct-name">name</a> to access the <a data-link-type="dfn" href="#tuple" id="ref-for-tuple②">tuple</a>’s <a data-link-type="dfn" href="#struct-item" id="ref-for-struct-item②">items</a>. </p> </div> <h3 class="heading settled" data-level="3.6" id="algorithm-control-flow"><span class="secno">3.6. </span><span class="content">Control flow</span><a class="self-link" href="#algorithm-control-flow"></a></h3> <p>The control flow of algorithms is such that a requirement to "return" or "throw" terminates the algorithm the statement was in. "Return" will hand the given value, if any, to its caller. "Throw" will make the caller automatically rethrow the given value, if any, and thereby terminate the caller’s algorithm. Using prose the caller has the ability to "catch" the exception and perform another action. </p> <h3 class="heading settled" data-level="3.7" id="algorithm-conditional-abort"><span class="secno">3.7. </span><span class="content">Conditional abort</span><a class="self-link" href="#algorithm-conditional-abort"></a></h3> <p>Sometimes it is useful to stop performing a series of steps once a condition becomes true. </p> <p>To do this, state that a given series of steps will <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="abort-when">abort when</dfn> a specific <var>condition</var> is reached. This indicates that the specified steps must be evaluated, not as-written, but by additionally inserting a step before each of them that evaluates <var>condition</var>, and if <var>condition</var> evaluates to true, skips the remaining steps. </p> <p>In such algorithms, the subsequent step can be annotated to run <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="if-aborted">if aborted</dfn>, in which case it must run if any of the preceding steps were skipped due to the <var>condition</var> of the preceding <a data-link-type="dfn" href="#abort-when" id="ref-for-abort-when">abort when</a> step evaluated to true. </p> <div class="example" id="example-conditional-abort"> <a class="self-link" href="#example-conditional-abort"></a> <p>The following algorithm </p> <ol> <li> <p>Let <var>result</var> be an empty <a data-link-type="dfn" href="#list" id="ref-for-list①">list</a>. </p> <li> <p>Run these steps, but <a data-link-type="dfn" href="#abort-when" id="ref-for-abort-when①">abort when</a> the user clicks the "Cancel" button: </p> <ol> <li> <p>Compute the first million digits of <var>π</var>, and <a data-link-type="dfn" href="#list-append" id="ref-for-list-append">append</a> the result to <var>result</var>. </p> <li> <p>Compute the first million digits of <var>e</var>, and <a data-link-type="dfn" href="#list-append" id="ref-for-list-append①">append</a> the result to <var>result</var>. </p> <li> <p>Compute the first million digits of <var>φ</var>, and <a data-link-type="dfn" href="#list-append" id="ref-for-list-append②">append</a> the result to <var>result</var>. </p> </ol> <li> <p><a data-link-type="dfn" href="#if-aborted" id="ref-for-if-aborted">If aborted</a>, <a data-link-type="dfn" href="#list-append" id="ref-for-list-append③">append</a> "<code>Didn’t finish!</code>" to <var>result</var>. </p> </ol> <p>is equivalent to the more verbose formulation</p> <ol> <li> <p>Let <var>result</var> be an empty <a data-link-type="dfn" href="#list" id="ref-for-list②">list</a>. </p> <li> <p>If the user has not clicked the "Cancel" button, then: </p> <ol> <li> <p>Compute the first million digits of <var>π</var>, and <a data-link-type="dfn" href="#list-append" id="ref-for-list-append④">append</a> the result to <var>result</var>. </p> <li> <p>If the user has not clicked the "Cancel" button, then: </p> <ol> <li> <p>Compute the first million digits of <var>e</var>, and <a data-link-type="dfn" href="#list-append" id="ref-for-list-append⑤">append</a> the result to <var>result</var>. </p> <li> <p>If the user has not clicked the "Cancel" button, then compute the first million digits of <var>φ</var>, and <a data-link-type="dfn" href="#list-append" id="ref-for-list-append⑥">append</a> the result to <var>result</var>. </p> </ol> </ol> <li> <p>If the user clicked the "Cancel" button, then <a data-link-type="dfn" href="#list-append" id="ref-for-list-append⑦">append</a> "<code>Didn’t finish!</code>" to <var>result</var>. </p> </ol> </div> <p class="note" role="note">Whenever this construct is used, implementations are allowed to evaluate <var>condition</var> during the specified steps rather than before and after each step, as long as the end result is indistinguishable. For instance, as long as <var>result</var> in the above example is not mutated during a compute operation, the user agent could stop the computation. </p> <h3 class="heading settled" data-level="3.8" id="algorithm-conditional-statements"><span class="secno">3.8. </span><span class="content">Conditional statements</span><a class="self-link" href="#algorithm-conditional-statements"></a></h3> <p>Algorithms with conditional statements should use the keywords "if", "then", and "otherwise". </p> <div class="example" id="example-conditional-statement"> <a class="self-link" href="#example-conditional-statement"></a> <ol> <li> <p>Let <var>value</var> be null. </p> <li> <p>If <var>input</var> is a <a data-link-type="dfn" href="#string" id="ref-for-string③">string</a>, then set <var>value</var> to <var>input</var>. </p> <li> <p>Return <var>value</var>. </p> </ol> </div> <p>Once the keyword "otherwise" is used, the keyword "then" is omitted.</p> <div class="example" id="example-conditional-statement-no-then-1"> <a class="self-link" href="#example-conditional-statement-no-then-1"></a> <ol> <li> <p>Let <var>value</var> be null. </p> <li> <p>If <var>input</var> is a <a data-link-type="dfn" href="#string" id="ref-for-string④">string</a>, then set <var>value</var> to <var>input</var>. </p> <li> <p>Otherwise, set <var>value</var> to failure. </p> <li> <p>Return <var>value</var>. </p> </ol> </div> <div class="example" id="example-conditional-statement-no-then-2"> <a class="self-link" href="#example-conditional-statement-no-then-2"></a> <ol> <li> <p>Let <var>value</var> be null. </p> <li> <p>If <var>input</var> is a <a data-link-type="dfn" href="#string" id="ref-for-string⑤">string</a>, then set <var>value</var> to <var>input</var>. </p> <li> <p>Otherwise, if <var>input</var> is a <a data-link-type="dfn" href="#list" id="ref-for-list③">list</a> of <a data-link-type="dfn" href="#string" id="ref-for-string⑥">strings</a>, set <var>value</var> to <var>input</var>[0]. </p> <li> <p>Otherwise, throw a <code class="idl"><a data-link-type="idl" href="https://webidl.spec.whatwg.org/#exceptiondef-typeerror" id="ref-for-exceptiondef-typeerror">TypeError</a></code>. </p> <li> <p>Return <var>value</var>. </p> </ol> </div> <h3 class="heading settled" data-level="3.9" id="algorithm-iteration"><span class="secno">3.9. </span><span class="content">Iteration</span><a class="self-link" href="#algorithm-iteration"></a></h3> <p>There’s a variety of ways to repeat a set of steps until a condition is reached. </p> <p class="note" role="note">The Infra Standard is not (yet) exhaustive on this; please file an issue if you need something. </p> <dl> <dt>For each <dd> <p>As defined for <a data-link-type="dfn" href="#list-iterate" id="ref-for-list-iterate">lists</a> (and derivatives) and <a data-link-type="dfn" href="#map-iterate" id="ref-for-map-iterate">maps</a>. </p> <dt><dfn class="dfn-paneled" data-dfn-for="iteration" data-dfn-type="dfn" data-export data-lt="while" id="iteration-while">While</dfn> <dd> <p>An instruction to repeat a set of steps as long as a condition is met. </p> <div class="example" id="example-while"> <a class="self-link" href="#example-while"></a> <p>While <var>condition</var> is "<code>met</code>": </p> <ol> <li> <p>… </p> </ol> </div> </dl> <p>An iteration’s flow can be controlled via requirements to <dfn class="dfn-paneled" data-dfn-for="iteration" data-dfn-type="dfn" data-export id="iteration-continue">continue</dfn> or <dfn class="dfn-paneled" data-dfn-for="iteration" data-dfn-type="dfn" data-export id="iteration-break">break</dfn>. <a data-link-type="dfn" href="#iteration-continue" id="ref-for-iteration-continue">Continue</a> will skip over any remaining steps in an iteration, proceeding to the next item. If no further items remain, the iteration will stop. <a data-link-type="dfn" href="#iteration-break" id="ref-for-iteration-break">Break</a> will skip over any remaining steps in an iteration, and skip over any remaining items as well, stopping the iteration. </p> <div class="example" id="example-break-continue"> <a class="self-link" href="#example-break-continue"></a> <p>Let <var>example</var> be the <a data-link-type="dfn" href="#list" id="ref-for-list④">list</a> « 1, 2, 3, 4 ». The following prose would perform <var>operation</var> upon 1, then 2, then 3, then 4: </p> <ol> <li> <p><a data-link-type="dfn" href="#list-iterate" id="ref-for-list-iterate①">For each</a> <var>item</var> of <var>example</var>: </p> <ol> <li>Perform <var>operation</var> on <var>item</var>. </ol> </ol> <p>The following prose would perform <var>operation</var> upon 1, then 2, then 4. 3 would be skipped. </p> <ol> <li> <p><a data-link-type="dfn" href="#list-iterate" id="ref-for-list-iterate②">For each</a> <var>item</var> of <var>example</var>: </p> <ol> <li>If <var>item</var> is 3, then <a data-link-type="dfn" href="#iteration-continue" id="ref-for-iteration-continue①">continue</a>. <li>Perform <var>operation</var> on <var>item</var>. </ol> </ol> <p>The following prose would perform <var>operation</var> upon 1, then 2. 3 and 4 would be skipped. </p> <ol> <li> <p><a data-link-type="dfn" href="#list-iterate" id="ref-for-list-iterate③">For each</a> <var>item</var> of <var>example</var>: </p> <ol> <li>If <var>item</var> is 3, then <a data-link-type="dfn" href="#iteration-break" id="ref-for-iteration-break①">break</a>. <li>Perform <var>operation</var> on <var>item</var>. </ol> </ol> </div> <h3 class="heading settled" data-level="3.10" id="assertions"><span class="secno">3.10. </span><span class="content">Assertions</span><a class="self-link" href="#assertions"></a></h3> <p>To improve readability, it can sometimes help to add assertions to algorithms, stating invariants. To do this, write "<dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="assert">Assert</dfn>:", followed by a statement that must be true. If the statement ends up being false that indicates an issue with the document using the Infra Standard that should be reported and addressed. </p> <p class="note" role="note">Since the statement can only ever be true, it has no implications for implementations. </p> <div class="example" id="example-assert"> <a class="self-link" href="#example-assert"></a> <ol> <li> <p>Let <var>x</var> be "<code>Aperture Science</code>". </p> <li> <p><a data-link-type="dfn" href="#assert" id="ref-for-assert①">Assert</a>: <var>x</var> is "<code>Aperture Science</code>". </p> </ol> </div> <h2 class="heading settled" data-level="4" id="primitive-data-types"><span class="secno">4. </span><span class="content">Primitive data types</span><a class="self-link" href="#primitive-data-types"></a></h2> <h3 class="heading settled" data-level="4.1" id="nulls"><span class="secno">4.1. </span><span class="content">Nulls</span><a class="self-link" href="#nulls"></a></h3> <p>The value null is used to indicate the lack of a value. It can be used interchangeably with the JavaScript <b>null</b> value. <a data-link-type="biblio" href="#biblio-ecma-262" title="ECMAScript Language Specification">[ECMA-262]</a> </p> <p class="example" id="example-null"><a class="self-link" href="#example-null"></a>Let <var>element</var> be null. </p> <p class="example" id="example-null-return"><a class="self-link" href="#example-null-return"></a>If <var>input</var> is the empty string, then return null. </p> <h3 class="heading settled" data-level="4.2" id="booleans"><span class="secno">4.2. </span><span class="content">Booleans</span><a class="self-link" href="#booleans"></a></h3> <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="boolean">boolean</dfn> is either true or false. </p> <p class="example" id="example-boolean"><a class="self-link" href="#example-boolean"></a>Let <var>elementSeen</var> be false. </p> <h3 class="heading settled" data-level="4.3" id="numbers"><span class="secno">4.3. </span><span class="content">Numbers</span><a class="self-link" href="#numbers"></a></h3> <p class="XXX">Numbers are complicated; please see <a href="https://github.com/whatwg/infra/issues/87">issue #87</a>. In due course we hope to offer more guidance here around types and mathematical operations. Help appreciated! </p> <hr> <p>An <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="8-bit-unsigned-integer">8-bit unsigned integer</dfn> is an integer in the range 0 to 255 (0 to 2<sup>8</sup> − 1), inclusive. </p> <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="16-bit-unsigned-integer">16-bit unsigned integer</dfn> is an integer in the range 0 to 65535 (0 to 2<sup>16</sup> − 1), inclusive. </p> <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="32-bit-unsigned-integer">32-bit unsigned integer</dfn> is an integer in the range 0 to 4294967295 (0 to 2<sup>32</sup> − 1), inclusive. </p> <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="64-bit-unsigned-integer">64-bit unsigned integer</dfn> is an integer in the range 0 to 18446744073709551615 (0 to 2<sup>64</sup> − 1), inclusive. </p> <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="128-bit-unsigned-integer">128-bit unsigned integer</dfn> is an integer in the range 0 to 340282366920938463463374607431768211455 (0 to 2<sup>128</sup> − 1), inclusive. </p> <p class="example" id="example-128-bit-unsigned-integer"><a class="self-link" href="#example-128-bit-unsigned-integer"></a>An IPv6 address is an <a data-link-type="dfn" href="#128-bit-unsigned-integer" id="ref-for-128-bit-unsigned-integer">128-bit unsigned integer</a>. </p> <hr> <p>An <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="8-bit-signed-integer">8-bit signed integer</dfn> is an integer in the range −128 to 127 (−2<sup>7</sup> to 2<sup>7</sup> − 1), inclusive. </p> <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="16-bit-signed-integer">16-bit signed integer</dfn> is an integer in the range −32768 to 32767 (−2<sup>15</sup> to 2<sup>15</sup> − 1), inclusive. </p> <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="32-bit-signed-integer">32-bit signed integer</dfn> is an integer in the range −2147483648 to 2147483647 (−2<sup>31</sup> to 2<sup>31</sup> − 1), inclusive. </p> <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="64-bit-signed-integer">64-bit signed integer</dfn> is an integer in the range −9223372036854775808 to 9223372036854775807 (−2<sup>63</sup> to 2<sup>63</sup> − 1), inclusive. </p> <h3 class="heading settled" data-level="4.4" id="bytes"><span class="secno">4.4. </span><span class="content">Bytes</span><a class="self-link" href="#bytes"></a></h3> <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="byte">byte</dfn> is a sequence of eight bits and is represented as "<code>0x</code>" followed by two <a data-link-type="dfn" href="#ascii-upper-hex-digit" id="ref-for-ascii-upper-hex-digit">ASCII upper hex digits</a>, in the range 0x00 to 0xFF, inclusive. A <a data-link-type="dfn" href="#byte" id="ref-for-byte">byte</a>’s <dfn class="dfn-paneled" data-dfn-for="byte" data-dfn-type="dfn" data-export id="byte-value">value</dfn> is its underlying number. </p> <p class="example" id="example-byte-value"><a class="self-link" href="#example-byte-value"></a>0x40 is a <a data-link-type="dfn" href="#byte" id="ref-for-byte①">byte</a> whose <a data-link-type="dfn" href="#byte-value" id="ref-for-byte-value">value</a> is 64. </p> <p>An <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="ascii-byte">ASCII byte</dfn> is a <a data-link-type="dfn" href="#byte" id="ref-for-byte②">byte</a> in the range 0x00 (NUL) to 0x7F (DEL), inclusive. As illustrated, an <a data-link-type="dfn" href="#ascii-byte" id="ref-for-ascii-byte">ASCII byte</a>, excluding 0x28 and 0x29, may be followed by the representation outlined in the <a href="https://tools.ietf.org/html/rfc20#section-2">Standard Code</a> section of <cite>ASCII format for Network Interchange</cite>, between parentheses. <a data-link-type="biblio" href="#biblio-rfc20" title="ASCII format for network interchange">[RFC20]</a> </p> <p>0x28 may be followed by "(left parenthesis)" and 0x29 by "(right parenthesis)". </p> <p class="example" id="example-byte-notation"><a class="self-link" href="#example-byte-notation"></a>0x49 (I) when <a data-link-type="dfn" href="https://encoding.spec.whatwg.org/#utf-8-decode" id="ref-for-utf-8-decode①">UTF-8 decoded</a> becomes the <a data-link-type="dfn" href="#code-point" id="ref-for-code-point">code point</a> U+0049 (I). </p> <h3 class="heading settled" data-level="4.5" id="byte-sequences"><span class="secno">4.5. </span><span class="content">Byte sequences</span><a class="self-link" href="#byte-sequences"></a></h3> <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="byte-sequence">byte sequence</dfn> is a sequence of <a data-link-type="dfn" href="#byte" id="ref-for-byte③">bytes</a>, represented as a space-separated sequence of bytes. Byte sequences with bytes in the range 0x20 (SP) to 0x7E (~), inclusive, can alternately be written as a string, but using backticks instead of quotation marks, to avoid confusion with an actual <a data-link-type="dfn" href="#string" id="ref-for-string⑦">string</a>. </p> <div class="example" id="example-byte-sequence-notation"> <a class="self-link" href="#example-byte-sequence-notation"></a> <p>0x48 0x49 can also be represented as `<code>HI</code>`. </p> <p>Headers, such as `<code>Content-Type</code>`, are <a data-link-type="dfn" href="#byte-sequence" id="ref-for-byte-sequence③">byte sequences</a>. </p> </div> <p class="note" role="note">To get a <a data-link-type="dfn" href="#byte-sequence" id="ref-for-byte-sequence④">byte sequence</a> out of a <a data-link-type="dfn" href="#string" id="ref-for-string⑧">string</a>, using <a data-link-type="dfn" href="https://encoding.spec.whatwg.org/#utf-8-encode" id="ref-for-utf-8-encode">UTF-8 encode</a> from <cite>Encoding</cite> is encouraged. In rare circumstances <a data-link-type="dfn" href="#isomorphic-encode" id="ref-for-isomorphic-encode">isomorphic encode</a> might be needed. <a data-link-type="biblio" href="#biblio-encoding" title="Encoding Standard">[ENCODING]</a> </p> <p>A <a data-link-type="dfn" href="#byte-sequence" id="ref-for-byte-sequence⑤">byte sequence</a>’s <dfn class="dfn-paneled" data-dfn-for="byte sequence" data-dfn-type="dfn" data-export id="byte-sequence-length">length</dfn> is the number of <a data-link-type="dfn" href="#byte" id="ref-for-byte④">bytes</a> it contains. </p> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="byte-lowercase">byte-lowercase</dfn> a <a data-link-type="dfn" href="#byte-sequence" id="ref-for-byte-sequence⑥">byte sequence</a>, increase each <a data-link-type="dfn" href="#byte" id="ref-for-byte⑤">byte</a> it contains, in the range 0x41 (A) to 0x5A (Z), inclusive, by 0x20. </p> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="byte-uppercase">byte-uppercase</dfn> a <a data-link-type="dfn" href="#byte-sequence" id="ref-for-byte-sequence⑦">byte sequence</a>, subtract each <a data-link-type="dfn" href="#byte" id="ref-for-byte⑥">byte</a> it contains, in the range 0x61 (a) to 0x7A (z), inclusive, by 0x20. </p> <p>A <a data-link-type="dfn" href="#byte-sequence" id="ref-for-byte-sequence⑧">byte sequence</a> <var>A</var> is a <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="byte-case-insensitive">byte-case-insensitive</dfn> match for a <a data-link-type="dfn" href="#byte-sequence" id="ref-for-byte-sequence⑨">byte sequence</a> <var>B</var>, if the <a data-link-type="dfn" href="#byte-lowercase" id="ref-for-byte-lowercase">byte-lowercase</a> of <var>A</var> is the <a data-link-type="dfn" href="#byte-lowercase" id="ref-for-byte-lowercase①">byte-lowercase</a> of <var>B</var>. </p> <hr> <p>A <a data-link-type="dfn" href="#byte-sequence" id="ref-for-byte-sequence①⓪">byte sequence</a> <var>potentialPrefix</var> is a <dfn class="dfn-paneled" data-dfn-for="byte sequence" data-dfn-type="dfn" data-export id="byte-sequence-prefix">prefix</dfn> of a <a data-link-type="dfn" href="#byte-sequence" id="ref-for-byte-sequence①①">byte sequence</a> <var>input</var> if the following steps return true: </p> <ol> <li> <p>Let <var>i</var> be 0. </p> <li> <p><a data-link-type="dfn" href="#iteration-while" id="ref-for-iteration-while">While</a> true: </p> <ol> <li> <p>If <var>i</var> is greater than or equal to <var>potentialPrefix</var>’s <a data-link-type="dfn" href="#byte-sequence-length" id="ref-for-byte-sequence-length">length</a>, then return true. </p> <li> <p>If <var>i</var> is greater than or equal to <var>input</var>’s <a data-link-type="dfn" href="#byte-sequence-length" id="ref-for-byte-sequence-length①">length</a>, then return false. </p> <li> <p>Let <var>potentialPrefixByte</var> be the <var>i</var>th <a data-link-type="dfn" href="#byte" id="ref-for-byte⑦">byte</a> of <var>potentialPrefix</var>. </p> <li> <p>Let <var>inputByte</var> be the <var>i</var>th <a data-link-type="dfn" href="#byte" id="ref-for-byte⑧">byte</a> of <var>input</var>. </p> <li> <p>Return false if <var>potentialPrefixByte</var> is not <var>inputByte</var>. </p> <li> <p>Set <var>i</var> to <var>i</var> + 1. </p> </ol> </ol> <p>"<var>input</var> <dfn class="dfn-paneled" data-dfn-for="byte sequence" data-dfn-type="dfn" data-export data-lt="starts with|start with" id="byte-sequence-starts-with">starts with</dfn> <var>potentialPrefix</var>" can be used as a synonym for "<var>potentialPrefix</var> is a <a data-link-type="dfn" href="#byte-sequence-prefix" id="ref-for-byte-sequence-prefix">prefix</a> of <var>input</var>". </p> <p>A <a data-link-type="dfn" href="#byte-sequence" id="ref-for-byte-sequence①②">byte sequence</a> <var>a</var> is <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="byte-less-than">byte less than</dfn> a <a data-link-type="dfn" href="#byte-sequence" id="ref-for-byte-sequence①③">byte sequence</a> <var>b</var> if the following steps return true: </p> <ol> <li> <p>If <var>b</var> is a <a data-link-type="dfn" href="#byte-sequence-prefix" id="ref-for-byte-sequence-prefix①">prefix</a> of <var>a</var>, then return false. </p> <li> <p>If <var>a</var> is a <a data-link-type="dfn" href="#byte-sequence-prefix" id="ref-for-byte-sequence-prefix②">prefix</a> of <var>b</var>, then return true. </p> <li> <p>Let <var>n</var> be the smallest index such that the <var>n</var>th <a data-link-type="dfn" href="#byte" id="ref-for-byte⑨">byte</a> of <var>a</var> is different from the <var>n</var>th byte of <var>b</var>. (There has to be such an index, since neither byte sequence is a prefix of the other.) </p> <li> <p>If the <var>n</var>th byte of <var>a</var> is less than the <var>n</var>th byte of <var>b</var>, then return true. </p> <li> <p>Return false. </p> </ol> <hr> <div class="algorithm" data-algorithm="isomorphic decode"> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="isomorphic-decode">isomorphic decode</dfn> a <a data-link-type="dfn" href="#byte-sequence" id="ref-for-byte-sequence①④">byte sequence</a> <var>input</var>, return a <a data-link-type="dfn" href="#string" id="ref-for-string⑨">string</a> whose <a data-link-type="dfn" href="#string-code-point-length" id="ref-for-string-code-point-length">code point length</a> is equal to <var>input</var>’s <a data-link-type="dfn" href="#byte-sequence-length" id="ref-for-byte-sequence-length②">length</a> and whose <a data-link-type="dfn" href="#code-point" id="ref-for-code-point①">code points</a> have the same <a data-link-type="dfn" href="#code-point-value" id="ref-for-code-point-value">values</a> as the <a data-link-type="dfn" href="#byte-value" id="ref-for-byte-value①">values</a> of <var>input</var>’s <a data-link-type="dfn" href="#byte" id="ref-for-byte①⓪">bytes</a>, in the same order. </p> </div> <h3 class="heading settled" data-level="4.6" id="code-points"><span class="secno">4.6. </span><span class="content">Code points</span><a class="self-link" href="#code-points"></a></h3> <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-lt="code point|character" id="code-point">code point</dfn> is a Unicode code point and is represented as "U+" followed by four-to-six <a data-link-type="dfn" href="#ascii-upper-hex-digit" id="ref-for-ascii-upper-hex-digit①">ASCII upper hex digits</a>, in the range U+0000 to U+10FFFF, inclusive. A <a data-link-type="dfn" href="#code-point" id="ref-for-code-point②">code point</a>’s <dfn class="dfn-paneled" data-dfn-for="code point" data-dfn-type="dfn" data-export id="code-point-value">value</dfn> is its underlying number. </p> <p>A <a data-link-type="dfn" href="#code-point" id="ref-for-code-point③">code point</a> may be followed by its name, by its rendered form between parentheses when it is not U+0028 or U+0029, or by both. Documents using the Infra Standard are encouraged to follow <a data-link-type="dfn" href="#code-point" id="ref-for-code-point④">code points</a> by their name when they cannot be rendered or are U+0028 or U+0029; otherwise, follow them by their rendered form between parentheses, for legibility. </p> <p>A <a data-link-type="dfn" href="#code-point" id="ref-for-code-point⑤">code point</a>’s name is defined in <cite>Unicode</cite> and represented in <a data-link-type="dfn" href="#ascii-uppercase" id="ref-for-ascii-uppercase①">ASCII uppercase</a>. <a data-link-type="biblio" href="#biblio-unicode" title="The Unicode Standard">[UNICODE]</a> </p> <div class="example" id="example-code-point-notation"> <a class="self-link" href="#example-code-point-notation"></a> <p>The <a data-link-type="dfn" href="#code-point" id="ref-for-code-point⑥">code point</a> rendered as 🤔 is represented as U+1F914. </p> <p>When referring to that <a data-link-type="dfn" href="#code-point" id="ref-for-code-point⑦">code point</a>, we might say "U+1F914 (🤔)", to provide extra context. Documents are allowed to use "U+1F914 THINKING FACE (🤔)" as well, though this is somewhat verbose. </p> </div> <p class="example" id="example-code-point-notation-hard-to-render"><a class="self-link" href="#example-code-point-notation-hard-to-render"></a><a data-link-type="dfn" href="#code-point" id="ref-for-code-point⑧">Code points</a> that are difficult to render unambigiously, such as U+000A, can be referred to as "U+000A LF". U+0029 can be referred to as "U+0029 RIGHT PARENTHESIS", because even though it renders, this avoids unmatched parentheses. </p> <p><a data-link-type="dfn" href="#code-point" id="ref-for-code-point⑨">Code points</a> are sometimes referred to as <a data-link-type="dfn" href="#code-point" id="ref-for-code-point①⓪">characters</a> and in certain contexts are prefixed with "0x" rather than "U+". </p> <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="leading-surrogate">leading surrogate</dfn> is a <a data-link-type="dfn" href="#code-point" id="ref-for-code-point①①">code point</a> that is in the range U+D800 to U+DBFF, inclusive. </p> <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="trailing-surrogate">trailing surrogate</dfn> is a <a data-link-type="dfn" href="#code-point" id="ref-for-code-point①②">code point</a> that is in the range U+DC00 to U+DFFF, inclusive. </p> <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="surrogate">surrogate</dfn> is a <a data-link-type="dfn" href="#leading-surrogate" id="ref-for-leading-surrogate">leading surrogate</a> or a <a data-link-type="dfn" href="#trailing-surrogate" id="ref-for-trailing-surrogate">trailing surrogate</a>. </p> <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="scalar-value">scalar value</dfn> is a <a data-link-type="dfn" href="#code-point" id="ref-for-code-point①③">code point</a> that is not a <a data-link-type="dfn" href="#surrogate" id="ref-for-surrogate">surrogate</a>. </p> <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="noncharacter">noncharacter</dfn> is a <a data-link-type="dfn" href="#code-point" id="ref-for-code-point①④">code point</a> that is in the range U+FDD0 to U+FDEF, inclusive, or U+FFFE, U+FFFF, U+1FFFE, U+1FFFF, U+2FFFE, U+2FFFF, U+3FFFE, U+3FFFF, U+4FFFE, U+4FFFF, U+5FFFE, U+5FFFF, U+6FFFE, U+6FFFF, U+7FFFE, U+7FFFF, U+8FFFE, U+8FFFF, U+9FFFE, U+9FFFF, U+AFFFE, U+AFFFF, U+BFFFE, U+BFFFF, U+CFFFE, U+CFFFF, U+DFFFE, U+DFFFF, U+EFFFE, U+EFFFF, U+FFFFE, U+FFFFF, U+10FFFE, or U+10FFFF. </p> <p>An <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="ascii-code-point">ASCII code point</dfn> is a <a data-link-type="dfn" href="#code-point" id="ref-for-code-point①⑤">code point</a> in the range U+0000 NULL to U+007F DELETE, inclusive. </p> <p>An <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-lt="ASCII tab or newline|ASCII tabs or newlines" id="ascii-tab-or-newline">ASCII tab or newline</dfn> is U+0009 TAB, U+000A LF, or U+000D CR. </p> <p><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="ascii-whitespace">ASCII whitespace</dfn> is U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, or U+0020 SPACE. </p> <p class="note" role="note">"Whitespace" is a mass noun. </p> <div class="note" role="note"> <p>The XML, JSON, and parts of the HTTP specifications exclude U+000C FF in their definition of whitespace: </p> <ul class="brief"> <li><a href="https://www.w3.org/TR/xml/#NT-S">XML’s S production</a> <li><a href="https://www.rfc-editor.org/rfc/rfc8259#section-2">JSON’s ws production</a> <li><a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#http-whitespace" id="ref-for-http-whitespace">HTTP whitespace</a> </ul> <p>Prefer using Infra’s <a data-link-type="dfn" href="#ascii-whitespace" id="ref-for-ascii-whitespace">ASCII whitespace</a> definition for new features, unless your specification deals exclusively with XML/JSON/HTTP. </p> </div> <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="c0-control">C0 control</dfn> is a <a data-link-type="dfn" href="#code-point" id="ref-for-code-point①⑥">code point</a> in the range U+0000 NULL to U+001F INFORMATION SEPARATOR ONE, inclusive. </p> <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-lt="C0 control or space|C0 controls or spaces" id="c0-control-or-space">C0 control or space</dfn> is a <a data-link-type="dfn" href="#c0-control" id="ref-for-c0-control">C0 control</a> or U+0020 SPACE. </p> <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="control">control</dfn> is a <a data-link-type="dfn" href="#c0-control" id="ref-for-c0-control①">C0 control</a> or a <a data-link-type="dfn" href="#code-point" id="ref-for-code-point①⑦">code point</a> in the range U+007F DELETE to U+009F APPLICATION PROGRAM COMMAND, inclusive. </p> <p>An <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="ascii-digit">ASCII digit</dfn> is a <a data-link-type="dfn" href="#code-point" id="ref-for-code-point①⑧">code point</a> in the range U+0030 (0) to U+0039 (9), inclusive. </p> <p>An <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="ascii-upper-hex-digit">ASCII upper hex digit</dfn> is an <a data-link-type="dfn" href="#ascii-digit" id="ref-for-ascii-digit">ASCII digit</a> or a <a data-link-type="dfn" href="#code-point" id="ref-for-code-point①⑨">code point</a> in the range U+0041 (A) to U+0046 (F), inclusive. </p> <p>An <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="ascii-lower-hex-digit">ASCII lower hex digit</dfn> is an <a data-link-type="dfn" href="#ascii-digit" id="ref-for-ascii-digit①">ASCII digit</a> or a <a data-link-type="dfn" href="#code-point" id="ref-for-code-point②⓪">code point</a> in the range U+0061 (a) to U+0066 (f), inclusive. </p> <p>An <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="ascii-hex-digit">ASCII hex digit</dfn> is an <a data-link-type="dfn" href="#ascii-upper-hex-digit" id="ref-for-ascii-upper-hex-digit②">ASCII upper hex digit</a> or <a data-link-type="dfn" href="#ascii-lower-hex-digit" id="ref-for-ascii-lower-hex-digit">ASCII lower hex digit</a>. </p> <p>An <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="ascii-upper-alpha">ASCII upper alpha</dfn> is a <a data-link-type="dfn" href="#code-point" id="ref-for-code-point②①">code point</a> in the range U+0041 (A) to U+005A (Z), inclusive. </p> <p>An <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="ascii-lower-alpha">ASCII lower alpha</dfn> is a <a data-link-type="dfn" href="#code-point" id="ref-for-code-point②②">code point</a> in the range U+0061 (a) to U+007A (z), inclusive. </p> <p>An <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="ascii-alpha">ASCII alpha</dfn> is an <a data-link-type="dfn" href="#ascii-upper-alpha" id="ref-for-ascii-upper-alpha">ASCII upper alpha</a> or <a data-link-type="dfn" href="#ascii-lower-alpha" id="ref-for-ascii-lower-alpha">ASCII lower alpha</a>. </p> <p>An <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="ascii-alphanumeric">ASCII alphanumeric</dfn> is an <a data-link-type="dfn" href="#ascii-digit" id="ref-for-ascii-digit②">ASCII digit</a> or <a data-link-type="dfn" href="#ascii-alpha" id="ref-for-ascii-alpha">ASCII alpha</a>. </p> <h3 class="heading settled" data-level="4.7" id="strings"><span class="secno">4.7. </span><span class="content">Strings</span><a class="self-link" href="#strings"></a></h3> <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-lt="string|JavaScript string" id="string">string</dfn> is a sequence of <a data-link-type="dfn" href="#16-bit-unsigned-integer" id="ref-for-16-bit-unsigned-integer">16-bit unsigned integers</a>, also known as <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-lt="code unit" id="code-unit">code units</dfn>. A <a data-link-type="dfn" href="#string" id="ref-for-string①⓪">string</a> is also known as a <a data-link-type="dfn" href="#string" id="javascript-string">JavaScript string</a>. <a data-link-type="dfn" href="#string" id="ref-for-string①①">Strings</a> are denoted by double quotes and monospace font. </p> <p class="example" id="example-string-notation"><a class="self-link" href="#example-string-notation"></a>"<code>Hello, world!</code>" is a string. </p> <p class="note" role="note">This is different from how <cite>Unicode</cite> defines "code unit". In particular it refers exclusively to how <cite>Unicode</cite> defines it for Unicode 16-bit strings. <a data-link-type="biblio" href="#biblio-unicode" title="The Unicode Standard">[UNICODE]</a> </p> <p>A <a data-link-type="dfn" href="#string" id="ref-for-string①②">string</a> can also be interpreted as containing <a data-link-type="dfn" href="#code-point" id="ref-for-code-point②③">code points</a>, per the conversion defined in <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-ecmascript-language-types-string-type" id="ref-for-sec-ecmascript-language-types-string-type">The String Type</a> section of the JavaScript specification. <a data-link-type="biblio" href="#biblio-ecma-262" title="ECMAScript Language Specification">[ECMA-262]</a> </p> <p class="note" role="note">This conversion process converts surrogate pairs into their corresponding <a data-link-type="dfn" href="#scalar-value" id="ref-for-scalar-value">scalar value</a> and maps any remaining surrogates to their corresponding <a data-link-type="dfn" href="#code-point" id="ref-for-code-point②④">code point</a>, leaving them effectively as-is. </p> <p class="example" id="example-javascript-string-in-code-points"><a class="self-link" href="#example-javascript-string-in-code-points"></a>A <a data-link-type="dfn" href="#string" id="ref-for-string①③">string</a> consisting of the <a data-link-type="dfn" href="#code-unit" id="ref-for-code-unit">code units</a> 0xD83D, 0xDCA9, and 0xD800, when interpreted as containing <a data-link-type="dfn" href="#code-point" id="ref-for-code-point②⑤">code points</a>, would consist of the <a data-link-type="dfn" href="#code-point" id="ref-for-code-point②⑥">code points</a> U+1F4A9 and U+D800. </p> <p>A <a data-link-type="dfn" href="#string" id="ref-for-string①④">string</a>’s <dfn class="dfn-paneled" data-dfn-for="string,JavaScript string,ASCII string,isomorphic string,scalar value string" data-dfn-type="dfn" data-export id="string-length">length<span id="javascript-string-length"></span></dfn> is the number of <a data-link-type="dfn" href="#code-unit" id="ref-for-code-unit①">code units</a> it contains. </p> <p>A <a data-link-type="dfn" href="#string" id="ref-for-string①⑤">string</a>’s <dfn class="dfn-paneled" data-dfn-for="string,JavaScript string,ASCII string,isomorphic string,scalar value string" data-dfn-type="dfn" data-export id="string-code-point-length">code point length</dfn> is the number of <a data-link-type="dfn" href="#code-point" id="ref-for-code-point②⑦">code points</a> it contains. </p> <hr> <p>To signify <a data-link-type="dfn" href="#string" id="ref-for-string①⑥">strings</a> with additional restrictions on the <a data-link-type="dfn" href="#code-point" id="ref-for-code-point②⑧">code points</a> they can contain this specification defines <a data-link-type="dfn" href="#ascii-string" id="ref-for-ascii-string">ASCII strings</a>, <a data-link-type="dfn" href="#isomorphic-string" id="ref-for-isomorphic-string">isomorphic strings</a>, and <a data-link-type="dfn" href="#scalar-value-string" id="ref-for-scalar-value-string">scalar value strings</a>. Using these improves clarity in specifications. </p> <p>An <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="ascii-string">ASCII string</dfn> is a <a data-link-type="dfn" href="#string" id="ref-for-string①⑦">string</a> whose <a data-link-type="dfn" href="#code-point" id="ref-for-code-point②⑨">code points</a> are all <a data-link-type="dfn" href="#ascii-code-point" id="ref-for-ascii-code-point">ASCII code points</a>. </p> <p>An <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="isomorphic-string">isomorphic string</dfn> is a <a data-link-type="dfn" href="#string" id="ref-for-string①⑧">string</a> whose <a data-link-type="dfn" href="#code-point" id="ref-for-code-point③⓪">code points</a> are all in the range U+0000 NULL to U+00FF (ÿ), inclusive. </p> <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="scalar-value-string">scalar value string</dfn> is a <a data-link-type="dfn" href="#string" id="ref-for-string①⑨">string</a> whose <a data-link-type="dfn" href="#code-point" id="ref-for-code-point③①">code points</a> are all <a data-link-type="dfn" href="#scalar-value" id="ref-for-scalar-value①">scalar values</a>. </p> <p class="note" role="note">A <a data-link-type="dfn" href="#scalar-value-string" id="ref-for-scalar-value-string①">scalar value string</a> is useful for any kind of I/O or other kind of operation where <a data-link-type="dfn" href="https://encoding.spec.whatwg.org/#utf-8-encode" id="ref-for-utf-8-encode①">UTF-8 encode</a> comes into play. </p> <hr> <p>To <dfn class="dfn-paneled" data-dfn-for="string,JavaScript string" data-dfn-type="dfn" data-export id="javascript-string-convert">convert</dfn> a <a data-link-type="dfn" href="#string" id="ref-for-string②⓪">string</a> into a <a data-link-type="dfn" href="#scalar-value-string" id="ref-for-scalar-value-string②">scalar value string</a>, replace any <a data-link-type="dfn" href="#surrogate" id="ref-for-surrogate①">surrogates</a> with U+FFFD (�). </p> <div class="note" role="note"> <p>The replaced surrogates are never part of surrogate pairs, since the process of interpreting the string as containing <a data-link-type="dfn" href="#code-point" id="ref-for-code-point③②">code points</a> will have converted surrogate pairs into <a data-link-type="dfn" href="#scalar-value" id="ref-for-scalar-value②">scalar values</a>. </p> <p>A <a data-link-type="dfn" href="#scalar-value-string" id="ref-for-scalar-value-string③">scalar value string</a> can always be used as a <a data-link-type="dfn" href="#string" id="ref-for-string②①">string</a> implicitly since every <a data-link-type="dfn" href="#scalar-value-string" id="ref-for-scalar-value-string④">scalar value string</a> is a <a data-link-type="dfn" href="#string" id="ref-for-string②②">string</a>. On the other hand, a <a data-link-type="dfn" href="#string" id="ref-for-string②③">string</a> can only be implicitly used as a <a data-link-type="dfn" href="#scalar-value-string" id="ref-for-scalar-value-string⑤">scalar value string</a> if it is known to not contain <a data-link-type="dfn" href="#surrogate" id="ref-for-surrogate②">surrogates</a>; otherwise a <a data-link-type="dfn" href="#javascript-string-convert" id="ref-for-javascript-string-convert">conversion</a> is to be performed. </p> <p>An implementation likely has to perform explicit conversion, depending on how it actually ends up representing <a data-link-type="dfn" href="#string" id="ref-for-string②④">strings</a> and <a data-link-type="dfn" href="#scalar-value-string" id="ref-for-scalar-value-string⑥">scalar value strings</a>. It is fairly typical for implementations to have multiple implementations of <a data-link-type="dfn" href="#string" id="ref-for-string②⑤">strings</a> alone for performance and memory reasons. </p> </div> <hr> <p>A <a data-link-type="dfn" href="#string" id="ref-for-string②⑥">string</a> <var>a</var> <dfn class="dfn-paneled" data-dfn-for="string" data-dfn-type="dfn" data-export data-lt="is|identical to" id="string-is">is</dfn> or is <a data-link-type="dfn" href="#string-is" id="ref-for-string-is">identical to</a> a <a data-link-type="dfn" href="#string" id="ref-for-string②⑦">string</a> <var>b</var> if it consists of the same sequence of <a data-link-type="dfn" href="#code-unit" id="ref-for-code-unit②">code units</a>. </p> <p>Except where otherwise stated, all string comparisons use <a data-link-type="dfn" href="#string-is" id="ref-for-string-is①">is</a>. </p> <p class="note" role="note">This type of <a data-link-type="dfn" href="#string" id="ref-for-string②⑧">string</a> comparison was formerly known as a "case-sensitive" comparison in <cite>HTML</cite>. Strings that compare as <a data-link-type="dfn" href="#string-is" id="ref-for-string-is②">identical to</a> one another are not only sensitive to case variation (such as UPPER and lower case), but also to other code point encoding choices, such as normalization form or the order of combining marks. Two strings that are visually or even canonically equivalent according to <cite>Unicode</cite> might still not be <a data-link-type="dfn" href="#string-is" id="ref-for-string-is③">identical to</a> each other. <a data-link-type="biblio" href="#biblio-html" title="HTML Standard">[HTML]</a> <a data-link-type="biblio" href="#biblio-unicode" title="The Unicode Standard">[UNICODE]</a> </p> <p>A <a data-link-type="dfn" href="#string" id="ref-for-string②⑨">string</a> <var>potentialPrefix</var> is a <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="code-unit-prefix">code unit prefix</dfn> of a <a data-link-type="dfn" href="#string" id="ref-for-string③⓪">string</a> <var>input</var> if the following steps return true: </p> <ol> <li> <p>Let <var>i</var> be 0. </p> <li> <p><a data-link-type="dfn" href="#iteration-while" id="ref-for-iteration-while①">While</a> true: </p> <ol> <li> <p>If <var>i</var> is greater than or equal to <var>potentialPrefix</var>’s <a data-link-type="dfn" href="#string-length" id="ref-for-string-length">length</a>, then return true. </p> <li> <p>If <var>i</var> is greater than or equal to <var>input</var>’s <a data-link-type="dfn" href="#string-length" id="ref-for-string-length①">length</a>, then return false. </p> <li> <p>Let <var>potentialPrefixCodeUnit</var> be the <var>i</var>th <a data-link-type="dfn" href="#code-unit" id="ref-for-code-unit③">code unit</a> of <var>potentialPrefix</var>. </p> <li> <p>Let <var>inputCodeUnit</var> be the <var>i</var>th <a data-link-type="dfn" href="#code-unit" id="ref-for-code-unit④">code unit</a> of <var>input</var>. </p> <li> <p>Return false if <var>potentialPrefixCodeUnit</var> is not <var>inputCodeUnit</var>. </p> <li> <p>Set <var>i</var> to <var>i</var> + 1. </p> </ol> </ol> <p>When it is clear from context that <a data-link-type="dfn" href="#code-unit" id="ref-for-code-unit⑤">code units</a> are in play, e.g., because one of the strings is a literal containing only characters that are in the range U+0020 SPACE to U+007E (~), "<var>input</var> <dfn class="dfn-paneled" data-dfn-for="string" data-dfn-type="dfn" data-export id="string-starts-with">starts with</dfn> <var>potentialPrefix</var>" can be used as a synonym for "<var>potentialPrefix</var> is a <a data-link-type="dfn" href="#code-unit-prefix" id="ref-for-code-unit-prefix">code unit prefix</a> of <var>input</var>". </p> <p class="example" id="code-unit-prefix-example"><a class="self-link" href="#code-unit-prefix-example"></a>With unknown values, it is good to be explicit: <var>targetString</var> is a <a data-link-type="dfn" href="#code-unit-prefix" id="ref-for-code-unit-prefix①">code unit prefix</a> of <var>userInput</var>. But with a literal, we can use plainer language: <var>userInput</var> <a data-link-type="dfn" href="#string-starts-with" id="ref-for-string-starts-with">starts with</a> "<code>!</code>". </p> <p>A <a data-link-type="dfn" href="#string" id="ref-for-string③①">string</a> <var>potentialSuffix</var> is a <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="code-unit-suffix">code unit suffix</dfn> of a <a data-link-type="dfn" href="#string" id="ref-for-string③②">string</a> <var>input</var> if the following steps return true: </p> <ol> <li> <p>Let <var>i</var> be 1. </p> <li> <p><a data-link-type="dfn" href="#iteration-while" id="ref-for-iteration-while②">While</a> true: </p> <ol> <li> <p>Let <var>potentialSuffixIndex</var> be <var>potentialSuffix</var>’s <a data-link-type="dfn" href="#string-length" id="ref-for-string-length②">length</a> − <var>i</var>. </p> <li> <p>Let <var>inputIndex</var> be <var>input</var>’s <a data-link-type="dfn" href="#string-length" id="ref-for-string-length③">length</a> − <var>i</var>. </p> <li> <p>If <var>potentialSuffixIndex</var> is less than 0, then return true. </p> <li> <p>If <var>inputIndex</var> is less than 0, then return false. </p> <li> <p>Let <var>potentialSuffixCodeUnit</var> be the <var>potentialSuffixIndex</var>th <a data-link-type="dfn" href="#code-unit" id="ref-for-code-unit⑥">code unit</a> of <var>potentialSuffix</var>. </p> <li> <p>Let <var>inputCodeUnit</var> be the <var>inputIndex</var>th <a data-link-type="dfn" href="#code-unit" id="ref-for-code-unit⑦">code unit</a> of <var>input</var>. </p> <li> <p>Return false if <var>potentialSuffixCodeUnit</var> is not <var>inputCodeUnit</var>. </p> <li> <p>Set <var>i</var> to <var>i</var> + 1. </p> </ol> </ol> <p>When it is clear from context that <a data-link-type="dfn" href="#code-unit" id="ref-for-code-unit⑧">code units</a> are in play, e.g., because one of the strings is a literal containing only characters that are in the range U+0020 SPACE to U+007E (~), "<var>input</var> <dfn class="dfn-paneled" data-dfn-for="string" data-dfn-type="dfn" data-export id="string-ends-with">ends with</dfn> <var>potentialSuffix</var>" can be used as a synonym for "<var>potentialSuffix</var> is a <a data-link-type="dfn" href="#code-unit-suffix" id="ref-for-code-unit-suffix">code unit suffix</a> of <var>input</var>". </p> <p class="example" id="code-unit-suffix-example"><a class="self-link" href="#code-unit-suffix-example"></a>With unknown values, it is good to be explicit: <var>targetString</var> is a <a data-link-type="dfn" href="#code-unit-suffix" id="ref-for-code-unit-suffix①">code unit suffix</a> of <var>domain</var>. But with a literal, we can use plainer language: <var>domain</var> <a data-link-type="dfn" href="#string-ends-with" id="ref-for-string-ends-with">ends with</a> "<code>.</code>". </p> <hr> <p>A <a data-link-type="dfn" href="#string" id="ref-for-string③③">string</a> <var>a</var> is <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="code-unit-less-than">code unit less than</dfn> a <a data-link-type="dfn" href="#string" id="ref-for-string③④">string</a> <var>b</var> if the following steps return true: </p> <ol> <li> <p>If <var>b</var> is a <a data-link-type="dfn" href="#code-unit-prefix" id="ref-for-code-unit-prefix②">code unit prefix</a> of <var>a</var>, then return false. </p> <li> <p>If <var>a</var> is a <a data-link-type="dfn" href="#code-unit-prefix" id="ref-for-code-unit-prefix③">code unit prefix</a> of <var>b</var>, then return true. </p> <li> <p>Let <var>n</var> be the smallest index such that the <var>n</var>th <a data-link-type="dfn" href="#code-unit" id="ref-for-code-unit⑨">code unit</a> of <var>a</var> is different from the <var>n</var>th code unit of <var>b</var>. (There has to be such an index, since neither string is a prefix of the other.) </p> <li> <p>If the <var>n</var>th code unit of <var>a</var> is less than the <var>n</var>th code unit of <var>b</var>, then return true. </p> <li> <p>Return false. </p> </ol> <p class="note" role="note">This matches the ordering used by JavaScript’s <code><</code> operator, and its <code class="idl"><a data-link-type="idl" href="https://tc39.github.io/ecma262/#sec-array.prototype.sort" id="ref-for-sec-array.prototype.sort">sort()</a></code> method on an array of strings. This ordering compares the 16-bit code units in each string, producing a highly efficient, consistent, and deterministic sort order. The resulting ordering will not match any particular alphabet or lexicographic order, particularly for <a data-link-type="dfn" href="#code-point" id="ref-for-code-point③③">code points</a> represented by a surrogate pair. <a data-link-type="biblio" href="#biblio-ecma-262" title="ECMAScript Language Specification">[ECMA-262]</a> </p> <p class="example" id="example-code-unit-less-than"><a class="self-link" href="#example-code-unit-less-than"></a>For example, the code point U+FF5E FULLWIDTH TILDE (~) is obviously less than the code point U+1F600 (😀), but the tilde is composed of a single code unit 0xFF5E, while the smiley is composed of two code units 0xD83D and 0XDE00, so the smiley is <a data-link-type="dfn" href="#code-unit-less-than" id="ref-for-code-unit-less-than">code unit less than</a> the tilde. </p> <hr> <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="code-unit-substring">code unit substring</dfn> from <var>start</var> with length <var>length</var> within a <a data-link-type="dfn" href="#string" id="ref-for-string③⑤">string</a> <var>string</var> is determined as follows: </p> <ol> <li> <p><a data-link-type="dfn" href="#assert" id="ref-for-assert②">Assert</a>: <var>start</var> and <var>length</var> are nonnegative.</p> <li> <p><a data-link-type="dfn" href="#assert" id="ref-for-assert③">Assert</a>: <var>start</var> + <var>length</var> is less than or equal to <var>string</var>’s <a data-link-type="dfn" href="#string-length" id="ref-for-string-length④">length</a>.</p> <li> <p>Let <var>result</var> be the empty string.</p> <li> <p><a data-link-type="dfn" href="#list-iterate" id="ref-for-list-iterate④">For each</a> <var>i</var> in <a data-link-type="dfn" href="#the-exclusive-range" id="ref-for-the-exclusive-range">the range</a> from <var>start</var> to <var>start</var> + <var>length</var>, exclusive: append the <var>i</var>th <a data-link-type="dfn" href="#code-unit" id="ref-for-code-unit①⓪">code unit</a> of <var>string</var> to <var>result</var>.</p> <li> <p>Return <var>result</var>.</p> </ol> <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-lt="code unit substring by positions" id="code-unit-substring-by-positions">code unit substring</dfn> from <var>start</var> to <var>end</var> within a <a data-link-type="dfn" href="#string" id="ref-for-string③⑥">string</a> <var>string</var> is the <a data-link-type="dfn" href="#code-unit-substring" id="ref-for-code-unit-substring">code unit substring</a> from <var>start</var> with length <var>end</var> − <var>start</var> within <var>string</var>. </p> <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-lt="code unit substring to the end of the string" id="code-unit-substring-to-the-end-of-the-string">code unit substring</dfn> from <var>start</var> to the end of a <a data-link-type="dfn" href="#string" id="ref-for-string③⑦">string</a> <var>string</var> is the <a data-link-type="dfn" href="#code-unit-substring-by-positions" id="ref-for-code-unit-substring-by-positions">code unit substring</a> from <var>start</var> to <var>string</var>’s <a data-link-type="dfn" href="#string-length" id="ref-for-string-length⑤">length</a> within <var>string</var>. </p> <p class="example" id="example-code-unit-substring"><a class="self-link" href="#example-code-unit-substring"></a>The <a data-link-type="dfn" href="#code-unit-substring" id="ref-for-code-unit-substring①">code unit substring</a> from 1 with length 3 within "<code>Hello world</code>" is "<code>ell</code>". This can also be expressed as the <a data-link-type="dfn" href="#code-unit-substring-by-positions" id="ref-for-code-unit-substring-by-positions①">code unit substring</a> from 1 to 4. </p> <p class="note" role="note">The numbers given to these algorithms are best thought of as positions <em>between</em> <a data-link-type="dfn" href="#code-unit" id="ref-for-code-unit①①">code units</a>, not indices of the code units themselves. The substring returned is then formed by the code units between these positions. That explains why, for example, the <a data-link-type="dfn" href="#code-unit-substring-by-positions" id="ref-for-code-unit-substring-by-positions②">code unit substring</a> from 0 to 0 within the empty string is the empty string, even though there is no code unit at index 0 within the empty string. </p> <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="code-point-substring">code point substring</dfn> within a <a data-link-type="dfn" href="#string" id="ref-for-string③⑧">string</a> <var>string</var> from <var>start</var> with length <var>length</var> is determined as follows: </p> <ol> <li> <p><a data-link-type="dfn" href="#assert" id="ref-for-assert④">Assert</a>: <var>start</var> and <var>length</var> are nonnegative.</p> <li> <p><a data-link-type="dfn" href="#assert" id="ref-for-assert⑤">Assert</a>: <var>start</var> + <var>length</var> is less than or equal to <var>string</var>’s <a data-link-type="dfn" href="#string-code-point-length" id="ref-for-string-code-point-length①">code point length</a>.</p> <li> <p>Let <var>result</var> be the empty string.</p> <li> <p><a data-link-type="dfn" href="#list-iterate" id="ref-for-list-iterate⑤">For each</a> <var>i</var> in <a data-link-type="dfn" href="#the-exclusive-range" id="ref-for-the-exclusive-range①">the range</a> from <var>start</var> to <var>start</var> + <var>length</var>, exclusive: append the <var>i</var>th <a data-link-type="dfn" href="#code-point" id="ref-for-code-point③④">code point</a> of <var>string</var> to <var>result</var>.</p> <li> <p>Return <var>result</var>.</p> </ol> <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-lt="code point substring by positions" id="code-point-substring-by-positions">code point substring</dfn> from <var>start</var> to <var>end</var> within a <a data-link-type="dfn" href="#string" id="ref-for-string③⑨">string</a> <var>string</var> is the <a data-link-type="dfn" href="#code-point-substring" id="ref-for-code-point-substring">code point substring</a> within <var>string</var> from <var>start</var> with length <var>end</var> − <var>start</var>. </p> <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-lt="code point substring to the end of the string" id="code-point-substring-to-the-end-of-the-string">code point substring</dfn> from <var>start</var> to the end of a <a data-link-type="dfn" href="#string" id="ref-for-string④⓪">string</a> <var>string</var> is the <a data-link-type="dfn" href="#code-point-substring-by-positions" id="ref-for-code-point-substring-by-positions">code point substring</a> from <var>start</var> to <var>string</var>’s <a data-link-type="dfn" href="#string-code-point-length" id="ref-for-string-code-point-length②">code point length</a> within <var>string</var>. </p> <div class="example" id="example-code-unit-vs-point-substring"> <a class="self-link" href="#example-code-unit-vs-point-substring"></a> <p>Generally, <a data-link-type="dfn" href="#code-unit-substring" id="ref-for-code-unit-substring②">code unit substring</a> is used when given developer-supplied positions or lengths, since that is how string indexing works in JavaScript. See, for example, the methods of the <code class="idl"><a data-link-type="idl" href="https://dom.spec.whatwg.org/#characterdata" id="ref-for-characterdata">CharacterData</a></code> class. <a data-link-type="biblio" href="#biblio-dom" title="DOM Standard">[DOM]</a> </p> <p>Otherwise, <a data-link-type="dfn" href="#code-point-substring" id="ref-for-code-point-substring①">code point substring</a> is likely to be better. For example, the <a data-link-type="dfn" href="#code-point-substring" id="ref-for-code-point-substring②">code point substring</a> from 0 with length 1 within "<code>👽</code>" is "<code>👽</code>", whereas the <a data-link-type="dfn" href="#code-unit-substring" id="ref-for-code-unit-substring③">code unit substring</a> from 0 with length 1 within "<code>👽</code>" is the <a data-link-type="dfn" href="#string" id="ref-for-string④①">string</a> containing the single <a data-link-type="dfn" href="#surrogate" id="ref-for-surrogate③">surrogate</a> U+D83B. </p> </div> <hr> <div class="algorithm" data-algorithm="isomorphic encode"> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="isomorphic-encode">isomorphic encode</dfn> an <a data-link-type="dfn" href="#isomorphic-string" id="ref-for-isomorphic-string①">isomorphic string</a> <var>input</var>: return a <a data-link-type="dfn" href="#byte-sequence" id="ref-for-byte-sequence①⑤">byte sequence</a> whose <a data-link-type="dfn" href="#byte-sequence-length" id="ref-for-byte-sequence-length③">length</a> is equal to <var>input</var>’s <a data-link-type="dfn" href="#string-code-point-length" id="ref-for-string-code-point-length③">code point length</a> and whose <a data-link-type="dfn" href="#byte" id="ref-for-byte①①">bytes</a> have the same <a data-link-type="dfn" href="#byte-value" id="ref-for-byte-value②">values</a> as the <a data-link-type="dfn" href="#code-point-value" id="ref-for-code-point-value①">values</a> of <var>input</var>’s <a data-link-type="dfn" href="#code-point" id="ref-for-code-point③⑤">code points</a>, in the same order. </p> </div> <hr> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="ascii-lowercase">ASCII lowercase</dfn> a <a data-link-type="dfn" href="#string" id="ref-for-string④②">string</a>, replace all <a data-link-type="dfn" href="#ascii-upper-alpha" id="ref-for-ascii-upper-alpha①">ASCII upper alphas</a> in the <a data-link-type="dfn" href="#string" id="ref-for-string④③">string</a> with their corresponding <a data-link-type="dfn" href="#code-point" id="ref-for-code-point③⑥">code point</a> in <a data-link-type="dfn" href="#ascii-lower-alpha" id="ref-for-ascii-lower-alpha①">ASCII lower alpha</a>. </p> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="ascii-uppercase">ASCII uppercase</dfn> a <a data-link-type="dfn" href="#string" id="ref-for-string④④">string</a>, replace all <a data-link-type="dfn" href="#ascii-lower-alpha" id="ref-for-ascii-lower-alpha②">ASCII lower alphas</a> in the <a data-link-type="dfn" href="#string" id="ref-for-string④⑤">string</a> with their corresponding <a data-link-type="dfn" href="#code-point" id="ref-for-code-point③⑦">code point</a> in <a data-link-type="dfn" href="#ascii-upper-alpha" id="ref-for-ascii-upper-alpha②">ASCII upper alpha</a>. </p> <p>A <a data-link-type="dfn" href="#string" id="ref-for-string④⑥">string</a> <var>A</var> is an <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="ascii-case-insensitive">ASCII case-insensitive</dfn> match for a <a data-link-type="dfn" href="#string" id="ref-for-string④⑦">string</a> <var>B</var>, if the <a data-link-type="dfn" href="#ascii-lowercase" id="ref-for-ascii-lowercase">ASCII lowercase</a> of <var>A</var> is the <a data-link-type="dfn" href="#ascii-lowercase" id="ref-for-ascii-lowercase①">ASCII lowercase</a> of <var>B</var>. </p> <div class="algorithm" data-algorithm="ASCII encode"> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="ascii-encode">ASCII encode</dfn> an <a data-link-type="dfn" href="#ascii-string" id="ref-for-ascii-string①">ASCII string</a> <var>input</var>: return the <a data-link-type="dfn" href="#isomorphic-encode" id="ref-for-isomorphic-encode①">isomorphic encoding</a> of <var>input</var>. </p> <p class="note" role="note"><a data-link-type="dfn" href="#isomorphic-encode" id="ref-for-isomorphic-encode②">Isomorphic encode</a> and <a data-link-type="dfn" href="https://encoding.spec.whatwg.org/#utf-8-encode" id="ref-for-utf-8-encode②">UTF-8 encode</a> return the same <a data-link-type="dfn" href="#byte-sequence" id="ref-for-byte-sequence①⑥">byte sequence</a> for <var>input</var>. </p> </div> <div class="algorithm" data-algorithm="ASCII decode"> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="ascii-decode">ASCII decode</dfn> a <a data-link-type="dfn" href="#byte-sequence" id="ref-for-byte-sequence①⑦">byte sequence</a> <var>input</var>, run these steps: </p> <ol> <li> <p><a data-link-type="dfn" href="#assert" id="ref-for-assert⑥">Assert</a>: all bytes in <var>input</var> are <a data-link-type="dfn" href="#ascii-byte" id="ref-for-ascii-byte①">ASCII bytes</a>. </p> <p class="note" role="note">Note: This precondition ensures that <a data-link-type="dfn" href="#isomorphic-decode" id="ref-for-isomorphic-decode①">isomorphic decode</a> and <a data-link-type="dfn" href="https://encoding.spec.whatwg.org/#utf-8-decode" id="ref-for-utf-8-decode②">UTF-8 decode</a> return the same <a data-link-type="dfn" href="#string" id="ref-for-string④⑧">string</a> for this input. </p> <li> <p>Return the <a data-link-type="dfn" href="#isomorphic-decode" id="ref-for-isomorphic-decode②">isomorphic decoding</a> of <var>input</var>. </p> </ol> </div> <hr> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="strip-newlines">strip newlines</dfn> from a <a data-link-type="dfn" href="#string" id="ref-for-string④⑨">string</a>, remove any U+000A LF and U+000D CR <a data-link-type="dfn" href="#code-point" id="ref-for-code-point③⑧">code points</a> from the <a data-link-type="dfn" href="#string" id="ref-for-string⑤⓪">string</a>. </p> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="normalize-newlines">normalize newlines</dfn> in a <a data-link-type="dfn" href="#string" id="ref-for-string⑤①">string</a>, replace every U+000D CR U+000A LF <a data-link-type="dfn" href="#code-point" id="ref-for-code-point③⑨">code point</a> pair with a single U+000A LF <a data-link-type="dfn" href="#code-point" id="ref-for-code-point④⓪">code point</a>, and then replace every remaining U+000D CR <a data-link-type="dfn" href="#code-point" id="ref-for-code-point④①">code point</a> with a U+000A LF <a data-link-type="dfn" href="#code-point" id="ref-for-code-point④②">code point</a>. </p> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="strip-leading-and-trailing-ascii-whitespace">strip leading and trailing ASCII whitespace</dfn> from a <a data-link-type="dfn" href="#string" id="ref-for-string⑤②">string</a>, remove all <a data-link-type="dfn" href="#ascii-whitespace" id="ref-for-ascii-whitespace①">ASCII whitespace</a> that are at the start or the end of the <a data-link-type="dfn" href="#string" id="ref-for-string⑤③">string</a>. </p> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="strip-and-collapse-ascii-whitespace">strip and collapse ASCII whitespace</dfn> in a <a data-link-type="dfn" href="#string" id="ref-for-string⑤④">string</a>, replace any sequence of one or more consecutive <a data-link-type="dfn" href="#code-point" id="ref-for-code-point④③">code points</a> that are <a data-link-type="dfn" href="#ascii-whitespace" id="ref-for-ascii-whitespace②">ASCII whitespace</a> in the <a data-link-type="dfn" href="#string" id="ref-for-string⑤⑤">string</a> with a single U+0020 SPACE <a data-link-type="dfn" href="#code-point" id="ref-for-code-point④④">code point</a>, and then remove any leading and trailing <a data-link-type="dfn" href="#ascii-whitespace" id="ref-for-ascii-whitespace③">ASCII whitespace</a> from that string. </p> <hr> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-lt="collect a sequence of code points|collecting a sequence of code points" id="collect-a-sequence-of-code-points">collect a sequence of <a data-link-type="dfn" href="#code-point" id="ref-for-code-point④⑤">code points</a></dfn> meeting a condition <var>condition</var> from a <a data-link-type="dfn" href="#string" id="ref-for-string⑤⑥">string</a> <var>input</var>, given a <dfn class="dfn-paneled" data-dfn-for="string" data-dfn-type="dfn" data-export id="string-position-variable">position variable</dfn> <var>position</var> tracking the position of the calling algorithm within <var>input</var>:</p> <ol> <li> <p>Let <var>result</var> be the empty <a data-link-type="dfn" href="#string" id="ref-for-string⑤⑦">string</a>. </p> <li> <p>While <var>position</var> doesn’t point past the end of <var>input</var> and the <a data-link-type="dfn" href="#code-point" id="ref-for-code-point④⑥">code point</a> at <var>position</var> within <var>input</var> meets the condition <var>condition</var>: </p> <ol> <li> <p>Append that <a data-link-type="dfn" href="#code-point" id="ref-for-code-point④⑦">code point</a> to the end of <var>result</var>. </p> <li> <p>Advance <var>position</var> by 1. </p> </ol> <li> <p>Return <var>result</var>. </p> </ol> <p class="note" role="note">In addition to returning the collected <a data-link-type="dfn" href="#code-point" id="ref-for-code-point④⑧">code points</a>, this algorithm updates the <a data-link-type="dfn" href="#string-position-variable" id="ref-for-string-position-variable">position variable</a> in the calling algorithm. </p> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="skip-ascii-whitespace">skip ASCII whitespace</dfn> within a <a data-link-type="dfn" href="#string" id="ref-for-string⑤⑧">string</a> <var>input</var> given a <a data-link-type="dfn" href="#string-position-variable" id="ref-for-string-position-variable①">position variable</a> <var>position</var>, <a data-link-type="dfn" href="#collect-a-sequence-of-code-points" id="ref-for-collect-a-sequence-of-code-points">collect a sequence of code points</a> that are <a data-link-type="dfn" href="#ascii-whitespace" id="ref-for-ascii-whitespace④">ASCII whitespace</a> from <var>input</var> given <var>position</var>. The collected <a data-link-type="dfn" href="#code-point" id="ref-for-code-point④⑨">code points</a> are not used, but <var>position</var> is still updated. </p> <hr> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-lt="strictly split|strictly split a string" id="strictly-split">strictly split a <a data-link-type="dfn" href="#string" id="ref-for-string⑤⑨">string</a></dfn> <var>input</var> on a particular delimiter <a data-link-type="dfn" href="#code-point" id="ref-for-code-point⑤⓪">code point</a> <var>delimiter</var>:</p> <ol> <li> <p>Let <var>position</var> be a <a data-link-type="dfn" href="#string-position-variable" id="ref-for-string-position-variable②">position variable</a> for <var>input</var>, initially pointing at the start of <var>input</var>. </p> <li> <p>Let <var>tokens</var> be a <a data-link-type="dfn" href="#list" id="ref-for-list⑤">list</a> of <a data-link-type="dfn" href="#string" id="ref-for-string⑥⓪">strings</a>, initially empty. </p> <li> <p>Let <var>token</var> be the result of <a data-link-type="dfn" href="#collect-a-sequence-of-code-points" id="ref-for-collect-a-sequence-of-code-points①">collecting a sequence of code points</a> that are not equal to <var>delimiter</var> from <var>input</var>, given <var>position</var>. </p> <li> <p><a data-link-type="dfn" href="#list-append" id="ref-for-list-append⑧">Append</a> <var>token</var> to <var>tokens</var>. </p> <li> <p>While <var>position</var> is not past the end of <var>input</var>: </p> <ol> <li> <p><a data-link-type="dfn" href="#assert" id="ref-for-assert⑦">Assert</a>: the <a data-link-type="dfn" href="#code-point" id="ref-for-code-point⑤①">code point</a> at <var>position</var> within <var>input</var> is <var>delimiter</var>. </p> <li> <p>Advance <var>position</var> by 1. </p> <li> <p>Let <var>token</var> be the result of <a data-link-type="dfn" href="#collect-a-sequence-of-code-points" id="ref-for-collect-a-sequence-of-code-points②">collecting a sequence of code points</a> that are not equal to <var>delimiter</var> from <var>input</var>, given <var>position</var>. </p> <li> <p><a data-link-type="dfn" href="#list-append" id="ref-for-list-append⑨">Append</a> <var>token</var> to <var>tokens</var>. </p> </ol> <li> <p>Return <var>tokens</var>. </p> </ol> <p class="note" role="note">This algorithm is a "strict" split, as opposed to the commonly-used variants <a data-link-type="dfn" href="#split-on-ascii-whitespace" id="ref-for-split-on-ascii-whitespace">for ASCII whitespace</a> and <a data-link-type="dfn" href="#split-on-commas" id="ref-for-split-on-commas">for commas</a> below, which are both more lenient in various ways involving interspersed <a data-link-type="dfn" href="#ascii-whitespace" id="ref-for-ascii-whitespace⑤">ASCII whitespace</a>. </p> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-lt="split on ASCII whitespace|split a string on ASCII whitespace" id="split-on-ascii-whitespace">split a <a data-link-type="dfn" href="#string" id="ref-for-string⑥①">string</a> <var>input</var> on ASCII whitespace</dfn>: </p> <ol> <li> <p>Let <var>position</var> be a <a data-link-type="dfn" href="#string-position-variable" id="ref-for-string-position-variable③">position variable</a> for <var>input</var>, initially pointing at the start of <var>input</var>. </p> <li> <p>Let <var>tokens</var> be a <a data-link-type="dfn" href="#list" id="ref-for-list⑥">list</a> of <a data-link-type="dfn" href="#string" id="ref-for-string⑥②">strings</a>, initially empty. </p> <li> <p><a data-link-type="dfn" href="#skip-ascii-whitespace" id="ref-for-skip-ascii-whitespace">Skip ASCII whitespace</a> within <var>input</var> given <var>position</var>. </p> <li> <p>While <var>position</var> is not past the end of <var>input</var>: </p> <ol> <li> <p>Let <var>token</var> be the result of <a data-link-type="dfn" href="#collect-a-sequence-of-code-points" id="ref-for-collect-a-sequence-of-code-points③">collecting a sequence of code points</a> that are not <a data-link-type="dfn" href="#ascii-whitespace" id="ref-for-ascii-whitespace⑥">ASCII whitespace</a> from <var>input</var>, given <var>position</var>. </p> <li> <p><a data-link-type="dfn" href="#list-append" id="ref-for-list-append①⓪">Append</a> <var>token</var> to <var>tokens</var>. </p> <li> <p><a data-link-type="dfn" href="#skip-ascii-whitespace" id="ref-for-skip-ascii-whitespace①">Skip ASCII whitespace</a> within <var>input</var> given <var>position</var>. </p> </ol> <li> <p>Return <var>tokens</var>. </p> </ol> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-lt="split on commas|split a string on commas" id="split-on-commas">split a <a data-link-type="dfn" href="#string" id="ref-for-string⑥③">string</a> <var>input</var> on commas</dfn>: </p> <ol> <li> <p>Let <var>position</var> be a <a data-link-type="dfn" href="#string-position-variable" id="ref-for-string-position-variable④">position variable</a> for <var>input</var>, initially pointing at the start of <var>input</var>. </p> <li> <p>Let <var>tokens</var> be a <a data-link-type="dfn" href="#list" id="ref-for-list⑦">list</a> of <a data-link-type="dfn" href="#string" id="ref-for-string⑥④">strings</a>, initially empty. </p> <li> <p>While <var>position</var> is not past the end of <var>input</var>: </p> <ol> <li> <p>Let <var>token</var> be the result of <a data-link-type="dfn" href="#collect-a-sequence-of-code-points" id="ref-for-collect-a-sequence-of-code-points④">collecting a sequence of code points</a> that are not U+002C (,) from <var>input</var>, given <var>position</var>. </p> <p class="note" role="note"><var>token</var> might be the empty string. </p> <li><a data-link-type="dfn" href="#strip-leading-and-trailing-ascii-whitespace" id="ref-for-strip-leading-and-trailing-ascii-whitespace">Strip leading and trailing ASCII whitespace</a> from <var>token</var>. <li> <p><a data-link-type="dfn" href="#list-append" id="ref-for-list-append①①">Append</a> <var>token</var> to <var>tokens</var>. </p> <li> <p>If <var>position</var> is not past the end of <var>input</var>, then: </p> <ol> <li> <p><a data-link-type="dfn" href="#assert" id="ref-for-assert⑧">Assert</a>: the <a data-link-type="dfn" href="#code-point" id="ref-for-code-point⑤②">code point</a> at <var>position</var> within <var>input</var> is U+002C (,). </p> <li> <p>Advance <var>position</var> by 1. </p> </ol> </ol> <li> <p>Return <var>tokens</var>. </p> </ol> <p>To <dfn class="dfn-paneled" data-dfn-for="string" data-dfn-type="dfn" data-export data-lt="concatenate|concatenation" id="string-concatenate">concatenate</dfn> a <a data-link-type="dfn" href="#list" id="ref-for-list⑧">list</a> of <a data-link-type="dfn" href="#string" id="ref-for-string⑥⑤">strings</a> <var>list</var>, using an optional separator string <var>separator</var>, run these steps: </p> <ol> <li> <p>If <var>list</var> <a data-link-type="dfn" href="#list-is-empty" id="ref-for-list-is-empty">is empty</a>, then return the empty string. </p> <li> <p>If <var>separator</var> is not given, then set <var>separator</var> to the empty string. </p> <li> <p>Return a <a data-link-type="dfn" href="#string" id="ref-for-string⑥⑥">string</a> whose contents are <var>list</var>’s <a data-link-type="dfn" href="#list-item" id="ref-for-list-item">items</a>, in order, separated from each other by <var>separator</var>. </p> </ol> <p class="example" id="example-string-concatenate"><a class="self-link" href="#example-string-concatenate"></a>To serialize a set <var>set</var>, return the <a data-link-type="dfn" href="#string-concatenate" id="ref-for-string-concatenate">concatenation</a> of <var>set</var> using U+0020 SPACE. </p> <h3 class="heading settled" data-level="4.8" id="time"><span class="secno">4.8. </span><span class="content">Time</span><a class="self-link" href="#time"></a></h3> <p>Represent time using the <a data-link-type="dfn" href="https://w3c.github.io/hr-time/#dfn-moment" id="ref-for-dfn-moment">moment</a> and <a data-link-type="dfn" href="https://w3c.github.io/hr-time/#dfn-duration" id="ref-for-dfn-duration">duration</a> specification types. Follow the advice in <a href="https://w3c.github.io/hr-time/#sec-tools"><cite>High Resolution Time</cite> § 3 Tools for Specification Authors</a> when creating these and exchanging them with JavaScript. <a data-link-type="biblio" href="#biblio-hr-time" title="High Resolution Time">[HR-TIME]</a> </p> <h2 class="heading settled" data-level="5" id="data-structures"><span class="secno">5. </span><span class="content">Data structures</span><a class="self-link" href="#data-structures"></a></h2> <p>Conventionally, specifications have operated on a variety of vague specification-level data structures, based on shared understanding of their semantics. This generally works well, but can lead to ambiguities around edge cases, such as iteration order or what happens when you <a data-link-type="dfn" href="#set-append" id="ref-for-set-append">append</a> an <a data-link-type="dfn" href="#list-item" id="ref-for-list-item①">item</a> to an <a data-link-type="dfn" href="#ordered-set" id="ref-for-ordered-set">ordered set</a> that the set already <a data-link-type="dfn" href="#list-contain" id="ref-for-list-contain">contains</a>. It has also led to a variety of divergent notation and phrasing, especially around more complex data structures such as <a data-link-type="dfn" href="#ordered-map" id="ref-for-ordered-map">maps</a>. </p> <p>This standard provides a small set of common data structures, along with notation and phrasing for working with them, in order to create common ground. </p> <h3 class="heading settled" data-level="5.1" id="lists"><span class="secno">5.1. </span><span class="content">Lists</span><a class="self-link" href="#lists"></a></h3> <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="list">list</dfn> is a specification type consisting of a finite ordered sequence of <dfn class="dfn-paneled" data-dfn-for="list,stack,queue,set" data-dfn-type="dfn" data-export data-lt="item" id="list-item">items</dfn>. </p> <p>For notational convenience, a literal syntax can be used to express <a data-link-type="dfn" href="#list" id="ref-for-list⑨">lists</a>, by surrounding the list by « » characters and separating its <a data-link-type="dfn" href="#list-item" id="ref-for-list-item②">items</a> with a comma. An indexing syntax can be used by providing a zero-based index into a list inside square brackets. The index cannot be out-of-bounds, except when used with <a data-link-type="dfn" href="#list-contain" id="ref-for-list-contain①">exists</a>. </p> <p class="example" id="example-list-notation"><a class="self-link" href="#example-list-notation"></a>Let <var>example</var> be the <a data-link-type="dfn" href="#list" id="ref-for-list①⓪">list</a> « "<code>a</code>", "<code>b</code>", "<code>c</code>", "<code>a</code>" ». Then <var>example</var>[1] is the <a data-link-type="dfn" href="#string" id="ref-for-string⑥⑦">string</a> "<code>b</code>". </p> <p>For notational convenience, a multiple assignment syntax may be used to assign multiple variables to the <a data-link-type="dfn" href="#list" id="ref-for-list①①">list</a>’s <a data-link-type="dfn" href="#list-item" id="ref-for-list-item③">items</a>, by surrounding the variables to be assigned by « » characters and separating each variable name with a comma. The <a data-link-type="dfn" href="#list" id="ref-for-list①②">list</a>’s <a data-link-type="dfn" href="#list-size" id="ref-for-list-size">size</a> must be the same as the number of variables to be assigned. Each variable given is then set to the value of the <a data-link-type="dfn" href="#list" id="ref-for-list①③">list</a>’s <a data-link-type="dfn" href="#list-item" id="ref-for-list-item④">item</a> at the corresponding index. </p> <div class="example" id="example-list-multiple-assignment"> <a class="self-link" href="#example-list-multiple-assignment"></a> <ol> <li> <p>Let <var>value</var> be the <a data-link-type="dfn" href="#list" id="ref-for-list①④">list</a> « "<code>a</code>", "<code>b</code>", "<code>c</code>" ». </p> <li> <p>Let « <var>a</var>, <var>b</var>, <var>c</var> » be <var>value</var>. </p> <li> <p><a data-link-type="dfn" href="#assert" id="ref-for-assert⑨">Assert</a>: <var>a</var> is "<code>a</code>". </p> <li> <p><a data-link-type="dfn" href="#assert" id="ref-for-assert①⓪">Assert</a>: <var>b</var> is "<code>b</code>". </p> <li> <p><a data-link-type="dfn" href="#assert" id="ref-for-assert①①">Assert</a>: <var>c</var> is "<code>c</code>". </p> </ol> </div> <p>When a <a data-link-type="dfn" href="#list" id="ref-for-list①⑤">list</a>’s contents are not fully controlled, as is the case for lists from user input, the <a data-link-type="dfn" href="#list" id="ref-for-list①⑥">list</a>’s <a data-link-type="dfn" href="#list-size" id="ref-for-list-size①">size</a> should be checked to ensure it is the expected size before list multiple assignment syntax is used. </p> <div class="example" id="example-list-multiple-assignment-size"> <a class="self-link" href="#example-list-multiple-assignment-size"></a> <ol> <li> <p>If <var>list</var>’s <a data-link-type="dfn" href="#list-size" id="ref-for-list-size②">size</a> is not <code>3</code>, then return failure. </p> <li> <p>Let « <var>a</var>, <var>b</var>, <var>c</var> » be <var>list</var>. </p> </ol> </div> <hr> <p>To <dfn class="dfn-paneled" data-dfn-for="list" data-dfn-type="dfn" data-export id="list-append">append</dfn> to a <a data-link-type="dfn" href="#list" id="ref-for-list①⑦">list</a> that is not an <a data-link-type="dfn" href="#ordered-set" id="ref-for-ordered-set①">ordered set</a> is to add the given <a data-link-type="dfn" href="#list-item" id="ref-for-list-item⑤">item</a> to the end of the list. </p> <p>To <dfn class="dfn-paneled" data-dfn-for="list" data-dfn-type="dfn" data-export id="list-extend">extend</dfn> a <a data-link-type="dfn" href="#list" id="ref-for-list①⑧">list</a> <var>A</var> with a <a data-link-type="dfn" href="#list" id="ref-for-list①⑨">list</a> <var>B</var>, <a data-link-type="dfn" href="#list-iterate" id="ref-for-list-iterate⑥">for each</a> <var>item</var> of <var>B</var>, <a data-link-type="dfn" href="#list-append" id="ref-for-list-append①②">append</a> <var>item</var> to <var>A</var>. </p> <div class="example" id="example-list-extend"> <a class="self-link" href="#example-list-extend"></a> <ol> <li> <p>Let <var>ghostbusters</var> be « "<code>Erin Gilbert</code>", "<code>Abby Yates</code>" ». </p> <li> <p><a data-link-type="dfn" href="#list-extend" id="ref-for-list-extend">Extend</a> <var>ghostbusters</var> with « "<code>Jillian Holtzmann</code>", "<code>Patty Tolan</code>" ». </p> <li> <p><a data-link-type="dfn" href="#assert" id="ref-for-assert①②">Assert</a>: <var>ghostbusters</var>’s <a data-link-type="dfn" href="#list-size" id="ref-for-list-size③">size</a> is 4. </p> <li> <p><a data-link-type="dfn" href="#assert" id="ref-for-assert①③">Assert</a>: <var>ghostbusters</var>[2] is "<code>Jillian Holtzmann</code>". </p> </ol> </div> <p>To <dfn class="dfn-paneled" data-dfn-for="list" data-dfn-type="dfn" data-export id="list-prepend">prepend</dfn> to a <a data-link-type="dfn" href="#list" id="ref-for-list②⓪">list</a> that is not an <a data-link-type="dfn" href="#ordered-set" id="ref-for-ordered-set②">ordered set</a> is to add the given <a data-link-type="dfn" href="#list-item" id="ref-for-list-item⑥">item</a> to the beginning of the list. </p> <p>To <dfn class="dfn-paneled" data-dfn-for="list" data-dfn-type="dfn" data-export id="list-replace">replace</dfn> within a <a data-link-type="dfn" href="#list" id="ref-for-list②①">list</a> that is not an <a data-link-type="dfn" href="#ordered-set" id="ref-for-ordered-set③">ordered set</a> is to replace all items from the list that match a given condition with the given <a data-link-type="dfn" href="#list-item" id="ref-for-list-item⑦">item</a>, or do nothing if none do. </p> <p class="note" role="note">The above definitions are modified when the <a data-link-type="dfn" href="#list" id="ref-for-list②②">list</a> is an <a data-link-type="dfn" href="#ordered-set" id="ref-for-ordered-set④">ordered set</a>; see below for <a data-link-type="dfn" href="#set-append" id="ref-for-set-append①">ordered set append</a>, <a data-link-type="dfn" href="#set-prepend" id="ref-for-set-prepend">prepend</a>, and <a data-link-type="dfn" href="#set-replace" id="ref-for-set-replace">replace</a>. </p> <p>To <dfn class="dfn-paneled" data-dfn-for="list,set" data-dfn-type="dfn" data-export id="list-insert">insert</dfn> an <a data-link-type="dfn" href="#list-item" id="ref-for-list-item⑧">item</a> into a <a data-link-type="dfn" href="#list" id="ref-for-list②③">list</a> before an index is to add the given item to the list between the given index − 1 and the given index. If the given index is 0, then <a data-link-type="dfn" href="#list-prepend" id="ref-for-list-prepend">prepend</a> the given item to the list. </p> <p>To <dfn class="dfn-paneled" data-dfn-for="list,set" data-dfn-type="dfn" data-export id="list-remove">remove</dfn> zero or more <a data-link-type="dfn" href="#list-item" id="ref-for-list-item⑨">items</a> from a <a data-link-type="dfn" href="#list" id="ref-for-list②④">list</a> is to remove all items from the list that match a given condition, or do nothing if none do. </p> <div class="example" id="example-list-remove"> <a class="self-link" href="#example-list-remove"></a> <p><a data-link-type="dfn" href="#list-remove" id="ref-for-list-remove">Removing</a> <var>x</var> from the <a data-link-type="dfn" href="#list" id="ref-for-list②⑤">list</a> « <var>x</var>, <var>y</var>, <var>z</var>, <var>x</var> » is to remove all items from the list that are equal to <var>x</var>. The list now is equivalent to « <var>y</var>, <var>z</var> ». </p> <p><a data-link-type="dfn" href="#list-remove" id="ref-for-list-remove①">Removing</a> all items that start with the <a data-link-type="dfn" href="#string" id="ref-for-string⑥⑧">string</a> "<code>a</code>" from the <a data-link-type="dfn" href="#list" id="ref-for-list②⑥">list</a> « "<code>a</code>", "<code>b</code>", "<code>ab</code>", "<code>ba</code>" » is to remove the items "<code>a</code>" and "<code>ab</code>". The list is now equivalent to « "<code>b</code>", "<code>ba</code>" ». </p> </div> <p>To <dfn class="dfn-paneled" data-dfn-for="list,stack,queue,set" data-dfn-type="dfn" data-export id="list-empty">empty</dfn> a <a data-link-type="dfn" href="#list" id="ref-for-list②⑦">list</a> is to <a data-link-type="dfn" href="#list-remove" id="ref-for-list-remove②">remove</a> all of its <a data-link-type="dfn" href="#list-item" id="ref-for-list-item①⓪">items</a>. </p> <p>A <a data-link-type="dfn" href="#list" id="ref-for-list②⑧">list</a> <dfn class="dfn-paneled" data-dfn-for="list,stack,queue,set" data-dfn-type="dfn" data-export data-lt="contain|exist" id="list-contain">contains</dfn> an <a data-link-type="dfn" href="#list-item" id="ref-for-list-item①①">item</a> if it appears in the list. We can also denote this by saying that, for a <a data-link-type="dfn" href="#list" id="ref-for-list②⑨">list</a> <var>list</var> and an index <var>index</var>, "<var>list</var>[<var>index</var>] <a data-link-type="dfn" href="#list-contain" id="ref-for-list-contain②">exists</a>". </p> <p>A <a data-link-type="dfn" href="#list" id="ref-for-list③⓪">list</a>’s <dfn class="dfn-paneled" data-dfn-for="list,stack,queue,set" data-dfn-type="dfn" data-export id="list-size">size</dfn> is the number of <a data-link-type="dfn" href="#list-item" id="ref-for-list-item①②">items</a> the list <a data-link-type="dfn" href="#list-contain" id="ref-for-list-contain③">contains</a>. </p> <p>A <a data-link-type="dfn" href="#list" id="ref-for-list③①">list</a> <dfn class="dfn-paneled" data-dfn-for="list,stack,queue,set" data-dfn-type="dfn" data-export data-lt="is empty|is not empty" id="list-is-empty">is empty</dfn> if its <a data-link-type="dfn" href="#list-size" id="ref-for-list-size④">size</a> is zero. </p> <p>To <dfn class="dfn-paneled" data-dfn-for="list,stack,queue,set" data-dfn-type="dfn" data-export data-lt="get the indices|indices" id="list-get-the-indices">get the indices</dfn> of a <a data-link-type="dfn" href="#list" id="ref-for-list③②">list</a>, return <a data-link-type="dfn" href="#the-exclusive-range" id="ref-for-the-exclusive-range②">the range</a> from 0 to the list’s <a data-link-type="dfn" href="#list-size" id="ref-for-list-size⑤">size</a>, exclusive. </p> <p>To <dfn class="dfn-paneled" data-dfn-for="list,set" data-dfn-type="dfn" data-export data-lt="iterate|for each" id="list-iterate">iterate</dfn> over a <a data-link-type="dfn" href="#list" id="ref-for-list③③">list</a>, performing a set of steps on each <a data-link-type="dfn" href="#list-item" id="ref-for-list-item①③">item</a> in order, use phrasing of the form "<a data-link-type="dfn" href="#list-iterate" id="ref-for-list-iterate⑦">For each</a> <var>item</var> of <var>list</var>", and then operate on <var>item</var> in the subsequent prose. </p> <p>To <dfn class="dfn-paneled" data-dfn-for="list,stack,queue,set" data-dfn-type="dfn" data-export id="list-clone">clone</dfn> a <a data-link-type="dfn" href="#list" id="ref-for-list③④">list</a> <var>list</var> is to create a new <a data-link-type="dfn" href="#list" id="ref-for-list③⑤">list</a> <var>clone</var>, of the same designation, and, <a data-link-type="dfn" href="#list-iterate" id="ref-for-list-iterate⑧">for each</a> <var>item</var> of <var>list</var>, <a data-link-type="dfn" href="#list-append" id="ref-for-list-append①③">append</a> <var>item</var> to <var>clone</var>, so that <var>clone</var> <a data-link-type="dfn" href="#list-contain" id="ref-for-list-contain④">contains</a> the same <a data-link-type="dfn" href="#list-item" id="ref-for-list-item①④">items</a>, in the same order as <var>list</var>. </p> <p class="note" role="note">This is a "shallow clone", as the <a data-link-type="dfn" href="#list-item" id="ref-for-list-item①⑤">items</a> themselves are not cloned in any way. </p> <p class="example" id="example-list-clone"><a class="self-link" href="#example-list-clone"></a>Let <var>original</var> be the <a data-link-type="dfn" href="#ordered-set" id="ref-for-ordered-set⑤">ordered set</a> « "<code>a</code>", "<code>b</code>", "<code>c</code>" ». <a data-link-type="dfn" href="#list-clone" id="ref-for-list-clone">Cloning</a> <var>original</var> creates a new <a data-link-type="dfn" href="#ordered-set" id="ref-for-ordered-set⑥">ordered set</a> <var>clone</var>, so that <a data-link-type="dfn" href="#set-replace" id="ref-for-set-replace①">replacing</a> "<code>a</code>" with "<code>foo</code>" in <var>clone</var> gives « "<code>foo</code>", "<code>b</code>", "<code>c</code>" », while <var>original</var>[0] is still the <a data-link-type="dfn" href="#string" id="ref-for-string⑥⑨">string</a> "<code>a</code>". </p> <p>To <dfn class="dfn-paneled" data-dfn-for="list,stack,queue,set" data-dfn-type="dfn" data-export data-lt="sort in ascending order|sorting in ascending order|sort|sorting" id="list-sort-in-ascending-order">sort in ascending order</dfn> a <a data-link-type="dfn" href="#list" id="ref-for-list③⑥">list</a> <var>list</var>, with a less than algorithm <var>lessThanAlgo</var>, is to create a new <a data-link-type="dfn" href="#list" id="ref-for-list③⑦">list</a> <var>sorted</var>, containing the same <a data-link-type="dfn" href="#list-item" id="ref-for-list-item①⑥">items</a> as <var>list</var> but sorted so that according to <var>lessThanAlgo</var>, each item is less than the one following it, if any. For items that sort the same (i.e., for which <var>lessThanAlgo</var> returns false for both comparisons), their relative order in <var>sorted</var> must be the same as it was in <var>list</var>. </p> <p>To <dfn class="dfn-paneled" data-dfn-for="list,stack,queue,set" data-dfn-type="dfn" data-export data-lt="sort in descending order|sorting in descending order" id="list-sort-in-descending-order">sort in descending order</dfn> a <a data-link-type="dfn" href="#list" id="ref-for-list③⑧">list</a> <var>list</var>, with a less than algorithm <var>lessThanAlgo</var>, is to create a new <a data-link-type="dfn" href="#list" id="ref-for-list③⑨">list</a> <var>sorted</var>, containing the same <a data-link-type="dfn" href="#list-item" id="ref-for-list-item①⑦">items</a> as <var>list</var> but sorted so that according to <var>lessThanAlgo</var>, each item is less than the one preceding it, if any. For items that sort the same (i.e., for which <var>lessThanAlgo</var> returns false for both comparisons), their relative order in <var>sorted</var> must be the same as it was in <var>list</var>. </p> <p class="example" id="example-list-sort"><a class="self-link" href="#example-list-sort"></a>Let <var>original</var> be the <a data-link-type="dfn" href="#list" id="ref-for-list④⓪">list</a> « (200, "<code>OK</code>"), (404, "<code>Not Found</code>"), (null, "<code>OK</code>") ». <a data-link-type="dfn" href="#list-sort-in-ascending-order" id="ref-for-list-sort-in-ascending-order">Sorting</a> <var>original</var> in ascending order, with <var>a</var> being less than <var>b</var> if <var>a</var>’s second <a data-link-type="dfn" href="#struct-item" id="ref-for-struct-item③">item</a> is <a data-link-type="dfn" href="#code-unit-less-than" id="ref-for-code-unit-less-than①">code unit less than</a> <var>b</var>’s second <a data-link-type="dfn" href="#struct-item" id="ref-for-struct-item④">item</a>, gives the result « (404, "<code>Not Found</code>"), (200, "<code>OK</code>"), (null, "<code>OK</code>") ».</p> <hr> <p>The <a data-link-type="dfn" href="#list" id="ref-for-list④①">list</a> type originates from the JavaScript specification (where it is capitalized, as <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-list-and-record-specification-type" id="ref-for-sec-list-and-record-specification-type">List</a>); we repeat some elements of its definition here for ease of reference, and provide an expanded vocabulary for manipulating <a data-link-type="dfn" href="#list" id="ref-for-list④②">lists</a>. Whenever JavaScript expects a <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-list-and-record-specification-type" id="ref-for-sec-list-and-record-specification-type①">List</a>, a <a data-link-type="dfn" href="#list" id="ref-for-list④③">list</a> as defined here can be used; they are the same type. <a data-link-type="biblio" href="#biblio-ecma-262" title="ECMAScript Language Specification">[ECMA-262]</a> </p> <h4 class="heading settled" data-level="5.1.1" id="stacks"><span class="secno">5.1.1. </span><span class="content">Stacks</span><a class="self-link" href="#stacks"></a></h4> <p>Some <a data-link-type="dfn" href="#list" id="ref-for-list④④">lists</a> are designated as <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-lt="stack" id="stack">stacks</dfn>. A stack is a <a data-link-type="dfn" href="#list" id="ref-for-list④⑤">list</a>, but conventionally, the following operations are used to operate on it, instead of using <a data-link-type="dfn" href="#list-append" id="ref-for-list-append①④">append</a>, <a data-link-type="dfn" href="#list-prepend" id="ref-for-list-prepend①">prepend</a>, or <a data-link-type="dfn" href="#list-remove" id="ref-for-list-remove③">remove</a>. </p> <p>To <dfn class="dfn-paneled" data-dfn-for="stack" data-dfn-type="dfn" data-export id="stack-push">push</dfn> onto a <a data-link-type="dfn" href="#stack" id="ref-for-stack">stack</a> is to <a data-link-type="dfn" href="#list-append" id="ref-for-list-append①⑤">append</a> to it. </p> <p>To <dfn class="dfn-paneled" data-dfn-for="stack" data-dfn-type="dfn" data-export id="stack-pop">pop</dfn> from a <a data-link-type="dfn" href="#stack" id="ref-for-stack①">stack</a>: if the <a data-link-type="dfn" href="#stack" id="ref-for-stack②">stack</a> <a data-link-type="dfn" href="#list-is-empty" id="ref-for-list-is-empty①">is not empty</a>, then <a data-link-type="dfn" href="#list-remove" id="ref-for-list-remove④">remove</a> its last <a data-link-type="dfn" href="#list-item" id="ref-for-list-item①⑧">item</a> and return it; otherwise, return nothing. </p> <p>To <dfn class="dfn-paneled" data-dfn-for="stack" data-dfn-type="dfn" data-export id="stack-peek">peek</dfn> into a <a data-link-type="dfn" href="#stack" id="ref-for-stack③">stack</a>: if the <a data-link-type="dfn" href="#stack" id="ref-for-stack④">stack</a> <a data-link-type="dfn" href="#list-is-empty" id="ref-for-list-is-empty②">is not empty</a>, then return its last <a data-link-type="dfn" href="#list-item" id="ref-for-list-item①⑨">item</a>; otherwise, return nothing. </p> <p>Although <a data-link-type="dfn" href="#stack" id="ref-for-stack⑤">stacks</a> are <a data-link-type="dfn" href="#list" id="ref-for-list④⑥">lists</a>, <a data-link-type="dfn" href="#list-iterate" id="ref-for-list-iterate⑨">for each</a> must not be used with them; instead, a combination of <a data-link-type="dfn" href="#iteration-while" id="ref-for-iteration-while③">while</a> and <a data-link-type="dfn" href="#stack-pop" id="ref-for-stack-pop">pop</a> is more appropriate. </p> <h4 class="heading settled" data-level="5.1.2" id="queues"><span class="secno">5.1.2. </span><span class="content">Queues</span><a class="self-link" href="#queues"></a></h4> <p>Some <a data-link-type="dfn" href="#list" id="ref-for-list④⑦">lists</a> are designated as <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-lt="queue" id="queue">queues</dfn>. A queue is a <a data-link-type="dfn" href="#list" id="ref-for-list④⑧">list</a>, but conventionally, the following operations are used to operate on it, instead of using <a data-link-type="dfn" href="#list-append" id="ref-for-list-append①⑥">append</a>, <a data-link-type="dfn" href="#list-prepend" id="ref-for-list-prepend②">prepend</a>, or <a data-link-type="dfn" href="#list-remove" id="ref-for-list-remove⑤">remove</a>. </p> <p>To <dfn class="dfn-paneled" data-dfn-for="queue" data-dfn-type="dfn" data-export id="queue-enqueue">enqueue</dfn> in a <a data-link-type="dfn" href="#queue" id="ref-for-queue">queue</a> is to <a data-link-type="dfn" href="#list-append" id="ref-for-list-append①⑦">append</a> to it. </p> <p>To <dfn class="dfn-paneled" data-dfn-for="queue" data-dfn-type="dfn" data-export id="queue-dequeue">dequeue</dfn> from a <a data-link-type="dfn" href="#queue" id="ref-for-queue①">queue</a> is to <a data-link-type="dfn" href="#list-remove" id="ref-for-list-remove⑥">remove</a> its first <a data-link-type="dfn" href="#list-item" id="ref-for-list-item②⓪">item</a> and return it, if the <a data-link-type="dfn" href="#queue" id="ref-for-queue②">queue</a> <a data-link-type="dfn" href="#list-is-empty" id="ref-for-list-is-empty③">is not empty</a>, or to return nothing if it is. </p> <p>Although <a data-link-type="dfn" href="#queue" id="ref-for-queue③">queues</a> are <a data-link-type="dfn" href="#list" id="ref-for-list④⑨">lists</a>, <a data-link-type="dfn" href="#list-iterate" id="ref-for-list-iterate①⓪">for each</a> must not be used with them; instead, a combination of <a data-link-type="dfn" href="#iteration-while" id="ref-for-iteration-while④">while</a> and <a data-link-type="dfn" href="#queue-dequeue" id="ref-for-queue-dequeue">dequeue</a> is more appropriate. </p> <h4 class="heading settled" data-level="5.1.3" id="sets"><span class="secno">5.1.3. </span><span class="content">Sets</span><a class="self-link" href="#sets"></a></h4> <p>Some <a data-link-type="dfn" href="#list" id="ref-for-list⑤⓪">lists</a> are designated as <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-lt="ordered set|set" id="ordered-set">ordered sets</dfn>. An ordered set is a <a data-link-type="dfn" href="#list" id="ref-for-list⑤①">list</a> with the additional semantic that it must not contain the same <a data-link-type="dfn" href="#list-item" id="ref-for-list-item②①">item</a> twice. </p> <p class="note" role="note">Almost all cases on the web platform require an <em>ordered</em> set, instead of an unordered one, since interoperability requires that any developer-exposed enumeration of the set’s contents be consistent between browsers. In those cases where order is not important, we still use ordered sets; implementations can optimize based on the fact that the order is not observable. </p> <p>To <dfn class="dfn-paneled" data-dfn-for="set" data-dfn-type="dfn" data-export id="set-append">append</dfn> to an <a data-link-type="dfn" href="#ordered-set" id="ref-for-ordered-set⑦">ordered set</a>: if the set <a data-link-type="dfn" href="#list-contain" id="ref-for-list-contain⑤">contains</a> the given <a data-link-type="dfn" href="#list-item" id="ref-for-list-item②②">item</a>, then do nothing; otherwise, perform the normal <a data-link-type="dfn" href="#list" id="ref-for-list⑤②">list</a> <a data-link-type="dfn" href="#list-append" id="ref-for-list-append①⑧">append</a> operation. </p> <p>To <dfn class="dfn-paneled" data-dfn-for="set" data-dfn-type="dfn" data-export id="set-prepend">prepend</dfn> to an <a data-link-type="dfn" href="#ordered-set" id="ref-for-ordered-set⑧">ordered set</a>: if the set <a data-link-type="dfn" href="#list-contain" id="ref-for-list-contain⑥">contains</a> the given <a data-link-type="dfn" href="#list-item" id="ref-for-list-item②③">item</a>, then do nothing; otherwise, perform the normal <a data-link-type="dfn" href="#list" id="ref-for-list⑤③">list</a> <a data-link-type="dfn" href="#list-prepend" id="ref-for-list-prepend③">prepend</a> operation. </p> <p>To <dfn class="dfn-paneled" data-dfn-for="set" data-dfn-type="dfn" data-export data-lt="replace|replacing" id="set-replace">replace</dfn> within an <a data-link-type="dfn" href="#ordered-set" id="ref-for-ordered-set⑨">ordered set</a> <var>set</var>, given <var>item</var> and <var>replacement</var>: if <var>set</var> <a data-link-type="dfn" href="#list-contain" id="ref-for-list-contain⑦">contains</a> <var>item</var> or <var>replacement</var>, then replace the first instance of either with <var>replacement</var> and <a data-link-type="dfn" href="#list-remove" id="ref-for-list-remove⑦">remove</a> all other instances. </p> <p class="example" id="example-set-replace"><a class="self-link" href="#example-set-replace"></a><a data-link-type="dfn" href="#set-replace" id="ref-for-set-replace②">Replacing</a> "a" with "c" within the <a data-link-type="dfn" href="#ordered-set" id="ref-for-ordered-set①⓪">ordered set</a> « "a", "b", "c" » gives « "c", "b" ». Within « "c", "b", "a" » it gives « "c", "b" » as well. </p> <p>An <a data-link-type="dfn" href="#ordered-set" id="ref-for-ordered-set①①">ordered set</a> <var>set</var> is a <dfn class="dfn-paneled" data-dfn-for="set" data-dfn-type="dfn" data-export id="set-subset">subset</dfn> of another <a data-link-type="dfn" href="#ordered-set" id="ref-for-ordered-set①②">ordered set</a> <var>superset</var> (and conversely, <var>superset</var> is a <dfn class="dfn-paneled" data-dfn-for="set" data-dfn-type="dfn" data-export id="set-superset">superset</dfn> of <var>set</var>) if, <a data-link-type="dfn" href="#list-iterate" id="ref-for-list-iterate①①">for each</a> <var>item</var> of <var>set</var>, <var>superset</var> <a data-link-type="dfn" href="#list-contain" id="ref-for-list-contain⑧">contains</a> <var>item</var>. </p> <p class="note" role="note">This implies that an <a data-link-type="dfn" href="#ordered-set" id="ref-for-ordered-set①③">ordered set</a> is both a <a data-link-type="dfn" href="#set-subset" id="ref-for-set-subset">subset</a> and a <a data-link-type="dfn" href="#set-superset" id="ref-for-set-superset">superset</a> of itself. </p> <p>The <dfn class="dfn-paneled" data-dfn-for="set" data-dfn-type="dfn" data-export id="set-intersection">intersection</dfn> of <a data-link-type="dfn" href="#ordered-set" id="ref-for-ordered-set①④">ordered sets</a> <var>A</var> and <var>B</var>, is the result of creating a new <a data-link-type="dfn" href="#ordered-set" id="ref-for-ordered-set①⑤">ordered set</a> <var>set</var> and, <a data-link-type="dfn" href="#list-iterate" id="ref-for-list-iterate①②">for each</a> <var>item</var> of <var>A</var>, if <var>B</var> <a data-link-type="dfn" href="#list-contain" id="ref-for-list-contain⑨">contains</a> <var>item</var>, <a data-link-type="dfn" href="#set-append" id="ref-for-set-append②">appending</a> <var>item</var> to <var>set</var>. </p> <p>The <dfn class="dfn-paneled" data-dfn-for="set" data-dfn-type="dfn" data-export id="set-union">union</dfn> of <a data-link-type="dfn" href="#ordered-set" id="ref-for-ordered-set①⑥">ordered sets</a> <var>A</var> and <var>B</var>, is the result of <a data-link-type="dfn" href="#list-clone" id="ref-for-list-clone①">cloning</a> <var>A</var> as <var>set</var> and, <a data-link-type="dfn" href="#list-iterate" id="ref-for-list-iterate①③">for each</a> <var>item</var> of <var>B</var>, <a data-link-type="dfn" href="#set-append" id="ref-for-set-append③">appending</a> <var>item</var> to <var>set</var>. </p> <hr> <p><dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-lt="the range|the inclusive range" id="the-range">The range</dfn> <var>n</var> to <var>m</var>, inclusive, creates a new <a data-link-type="dfn" href="#ordered-set" id="ref-for-ordered-set①⑦">ordered set</a> containing all of the integers from <var>n</var> up to and including <var>m</var> in consecutively increasing order, as long as <var>m</var> is greater than or equal to <var>n</var>. </p> <p><dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-lt="the exclusive range" id="the-exclusive-range">The range</dfn> <var>n</var> to <var>m</var>, exclusive, creates a new <a data-link-type="dfn" href="#ordered-set" id="ref-for-ordered-set①⑧">ordered set</a> containing all of the integers from <var>n</var> up to and including <var>m</var> − 1 in consecutively increasing order, as long as <var>m</var> is greater than <var>n</var>. If <var>m</var> equals <var>n</var>, then it creates an empty <a data-link-type="dfn" href="#ordered-set" id="ref-for-ordered-set①⑨">ordered set</a>. </p> <p class="example" id="example-the-range"><a class="self-link" href="#example-the-range"></a><a data-link-type="dfn" href="#list-iterate" id="ref-for-list-iterate①④">For each</a> <var>n</var> of <a data-link-type="dfn" href="#the-range" id="ref-for-the-range">the range</a> 1 to 4, inclusive, … </p> <h3 class="heading settled" data-level="5.2" id="maps"><span class="secno">5.2. </span><span class="content">Maps</span><a class="self-link" href="#maps"></a></h3> <p>An <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-lt="ordered map|map" id="ordered-map">ordered map</dfn>, or sometimes just "map", is a specification type consisting of a finite ordered sequence of <a data-link-type="dfn" href="#tuple" id="ref-for-tuple③">tuples</a>, each consisting of a <dfn class="dfn-paneled" data-dfn-for="map" data-dfn-type="dfn" data-export id="map-key">key</dfn> and a <dfn class="dfn-paneled" data-dfn-for="map" data-dfn-type="dfn" data-export id="map-value">value</dfn>, with no key appearing twice. Each such tuple is called an <dfn class="dfn-paneled" data-dfn-for="map" data-dfn-type="dfn" data-export id="map-entry">entry</dfn>. </p> <p class="note" role="note">As with <a data-link-type="dfn" href="#ordered-set" id="ref-for-ordered-set②⓪">ordered sets</a>, by default we assume that maps need to be ordered for interoperability among implementations. </p> <p>A literal syntax can be used to express <a data-link-type="dfn" href="#ordered-map" id="ref-for-ordered-map①">ordered maps</a>, by surrounding the ordered map with «[ ]» characters, denoting each of its <a data-link-type="dfn" href="#map-entry" id="ref-for-map-entry">entries</a> as <var>key</var> → <var>value</var>, and separating its entries with a comma. </p> <p class="example" id="example-map-notation"><a class="self-link" href="#example-map-notation"></a>Let <var>example</var> be the <a data-link-type="dfn" href="#ordered-map" id="ref-for-ordered-map②">ordered map</a> «[ "<code>a</code>" → `<code>x</code>`, "<code>b</code>" → `<code>y</code>` ]». Then <var>example</var>["<code>a</code>"] is the <a data-link-type="dfn" href="#byte-sequence" id="ref-for-byte-sequence①⑧">byte sequence</a> `<code>x</code>`. </p> <hr> <p>To <dfn class="dfn-paneled" data-dfn-for="map" data-dfn-type="dfn" data-export data-lt="get|get the value" id="map-get">get the value of an entry</dfn> in an <a data-link-type="dfn" href="#ordered-map" id="ref-for-ordered-map③">ordered map</a> <var>map</var> given a <a data-link-type="dfn" href="#map-key" id="ref-for-map-key">key</a> <var>key</var>: </p> <ol> <li> <p>Assert: <var>map</var> <a data-link-type="dfn" href="#map-exists" id="ref-for-map-exists">contains</a> <var>key</var>. </p> <li> <p>Return the <a data-link-type="dfn" href="#map-value" id="ref-for-map-value">value</a> of the <a data-link-type="dfn" href="#map-entry" id="ref-for-map-entry①">entry</a> in <var>map</var> whose <a data-link-type="dfn" href="#map-key" id="ref-for-map-key①">key</a> is <var>key</var>. </p> </ol> <p>We can also denote <a data-link-type="dfn" href="#map-get" id="ref-for-map-get">getting the value of an entry</a> using an indexing syntax, by providing a <a data-link-type="dfn" href="#map-key" id="ref-for-map-key②">key</a> inside square brackets directly following a <a data-link-type="dfn" href="#ordered-map" id="ref-for-ordered-map④">map</a>. </p> <p class="example" id="example-map-get"><a class="self-link" href="#example-map-get"></a>If <var>map</var>["<code>test</code>"] <a data-link-type="dfn" href="#map-exists" id="ref-for-map-exists①">exists</a>, then return <var>map</var>["<code>test</code>"]. </p> <p>To <dfn class="dfn-paneled" data-dfn-for="map" data-dfn-type="dfn" data-export data-lt="set|set the value" id="map-set">set the value of an entry</dfn> in an <a data-link-type="dfn" href="#ordered-map" id="ref-for-ordered-map⑤">ordered map</a> to a given <a data-link-type="dfn" href="#map-value" id="ref-for-map-value①">value</a> is to update the value of any existing <a data-link-type="dfn" href="#map-entry" id="ref-for-map-entry②">entry</a> if the map <a data-link-type="dfn" href="#map-exists" id="ref-for-map-exists②">contains</a> an entry with the given <a data-link-type="dfn" href="#map-key" id="ref-for-map-key③">key</a>, or if none such exists, to add a new entry with the given key/value to the end of the map. We can also denote this by saying, for an <a data-link-type="dfn" href="#ordered-map" id="ref-for-ordered-map⑥">ordered map</a> <var>map</var>, key <var>key</var>, and value <var>value</var>, "<a data-link-type="dfn" href="#map-set" id="ref-for-map-set">set</a> <var>map</var>[<var>key</var>] to <var>value</var>". </p> <p>To <dfn class="dfn-paneled" data-dfn-for="map" data-dfn-type="dfn" data-export data-lt="remove" id="map-remove">remove an entry</dfn> from an <a data-link-type="dfn" href="#ordered-map" id="ref-for-ordered-map⑦">ordered map</a> is to remove all <a data-link-type="dfn" href="#map-entry" id="ref-for-map-entry③">entries</a> from the map that match a given condition, or do nothing if none do. If the condition is having a certain <a data-link-type="dfn" href="#map-key" id="ref-for-map-key④">key</a>, then we can also denote this by saying, for an <a data-link-type="dfn" href="#ordered-map" id="ref-for-ordered-map⑧">ordered map</a> <var>map</var> and key <var>key</var>, "<a data-link-type="dfn" href="#map-remove" id="ref-for-map-remove">remove</a> <var>map</var>[<var>key</var>]". </p> <p>To <dfn class="dfn-paneled" data-dfn-for="map" data-dfn-type="dfn" data-export id="map-clear">clear</dfn> an <a data-link-type="dfn" href="#ordered-map" id="ref-for-ordered-map⑨">ordered map</a> is to remove all <a data-link-type="dfn" href="#map-entry" id="ref-for-map-entry④">entries</a> from the map. </p> <p>An <a data-link-type="dfn" href="#ordered-map" id="ref-for-ordered-map①⓪">ordered map</a> <dfn class="dfn-paneled" data-dfn-for="map" data-dfn-type="dfn" data-export data-lt="exist|contain" id="map-exists">contains an <a data-link-type="dfn" href="#map-entry" id="ref-for-map-entry⑤">entry</a> with a given key</dfn> if there exists an entry with that <a data-link-type="dfn" href="#map-key" id="ref-for-map-key⑤">key</a>. We can also denote this by saying that, for an <a data-link-type="dfn" href="#ordered-map" id="ref-for-ordered-map①①">ordered map</a> <var>map</var> and key <var>key</var>, "<var>map</var>[<var>key</var>] <a data-link-type="dfn" href="#map-exists" id="ref-for-map-exists③">exists</a>". </p> <p>To <dfn class="dfn-paneled" data-dfn-for="map" data-dfn-type="dfn" data-export data-lt="getting the keys|get the keys|keys" id="map-getting-the-keys">get the keys</dfn> of an <a data-link-type="dfn" href="#ordered-map" id="ref-for-ordered-map①②">ordered map</a>, return a new <a data-link-type="dfn" href="#ordered-set" id="ref-for-ordered-set②①">ordered set</a> whose <a data-link-type="dfn" href="#list-item" id="ref-for-list-item②④">items</a> are each of the <a data-link-type="dfn" href="#map-getting-the-keys" id="ref-for-map-getting-the-keys">keys</a> in the map’s <a data-link-type="dfn" href="#map-entry" id="ref-for-map-entry⑥">entries</a>. </p> <p>To <dfn class="dfn-paneled" data-dfn-for="map" data-dfn-type="dfn" data-export data-lt="getting the values|get the values|values" id="map-getting-the-values">get the values</dfn> of an <a data-link-type="dfn" href="#ordered-map" id="ref-for-ordered-map①③">ordered map</a>, return a new <a data-link-type="dfn" href="#list" id="ref-for-list⑤④">list</a> whose <a data-link-type="dfn" href="#list-item" id="ref-for-list-item②⑤">items</a> are each of the <a data-link-type="dfn" href="#map-getting-the-values" id="ref-for-map-getting-the-values">values</a> in the map’s <a data-link-type="dfn" href="#map-entry" id="ref-for-map-entry⑦">entries</a>. </p> <p>An <a data-link-type="dfn" href="#ordered-map" id="ref-for-ordered-map①④">ordered map</a>’s <dfn class="dfn-paneled" data-dfn-for="map" data-dfn-type="dfn" data-export id="map-size">size</dfn> is the <a data-link-type="dfn" href="#list-size" id="ref-for-list-size⑥">size</a> of the result of running <a data-link-type="dfn" href="#map-getting-the-keys" id="ref-for-map-getting-the-keys①">get the keys</a> on the map. </p> <p>An <a data-link-type="dfn" href="#ordered-map" id="ref-for-ordered-map①⑤">ordered map</a> <dfn class="dfn-paneled" data-dfn-for="map" data-dfn-type="dfn" data-export data-lt="is empty|is not empty" id="map-is-empty">is empty</dfn> if its <a data-link-type="dfn" href="#map-size" id="ref-for-map-size">size</a> is zero. </p> <p>To <dfn class="dfn-paneled" data-dfn-for="map" data-dfn-type="dfn" data-export data-lt="iterate|for each" id="map-iterate">iterate</dfn> over an <a data-link-type="dfn" href="#ordered-map" id="ref-for-ordered-map①⑥">ordered map</a>, performing a set of steps on each <a data-link-type="dfn" href="#map-entry" id="ref-for-map-entry⑧">entry</a> in order, use phrasing of the form "<a data-link-type="dfn" href="#map-iterate" id="ref-for-map-iterate①">For each</a> <var>key</var> → <var>value</var> of <var>map</var>", and then operate on <var>key</var> and <var>value</var> in the subsequent prose. </p> <p>To <dfn class="dfn-paneled" data-dfn-for="map" data-dfn-type="dfn" data-export id="map-clone">clone</dfn> an <a data-link-type="dfn" href="#ordered-map" id="ref-for-ordered-map①⑦">ordered map</a> <var>map</var> is to create a new <a data-link-type="dfn" href="#ordered-map" id="ref-for-ordered-map①⑧">ordered map</a> <var>clone</var>, and, <a data-link-type="dfn" href="#map-iterate" id="ref-for-map-iterate②">for each</a> <var>key</var> → <var>value</var> of <var>map</var>, <a data-link-type="dfn" href="#map-set" id="ref-for-map-set①">set</a> <var>clone</var>[<var>key</var>] to <var>value</var>. </p> <p class="note" role="note">This is a "shallow clone", as the <a data-link-type="dfn" href="#map-getting-the-keys" id="ref-for-map-getting-the-keys②">keys</a> and <a data-link-type="dfn" href="#map-getting-the-values" id="ref-for-map-getting-the-values①">values</a> themselves are not cloned in any way. </p> <p class="example" id="example-map-clone"><a class="self-link" href="#example-map-clone"></a>Let <var>original</var> be the <a data-link-type="dfn" href="#ordered-map" id="ref-for-ordered-map①⑨">ordered map</a> «[ "<code>a</code>" → «1, 2, 3», "<code>b</code>" → «» ]». <a data-link-type="dfn" href="#list-clone" id="ref-for-list-clone②">Cloning</a> <var>original</var> creates a new <a data-link-type="dfn" href="#ordered-map" id="ref-for-ordered-map②⓪">ordered map</a> <var>clone</var>, so that <a data-link-type="dfn" href="#map-set" id="ref-for-map-set②">setting</a> <var>clone</var>["<code>a</code>"] to «-1, -2, -3» gives «[ "<code>a</code>" → «-1, -2, -3», "<code>b</code>" → «» ]» and leaves <var>original</var> unchanged. However, <a data-link-type="dfn" href="#list-append" id="ref-for-list-append①⑨">appending</a> 4 to <var>clone</var>["<code>b</code>"] will modify the corresponding <a data-link-type="dfn" href="#map-value" id="ref-for-map-value②">value</a> in both <var>clone</var> and <var>original</var>, as they both point to the same <a data-link-type="dfn" href="#list" id="ref-for-list⑤⑤">list</a>. </p> <p>To <dfn class="dfn-paneled" data-dfn-for="map" data-dfn-type="dfn" data-export data-lt="sort in ascending order|sorting in ascending order|sort|sorting" id="map-sort-in-ascending-order">sort in ascending order</dfn> a <a data-link-type="dfn" href="#ordered-map" id="ref-for-ordered-map②①">map</a> <var>map</var>, with a less than algorithm <var>lessThanAlgo</var>, is to create a new <a data-link-type="dfn" href="#ordered-map" id="ref-for-ordered-map②②">map</a> <var>sorted</var>, containing the same <a data-link-type="dfn" href="#map-entry" id="ref-for-map-entry⑨">entries</a> as <var>map</var> but sorted so that according to <var>lessThanAlgo</var>, each entry is less than the one following it, if any. For entries that sort the same (i.e., for which <var>lessThanAlgo</var> returns false for both comparisons), their relative order in <var>sorted</var> must be the same as it was in <var>map</var>. </p> <p>To <dfn class="dfn-paneled" data-dfn-for="map" data-dfn-type="dfn" data-export data-lt="sort in descending order|sorting in descending order" id="map-sort-in-descending-order">sort in descending order</dfn> a <a data-link-type="dfn" href="#ordered-map" id="ref-for-ordered-map②③">map</a> <var>map</var>, with a less than algorithm <var>lessThanAlgo</var>, is to create a new <a data-link-type="dfn" href="#ordered-map" id="ref-for-ordered-map②④">map</a> <var>sorted</var>, containing the same <a data-link-type="dfn" href="#map-entry" id="ref-for-map-entry①⓪">entries</a> as <var>map</var> but sorted so that according to <var>lessThanAlgo</var>, each entry is less than the one preceding it, if any. For entries that sort the same (i.e., for which <var>lessThanAlgo</var> returns false for both comparisons), their relative order in <var>sorted</var> must be the same as it was in <var>map</var>. </p> <h3 class="heading settled" data-level="5.3" id="structs"><span class="secno">5.3. </span><span class="content">Structs</span><a class="self-link" href="#structs"></a></h3> <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="struct">struct</dfn> is a specification type consisting of a finite set of <dfn class="dfn-paneled" data-dfn-for="struct,tuple" data-dfn-type="dfn" data-export data-lt="item" id="struct-item">items</dfn>, each of which has a unique and immutable <dfn class="dfn-paneled" data-dfn-for="struct,tuple" data-dfn-type="dfn" data-export id="struct-name">name</dfn>. An <a data-link-type="dfn" href="#struct-item" id="ref-for-struct-item⑤">item</a> holds a value of a defined type. </p> <div class="example" id="example-struct"> <a class="self-link" href="#example-struct"></a> <p>An <dfn data-var-ignore>email</dfn> is an example <a data-link-type="dfn" href="#struct" id="ref-for-struct①">struct</a> consisting of a <dfn data-var-ignore>local part</dfn> (a string) and a <dfn data-var-ignore>host</dfn> (a <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-host" id="ref-for-concept-host">host</a>). </p> <p>A nonsense algorithm might use this definition as follows: </p> <ol> <li>Let <var>email</var> be an email whose local part is "<code>hostmaster</code>" and host is <code>infra.example</code>. <li>… </ol> </div> <h4 class="heading settled" data-level="5.3.1" id="tuples"><span class="secno">5.3.1. </span><span class="content">Tuples</span><a class="self-link" href="#tuples"></a></h4> <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="tuple">tuple</dfn> is a <a data-link-type="dfn" href="#struct" id="ref-for-struct②">struct</a> whose <a data-link-type="dfn" href="#struct-item" id="ref-for-struct-item⑥">items</a> are ordered. For notational convenience, a literal syntax can be used to express <a data-link-type="dfn" href="#tuple" id="ref-for-tuple④">tuples</a>, by surrounding the tuple with parenthesis and separating its <a data-link-type="dfn" href="#struct-item" id="ref-for-struct-item⑦">items</a> with a comma. To use this notation, the <a data-link-type="dfn" href="#struct-name" id="ref-for-struct-name①">names</a> need to be clear from context. This can be done by preceding the first instance with the name given to the <a data-link-type="dfn" href="#tuple" id="ref-for-tuple⑤">tuple</a>. An indexing syntax can be used by providing a zero-based index into a <a data-link-type="dfn" href="#tuple" id="ref-for-tuple⑥">tuple</a> inside square brackets. The index cannot be out-of-bounds. </p> <div class="example" id="example-tuple"> <a class="self-link" href="#example-tuple"></a> <p>A <dfn data-var-ignore>status</dfn> is an example <a data-link-type="dfn" href="#tuple" id="ref-for-tuple⑦">tuple</a> consisting of a <dfn data-var-ignore>code</dfn> (a number) and <dfn data-var-ignore>text</dfn> (a byte sequence). </p> <p>A nonsense algorithm that manipulates status tuples for the purpose of demonstrating their usage is then:</p> <ol> <li>Let <var>statusInstance</var> be the status (200, `<code>OK</code>`). <li>Set <var>statusInstance</var> to (301, `<code>FOO BAR</code>`). <li>If <var>statusInstance</var>’s code is 404, then … </ol> <p>The last step could also be written as "If <var>statusInstance</var>[0] is 404, then …". This might be preferable if the <a data-link-type="dfn" href="#tuple" id="ref-for-tuple⑧">tuple</a> <a data-link-type="dfn" href="#struct-name" id="ref-for-struct-name②">names</a> do not have explicit definitions. </p> </div> <p class="note" role="note">It is intentional that not all <a data-link-type="dfn" href="#struct" id="ref-for-struct③">structs</a> are <a data-link-type="dfn" href="#tuple" id="ref-for-tuple⑨">tuples</a>. Documents using the Infra Standard might need the flexibility to add new <a data-link-type="dfn" href="#struct-name" id="ref-for-struct-name③">names</a> to their struct without breaking literal syntax used by their dependencies. In that case a tuple is not appropriate. </p> <h2 class="heading settled" data-level="6" id="json"><span class="secno">6. </span><span class="content">JSON</span><a class="self-link" href="#json"></a></h2> <p class="note" role="note">The conventions used in the algorithms in this section are those of the JavaScript specification. <a data-link-type="biblio" href="#biblio-ecma-262" title="ECMAScript Language Specification">[ECMA-262]</a> </p> <div class="algorithm" data-algorithm="parse a JSON string to a JavaScript value"> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="parse-a-json-string-to-a-javascript-value">parse a JSON string to a JavaScript value</dfn>, given a <a data-link-type="dfn" href="#string" id="ref-for-string⑦⓪">string</a> <var>string</var>: </p> <ol> <li> <p>Return ? <a data-link-type="abstract-op" href="https://tc39.github.io/ecma262/#sec-call" id="ref-for-sec-call">Call</a>(<a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-json.parse" id="ref-for-sec-json.parse">%JSON.parse%</a>, undefined, « <var>string</var> »). </p> </ol> </div> <div class="algorithm" data-algorithm="parse JSON bytes to a JavaScript value"> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-lt="parse JSON bytes to a JavaScript value|parse JSON from bytes" id="parse-json-bytes-to-a-javascript-value">parse JSON bytes to a JavaScript value</dfn>, given a <a data-link-type="dfn" href="#byte-sequence" id="ref-for-byte-sequence①⑨">byte sequence</a> <var>bytes</var>: </p> <ol> <li> <p>Let <var>string</var> be the result of running <a data-link-type="dfn" href="https://encoding.spec.whatwg.org/#utf-8-decode" id="ref-for-utf-8-decode③">UTF-8 decode</a> on <var>bytes</var>. <a data-link-type="biblio" href="#biblio-encoding" title="Encoding Standard">[ENCODING]</a> </p> <li> <p>Return the result of <a data-link-type="dfn" href="#parse-a-json-string-to-a-javascript-value" id="ref-for-parse-a-json-string-to-a-javascript-value">parsing a JSON string to a JavaScript value</a> given <var>string</var>. </p> </ol> </div> <div class="algorithm" data-algorithm="serialize a JavaScript value to a JSON string"> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="serialize-a-javascript-value-to-a-json-string">serialize a JavaScript value to a JSON string</dfn>, given a JavaScript value <var>value</var>: </p> <ol> <li> <p>Let <var>result</var> be ? <a data-link-type="abstract-op" href="https://tc39.github.io/ecma262/#sec-call" id="ref-for-sec-call①">Call</a>(<a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-json.stringify" id="ref-for-sec-json.stringify">%JSON.stringify%</a>, undefined, « <var>value</var> »). </p> <p class="note" role="note">Since no additional arguments are passed to <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-json.stringify" id="ref-for-sec-json.stringify①">%JSON.stringify%</a>, the resulting string will have no whitespace inserted. </p> <li> <p>If <var>result</var> is undefined, then throw a <code class="idl"><a data-link-type="idl" href="https://webidl.spec.whatwg.org/#exceptiondef-typeerror" id="ref-for-exceptiondef-typeerror①">TypeError</a></code>. </p> <p class="note" role="note">This can happen if <var>value</var> does not have a JSON representation, e.g., if it is undefined or a function. </p> <li> <p><a data-link-type="dfn" href="#assert" id="ref-for-assert①④">Assert</a>: <var>result</var> is a <a data-link-type="dfn" href="#string" id="ref-for-string⑦①">string</a>. </p> <li> <p>Return <var>result</var>. </p> </ol> </div> <div class="algorithm" data-algorithm="serialize a JavaScript value to JSON bytes"> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-lt="serialize a JavaScript value to JSON bytes|serialize JSON to bytes" id="serialize-a-javascript-value-to-json-bytes">serialize a JavaScript value to JSON bytes</dfn>, given a JavaScript value <var>value</var>: </p> <ol> <li> <p>Let <var>string</var> be the result of <a data-link-type="dfn" href="#serialize-a-javascript-value-to-a-json-string" id="ref-for-serialize-a-javascript-value-to-a-json-string">serializing a JavaScript value to a JSON string</a> given <var>value</var>. </p> <li> <p>Return the result of running <a data-link-type="dfn" href="https://encoding.spec.whatwg.org/#utf-8-encode" id="ref-for-utf-8-encode③">UTF-8 encode</a> on <var>string</var>. <a data-link-type="biblio" href="#biblio-encoding" title="Encoding Standard">[ENCODING]</a> </p> </ol> </div> <hr> <p>The above operations operate on JavaScript values directly; in particular, this means that the involved objects or arrays are tied to a particular <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#realm" id="ref-for-realm">JavaScript realm</a>. In standards, it is often more convenient to convert between JSON and realm-independent <a data-link-type="dfn" href="#ordered-map" id="ref-for-ordered-map②⑤">maps</a>, <a data-link-type="dfn" href="#list" id="ref-for-list⑤⑥">lists</a>, <a data-link-type="dfn" href="#string" id="ref-for-string⑦②">strings</a>, <a data-link-type="dfn" href="#boolean" id="ref-for-boolean②">booleans</a>, numbers, and nulls. </p> <div class="algorithm" data-algorithm="parse a JSON string to an Infra value"> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-lt="parse a JSON string to an Infra value|parse JSON into Infra values" id="parse-a-json-string-to-an-infra-value">parse a JSON string to an Infra value</dfn>, given a <a data-link-type="dfn" href="#string" id="ref-for-string⑦③">string</a> <var>string</var>: </p> <ol> <li> <p>Let <var>jsValue</var> be ? <a data-link-type="abstract-op" href="https://tc39.github.io/ecma262/#sec-call" id="ref-for-sec-call②">Call</a>(<a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-json.parse" id="ref-for-sec-json.parse①">%JSON.parse%</a>, undefined, « <var>string</var> »). </p> <li> <p>Return the result of <a data-link-type="dfn" href="#convert-a-json-derived-javascript-value-to-an-infra-value" id="ref-for-convert-a-json-derived-javascript-value-to-an-infra-value">converting a JSON-derived JavaScript value to an Infra value</a>, given <var>jsValue</var>. </p> </ol> </div> <div class="algorithm" data-algorithm="parse JSON bytes to an Infra value"> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="parse-json-bytes-to-an-infra-value">parse JSON bytes to an Infra value</dfn>, given a <a data-link-type="dfn" href="#byte-sequence" id="ref-for-byte-sequence②⓪">byte sequence</a> <var>bytes</var>: </p> <ol> <li> <p>Let <var>string</var> be the result of running <a data-link-type="dfn" href="https://encoding.spec.whatwg.org/#utf-8-decode" id="ref-for-utf-8-decode④">UTF-8 decode</a> on <var>bytes</var>. <a data-link-type="biblio" href="#biblio-encoding" title="Encoding Standard">[ENCODING]</a> </p> <li> <p>Return the result of <a data-link-type="dfn" href="#parse-a-json-string-to-an-infra-value" id="ref-for-parse-a-json-string-to-an-infra-value">parsing a JSON string to an Infra value</a> given <var>string</var>. </p> </ol> </div> <div class="algorithm" data-algorithm="convert a JSON-derived JavaScript value to an Infra value"> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="convert-a-json-derived-javascript-value-to-an-infra-value">convert a JSON-derived JavaScript value to an Infra value</dfn>, given a JavaScript value <var>jsValue</var>: </p> <ol> <li> <p>If <var>jsValue</var> is <emu-val>null</emu-val>, <var>jsValue</var> <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-ecmascript-language-types-boolean-type" id="ref-for-sec-ecmascript-language-types-boolean-type">is a Boolean</a>, <var>jsValue</var> <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-ecmascript-language-types-string-type" id="ref-for-sec-ecmascript-language-types-string-type①">is a String</a>, or <var>jsValue</var> <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-ecmascript-language-types-number-type" id="ref-for-sec-ecmascript-language-types-number-type">is a Number</a>, then return <var>jsValue</var>. </p> <li> <p>If <a data-link-type="abstract-op" href="https://tc39.github.io/ecma262/#sec-isarray" id="ref-for-sec-isarray">IsArray</a>(<var>jsValue</var>) is true, then: </p> <ol> <li> <p>Let <var>result</var> be an empty <a data-link-type="dfn" href="#list" id="ref-for-list⑤⑦">list</a>. </p> <li> <p>Let <var>length</var> be ! <a data-link-type="abstract-op" href="https://tc39.github.io/ecma262/#sec-tolength" id="ref-for-sec-tolength">ToLength</a>(! <a data-link-type="abstract-op" href="https://tc39.github.io/ecma262/#sec-get-o-p" id="ref-for-sec-get-o-p">Get</a>(<var>jsValue</var>, "<code>length</code>")). </p> <li> <p><a data-link-type="dfn" href="#list-iterate" id="ref-for-list-iterate①⑤">For each</a> <var>index</var> of <a data-link-type="dfn" href="#the-range" id="ref-for-the-range①">the range</a> 0 to <var>length</var> − 1, inclusive: </p> <ol> <li> <p>Let <var>indexName</var> be ! <a data-link-type="abstract-op" href="https://tc39.github.io/ecma262/#sec-tostring" id="ref-for-sec-tostring">ToString</a>(<var>index</var>). </p> <li> <p>Let <var>jsValueAtIndex</var> be ! <a data-link-type="abstract-op" href="https://tc39.github.io/ecma262/#sec-get-o-p" id="ref-for-sec-get-o-p①">Get</a>(<var>jsValue</var>, <var>indexName</var>). </p> <li> <p>Let <var>infraValueAtIndex</var> be the result of <a data-link-type="dfn" href="#convert-a-json-derived-javascript-value-to-an-infra-value" id="ref-for-convert-a-json-derived-javascript-value-to-an-infra-value①">converting a JSON-derived JavaScript value to an Infra value</a>, given <var>jsValueAtIndex</var>. </p> <li> <p><a data-link-type="dfn" href="#list-append" id="ref-for-list-append②⓪">Append</a> <var>infraValueAtIndex</var> to <var>result</var>. </p> </ol> <li> <p>Return <var>result</var>. </p> </ol> <li> <p>Let <var>result</var> be an empty <a data-link-type="dfn" href="#ordered-map" id="ref-for-ordered-map②⑥">ordered map</a>. </p> <li> <p><a data-link-type="dfn" href="#list-iterate" id="ref-for-list-iterate①⑥">For each</a> <var>key</var> of ! <var>jsValue</var>.[[OwnPropertyKeys]](): </p> <ol> <li> <p>Let <var>jsValueAtKey</var> be ! <a data-link-type="abstract-op" href="https://tc39.github.io/ecma262/#sec-get-o-p" id="ref-for-sec-get-o-p②">Get</a>(<var>jsValue</var>, <var>key</var>). </p> <li> <p>Let <var>infraValueAtKey</var> be the result of <a data-link-type="dfn" href="#convert-a-json-derived-javascript-value-to-an-infra-value" id="ref-for-convert-a-json-derived-javascript-value-to-an-infra-value②">converting a JSON-derived JavaScript value to an Infra value</a>, given <var>jsValueAtKey</var>. </p> <li> <p><a data-link-type="dfn" href="#map-set" id="ref-for-map-set③">Set</a> <var>result</var>[<var>key</var>] to <var>infraValueAtKey</var>. </p> </ol> <li> <p>Return <var>result</var>. </p> </ol> </div> <div class="algorithm" data-algorithm="serialize an Infra value to a JSON string"> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="serialize-an-infra-value-to-a-json-string">serialize an Infra value to a JSON string</dfn>, given a <a data-link-type="dfn" href="#string" id="ref-for-string⑦④">string</a>, <a data-link-type="dfn" href="#boolean" id="ref-for-boolean③">boolean</a>, number, null, <a data-link-type="dfn" href="#list" id="ref-for-list⑤⑧">list</a>, or <a data-link-type="dfn" href="#string" id="ref-for-string⑦⑤">string</a>-keyed <a data-link-type="dfn" href="#ordered-map" id="ref-for-ordered-map②⑦">map</a> <var>value</var>: </p> <ol> <li> <p>Let <var>jsValue</var> be the result of <a data-link-type="dfn" href="#convert-an-infra-value-to-a-json-compatible-javascript-value" id="ref-for-convert-an-infra-value-to-a-json-compatible-javascript-value">converting an Infra value to a JSON-compatible JavaScript value</a>, given <var>value</var>. </p> <li> <p>Return ! <a data-link-type="abstract-op" href="https://tc39.github.io/ecma262/#sec-call" id="ref-for-sec-call③">Call</a>(<a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-json.stringify" id="ref-for-sec-json.stringify②">%JSON.stringify%</a>, undefined, « <var>jsValue</var> »). </p> <p class="note" role="note">Since no additional arguments are passed to <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-json.stringify" id="ref-for-sec-json.stringify③">%JSON.stringify%</a>, the resulting string will have no whitespace inserted. </p> </ol> </div> <div class="algorithm" data-algorithm="serialize an Infra value to JSON bytes"> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="serialize-an-infra-value-to-json-bytes">serialize an Infra value to JSON bytes</dfn>, given a <a data-link-type="dfn" href="#string" id="ref-for-string⑦⑥">string</a>, <a data-link-type="dfn" href="#boolean" id="ref-for-boolean④">boolean</a>, number, null, <a data-link-type="dfn" href="#list" id="ref-for-list⑤⑨">list</a>, or <a data-link-type="dfn" href="#string" id="ref-for-string⑦⑦">string</a>-keyed <a data-link-type="dfn" href="#ordered-map" id="ref-for-ordered-map②⑧">map</a> <var>value</var>: </p> <ol> <li> <p>Let <var>string</var> be the result of <a data-link-type="dfn" href="#serialize-an-infra-value-to-a-json-string" id="ref-for-serialize-an-infra-value-to-a-json-string">serializing an Infra value to a JSON string</a>, given <var>value</var>. </p> <li> <p>Return the result of running <a data-link-type="dfn" href="https://encoding.spec.whatwg.org/#utf-8-encode" id="ref-for-utf-8-encode④">UTF-8 encode</a> on <var>string</var>. <a data-link-type="biblio" href="#biblio-encoding" title="Encoding Standard">[ENCODING]</a> </p> </ol> </div> <div class="algorithm" data-algorithm="convert an Infra value to a JSON-compatible JavaScript value"> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="convert-an-infra-value-to-a-json-compatible-javascript-value">convert an Infra value to a JSON-compatible JavaScript value</dfn>, given <var>value</var>: </p> <ol> <li> <p>If <var>value</var> is a <a data-link-type="dfn" href="#string" id="ref-for-string⑦⑧">string</a>, <a data-link-type="dfn" href="#boolean" id="ref-for-boolean⑤">boolean</a>, number, or null, then return <var>value</var>. </p> <li> <p>If <var>value</var> is a <a data-link-type="dfn" href="#list" id="ref-for-list⑥⓪">list</a>, then: </p> <ol> <li> <p>Let <var>jsValue</var> be ! <a data-link-type="abstract-op" href="https://tc39.github.io/ecma262/#sec-arraycreate" id="ref-for-sec-arraycreate">ArrayCreate</a>(0). </p> <li> <p>Let <var>i</var> be 0. </p> <li> <p><a data-link-type="dfn" href="#list-iterate" id="ref-for-list-iterate①⑦">For each</a> <var>listItem</var> of <var>value</var>: </p> <ol> <li> <p>Let <var>listItemJSValue</var> be the result of <a data-link-type="dfn" href="#convert-an-infra-value-to-a-json-compatible-javascript-value" id="ref-for-convert-an-infra-value-to-a-json-compatible-javascript-value①">converting an Infra value to a JSON-compatible JavaScript value</a>, given <var>listItem</var>. </p> <li> <p>Perform ! <a data-link-type="abstract-op" href="https://tc39.github.io/ecma262/#sec-createdatapropertyorthrow" id="ref-for-sec-createdatapropertyorthrow">CreateDataPropertyOrThrow</a>(<var>jsValue</var>, ! <a data-link-type="abstract-op" href="https://tc39.github.io/ecma262/#sec-tostring" id="ref-for-sec-tostring①">ToString</a>(<var>i</var>), <var>listItemJSValue</var>). </p> <li> <p>Set <var>i</var> to <var>i</var> + 1. </p> </ol> <li> <p>Return <var>jsValue</var>. </p> </ol> <li> <p>Assert: <var>value</var> is a <a data-link-type="dfn" href="#ordered-map" id="ref-for-ordered-map②⑨">map</a>. </p> <li> <p>Let <var>jsValue</var> be ! <a data-link-type="abstract-op" href="https://tc39.github.io/ecma262/#sec-ordinaryobjectcreate" id="ref-for-sec-ordinaryobjectcreate">OrdinaryObjectCreate</a>(null). </p> <li> <p><a data-link-type="dfn" href="#list-iterate" id="ref-for-list-iterate①⑧">For each</a> <var>mapKey</var> → <var>mapValue</var> of <var>value</var>: </p> <ol> <li> <p>Assert: <var>mapKey</var> is a <a data-link-type="dfn" href="#string" id="ref-for-string⑦⑨">string</a>. </p> <li> <p>Let <var>mapValueJSValue</var> be the result of <a data-link-type="dfn" href="#convert-an-infra-value-to-a-json-compatible-javascript-value" id="ref-for-convert-an-infra-value-to-a-json-compatible-javascript-value②">converting an Infra value to a JSON-compatible JavaScript value</a>, given <var>mapValue</var>. </p> <li> <p>Perform ! <a data-link-type="abstract-op" href="https://tc39.github.io/ecma262/#sec-createdatapropertyorthrow" id="ref-for-sec-createdatapropertyorthrow①">CreateDataPropertyOrThrow</a>(<var>jsValue</var>, <var>mapKey</var>, <var>mapValueJSValue</var>). </p> </ol> <li> <p>Return <var>jsValue</var>. </p> </ol> <p class="warning">Because it is rarely appropriate to manipulate JavaScript values directly in specifications, prefer using <a data-link-type="dfn" href="#serialize-an-infra-value-to-a-json-string" id="ref-for-serialize-an-infra-value-to-a-json-string①">serialize an Infra value to a JSON string</a> or <a data-link-type="dfn" href="#serialize-an-infra-value-to-json-bytes" id="ref-for-serialize-an-infra-value-to-json-bytes">serialize an Infra value to JSON bytes</a> instead of using this algorithm. Please <a href="https://github.com/whatwg/infra/issues/new">file an issue</a> to discuss your use case if you believe you need to use <a data-link-type="dfn" href="#convert-an-infra-value-to-a-json-compatible-javascript-value" id="ref-for-convert-an-infra-value-to-a-json-compatible-javascript-value③">convert an Infra value to a JSON-compatible JavaScript value</a>. </p> </div> <h2 class="heading settled" data-level="7" id="forgiving-base64"><span class="secno">7. </span><span class="content">Forgiving base64</span><a class="self-link" href="#forgiving-base64"></a></h2> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="forgiving-base64-encode">forgiving-base64 encode</dfn> given a <a data-link-type="dfn" href="#byte-sequence" id="ref-for-byte-sequence②①">byte sequence</a> <var>data</var>, apply the base64 algorithm defined in section 4 of RFC 4648 to <var>data</var> and return the result. <a data-link-type="biblio" href="#biblio-rfc4648" title="The Base16, Base32, and Base64 Data Encodings">[RFC4648]</a> </p> <p class="note no-backref" role="note">This is named <a data-link-type="dfn" href="#forgiving-base64-encode" id="ref-for-forgiving-base64-encode">forgiving-base64 encode</a> for symmetry with <a data-link-type="dfn" href="#forgiving-base64-decode" id="ref-for-forgiving-base64-decode">forgiving-base64 decode</a>, which is different from the RFC as it defines error handling for certain inputs. </p> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="forgiving-base64-decode">forgiving-base64 decode</dfn> given a string <var>data</var>, run these steps:</p> <ol> <li> <p>Remove all <a data-link-type="dfn" href="#ascii-whitespace" id="ref-for-ascii-whitespace⑦">ASCII whitespace</a> from <var>data</var>. </p> <li> <p>If <var>data</var>’s <a data-link-type="dfn" href="#string-code-point-length" id="ref-for-string-code-point-length④">code point length</a> divides by 4 leaving no remainder, then: </p> <ol> <li> <p>If <var>data</var> ends with one or two U+003D (=) <a data-link-type="dfn" href="#code-point" id="ref-for-code-point⑤③">code points</a>, then remove them from <var>data</var>. </p> </ol> <li> <p>If <var>data</var>’s <a data-link-type="dfn" href="#string-code-point-length" id="ref-for-string-code-point-length⑤">code point length</a> divides by 4 leaving a remainder of 1, then return failure. </p> <li> <p>If <var>data</var> contains a <a data-link-type="dfn" href="#code-point" id="ref-for-code-point⑤④">code point</a> that is not one of </p> <ul class="brief"> <li>U+002B (+) <li>U+002F (/) <li><a data-link-type="dfn" href="#ascii-alphanumeric" id="ref-for-ascii-alphanumeric">ASCII alphanumeric</a> </ul> <p>then return failure. </p> <li> <p>Let <var>output</var> be an empty <a data-link-type="dfn" href="#byte-sequence" id="ref-for-byte-sequence②②">byte sequence</a>. </p> <li> <p>Let <var>buffer</var> be an empty buffer that can have bits appended to it. </p> <li> <p>Let <var>position</var> be a <a data-link-type="dfn" href="#string-position-variable" id="ref-for-string-position-variable⑤">position variable</a> for <var>data</var>, initially pointing at the start of <var>data</var>. </p> <li> <p>While <var>position</var> does not point past the end of <var>data</var>: </p> <ol> <li> <p>Find the <a data-link-type="dfn" href="#code-point" id="ref-for-code-point⑤⑤">code point</a> pointed to by <var>position</var> in the second column of Table 1: The Base 64 Alphabet of RFC 4648. Let <var>n</var> be the number given in the first cell of the same row. <a data-link-type="biblio" href="#biblio-rfc4648" title="The Base16, Base32, and Base64 Data Encodings">[RFC4648]</a> </p> <li> <p>Append the six bits corresponding to <var>n</var>, most significant bit first, to <var>buffer</var>. </p> <li> <p>If <var>buffer</var> has accumulated 24 bits, interpret them as three 8-bit big-endian numbers. Append three bytes with values equal to those numbers to <var>output</var>, in the same order, and then empty <var>buffer</var>. </p> <li> <p>Advance <var>position</var> by 1. </p> </ol> <li> <p>If <var>buffer</var> is not empty, it contains either 12 or 18 bits. If it contains 12 bits, then discard the last four and interpret the remaining eight as an 8-bit big-endian number. If it contains 18 bits, then discard the last two and interpret the remaining 16 as two 8-bit big-endian numbers. Append the one or two bytes with values equal to those one or two numbers to <var>output</var>, in the same order.</p> <p class="note" role="note">The discarded bits mean that, for instance, "<code>YQ</code>" and "<code>YR</code>" both return `<code>a</code>`. </p> <li> <p>Return <var>output</var>. </p> </ol> <h2 class="heading settled" data-level="8" id="namespaces"><span class="secno">8. </span><span class="content">Namespaces</span><a class="self-link" href="#namespaces"></a></h2> <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="html-namespace">HTML namespace</dfn> is "<code>http://www.w3.org/1999/xhtml</code>". </p> <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="mathml-namespace">MathML namespace</dfn> is "<code>http://www.w3.org/1998/Math/MathML</code>". </p> <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="svg-namespace">SVG namespace</dfn> is "<code>http://www.w3.org/2000/svg</code>". </p> <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="xlink-namespace">XLink namespace</dfn> is "<code>http://www.w3.org/1999/xlink</code>". </p> <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="xml-namespace">XML namespace</dfn> is "<code>http://www.w3.org/XML/1998/namespace</code>". </p> <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="xmlns-namespace">XMLNS namespace</dfn> is "<code>http://www.w3.org/2000/xmlns/</code>". </p> <h2 class="no-num heading settled" id="acknowledgments"><span class="content">Acknowledgments</span><a class="self-link" href="#acknowledgments"></a></h2> <p>Many thanks to Addison Phillips, Andreu Botella, Aryeh Gregor, Ben Kelly, Chris Rebert, Daniel Ehrenberg, Dominic Farolino, Gabriel Pivovarov, Ian Hickson, Jakob Ackermann, Jake Archibald, Jeff Hodges, Jeffrey Yasskin, Jungkee Song, Leonid Vasilyev, Maciej Stachowiak, Malika Aubakirova, Martin Thomson, Michael™ Smith, Mike West, Mike Taylor, Ms2ger, Pavel "Al Arz" Kurochkin, Philip Jägenstedt, Rashaun "Snuggs" Stovall, Sergey Shekyan, Simon Pieters, Tab Atkins, Tobie Langel, triple-underscore, Wolf Lammen, and Xue Fuqiao for being awesome! </p> <p>This standard is written by <a href="https://annevankesteren.nl/" lang="nl">Anne van Kesteren</a> (<a href="https://www.apple.com/">Apple</a>, <a href="mailto:annevk@annevk.nl">annevk@annevk.nl</a>) and <a href="https://domenic.me/">Domenic Denicola</a> (<a href="https://www.google.com/">Google</a>, <a href="mailto:d@domenic.me">d@domenic.me</a>). </p> <h2 class="no-num heading settled" id="ipr"><span class="content">Intellectual property rights</span><a class="self-link" href="#ipr"></a></h2> <p>Copyright © WHATWG (Apple, Google, Mozilla, Microsoft). This work is licensed under a <a href="https://creativecommons.org/licenses/by/4.0/" rel="license">Creative Commons Attribution 4.0 International License</a>. To the extent portions of it are incorporated into source code, such portions in the source code are licensed under the <a href="https://opensource.org/licenses/BSD-3-Clause" rel="license">BSD 3-Clause License</a> instead.</p> <p>This is the Living Standard. Those interested in the patent-review version should view the <a href="/review-drafts/2024-01/">Living Standard Review Draft</a>.</p> </main> <script> "use strict"; if ("serviceWorker" in navigator) { navigator.serviceWorker.register("/service-worker.js"); } </script> <h2 class="no-num no-ref heading settled" id="index"><span class="content">Index</span><a class="self-link" href="#index"></a></h2> <h3 class="no-num no-ref heading settled" id="index-defined-here"><span class="content">Terms defined by this specification</span><a class="self-link" href="#index-defined-here"></a></h3> <ul class="index"> <li><a href="#128-bit-unsigned-integer">128-bit unsigned integer</a><span>, in § 4.3</span> <li><a href="#16-bit-signed-integer">16-bit signed integer</a><span>, in § 4.3</span> <li><a href="#16-bit-unsigned-integer">16-bit unsigned integer</a><span>, in § 4.3</span> <li><a href="#32-bit-signed-integer">32-bit signed integer</a><span>, in § 4.3</span> <li><a href="#32-bit-unsigned-integer">32-bit unsigned integer</a><span>, in § 4.3</span> <li><a href="#64-bit-signed-integer">64-bit signed integer</a><span>, in § 4.3</span> <li><a href="#64-bit-unsigned-integer">64-bit unsigned integer</a><span>, in § 4.3</span> <li><a href="#8-bit-signed-integer">8-bit signed integer</a><span>, in § 4.3</span> <li><a href="#8-bit-unsigned-integer">8-bit unsigned integer</a><span>, in § 4.3</span> <li><a href="#abort-when">abort when</a><span>, in § 3.7</span> <li> append <ul> <li><a href="#list-append">dfn for list</a><span>, in § 5.1</span> <li><a href="#set-append">dfn for set</a><span>, in § 5.1.3</span> </ul> <li><a href="#ascii-alpha">ASCII alpha</a><span>, in § 4.6</span> <li><a href="#ascii-alphanumeric">ASCII alphanumeric</a><span>, in § 4.6</span> <li><a href="#ascii-byte">ASCII byte</a><span>, in § 4.4</span> <li><a href="#ascii-case-insensitive">ASCII case-insensitive</a><span>, in § 4.7</span> <li><a href="#ascii-code-point">ASCII code point</a><span>, in § 4.6</span> <li><a href="#ascii-decode">ASCII decode</a><span>, in § 4.7</span> <li><a href="#ascii-digit">ASCII digit</a><span>, in § 4.6</span> <li><a href="#ascii-encode">ASCII encode</a><span>, in § 4.7</span> <li><a href="#ascii-hex-digit">ASCII hex digit</a><span>, in § 4.6</span> <li><a href="#ascii-lower-alpha">ASCII lower alpha</a><span>, in § 4.6</span> <li><a href="#ascii-lowercase">ASCII lowercase</a><span>, in § 4.7</span> <li><a href="#ascii-lower-hex-digit">ASCII lower hex digit</a><span>, in § 4.6</span> <li><a href="#ascii-string">ASCII string</a><span>, in § 4.7</span> <li><a href="#ascii-tab-or-newline">ASCII tab or newline</a><span>, in § 4.6</span> <li><a href="#ascii-tab-or-newline">ASCII tabs or newlines</a><span>, in § 4.6</span> <li><a href="#ascii-upper-alpha">ASCII upper alpha</a><span>, in § 4.6</span> <li><a href="#ascii-uppercase">ASCII uppercase</a><span>, in § 4.7</span> <li><a href="#ascii-upper-hex-digit">ASCII upper hex digit</a><span>, in § 4.6</span> <li><a href="#ascii-whitespace">ASCII whitespace</a><span>, in § 4.6</span> <li><a href="#assert">Assert</a><span>, in § 3.10</span> <li><a href="#boolean">boolean</a><span>, in § 4.2</span> <li><a href="#iteration-break">break</a><span>, in § 3.9</span> <li><a href="#byte">byte</a><span>, in § 4.4</span> <li><a href="#byte-case-insensitive">byte-case-insensitive</a><span>, in § 4.5</span> <li><a href="#byte-less-than">byte less than</a><span>, in § 4.5</span> <li><a href="#byte-lowercase">byte-lowercase</a><span>, in § 4.5</span> <li><a href="#byte-sequence">byte sequence</a><span>, in § 4.5</span> <li><a href="#byte-uppercase">byte-uppercase</a><span>, in § 4.5</span> <li><a href="#c0-control">C0 control</a><span>, in § 4.6</span> <li><a href="#c0-control-or-space">C0 control or space</a><span>, in § 4.6</span> <li><a href="#c0-control-or-space">C0 controls or spaces</a><span>, in § 4.6</span> <li><a href="#code-point">character</a><span>, in § 4.6</span> <li><a href="#map-clear">clear</a><span>, in § 5.2</span> <li> clone <ul> <li><a href="#list-clone">dfn for list, stack, queue, set</a><span>, in § 5.1</span> <li><a href="#map-clone">dfn for map</a><span>, in § 5.2</span> </ul> <li><a href="#code-point">code point</a><span>, in § 4.6</span> <li><a href="#string-code-point-length">code point length</a><span>, in § 4.7</span> <li><a href="#code-point-substring">code point substring</a><span>, in § 4.7</span> <li><a href="#code-point-substring-by-positions">code point substring by positions</a><span>, in § 4.7</span> <li><a href="#code-point-substring-to-the-end-of-the-string">code point substring to the end of the string</a><span>, in § 4.7</span> <li><a href="#code-unit">code unit</a><span>, in § 4.7</span> <li><a href="#code-unit-less-than">code unit less than</a><span>, in § 4.7</span> <li><a href="#code-unit-prefix">code unit prefix</a><span>, in § 4.7</span> <li><a href="#code-unit-substring">code unit substring</a><span>, in § 4.7</span> <li><a href="#code-unit-substring-by-positions">code unit substring by positions</a><span>, in § 4.7</span> <li><a href="#code-unit-substring-to-the-end-of-the-string">code unit substring to the end of the string</a><span>, in § 4.7</span> <li><a href="#code-unit-suffix">code unit suffix</a><span>, in § 4.7</span> <li><a href="#collect-a-sequence-of-code-points">collect a sequence of code points</a><span>, in § 4.7</span> <li><a href="#collect-a-sequence-of-code-points">collecting a sequence of code points</a><span>, in § 4.7</span> <li><a href="#string-concatenate">concatenate</a><span>, in § 4.7</span> <li><a href="#string-concatenate">concatenation</a><span>, in § 4.7</span> <li> contain <ul> <li><a href="#list-contain">dfn for list, stack, queue, set</a><span>, in § 5.1</span> <li><a href="#map-exists">dfn for map</a><span>, in § 5.2</span> </ul> <li><a href="#iteration-continue">continue</a><span>, in § 3.9</span> <li><a href="#control">control</a><span>, in § 4.6</span> <li><a href="#javascript-string-convert">convert</a><span>, in § 4.7</span> <li><a href="#convert-a-json-derived-javascript-value-to-an-infra-value">convert a JSON-derived JavaScript value to an Infra value</a><span>, in § 6</span> <li><a href="#convert-an-infra-value-to-a-json-compatible-javascript-value">convert an Infra value to a JSON-compatible JavaScript value</a><span>, in § 6</span> <li><a href="#queue-dequeue">dequeue</a><span>, in § 5.1.2</span> <li><a href="#list-empty">empty</a><span>, in § 5.1</span> <li><a href="#string-ends-with">ends with</a><span>, in § 4.7</span> <li><a href="#queue-enqueue">enqueue</a><span>, in § 5.1.2</span> <li><a href="#map-entry">entry</a><span>, in § 5.2</span> <li> exist <ul> <li><a href="#list-contain">dfn for list, stack, queue, set</a><span>, in § 5.1</span> <li><a href="#map-exists">dfn for map</a><span>, in § 5.2</span> </ul> <li><a href="#list-extend">extend</a><span>, in § 5.1</span> <li> for each <ul> <li><a href="#list-iterate">dfn for list, set</a><span>, in § 5.1</span> <li><a href="#map-iterate">dfn for map</a><span>, in § 5.2</span> </ul> <li><a href="#forgiving-base64-decode">forgiving-base64 decode</a><span>, in § 7</span> <li><a href="#forgiving-base64-encode">forgiving-base64 encode</a><span>, in § 7</span> <li><a href="#map-get">get</a><span>, in § 5.2</span> <li><a href="#list-get-the-indices">get the indices</a><span>, in § 5.1</span> <li><a href="#map-getting-the-keys">get the keys</a><span>, in § 5.2</span> <li><a href="#map-get">get the value</a><span>, in § 5.2</span> <li><a href="#map-getting-the-values">get the values</a><span>, in § 5.2</span> <li><a href="#map-getting-the-keys">getting the keys</a><span>, in § 5.2</span> <li><a href="#map-getting-the-values">getting the values</a><span>, in § 5.2</span> <li><a href="#html-namespace">HTML namespace</a><span>, in § 8</span> <li><a href="#string-is">identical to</a><span>, in § 4.7</span> <li><a href="#if-aborted">if aborted</a><span>, in § 3.7</span> <li><a href="#implementation">implementation</a><span>, in § 2.3</span> <li><a href="#implementation-defined">implementation-defined</a><span>, in § 2.3</span> <li><a href="#list-get-the-indices">indices</a><span>, in § 5.1</span> <li><a href="#list-insert">insert</a><span>, in § 5.1</span> <li><a href="#set-intersection">intersection</a><span>, in § 5.1.3</span> <li><a href="#string-is">is</a><span>, in § 4.7</span> <li> is empty <ul> <li><a href="#list-is-empty">dfn for list, stack, queue, set</a><span>, in § 5.1</span> <li><a href="#map-is-empty">dfn for map</a><span>, in § 5.2</span> </ul> <li> is not empty <ul> <li><a href="#list-is-empty">dfn for list, stack, queue, set</a><span>, in § 5.1</span> <li><a href="#map-is-empty">dfn for map</a><span>, in § 5.2</span> </ul> <li><a href="#isomorphic-decode">isomorphic decode</a><span>, in § 4.5</span> <li><a href="#isomorphic-encode">isomorphic encode</a><span>, in § 4.7</span> <li><a href="#isomorphic-string">isomorphic string</a><span>, in § 4.7</span> <li> item <ul> <li><a href="#list-item">dfn for list, stack, queue, set</a><span>, in § 5.1</span> <li><a href="#struct-item">dfn for struct, tuple</a><span>, in § 5.3</span> </ul> <li> iterate <ul> <li><a href="#list-iterate">dfn for list, set</a><span>, in § 5.1</span> <li><a href="#map-iterate">dfn for map</a><span>, in § 5.2</span> </ul> <li><a href="#string">JavaScript string</a><span>, in § 4.7</span> <li><a href="#map-key">key</a><span>, in § 5.2</span> <li><a href="#map-getting-the-keys">keys</a><span>, in § 5.2</span> <li><a href="#leading-surrogate">leading surrogate</a><span>, in § 4.6</span> <li> length <ul> <li><a href="#byte-sequence-length">dfn for byte sequence</a><span>, in § 4.5</span> <li><a href="#string-length">dfn for string, JavaScript string, ASCII string, isomorphic string, scalar value string</a><span>, in § 4.7</span> </ul> <li><a href="#list">list</a><span>, in § 5.1</span> <li><a href="#ordered-map">map</a><span>, in § 5.2</span> <li><a href="#mathml-namespace">MathML namespace</a><span>, in § 8</span> <li><a href="#struct-name">name</a><span>, in § 5.3</span> <li><a href="#noncharacter">noncharacter</a><span>, in § 4.6</span> <li><a href="#normalize-newlines">normalize newlines</a><span>, in § 4.7</span> <li><a href="#ordered-map">ordered map</a><span>, in § 5.2</span> <li><a href="#ordered-set">ordered set</a><span>, in § 5.1.3</span> <li><a href="#parse-a-json-string-to-a-javascript-value">parse a JSON string to a JavaScript value</a><span>, in § 6</span> <li><a href="#parse-a-json-string-to-an-infra-value">parse a JSON string to an Infra value</a><span>, in § 6</span> <li><a href="#parse-json-bytes-to-a-javascript-value">parse JSON bytes to a JavaScript value</a><span>, in § 6</span> <li><a href="#parse-json-bytes-to-an-infra-value">parse JSON bytes to an Infra value</a><span>, in § 6</span> <li><a href="#parse-json-bytes-to-a-javascript-value">parse JSON from bytes</a><span>, in § 6</span> <li><a href="#parse-a-json-string-to-an-infra-value">parse JSON into Infra values</a><span>, in § 6</span> <li><a href="#stack-peek">peek</a><span>, in § 5.1.1</span> <li><a href="#stack-pop">pop</a><span>, in § 5.1.1</span> <li><a href="#string-position-variable">position variable</a><span>, in § 4.7</span> <li><a href="#byte-sequence-prefix">prefix</a><span>, in § 4.5</span> <li> prepend <ul> <li><a href="#list-prepend">dfn for list</a><span>, in § 5.1</span> <li><a href="#set-prepend">dfn for set</a><span>, in § 5.1.3</span> </ul> <li><a href="#stack-push">push</a><span>, in § 5.1.1</span> <li><a href="#queue">queue</a><span>, in § 5.1.2</span> <li> remove <ul> <li><a href="#list-remove">dfn for list, set</a><span>, in § 5.1</span> <li><a href="#map-remove">dfn for map</a><span>, in § 5.2</span> </ul> <li> replace <ul> <li><a href="#list-replace">dfn for list</a><span>, in § 5.1</span> <li><a href="#set-replace">dfn for set</a><span>, in § 5.1.3</span> </ul> <li><a href="#set-replace">replacing</a><span>, in § 5.1.3</span> <li><a href="#scalar-value">scalar value</a><span>, in § 4.6</span> <li><a href="#scalar-value-string">scalar value string</a><span>, in § 4.7</span> <li><a href="#serialize-a-javascript-value-to-a-json-string">serialize a JavaScript value to a JSON string</a><span>, in § 6</span> <li><a href="#serialize-a-javascript-value-to-json-bytes">serialize a JavaScript value to JSON bytes</a><span>, in § 6</span> <li><a href="#serialize-an-infra-value-to-a-json-string">serialize an Infra value to a JSON string</a><span>, in § 6</span> <li><a href="#serialize-an-infra-value-to-json-bytes">serialize an Infra value to JSON bytes</a><span>, in § 6</span> <li><a href="#serialize-a-javascript-value-to-json-bytes">serialize JSON to bytes</a><span>, in § 6</span> <li> set <ul> <li><a href="#ordered-set">definition of</a><span>, in § 5.1.3</span> <li><a href="#map-set">dfn for map</a><span>, in § 5.2</span> </ul> <li><a href="#map-set">set the value</a><span>, in § 5.2</span> <li> size <ul> <li><a href="#list-size">dfn for list, stack, queue, set</a><span>, in § 5.1</span> <li><a href="#map-size">dfn for map</a><span>, in § 5.2</span> </ul> <li><a href="#skip-ascii-whitespace">skip ASCII whitespace</a><span>, in § 4.7</span> <li> sort <ul> <li><a href="#list-sort-in-ascending-order">dfn for list, stack, queue, set</a><span>, in § 5.1</span> <li><a href="#map-sort-in-ascending-order">dfn for map</a><span>, in § 5.2</span> </ul> <li> sort in ascending order <ul> <li><a href="#list-sort-in-ascending-order">dfn for list, stack, queue, set</a><span>, in § 5.1</span> <li><a href="#map-sort-in-ascending-order">dfn for map</a><span>, in § 5.2</span> </ul> <li> sort in descending order <ul> <li><a href="#list-sort-in-descending-order">dfn for list, stack, queue, set</a><span>, in § 5.1</span> <li><a href="#map-sort-in-descending-order">dfn for map</a><span>, in § 5.2</span> </ul> <li> sorting <ul> <li><a href="#list-sort-in-ascending-order">dfn for list, stack, queue, set</a><span>, in § 5.1</span> <li><a href="#map-sort-in-ascending-order">dfn for map</a><span>, in § 5.2</span> </ul> <li> sorting in ascending order <ul> <li><a href="#list-sort-in-ascending-order">dfn for list, stack, queue, set</a><span>, in § 5.1</span> <li><a href="#map-sort-in-ascending-order">dfn for map</a><span>, in § 5.2</span> </ul> <li> sorting in descending order <ul> <li><a href="#list-sort-in-descending-order">dfn for list, stack, queue, set</a><span>, in § 5.1</span> <li><a href="#map-sort-in-descending-order">dfn for map</a><span>, in § 5.2</span> </ul> <li><a href="#split-on-ascii-whitespace">split a string on ASCII whitespace</a><span>, in § 4.7</span> <li><a href="#split-on-commas">split a string on commas</a><span>, in § 4.7</span> <li><a href="#split-on-ascii-whitespace">split on ASCII whitespace</a><span>, in § 4.7</span> <li><a href="#split-on-commas">split on commas</a><span>, in § 4.7</span> <li><a href="#stack">stack</a><span>, in § 5.1.1</span> <li> starts with <ul> <li><a href="#byte-sequence-starts-with">dfn for byte sequence</a><span>, in § 4.5</span> <li><a href="#string-starts-with">dfn for string</a><span>, in § 4.7</span> </ul> <li><a href="#byte-sequence-starts-with">start with</a><span>, in § 4.5</span> <li><a href="#strictly-split">strictly split</a><span>, in § 4.7</span> <li><a href="#strictly-split">strictly split a string</a><span>, in § 4.7</span> <li><a href="#string">string</a><span>, in § 4.7</span> <li><a href="#strip-and-collapse-ascii-whitespace">strip and collapse ASCII whitespace</a><span>, in § 4.7</span> <li><a href="#strip-leading-and-trailing-ascii-whitespace">strip leading and trailing ASCII whitespace</a><span>, in § 4.7</span> <li><a href="#strip-newlines">strip newlines</a><span>, in § 4.7</span> <li><a href="#struct">struct</a><span>, in § 5.3</span> <li><a href="#set-subset">subset</a><span>, in § 5.1.3</span> <li><a href="#set-superset">superset</a><span>, in § 5.1.3</span> <li><a href="#surrogate">surrogate</a><span>, in § 4.6</span> <li><a href="#svg-namespace">SVG namespace</a><span>, in § 8</span> <li><a href="#the-exclusive-range">the exclusive range</a><span>, in § 5.1.3</span> <li><a href="#the-range">the inclusive range</a><span>, in § 5.1.3</span> <li><a href="#the-range">the range</a><span>, in § 5.1.3</span> <li><a href="#tracking-vector">tracking vector</a><span>, in § 2.4</span> <li><a href="#trailing-surrogate">trailing surrogate</a><span>, in § 4.6</span> <li><a href="#tuple">tuple</a><span>, in § 5.3.1</span> <li><a href="#set-union">union</a><span>, in § 5.1.3</span> <li><a href="#user-agent">user agent</a><span>, in § 2.3</span> <li> value <ul> <li><a href="#byte-value">dfn for byte</a><span>, in § 4.4</span> <li><a href="#code-point-value">dfn for code point</a><span>, in § 4.6</span> <li><a href="#map-value">dfn for map</a><span>, in § 5.2</span> </ul> <li><a href="#map-getting-the-values">values</a><span>, in § 5.2</span> <li><a href="#iteration-while">while</a><span>, in § 3.9</span> <li><a href="#willful-violation">willful violation</a><span>, in § 2.2</span> <li><a href="#xlink-namespace">XLink namespace</a><span>, in § 8</span> <li><a href="#xml-namespace">XML namespace</a><span>, in § 8</span> <li><a href="#xmlns-namespace">XMLNS namespace</a><span>, in § 8</span> </ul> <h3 class="no-num no-ref heading settled" id="index-defined-elsewhere"><span class="content">Terms defined by reference</span><a class="self-link" href="#index-defined-elsewhere"></a></h3> <ul class="index"> <li> <a data-link-type="biblio">[DOM]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="a8fc7c38">CharacterData</span> </ul> <li> <a data-link-type="biblio">[ECMA-262]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="8b3dfc64">%JSON.parse%</span> <li><span class="dfn-paneled" id="ca4a8997">%JSON.stringify%</span> <li><span class="dfn-paneled" id="437d21ea">ArrayCreate</span> <li><span class="dfn-paneled" id="1010768b">Call</span> <li><span class="dfn-paneled" id="cef3e940">CreateDataPropertyOrThrow</span> <li><span class="dfn-paneled" id="0d804898">Get</span> <li><span class="dfn-paneled" id="41110b4b">IsArray</span> <li><span class="dfn-paneled" id="cb213548">OrdinaryObjectCreate</span> <li><span class="dfn-paneled" id="d8530df1">ToLength</span> <li><span class="dfn-paneled" id="d5bd3770">ToString</span> <li><span class="dfn-paneled" id="d19654fd">is a Boolean</span> <li><span class="dfn-paneled" id="921f1639">is a Number</span> <li><span class="dfn-paneled" id="31f77191">is a String</span> <li><span class="dfn-paneled" id="66553159">List</span> <li><span class="dfn-paneled" id="db6dbae4">realm</span> <li><span class="dfn-paneled" id="b7ef7f32">sort()</span> <li><span class="dfn-paneled" id="1d2f9726">The String Type</span> </ul> <li> <a data-link-type="biblio">[ENCODING]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="b0fcb8d7">UTF-8 decode</span> <li><span class="dfn-paneled" id="0303e8e5">UTF-8 encode</span> </ul> <li> <a data-link-type="biblio">[FETCH]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="5fe4ff5e">HTTP whitespace</span> </ul> <li> <a data-link-type="biblio">[HR-TIME]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="4b2c8c72">duration</span> <li><span class="dfn-paneled" id="1e2edd5b">moment</span> </ul> <li> <a data-link-type="biblio">[URL]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="752d140b">host</span> </ul> <li> <a data-link-type="biblio">[WEBIDL]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="82ca3efc">TypeError</span> </ul> </ul> <h2 class="no-num no-ref heading settled" id="references"><span class="content">References</span><a class="self-link" href="#references"></a></h2> <h3 class="no-num no-ref heading settled" id="normative"><span class="content">Normative References</span><a class="self-link" href="#normative"></a></h3> <dl> <dt id="biblio-ecma-262">[ECMA-262] <dd><a href="https://tc39.es/ecma262/multipage/"><cite>ECMAScript Language Specification</cite></a>. URL: <a href="https://tc39.es/ecma262/multipage/">https://tc39.es/ecma262/multipage/</a> <dt id="biblio-encoding">[ENCODING] <dd>Anne van Kesteren. <a href="https://encoding.spec.whatwg.org/"><cite>Encoding Standard</cite></a>. Living Standard. URL: <a href="https://encoding.spec.whatwg.org/">https://encoding.spec.whatwg.org/</a> <dt id="biblio-hr-time">[HR-TIME] <dd>Yoav Weiss. <a href="https://w3c.github.io/hr-time/"><cite>High Resolution Time</cite></a>. URL: <a href="https://w3c.github.io/hr-time/">https://w3c.github.io/hr-time/</a> <dt id="biblio-infra">[Infra] <dd>Anne van Kesteren; Domenic Denicola. <a href="https://infra.spec.whatwg.org/"><cite>Infra Standard</cite></a>. Living Standard. URL: <a href="https://infra.spec.whatwg.org/">https://infra.spec.whatwg.org/</a> <dt id="biblio-rfc20">[RFC20] <dd>V.G. Cerf. <a href="https://www.rfc-editor.org/rfc/rfc20"><cite>ASCII format for network interchange</cite></a>. October 1969. Internet Standard. URL: <a href="https://www.rfc-editor.org/rfc/rfc20">https://www.rfc-editor.org/rfc/rfc20</a> <dt id="biblio-rfc2119">[RFC2119] <dd>S. Bradner. <a href="https://datatracker.ietf.org/doc/html/rfc2119"><cite>Key words for use in RFCs to Indicate Requirement Levels</cite></a>. March 1997. Best Current Practice. URL: <a href="https://datatracker.ietf.org/doc/html/rfc2119">https://datatracker.ietf.org/doc/html/rfc2119</a> <dt id="biblio-rfc4648">[RFC4648] <dd>S. Josefsson. <a href="https://www.rfc-editor.org/rfc/rfc4648"><cite>The Base16, Base32, and Base64 Data Encodings</cite></a>. October 2006. Proposed Standard. URL: <a href="https://www.rfc-editor.org/rfc/rfc4648">https://www.rfc-editor.org/rfc/rfc4648</a> <dt id="biblio-unicode">[UNICODE] <dd><a href="https://www.unicode.org/versions/latest/"><cite>The Unicode Standard</cite></a>. URL: <a href="https://www.unicode.org/versions/latest/">https://www.unicode.org/versions/latest/</a> <dt id="biblio-webidl">[WEBIDL] <dd>Edgar Chen; Timothy Gu. <a href="https://webidl.spec.whatwg.org/"><cite>Web IDL Standard</cite></a>. Living Standard. URL: <a href="https://webidl.spec.whatwg.org/">https://webidl.spec.whatwg.org/</a> </dl> <h3 class="no-num no-ref heading settled" id="informative"><span class="content">Informative References</span><a class="self-link" href="#informative"></a></h3> <dl> <dt id="biblio-cookies">[COOKIES] <dd>A. Barth. <a href="https://httpwg.org/specs/rfc6265.html"><cite>HTTP State Management Mechanism</cite></a>. April 2011. Proposed Standard. URL: <a href="https://httpwg.org/specs/rfc6265.html">https://httpwg.org/specs/rfc6265.html</a> <dt id="biblio-dom">[DOM] <dd>Anne van Kesteren. <a href="https://dom.spec.whatwg.org/"><cite>DOM Standard</cite></a>. Living Standard. URL: <a href="https://dom.spec.whatwg.org/">https://dom.spec.whatwg.org/</a> <dt id="biblio-fetch">[FETCH] <dd>Anne van Kesteren. <a href="https://fetch.spec.whatwg.org/"><cite>Fetch Standard</cite></a>. Living Standard. URL: <a href="https://fetch.spec.whatwg.org/">https://fetch.spec.whatwg.org/</a> <dt id="biblio-html">[HTML] <dd>Anne van Kesteren; et al. <a href="https://html.spec.whatwg.org/multipage/"><cite>HTML Standard</cite></a>. Living Standard. URL: <a href="https://html.spec.whatwg.org/multipage/">https://html.spec.whatwg.org/multipage/</a> <dt id="biblio-rfc6797">[RFC6797] <dd>J. Hodges; C. Jackson; A. Barth. <a href="https://www.rfc-editor.org/rfc/rfc6797"><cite>HTTP Strict Transport Security (HSTS)</cite></a>. November 2012. Proposed Standard. URL: <a href="https://www.rfc-editor.org/rfc/rfc6797">https://www.rfc-editor.org/rfc/rfc6797</a> <dt id="biblio-rfc791">[RFC791] <dd>J. Postel. <a href="https://www.rfc-editor.org/rfc/rfc791"><cite>Internet Protocol</cite></a>. September 1981. Internet Standard. URL: <a href="https://www.rfc-editor.org/rfc/rfc791">https://www.rfc-editor.org/rfc/rfc791</a> <dt id="biblio-rfc8174">[RFC8174] <dd>B. Leiba. <a href="https://www.rfc-editor.org/rfc/rfc8174"><cite>Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words</cite></a>. May 2017. Best Current Practice. URL: <a href="https://www.rfc-editor.org/rfc/rfc8174">https://www.rfc-editor.org/rfc/rfc8174</a> <dt id="biblio-rfc8259">[RFC8259] <dd>T. Bray, Ed.. <a href="https://www.rfc-editor.org/rfc/rfc8259"><cite>The JavaScript Object Notation (JSON) Data Interchange Format</cite></a>. December 2017. Internet Standard. URL: <a href="https://www.rfc-editor.org/rfc/rfc8259">https://www.rfc-editor.org/rfc/rfc8259</a> <dt id="biblio-storage">[STORAGE] <dd>Anne van Kesteren. <a href="https://storage.spec.whatwg.org/"><cite>Storage Standard</cite></a>. Living Standard. URL: <a href="https://storage.spec.whatwg.org/">https://storage.spec.whatwg.org/</a> <dt id="biblio-url">[URL] <dd>Anne van Kesteren. <a href="https://url.spec.whatwg.org/"><cite>URL Standard</cite></a>. Living Standard. URL: <a href="https://url.spec.whatwg.org/">https://url.spec.whatwg.org/</a> <dt id="biblio-xml">[XML] <dd>Tim Bray; et al. <a href="https://www.w3.org/TR/xml/"><cite>Extensible Markup Language (XML) 1.0 (Fifth Edition)</cite></a>. 26 November 2008. REC. URL: <a href="https://www.w3.org/TR/xml/">https://www.w3.org/TR/xml/</a> </dl> <script>/* Boilerplate: script-dom-helper */ "use strict"; function query(sel) { return document.querySelector(sel); } function queryAll(sel) { return [...document.querySelectorAll(sel)]; } function iter(obj) { if(!obj) return []; var it = obj[Symbol.iterator]; if(it) return it; return Object.entries(obj); } function mk(tagname, attrs, ...children) { const el = document.createElement(tagname); for(const [k,v] of iter(attrs)) { if(k.slice(0,3) == "_on") { const eventName = k.slice(3); el.addEventListener(eventName, v); } else if(k[0] == "_") { // property, not attribute el[k.slice(1)] = v; } else { if(v === false || v == null) { continue; } else if(v === true) { el.setAttribute(k, ""); continue; } else { el.setAttribute(k, v); } } } append(el, children); return el; } /* Create shortcuts for every known HTML element */ [ "a", "abbr", "acronym", "address", "applet", "area", "article", "aside", "audio", "b", "base", "basefont", "bdo", "big", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "datalist", "dd", "del", "details", "dfn", "dialog", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "font", "footer", "form", "frame", "frameset", "head", "header", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "html", "i", "iframe", "img", "input", "ins", "kbd", "label", "legend", "li", "link", "main", "map", "mark", "meta", "meter", "nav", "nobr", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "pre", "progress", "q", "s", "samp", "script", "section", "select", "small", "source", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "u", "ul", "var", "video", "wbr", "xmp", ].forEach(tagname=>{ mk[tagname] = (...args) => mk(tagname, ...args); }); function* nodesFromChildList(children) { for(const child of children.flat(Infinity)) { if(child instanceof Node) { yield child; } else { yield new Text(child); } } } function append(el, ...children) { for(const child of nodesFromChildList(children)) { if(el instanceof Node) el.appendChild(child); else el.push(child); } return el; } function insertAfter(el, ...children) { for(const child of nodesFromChildList(children)) { el.parentNode.insertBefore(child, el.nextSibling); } return el; } function clearContents(el) { el.innerHTML = ""; return el; } function parseHTML(markup) { if(markup.toLowerCase().trim().indexOf('<!doctype') === 0) { const doc = document.implementation.createHTMLDocument(""); doc.documentElement.innerHTML = markup; return doc; } else { const el = mk.template({}); el.innerHTML = markup; return el.content; } }</script> <script>/* Boilerplate: script-dfn-panel */ "use strict"; { let dfnPanelData = { "0303e8e5": {"dfnID":"0303e8e5","dfnText":"UTF-8 encode","external":true,"refSections":[{"refs":[{"id":"ref-for-utf-8-encode"}],"title":"4.5. Byte sequences"},{"refs":[{"id":"ref-for-utf-8-encode\u2460"},{"id":"ref-for-utf-8-encode\u2461"}],"title":"4.7. Strings"},{"refs":[{"id":"ref-for-utf-8-encode\u2462"},{"id":"ref-for-utf-8-encode\u2463"}],"title":"6. JSON"}],"url":"https://encoding.spec.whatwg.org/#utf-8-encode"}, "0d804898": {"dfnID":"0d804898","dfnText":"Get","external":true,"refSections":[{"refs":[{"id":"ref-for-sec-get-o-p"},{"id":"ref-for-sec-get-o-p\u2460"},{"id":"ref-for-sec-get-o-p\u2461"}],"title":"6. JSON"}],"url":"https://tc39.github.io/ecma262/#sec-get-o-p"}, "1010768b": {"dfnID":"1010768b","dfnText":"Call","external":true,"refSections":[{"refs":[{"id":"ref-for-sec-call"},{"id":"ref-for-sec-call\u2460"},{"id":"ref-for-sec-call\u2461"},{"id":"ref-for-sec-call\u2462"}],"title":"6. JSON"}],"url":"https://tc39.github.io/ecma262/#sec-call"}, "128-bit-unsigned-integer": {"dfnID":"128-bit-unsigned-integer","dfnText":"128-bit unsigned integer","external":false,"refSections":[{"refs":[{"id":"ref-for-128-bit-unsigned-integer"}],"title":"4.3. Numbers"}],"url":"#128-bit-unsigned-integer"}, "16-bit-signed-integer": {"dfnID":"16-bit-signed-integer","dfnText":"16-bit signed integer","external":false,"refSections":[],"url":"#16-bit-signed-integer"}, "16-bit-unsigned-integer": {"dfnID":"16-bit-unsigned-integer","dfnText":"16-bit unsigned integer","external":false,"refSections":[{"refs":[{"id":"ref-for-16-bit-unsigned-integer"}],"title":"4.7. Strings"}],"url":"#16-bit-unsigned-integer"}, "1d2f9726": {"dfnID":"1d2f9726","dfnText":"The String Type","external":true,"refSections":[{"refs":[{"id":"ref-for-sec-ecmascript-language-types-string-type"}],"title":"4.7. Strings"},{"refs":[{"id":"ref-for-sec-ecmascript-language-types-string-type\u2460"}],"title":"6. JSON"}],"url":"https://tc39.github.io/ecma262/#sec-ecmascript-language-types-string-type"}, "1e2edd5b": {"dfnID":"1e2edd5b","dfnText":"moment","external":true,"refSections":[{"refs":[{"id":"ref-for-dfn-moment"}],"title":"4.8. Time"}],"url":"https://w3c.github.io/hr-time/#dfn-moment"}, "31f77191": {"dfnID":"31f77191","dfnText":"is a String","external":true,"refSections":[{"refs":[{"id":"ref-for-sec-ecmascript-language-types-string-type"}],"title":"4.7. Strings"},{"refs":[{"id":"ref-for-sec-ecmascript-language-types-string-type\u2460"}],"title":"6. JSON"}],"url":"https://tc39.github.io/ecma262/#sec-ecmascript-language-types-string-type"}, "32-bit-signed-integer": {"dfnID":"32-bit-signed-integer","dfnText":"32-bit signed integer","external":false,"refSections":[],"url":"#32-bit-signed-integer"}, "32-bit-unsigned-integer": {"dfnID":"32-bit-unsigned-integer","dfnText":"32-bit unsigned integer","external":false,"refSections":[],"url":"#32-bit-unsigned-integer"}, "41110b4b": {"dfnID":"41110b4b","dfnText":"IsArray","external":true,"refSections":[{"refs":[{"id":"ref-for-sec-isarray"}],"title":"6. JSON"}],"url":"https://tc39.github.io/ecma262/#sec-isarray"}, "437d21ea": {"dfnID":"437d21ea","dfnText":"ArrayCreate","external":true,"refSections":[{"refs":[{"id":"ref-for-sec-arraycreate"}],"title":"6. JSON"}],"url":"https://tc39.github.io/ecma262/#sec-arraycreate"}, "4b2c8c72": {"dfnID":"4b2c8c72","dfnText":"duration","external":true,"refSections":[{"refs":[{"id":"ref-for-dfn-duration"}],"title":"4.8. Time"}],"url":"https://w3c.github.io/hr-time/#dfn-duration"}, "5fe4ff5e": {"dfnID":"5fe4ff5e","dfnText":"HTTP whitespace","external":true,"refSections":[{"refs":[{"id":"ref-for-http-whitespace"}],"title":"4.6. Code points"}],"url":"https://fetch.spec.whatwg.org/#http-whitespace"}, "64-bit-signed-integer": {"dfnID":"64-bit-signed-integer","dfnText":"64-bit signed integer","external":false,"refSections":[],"url":"#64-bit-signed-integer"}, "64-bit-unsigned-integer": {"dfnID":"64-bit-unsigned-integer","dfnText":"64-bit unsigned integer","external":false,"refSections":[],"url":"#64-bit-unsigned-integer"}, "66553159": {"dfnID":"66553159","dfnText":"List","external":true,"refSections":[{"refs":[{"id":"ref-for-sec-list-and-record-specification-type"},{"id":"ref-for-sec-list-and-record-specification-type\u2460"}],"title":"5.1. Lists"}],"url":"https://tc39.github.io/ecma262/#sec-list-and-record-specification-type"}, "752d140b": {"dfnID":"752d140b","dfnText":"host","external":true,"refSections":[{"refs":[{"id":"ref-for-concept-host"}],"title":"5.3. Structs"}],"url":"https://url.spec.whatwg.org/#concept-host"}, "8-bit-signed-integer": {"dfnID":"8-bit-signed-integer","dfnText":"8-bit signed integer","external":false,"refSections":[],"url":"#8-bit-signed-integer"}, "8-bit-unsigned-integer": {"dfnID":"8-bit-unsigned-integer","dfnText":"8-bit unsigned integer","external":false,"refSections":[],"url":"#8-bit-unsigned-integer"}, "82ca3efc": {"dfnID":"82ca3efc","dfnText":"TypeError","external":true,"refSections":[{"refs":[{"id":"ref-for-exceptiondef-typeerror"}],"title":"3.8. Conditional statements"},{"refs":[{"id":"ref-for-exceptiondef-typeerror\u2460"}],"title":"6. JSON"}],"url":"https://webidl.spec.whatwg.org/#exceptiondef-typeerror"}, "8b3dfc64": {"dfnID":"8b3dfc64","dfnText":"%JSON.parse%","external":true,"refSections":[{"refs":[{"id":"ref-for-sec-json.parse"},{"id":"ref-for-sec-json.parse\u2460"}],"title":"6. JSON"}],"url":"https://tc39.github.io/ecma262/#sec-json.parse"}, "921f1639": {"dfnID":"921f1639","dfnText":"is a Number","external":true,"refSections":[{"refs":[{"id":"ref-for-sec-ecmascript-language-types-number-type"}],"title":"6. JSON"}],"url":"https://tc39.github.io/ecma262/#sec-ecmascript-language-types-number-type"}, "a8fc7c38": {"dfnID":"a8fc7c38","dfnText":"CharacterData","external":true,"refSections":[{"refs":[{"id":"ref-for-characterdata"}],"title":"4.7. Strings"}],"url":"https://dom.spec.whatwg.org/#characterdata"}, "abort-when": {"dfnID":"abort-when","dfnText":"abort when","external":false,"refSections":[{"refs":[{"id":"ref-for-abort-when"},{"id":"ref-for-abort-when\u2460"}],"title":"3.7. Conditional abort"}],"url":"#abort-when"}, "ascii-alpha": {"dfnID":"ascii-alpha","dfnText":"ASCII alpha","external":false,"refSections":[{"refs":[{"id":"ref-for-ascii-alpha"}],"title":"4.6. Code points"}],"url":"#ascii-alpha"}, "ascii-alphanumeric": {"dfnID":"ascii-alphanumeric","dfnText":"ASCII alphanumeric","external":false,"refSections":[{"refs":[{"id":"ref-for-ascii-alphanumeric"}],"title":"7. Forgiving base64"}],"url":"#ascii-alphanumeric"}, "ascii-byte": {"dfnID":"ascii-byte","dfnText":"ASCII byte","external":false,"refSections":[{"refs":[{"id":"ref-for-ascii-byte"}],"title":"4.4. Bytes"},{"refs":[{"id":"ref-for-ascii-byte\u2460"}],"title":"4.7. Strings"}],"url":"#ascii-byte"}, "ascii-case-insensitive": {"dfnID":"ascii-case-insensitive","dfnText":"ASCII case-insensitive","external":false,"refSections":[],"url":"#ascii-case-insensitive"}, "ascii-code-point": {"dfnID":"ascii-code-point","dfnText":"ASCII code point","external":false,"refSections":[{"refs":[{"id":"ref-for-ascii-code-point"}],"title":"4.7. Strings"}],"url":"#ascii-code-point"}, "ascii-decode": {"dfnID":"ascii-decode","dfnText":"ASCII decode","external":false,"refSections":[],"url":"#ascii-decode"}, "ascii-digit": {"dfnID":"ascii-digit","dfnText":"ASCII digit","external":false,"refSections":[{"refs":[{"id":"ref-for-ascii-digit"},{"id":"ref-for-ascii-digit\u2460"},{"id":"ref-for-ascii-digit\u2461"}],"title":"4.6. Code points"}],"url":"#ascii-digit"}, "ascii-encode": {"dfnID":"ascii-encode","dfnText":"ASCII encode","external":false,"refSections":[],"url":"#ascii-encode"}, "ascii-hex-digit": {"dfnID":"ascii-hex-digit","dfnText":"ASCII hex digit","external":false,"refSections":[],"url":"#ascii-hex-digit"}, "ascii-lower-alpha": {"dfnID":"ascii-lower-alpha","dfnText":"ASCII lower alpha","external":false,"refSections":[{"refs":[{"id":"ref-for-ascii-lower-alpha"}],"title":"4.6. Code points"},{"refs":[{"id":"ref-for-ascii-lower-alpha\u2460"},{"id":"ref-for-ascii-lower-alpha\u2461"}],"title":"4.7. Strings"}],"url":"#ascii-lower-alpha"}, "ascii-lower-hex-digit": {"dfnID":"ascii-lower-hex-digit","dfnText":"ASCII lower hex digit","external":false,"refSections":[{"refs":[{"id":"ref-for-ascii-lower-hex-digit"}],"title":"4.6. Code points"}],"url":"#ascii-lower-hex-digit"}, "ascii-lowercase": {"dfnID":"ascii-lowercase","dfnText":"ASCII lowercase","external":false,"refSections":[{"refs":[{"id":"ref-for-ascii-lowercase"},{"id":"ref-for-ascii-lowercase\u2460"}],"title":"4.7. Strings"}],"url":"#ascii-lowercase"}, "ascii-string": {"dfnID":"ascii-string","dfnText":"ASCII string","external":false,"refSections":[{"refs":[{"id":"ref-for-ascii-string"},{"id":"ref-for-ascii-string\u2460"}],"title":"4.7. Strings"}],"url":"#ascii-string"}, "ascii-tab-or-newline": {"dfnID":"ascii-tab-or-newline","dfnText":"ASCII tab or newline","external":false,"refSections":[],"url":"#ascii-tab-or-newline"}, "ascii-upper-alpha": {"dfnID":"ascii-upper-alpha","dfnText":"ASCII upper alpha","external":false,"refSections":[{"refs":[{"id":"ref-for-ascii-upper-alpha"}],"title":"4.6. Code points"},{"refs":[{"id":"ref-for-ascii-upper-alpha\u2460"},{"id":"ref-for-ascii-upper-alpha\u2461"}],"title":"4.7. Strings"}],"url":"#ascii-upper-alpha"}, "ascii-upper-hex-digit": {"dfnID":"ascii-upper-hex-digit","dfnText":"ASCII upper hex digit","external":false,"refSections":[{"refs":[{"id":"ref-for-ascii-upper-hex-digit"}],"title":"4.4. Bytes"},{"refs":[{"id":"ref-for-ascii-upper-hex-digit\u2460"},{"id":"ref-for-ascii-upper-hex-digit\u2461"}],"title":"4.6. Code points"}],"url":"#ascii-upper-hex-digit"}, "ascii-uppercase": {"dfnID":"ascii-uppercase","dfnText":"ASCII uppercase","external":false,"refSections":[{"refs":[{"id":"ref-for-ascii-uppercase"}],"title":"3.3. Declaration"},{"refs":[{"id":"ref-for-ascii-uppercase\u2460"}],"title":"4.6. Code points"}],"url":"#ascii-uppercase"}, "ascii-whitespace": {"dfnID":"ascii-whitespace","dfnText":"ASCII whitespace","external":false,"refSections":[{"refs":[{"id":"ref-for-ascii-whitespace"}],"title":"4.6. Code points"},{"refs":[{"id":"ref-for-ascii-whitespace\u2460"},{"id":"ref-for-ascii-whitespace\u2461"},{"id":"ref-for-ascii-whitespace\u2462"},{"id":"ref-for-ascii-whitespace\u2463"},{"id":"ref-for-ascii-whitespace\u2464"},{"id":"ref-for-ascii-whitespace\u2465"}],"title":"4.7. Strings"},{"refs":[{"id":"ref-for-ascii-whitespace\u2466"}],"title":"7. Forgiving base64"}],"url":"#ascii-whitespace"}, "assert": {"dfnID":"assert","dfnText":"Assert","external":false,"refSections":[{"refs":[{"id":"ref-for-assert"}],"title":"3.5. Variables"},{"refs":[{"id":"ref-for-assert\u2460"}],"title":"3.10. Assertions"},{"refs":[{"id":"ref-for-assert\u2461"},{"id":"ref-for-assert\u2462"},{"id":"ref-for-assert\u2463"},{"id":"ref-for-assert\u2464"},{"id":"ref-for-assert\u2465"},{"id":"ref-for-assert\u2466"},{"id":"ref-for-assert\u2467"}],"title":"4.7. Strings"},{"refs":[{"id":"ref-for-assert\u2468"},{"id":"ref-for-assert\u2460\u24ea"},{"id":"ref-for-assert\u2460\u2460"},{"id":"ref-for-assert\u2460\u2461"},{"id":"ref-for-assert\u2460\u2462"}],"title":"5.1. Lists"},{"refs":[{"id":"ref-for-assert\u2460\u2463"}],"title":"6. JSON"}],"url":"#assert"}, "b0fcb8d7": {"dfnID":"b0fcb8d7","dfnText":"UTF-8 decode","external":true,"refSections":[{"refs":[{"id":"ref-for-utf-8-decode"}],"title":"3.5. Variables"},{"refs":[{"id":"ref-for-utf-8-decode\u2460"}],"title":"4.4. Bytes"},{"refs":[{"id":"ref-for-utf-8-decode\u2461"}],"title":"4.7. Strings"},{"refs":[{"id":"ref-for-utf-8-decode\u2462"},{"id":"ref-for-utf-8-decode\u2463"}],"title":"6. JSON"}],"url":"https://encoding.spec.whatwg.org/#utf-8-decode"}, "b7ef7f32": {"dfnID":"b7ef7f32","dfnText":"sort()","external":true,"refSections":[{"refs":[{"id":"ref-for-sec-array.prototype.sort"}],"title":"4.7. Strings"}],"url":"https://tc39.github.io/ecma262/#sec-array.prototype.sort"}, "boolean": {"dfnID":"boolean","dfnText":"boolean","external":false,"refSections":[{"refs":[{"id":"ref-for-boolean"},{"id":"ref-for-boolean\u2460"}],"title":"3.4. Parameters"},{"refs":[{"id":"ref-for-boolean\u2461"},{"id":"ref-for-boolean\u2462"},{"id":"ref-for-boolean\u2463"},{"id":"ref-for-boolean\u2464"}],"title":"6. JSON"}],"url":"#boolean"}, "byte": {"dfnID":"byte","dfnText":"byte","external":false,"refSections":[{"refs":[{"id":"ref-for-byte"},{"id":"ref-for-byte\u2460"},{"id":"ref-for-byte\u2461"}],"title":"4.4. Bytes"},{"refs":[{"id":"ref-for-byte\u2462"},{"id":"ref-for-byte\u2463"},{"id":"ref-for-byte\u2464"},{"id":"ref-for-byte\u2465"},{"id":"ref-for-byte\u2466"},{"id":"ref-for-byte\u2467"},{"id":"ref-for-byte\u2468"},{"id":"ref-for-byte\u2460\u24ea"}],"title":"4.5. Byte sequences"},{"refs":[{"id":"ref-for-byte\u2460\u2460"}],"title":"4.7. Strings"}],"url":"#byte"}, "byte-case-insensitive": {"dfnID":"byte-case-insensitive","dfnText":"byte-case-insensitive","external":false,"refSections":[],"url":"#byte-case-insensitive"}, "byte-less-than": {"dfnID":"byte-less-than","dfnText":"byte less than","external":false,"refSections":[],"url":"#byte-less-than"}, "byte-lowercase": {"dfnID":"byte-lowercase","dfnText":"byte-lowercase","external":false,"refSections":[{"refs":[{"id":"ref-for-byte-lowercase"},{"id":"ref-for-byte-lowercase\u2460"}],"title":"4.5. Byte sequences"}],"url":"#byte-lowercase"}, "byte-sequence": {"dfnID":"byte-sequence","dfnText":"byte sequence","external":false,"refSections":[{"refs":[{"id":"ref-for-byte-sequence"},{"id":"ref-for-byte-sequence\u2460"},{"id":"ref-for-byte-sequence\u2461"}],"title":"3.3. Declaration"},{"refs":[{"id":"ref-for-byte-sequence\u2462"},{"id":"ref-for-byte-sequence\u2463"},{"id":"ref-for-byte-sequence\u2464"},{"id":"ref-for-byte-sequence\u2465"},{"id":"ref-for-byte-sequence\u2466"},{"id":"ref-for-byte-sequence\u2467"},{"id":"ref-for-byte-sequence\u2468"},{"id":"ref-for-byte-sequence\u2460\u24ea"},{"id":"ref-for-byte-sequence\u2460\u2460"},{"id":"ref-for-byte-sequence\u2460\u2461"},{"id":"ref-for-byte-sequence\u2460\u2462"},{"id":"ref-for-byte-sequence\u2460\u2463"}],"title":"4.5. Byte sequences"},{"refs":[{"id":"ref-for-byte-sequence\u2460\u2464"},{"id":"ref-for-byte-sequence\u2460\u2465"},{"id":"ref-for-byte-sequence\u2460\u2466"}],"title":"4.7. Strings"},{"refs":[{"id":"ref-for-byte-sequence\u2460\u2467"}],"title":"5.2. Maps"},{"refs":[{"id":"ref-for-byte-sequence\u2460\u2468"},{"id":"ref-for-byte-sequence\u2461\u24ea"}],"title":"6. JSON"},{"refs":[{"id":"ref-for-byte-sequence\u2461\u2460"},{"id":"ref-for-byte-sequence\u2461\u2461"}],"title":"7. Forgiving base64"}],"url":"#byte-sequence"}, "byte-sequence-length": {"dfnID":"byte-sequence-length","dfnText":"length","external":false,"refSections":[{"refs":[{"id":"ref-for-byte-sequence-length"},{"id":"ref-for-byte-sequence-length\u2460"},{"id":"ref-for-byte-sequence-length\u2461"}],"title":"4.5. Byte sequences"},{"refs":[{"id":"ref-for-byte-sequence-length\u2462"}],"title":"4.7. Strings"}],"url":"#byte-sequence-length"}, "byte-sequence-prefix": {"dfnID":"byte-sequence-prefix","dfnText":"prefix","external":false,"refSections":[{"refs":[{"id":"ref-for-byte-sequence-prefix"},{"id":"ref-for-byte-sequence-prefix\u2460"},{"id":"ref-for-byte-sequence-prefix\u2461"}],"title":"4.5. Byte sequences"}],"url":"#byte-sequence-prefix"}, "byte-sequence-starts-with": {"dfnID":"byte-sequence-starts-with","dfnText":"starts with","external":false,"refSections":[],"url":"#byte-sequence-starts-with"}, "byte-uppercase": {"dfnID":"byte-uppercase","dfnText":"byte-uppercase","external":false,"refSections":[],"url":"#byte-uppercase"}, "byte-value": {"dfnID":"byte-value","dfnText":"value","external":false,"refSections":[{"refs":[{"id":"ref-for-byte-value"}],"title":"4.4. Bytes"},{"refs":[{"id":"ref-for-byte-value\u2460"}],"title":"4.5. Byte sequences"},{"refs":[{"id":"ref-for-byte-value\u2461"}],"title":"4.7. Strings"}],"url":"#byte-value"}, "c0-control": {"dfnID":"c0-control","dfnText":"C0 control","external":false,"refSections":[{"refs":[{"id":"ref-for-c0-control"},{"id":"ref-for-c0-control\u2460"}],"title":"4.6. Code points"}],"url":"#c0-control"}, "c0-control-or-space": {"dfnID":"c0-control-or-space","dfnText":"C0 control or space","external":false,"refSections":[],"url":"#c0-control-or-space"}, "ca4a8997": {"dfnID":"ca4a8997","dfnText":"%JSON.stringify%","external":true,"refSections":[{"refs":[{"id":"ref-for-sec-json.stringify"},{"id":"ref-for-sec-json.stringify\u2460"},{"id":"ref-for-sec-json.stringify\u2461"},{"id":"ref-for-sec-json.stringify\u2462"}],"title":"6. JSON"}],"url":"https://tc39.github.io/ecma262/#sec-json.stringify"}, "cb213548": {"dfnID":"cb213548","dfnText":"OrdinaryObjectCreate","external":true,"refSections":[{"refs":[{"id":"ref-for-sec-ordinaryobjectcreate"}],"title":"6. JSON"}],"url":"https://tc39.github.io/ecma262/#sec-ordinaryobjectcreate"}, "cef3e940": {"dfnID":"cef3e940","dfnText":"CreateDataPropertyOrThrow","external":true,"refSections":[{"refs":[{"id":"ref-for-sec-createdatapropertyorthrow"},{"id":"ref-for-sec-createdatapropertyorthrow\u2460"}],"title":"6. JSON"}],"url":"https://tc39.github.io/ecma262/#sec-createdatapropertyorthrow"}, "code-point": {"dfnID":"code-point","dfnText":"code point","external":false,"refSections":[{"refs":[{"id":"ref-for-code-point"}],"title":"4.4. Bytes"},{"refs":[{"id":"ref-for-code-point\u2460"}],"title":"4.5. Byte sequences"},{"refs":[{"id":"ref-for-code-point\u2461"},{"id":"ref-for-code-point\u2462"},{"id":"ref-for-code-point\u2463"},{"id":"ref-for-code-point\u2464"},{"id":"ref-for-code-point\u2465"},{"id":"ref-for-code-point\u2466"},{"id":"ref-for-code-point\u2467"},{"id":"ref-for-code-point\u2468"},{"id":"ref-for-code-point\u2460\u24ea"},{"id":"ref-for-code-point\u2460\u2460"},{"id":"ref-for-code-point\u2460\u2461"},{"id":"ref-for-code-point\u2460\u2462"},{"id":"ref-for-code-point\u2460\u2463"},{"id":"ref-for-code-point\u2460\u2464"},{"id":"ref-for-code-point\u2460\u2465"},{"id":"ref-for-code-point\u2460\u2466"},{"id":"ref-for-code-point\u2460\u2467"},{"id":"ref-for-code-point\u2460\u2468"},{"id":"ref-for-code-point\u2461\u24ea"},{"id":"ref-for-code-point\u2461\u2460"},{"id":"ref-for-code-point\u2461\u2461"}],"title":"4.6. Code points"},{"refs":[{"id":"ref-for-code-point\u2461\u2462"},{"id":"ref-for-code-point\u2461\u2463"},{"id":"ref-for-code-point\u2461\u2464"},{"id":"ref-for-code-point\u2461\u2465"},{"id":"ref-for-code-point\u2461\u2466"},{"id":"ref-for-code-point\u2461\u2467"},{"id":"ref-for-code-point\u2461\u2468"},{"id":"ref-for-code-point\u2462\u24ea"},{"id":"ref-for-code-point\u2462\u2460"},{"id":"ref-for-code-point\u2462\u2461"},{"id":"ref-for-code-point\u2462\u2462"},{"id":"ref-for-code-point\u2462\u2463"},{"id":"ref-for-code-point\u2462\u2464"},{"id":"ref-for-code-point\u2462\u2465"},{"id":"ref-for-code-point\u2462\u2466"},{"id":"ref-for-code-point\u2462\u2467"},{"id":"ref-for-code-point\u2462\u2468"},{"id":"ref-for-code-point\u2463\u24ea"},{"id":"ref-for-code-point\u2463\u2460"},{"id":"ref-for-code-point\u2463\u2461"},{"id":"ref-for-code-point\u2463\u2462"},{"id":"ref-for-code-point\u2463\u2463"},{"id":"ref-for-code-point\u2463\u2464"},{"id":"ref-for-code-point\u2463\u2465"},{"id":"ref-for-code-point\u2463\u2466"},{"id":"ref-for-code-point\u2463\u2467"},{"id":"ref-for-code-point\u2463\u2468"},{"id":"ref-for-code-point\u2464\u24ea"},{"id":"ref-for-code-point\u2464\u2460"},{"id":"ref-for-code-point\u2464\u2461"}],"title":"4.7. Strings"},{"refs":[{"id":"ref-for-code-point\u2464\u2462"},{"id":"ref-for-code-point\u2464\u2463"},{"id":"ref-for-code-point\u2464\u2464"}],"title":"7. Forgiving base64"}],"url":"#code-point"}, "code-point-substring": {"dfnID":"code-point-substring","dfnText":"code point substring","external":false,"refSections":[{"refs":[{"id":"ref-for-code-point-substring"},{"id":"ref-for-code-point-substring\u2460"},{"id":"ref-for-code-point-substring\u2461"}],"title":"4.7. Strings"}],"url":"#code-point-substring"}, "code-point-substring-by-positions": {"dfnID":"code-point-substring-by-positions","dfnText":"code point substring","external":false,"refSections":[{"refs":[{"id":"ref-for-code-point-substring-by-positions"}],"title":"4.7. Strings"}],"url":"#code-point-substring-by-positions"}, "code-point-substring-to-the-end-of-the-string": {"dfnID":"code-point-substring-to-the-end-of-the-string","dfnText":"code point substring","external":false,"refSections":[],"url":"#code-point-substring-to-the-end-of-the-string"}, "code-point-value": {"dfnID":"code-point-value","dfnText":"value","external":false,"refSections":[{"refs":[{"id":"ref-for-code-point-value"}],"title":"4.5. Byte sequences"},{"refs":[{"id":"ref-for-code-point-value\u2460"}],"title":"4.7. Strings"}],"url":"#code-point-value"}, "code-unit": {"dfnID":"code-unit","dfnText":"code units","external":false,"refSections":[{"refs":[{"id":"ref-for-code-unit"},{"id":"ref-for-code-unit\u2460"},{"id":"ref-for-code-unit\u2461"},{"id":"ref-for-code-unit\u2462"},{"id":"ref-for-code-unit\u2463"},{"id":"ref-for-code-unit\u2464"},{"id":"ref-for-code-unit\u2465"},{"id":"ref-for-code-unit\u2466"},{"id":"ref-for-code-unit\u2467"},{"id":"ref-for-code-unit\u2468"},{"id":"ref-for-code-unit\u2460\u24ea"},{"id":"ref-for-code-unit\u2460\u2460"}],"title":"4.7. Strings"}],"url":"#code-unit"}, "code-unit-less-than": {"dfnID":"code-unit-less-than","dfnText":"code unit less than","external":false,"refSections":[{"refs":[{"id":"ref-for-code-unit-less-than"}],"title":"4.7. Strings"},{"refs":[{"id":"ref-for-code-unit-less-than\u2460"}],"title":"5.1. Lists"}],"url":"#code-unit-less-than"}, "code-unit-prefix": {"dfnID":"code-unit-prefix","dfnText":"code unit prefix","external":false,"refSections":[{"refs":[{"id":"ref-for-code-unit-prefix"},{"id":"ref-for-code-unit-prefix\u2460"},{"id":"ref-for-code-unit-prefix\u2461"},{"id":"ref-for-code-unit-prefix\u2462"}],"title":"4.7. Strings"}],"url":"#code-unit-prefix"}, "code-unit-substring": {"dfnID":"code-unit-substring","dfnText":"code unit substring","external":false,"refSections":[{"refs":[{"id":"ref-for-code-unit-substring"},{"id":"ref-for-code-unit-substring\u2460"},{"id":"ref-for-code-unit-substring\u2461"},{"id":"ref-for-code-unit-substring\u2462"}],"title":"4.7. Strings"}],"url":"#code-unit-substring"}, "code-unit-substring-by-positions": {"dfnID":"code-unit-substring-by-positions","dfnText":"code unit substring","external":false,"refSections":[{"refs":[{"id":"ref-for-code-unit-substring-by-positions"},{"id":"ref-for-code-unit-substring-by-positions\u2460"},{"id":"ref-for-code-unit-substring-by-positions\u2461"}],"title":"4.7. Strings"}],"url":"#code-unit-substring-by-positions"}, "code-unit-substring-to-the-end-of-the-string": {"dfnID":"code-unit-substring-to-the-end-of-the-string","dfnText":"code unit substring","external":false,"refSections":[],"url":"#code-unit-substring-to-the-end-of-the-string"}, "code-unit-suffix": {"dfnID":"code-unit-suffix","dfnText":"code unit suffix","external":false,"refSections":[{"refs":[{"id":"ref-for-code-unit-suffix"},{"id":"ref-for-code-unit-suffix\u2460"}],"title":"4.7. Strings"}],"url":"#code-unit-suffix"}, "collect-a-sequence-of-code-points": {"dfnID":"collect-a-sequence-of-code-points","dfnText":"collect a sequence of code points","external":false,"refSections":[{"refs":[{"id":"ref-for-collect-a-sequence-of-code-points"},{"id":"ref-for-collect-a-sequence-of-code-points\u2460"},{"id":"ref-for-collect-a-sequence-of-code-points\u2461"},{"id":"ref-for-collect-a-sequence-of-code-points\u2462"},{"id":"ref-for-collect-a-sequence-of-code-points\u2463"}],"title":"4.7. Strings"}],"url":"#collect-a-sequence-of-code-points"}, "control": {"dfnID":"control","dfnText":"control","external":false,"refSections":[],"url":"#control"}, "convert-a-json-derived-javascript-value-to-an-infra-value": {"dfnID":"convert-a-json-derived-javascript-value-to-an-infra-value","dfnText":"convert a JSON-derived JavaScript value to an Infra value","external":false,"refSections":[{"refs":[{"id":"ref-for-convert-a-json-derived-javascript-value-to-an-infra-value"},{"id":"ref-for-convert-a-json-derived-javascript-value-to-an-infra-value\u2460"},{"id":"ref-for-convert-a-json-derived-javascript-value-to-an-infra-value\u2461"}],"title":"6. JSON"}],"url":"#convert-a-json-derived-javascript-value-to-an-infra-value"}, "convert-an-infra-value-to-a-json-compatible-javascript-value": {"dfnID":"convert-an-infra-value-to-a-json-compatible-javascript-value","dfnText":"convert an Infra value to a JSON-compatible JavaScript value","external":false,"refSections":[{"refs":[{"id":"ref-for-convert-an-infra-value-to-a-json-compatible-javascript-value"},{"id":"ref-for-convert-an-infra-value-to-a-json-compatible-javascript-value\u2460"},{"id":"ref-for-convert-an-infra-value-to-a-json-compatible-javascript-value\u2461"},{"id":"ref-for-convert-an-infra-value-to-a-json-compatible-javascript-value\u2462"}],"title":"6. JSON"}],"url":"#convert-an-infra-value-to-a-json-compatible-javascript-value"}, "d19654fd": {"dfnID":"d19654fd","dfnText":"is a Boolean","external":true,"refSections":[{"refs":[{"id":"ref-for-sec-ecmascript-language-types-boolean-type"}],"title":"6. JSON"}],"url":"https://tc39.github.io/ecma262/#sec-ecmascript-language-types-boolean-type"}, "d5bd3770": {"dfnID":"d5bd3770","dfnText":"ToString","external":true,"refSections":[{"refs":[{"id":"ref-for-sec-tostring"},{"id":"ref-for-sec-tostring\u2460"}],"title":"6. JSON"}],"url":"https://tc39.github.io/ecma262/#sec-tostring"}, "d8530df1": {"dfnID":"d8530df1","dfnText":"ToLength","external":true,"refSections":[{"refs":[{"id":"ref-for-sec-tolength"}],"title":"6. JSON"}],"url":"https://tc39.github.io/ecma262/#sec-tolength"}, "db6dbae4": {"dfnID":"db6dbae4","dfnText":"realm","external":true,"refSections":[{"refs":[{"id":"ref-for-realm"}],"title":"6. JSON"}],"url":"https://tc39.github.io/ecma262/#realm"}, "forgiving-base64-decode": {"dfnID":"forgiving-base64-decode","dfnText":"forgiving-base64 decode","external":false,"refSections":[{"refs":[{"id":"ref-for-forgiving-base64-decode"}],"title":"7. Forgiving base64"}],"url":"#forgiving-base64-decode"}, "forgiving-base64-encode": {"dfnID":"forgiving-base64-encode","dfnText":"forgiving-base64 encode","external":false,"refSections":[{"refs":[{"id":"ref-for-forgiving-base64-encode"}],"title":"7. Forgiving base64"}],"url":"#forgiving-base64-encode"}, "html-namespace": {"dfnID":"html-namespace","dfnText":"HTML namespace","external":false,"refSections":[],"url":"#html-namespace"}, "if-aborted": {"dfnID":"if-aborted","dfnText":"if aborted","external":false,"refSections":[{"refs":[{"id":"ref-for-if-aborted"}],"title":"3.7. Conditional abort"}],"url":"#if-aborted"}, "implementation": {"dfnID":"implementation","dfnText":"implementation","external":false,"refSections":[{"refs":[{"id":"ref-for-implementation"},{"id":"ref-for-implementation\u2460"},{"id":"ref-for-implementation\u2461"}],"title":"2.3. Terminology"}],"url":"#implementation"}, "implementation-defined": {"dfnID":"implementation-defined","dfnText":"implementation-defined","external":false,"refSections":[{"refs":[{"id":"ref-for-implementation-defined"},{"id":"ref-for-implementation-defined\u2460"}],"title":"2.3. Terminology"},{"refs":[{"id":"ref-for-implementation-defined\u2461"},{"id":"ref-for-implementation-defined\u2462"},{"id":"ref-for-implementation-defined\u2463"}],"title":"3.2. Avoid limits on algorithm inputs"}],"url":"#implementation-defined"}, "isomorphic-decode": {"dfnID":"isomorphic-decode","dfnText":"isomorphic decode","external":false,"refSections":[{"refs":[{"id":"ref-for-isomorphic-decode"}],"title":"3.3. Declaration"},{"refs":[{"id":"ref-for-isomorphic-decode\u2460"},{"id":"ref-for-isomorphic-decode\u2461"}],"title":"4.7. Strings"}],"url":"#isomorphic-decode"}, "isomorphic-encode": {"dfnID":"isomorphic-encode","dfnText":"isomorphic encode","external":false,"refSections":[{"refs":[{"id":"ref-for-isomorphic-encode"}],"title":"4.5. Byte sequences"},{"refs":[{"id":"ref-for-isomorphic-encode\u2460"},{"id":"ref-for-isomorphic-encode\u2461"}],"title":"4.7. Strings"}],"url":"#isomorphic-encode"}, "isomorphic-string": {"dfnID":"isomorphic-string","dfnText":"isomorphic string","external":false,"refSections":[{"refs":[{"id":"ref-for-isomorphic-string"},{"id":"ref-for-isomorphic-string\u2460"}],"title":"4.7. Strings"}],"url":"#isomorphic-string"}, "iteration-break": {"dfnID":"iteration-break","dfnText":"break","external":false,"refSections":[{"refs":[{"id":"ref-for-iteration-break"},{"id":"ref-for-iteration-break\u2460"}],"title":"3.9. Iteration"}],"url":"#iteration-break"}, "iteration-continue": {"dfnID":"iteration-continue","dfnText":"continue","external":false,"refSections":[{"refs":[{"id":"ref-for-iteration-continue"},{"id":"ref-for-iteration-continue\u2460"}],"title":"3.9. Iteration"}],"url":"#iteration-continue"}, "iteration-while": {"dfnID":"iteration-while","dfnText":"While","external":false,"refSections":[{"refs":[{"id":"ref-for-iteration-while"}],"title":"4.5. Byte sequences"},{"refs":[{"id":"ref-for-iteration-while\u2460"},{"id":"ref-for-iteration-while\u2461"}],"title":"4.7. Strings"},{"refs":[{"id":"ref-for-iteration-while\u2462"}],"title":"5.1.1. Stacks"},{"refs":[{"id":"ref-for-iteration-while\u2463"}],"title":"5.1.2. Queues"}],"url":"#iteration-while"}, "javascript-string-convert": {"dfnID":"javascript-string-convert","dfnText":"convert","external":false,"refSections":[{"refs":[{"id":"ref-for-javascript-string-convert"}],"title":"4.7. Strings"}],"url":"#javascript-string-convert"}, "leading-surrogate": {"dfnID":"leading-surrogate","dfnText":"leading surrogate","external":false,"refSections":[{"refs":[{"id":"ref-for-leading-surrogate"}],"title":"4.6. Code points"}],"url":"#leading-surrogate"}, "list": {"dfnID":"list","dfnText":"list","external":false,"refSections":[{"refs":[{"id":"ref-for-list"}],"title":"3.5. Variables"},{"refs":[{"id":"ref-for-list\u2460"},{"id":"ref-for-list\u2461"}],"title":"3.7. Conditional abort"},{"refs":[{"id":"ref-for-list\u2462"}],"title":"3.8. Conditional statements"},{"refs":[{"id":"ref-for-list\u2463"}],"title":"3.9. Iteration"},{"refs":[{"id":"ref-for-list\u2464"},{"id":"ref-for-list\u2465"},{"id":"ref-for-list\u2466"},{"id":"ref-for-list\u2467"}],"title":"4.7. Strings"},{"refs":[{"id":"ref-for-list\u2468"},{"id":"ref-for-list\u2460\u24ea"},{"id":"ref-for-list\u2460\u2460"},{"id":"ref-for-list\u2460\u2461"},{"id":"ref-for-list\u2460\u2462"},{"id":"ref-for-list\u2460\u2463"},{"id":"ref-for-list\u2460\u2464"},{"id":"ref-for-list\u2460\u2465"},{"id":"ref-for-list\u2460\u2466"},{"id":"ref-for-list\u2460\u2467"},{"id":"ref-for-list\u2460\u2468"},{"id":"ref-for-list\u2461\u24ea"},{"id":"ref-for-list\u2461\u2460"},{"id":"ref-for-list\u2461\u2461"},{"id":"ref-for-list\u2461\u2462"},{"id":"ref-for-list\u2461\u2463"},{"id":"ref-for-list\u2461\u2464"},{"id":"ref-for-list\u2461\u2465"},{"id":"ref-for-list\u2461\u2466"},{"id":"ref-for-list\u2461\u2467"},{"id":"ref-for-list\u2461\u2468"},{"id":"ref-for-list\u2462\u24ea"},{"id":"ref-for-list\u2462\u2460"},{"id":"ref-for-list\u2462\u2461"},{"id":"ref-for-list\u2462\u2462"},{"id":"ref-for-list\u2462\u2463"},{"id":"ref-for-list\u2462\u2464"},{"id":"ref-for-list\u2462\u2465"},{"id":"ref-for-list\u2462\u2466"},{"id":"ref-for-list\u2462\u2467"},{"id":"ref-for-list\u2462\u2468"},{"id":"ref-for-list\u2463\u24ea"},{"id":"ref-for-list\u2463\u2460"},{"id":"ref-for-list\u2463\u2461"},{"id":"ref-for-list\u2463\u2462"}],"title":"5.1. Lists"},{"refs":[{"id":"ref-for-list\u2463\u2463"},{"id":"ref-for-list\u2463\u2464"},{"id":"ref-for-list\u2463\u2465"}],"title":"5.1.1. Stacks"},{"refs":[{"id":"ref-for-list\u2463\u2466"},{"id":"ref-for-list\u2463\u2467"},{"id":"ref-for-list\u2463\u2468"}],"title":"5.1.2. Queues"},{"refs":[{"id":"ref-for-list\u2464\u24ea"},{"id":"ref-for-list\u2464\u2460"},{"id":"ref-for-list\u2464\u2461"},{"id":"ref-for-list\u2464\u2462"}],"title":"5.1.3. Sets"},{"refs":[{"id":"ref-for-list\u2464\u2463"},{"id":"ref-for-list\u2464\u2464"}],"title":"5.2. Maps"},{"refs":[{"id":"ref-for-list\u2464\u2465"},{"id":"ref-for-list\u2464\u2466"},{"id":"ref-for-list\u2464\u2467"},{"id":"ref-for-list\u2464\u2468"},{"id":"ref-for-list\u2465\u24ea"}],"title":"6. JSON"}],"url":"#list"}, "list-append": {"dfnID":"list-append","dfnText":"append","external":false,"refSections":[{"refs":[{"id":"ref-for-list-append"},{"id":"ref-for-list-append\u2460"},{"id":"ref-for-list-append\u2461"},{"id":"ref-for-list-append\u2462"},{"id":"ref-for-list-append\u2463"},{"id":"ref-for-list-append\u2464"},{"id":"ref-for-list-append\u2465"},{"id":"ref-for-list-append\u2466"}],"title":"3.7. Conditional abort"},{"refs":[{"id":"ref-for-list-append\u2467"},{"id":"ref-for-list-append\u2468"},{"id":"ref-for-list-append\u2460\u24ea"},{"id":"ref-for-list-append\u2460\u2460"}],"title":"4.7. Strings"},{"refs":[{"id":"ref-for-list-append\u2460\u2461"},{"id":"ref-for-list-append\u2460\u2462"}],"title":"5.1. Lists"},{"refs":[{"id":"ref-for-list-append\u2460\u2463"},{"id":"ref-for-list-append\u2460\u2464"}],"title":"5.1.1. Stacks"},{"refs":[{"id":"ref-for-list-append\u2460\u2465"},{"id":"ref-for-list-append\u2460\u2466"}],"title":"5.1.2. Queues"},{"refs":[{"id":"ref-for-list-append\u2460\u2467"}],"title":"5.1.3. Sets"},{"refs":[{"id":"ref-for-list-append\u2460\u2468"}],"title":"5.2. Maps"},{"refs":[{"id":"ref-for-list-append\u2461\u24ea"}],"title":"6. JSON"}],"url":"#list-append"}, "list-clone": {"dfnID":"list-clone","dfnText":"clone","external":false,"refSections":[{"refs":[{"id":"ref-for-list-clone"}],"title":"5.1. Lists"},{"refs":[{"id":"ref-for-list-clone\u2460"}],"title":"5.1.3. Sets"},{"refs":[{"id":"ref-for-list-clone\u2461"}],"title":"5.2. Maps"}],"url":"#list-clone"}, "list-contain": {"dfnID":"list-contain","dfnText":"contains","external":false,"refSections":[{"refs":[{"id":"ref-for-list-contain"}],"title":"5. Data structures"},{"refs":[{"id":"ref-for-list-contain\u2460"},{"id":"ref-for-list-contain\u2461"},{"id":"ref-for-list-contain\u2462"},{"id":"ref-for-list-contain\u2463"}],"title":"5.1. Lists"},{"refs":[{"id":"ref-for-list-contain\u2464"},{"id":"ref-for-list-contain\u2465"},{"id":"ref-for-list-contain\u2466"},{"id":"ref-for-list-contain\u2467"},{"id":"ref-for-list-contain\u2468"}],"title":"5.1.3. Sets"}],"url":"#list-contain"}, "list-empty": {"dfnID":"list-empty","dfnText":"empty","external":false,"refSections":[],"url":"#list-empty"}, "list-extend": {"dfnID":"list-extend","dfnText":"extend","external":false,"refSections":[{"refs":[{"id":"ref-for-list-extend"}],"title":"5.1. Lists"}],"url":"#list-extend"}, "list-get-the-indices": {"dfnID":"list-get-the-indices","dfnText":"get the indices","external":false,"refSections":[],"url":"#list-get-the-indices"}, "list-insert": {"dfnID":"list-insert","dfnText":"insert","external":false,"refSections":[],"url":"#list-insert"}, "list-is-empty": {"dfnID":"list-is-empty","dfnText":"is empty","external":false,"refSections":[{"refs":[{"id":"ref-for-list-is-empty"}],"title":"4.7. Strings"},{"refs":[{"id":"ref-for-list-is-empty\u2460"},{"id":"ref-for-list-is-empty\u2461"}],"title":"5.1.1. Stacks"},{"refs":[{"id":"ref-for-list-is-empty\u2462"}],"title":"5.1.2. Queues"}],"url":"#list-is-empty"}, "list-item": {"dfnID":"list-item","dfnText":"items","external":false,"refSections":[{"refs":[{"id":"ref-for-list-item"}],"title":"4.7. Strings"},{"refs":[{"id":"ref-for-list-item\u2460"}],"title":"5. Data structures"},{"refs":[{"id":"ref-for-list-item\u2461"},{"id":"ref-for-list-item\u2462"},{"id":"ref-for-list-item\u2463"},{"id":"ref-for-list-item\u2464"},{"id":"ref-for-list-item\u2465"},{"id":"ref-for-list-item\u2466"},{"id":"ref-for-list-item\u2467"},{"id":"ref-for-list-item\u2468"},{"id":"ref-for-list-item\u2460\u24ea"},{"id":"ref-for-list-item\u2460\u2460"},{"id":"ref-for-list-item\u2460\u2461"},{"id":"ref-for-list-item\u2460\u2462"},{"id":"ref-for-list-item\u2460\u2463"},{"id":"ref-for-list-item\u2460\u2464"},{"id":"ref-for-list-item\u2460\u2465"},{"id":"ref-for-list-item\u2460\u2466"}],"title":"5.1. Lists"},{"refs":[{"id":"ref-for-list-item\u2460\u2467"},{"id":"ref-for-list-item\u2460\u2468"}],"title":"5.1.1. Stacks"},{"refs":[{"id":"ref-for-list-item\u2461\u24ea"}],"title":"5.1.2. Queues"},{"refs":[{"id":"ref-for-list-item\u2461\u2460"},{"id":"ref-for-list-item\u2461\u2461"},{"id":"ref-for-list-item\u2461\u2462"}],"title":"5.1.3. Sets"},{"refs":[{"id":"ref-for-list-item\u2461\u2463"},{"id":"ref-for-list-item\u2461\u2464"}],"title":"5.2. Maps"}],"url":"#list-item"}, "list-iterate": {"dfnID":"list-iterate","dfnText":"iterate","external":false,"refSections":[{"refs":[{"id":"ref-for-list-iterate"},{"id":"ref-for-list-iterate\u2460"},{"id":"ref-for-list-iterate\u2461"},{"id":"ref-for-list-iterate\u2462"}],"title":"3.9. Iteration"},{"refs":[{"id":"ref-for-list-iterate\u2463"},{"id":"ref-for-list-iterate\u2464"}],"title":"4.7. Strings"},{"refs":[{"id":"ref-for-list-iterate\u2465"},{"id":"ref-for-list-iterate\u2466"},{"id":"ref-for-list-iterate\u2467"}],"title":"5.1. Lists"},{"refs":[{"id":"ref-for-list-iterate\u2468"}],"title":"5.1.1. Stacks"},{"refs":[{"id":"ref-for-list-iterate\u2460\u24ea"}],"title":"5.1.2. Queues"},{"refs":[{"id":"ref-for-list-iterate\u2460\u2460"},{"id":"ref-for-list-iterate\u2460\u2461"},{"id":"ref-for-list-iterate\u2460\u2462"},{"id":"ref-for-list-iterate\u2460\u2463"}],"title":"5.1.3. Sets"},{"refs":[{"id":"ref-for-list-iterate\u2460\u2464"},{"id":"ref-for-list-iterate\u2460\u2465"},{"id":"ref-for-list-iterate\u2460\u2466"},{"id":"ref-for-list-iterate\u2460\u2467"}],"title":"6. JSON"}],"url":"#list-iterate"}, "list-prepend": {"dfnID":"list-prepend","dfnText":"prepend","external":false,"refSections":[{"refs":[{"id":"ref-for-list-prepend"}],"title":"5.1. Lists"},{"refs":[{"id":"ref-for-list-prepend\u2460"}],"title":"5.1.1. Stacks"},{"refs":[{"id":"ref-for-list-prepend\u2461"}],"title":"5.1.2. Queues"},{"refs":[{"id":"ref-for-list-prepend\u2462"}],"title":"5.1.3. Sets"}],"url":"#list-prepend"}, "list-remove": {"dfnID":"list-remove","dfnText":"remove","external":false,"refSections":[{"refs":[{"id":"ref-for-list-remove"},{"id":"ref-for-list-remove\u2460"},{"id":"ref-for-list-remove\u2461"}],"title":"5.1. Lists"},{"refs":[{"id":"ref-for-list-remove\u2462"},{"id":"ref-for-list-remove\u2463"}],"title":"5.1.1. Stacks"},{"refs":[{"id":"ref-for-list-remove\u2464"},{"id":"ref-for-list-remove\u2465"}],"title":"5.1.2. Queues"},{"refs":[{"id":"ref-for-list-remove\u2466"}],"title":"5.1.3. Sets"}],"url":"#list-remove"}, "list-replace": {"dfnID":"list-replace","dfnText":"replace","external":false,"refSections":[],"url":"#list-replace"}, "list-size": {"dfnID":"list-size","dfnText":"size","external":false,"refSections":[{"refs":[{"id":"ref-for-list-size"},{"id":"ref-for-list-size\u2460"},{"id":"ref-for-list-size\u2461"},{"id":"ref-for-list-size\u2462"},{"id":"ref-for-list-size\u2463"},{"id":"ref-for-list-size\u2464"}],"title":"5.1. Lists"},{"refs":[{"id":"ref-for-list-size\u2465"}],"title":"5.2. Maps"}],"url":"#list-size"}, "list-sort-in-ascending-order": {"dfnID":"list-sort-in-ascending-order","dfnText":"sort in ascending order","external":false,"refSections":[{"refs":[{"id":"ref-for-list-sort-in-ascending-order"}],"title":"5.1. Lists"}],"url":"#list-sort-in-ascending-order"}, "list-sort-in-descending-order": {"dfnID":"list-sort-in-descending-order","dfnText":"sort in descending order","external":false,"refSections":[],"url":"#list-sort-in-descending-order"}, "map-clear": {"dfnID":"map-clear","dfnText":"clear","external":false,"refSections":[],"url":"#map-clear"}, "map-clone": {"dfnID":"map-clone","dfnText":"clone","external":false,"refSections":[],"url":"#map-clone"}, "map-entry": {"dfnID":"map-entry","dfnText":"entry","external":false,"refSections":[{"refs":[{"id":"ref-for-map-entry"},{"id":"ref-for-map-entry\u2460"},{"id":"ref-for-map-entry\u2461"},{"id":"ref-for-map-entry\u2462"},{"id":"ref-for-map-entry\u2463"},{"id":"ref-for-map-entry\u2464"},{"id":"ref-for-map-entry\u2465"},{"id":"ref-for-map-entry\u2466"},{"id":"ref-for-map-entry\u2467"},{"id":"ref-for-map-entry\u2468"},{"id":"ref-for-map-entry\u2460\u24ea"}],"title":"5.2. Maps"}],"url":"#map-entry"}, "map-exists": {"dfnID":"map-exists","dfnText":"contains an\nentry with a given key","external":false,"refSections":[{"refs":[{"id":"ref-for-map-exists"},{"id":"ref-for-map-exists\u2460"},{"id":"ref-for-map-exists\u2461"},{"id":"ref-for-map-exists\u2462"}],"title":"5.2. Maps"}],"url":"#map-exists"}, "map-get": {"dfnID":"map-get","dfnText":"get the value of an entry","external":false,"refSections":[{"refs":[{"id":"ref-for-map-get"}],"title":"5.2. Maps"}],"url":"#map-get"}, "map-getting-the-keys": {"dfnID":"map-getting-the-keys","dfnText":"get the keys","external":false,"refSections":[{"refs":[{"id":"ref-for-map-getting-the-keys"},{"id":"ref-for-map-getting-the-keys\u2460"},{"id":"ref-for-map-getting-the-keys\u2461"}],"title":"5.2. Maps"}],"url":"#map-getting-the-keys"}, "map-getting-the-values": {"dfnID":"map-getting-the-values","dfnText":"get the values","external":false,"refSections":[{"refs":[{"id":"ref-for-map-getting-the-values"},{"id":"ref-for-map-getting-the-values\u2460"}],"title":"5.2. Maps"}],"url":"#map-getting-the-values"}, "map-is-empty": {"dfnID":"map-is-empty","dfnText":"is empty","external":false,"refSections":[],"url":"#map-is-empty"}, "map-iterate": {"dfnID":"map-iterate","dfnText":"iterate","external":false,"refSections":[{"refs":[{"id":"ref-for-map-iterate"}],"title":"3.9. Iteration"},{"refs":[{"id":"ref-for-map-iterate\u2460"},{"id":"ref-for-map-iterate\u2461"}],"title":"5.2. Maps"}],"url":"#map-iterate"}, "map-key": {"dfnID":"map-key","dfnText":"key","external":false,"refSections":[{"refs":[{"id":"ref-for-map-key"},{"id":"ref-for-map-key\u2460"},{"id":"ref-for-map-key\u2461"},{"id":"ref-for-map-key\u2462"},{"id":"ref-for-map-key\u2463"},{"id":"ref-for-map-key\u2464"}],"title":"5.2. Maps"}],"url":"#map-key"}, "map-remove": {"dfnID":"map-remove","dfnText":"remove an entry","external":false,"refSections":[{"refs":[{"id":"ref-for-map-remove"}],"title":"5.2. Maps"}],"url":"#map-remove"}, "map-set": {"dfnID":"map-set","dfnText":"set the value of an entry","external":false,"refSections":[{"refs":[{"id":"ref-for-map-set"},{"id":"ref-for-map-set\u2460"},{"id":"ref-for-map-set\u2461"}],"title":"5.2. Maps"},{"refs":[{"id":"ref-for-map-set\u2462"}],"title":"6. JSON"}],"url":"#map-set"}, "map-size": {"dfnID":"map-size","dfnText":"size","external":false,"refSections":[{"refs":[{"id":"ref-for-map-size"}],"title":"5.2. Maps"}],"url":"#map-size"}, "map-sort-in-ascending-order": {"dfnID":"map-sort-in-ascending-order","dfnText":"sort in ascending order","external":false,"refSections":[],"url":"#map-sort-in-ascending-order"}, "map-sort-in-descending-order": {"dfnID":"map-sort-in-descending-order","dfnText":"sort in descending order","external":false,"refSections":[],"url":"#map-sort-in-descending-order"}, "map-value": {"dfnID":"map-value","dfnText":"value","external":false,"refSections":[{"refs":[{"id":"ref-for-map-value"},{"id":"ref-for-map-value\u2460"},{"id":"ref-for-map-value\u2461"}],"title":"5.2. Maps"}],"url":"#map-value"}, "mathml-namespace": {"dfnID":"mathml-namespace","dfnText":"MathML namespace","external":false,"refSections":[],"url":"#mathml-namespace"}, "noncharacter": {"dfnID":"noncharacter","dfnText":"noncharacter","external":false,"refSections":[],"url":"#noncharacter"}, "normalize-newlines": {"dfnID":"normalize-newlines","dfnText":"normalize newlines","external":false,"refSections":[],"url":"#normalize-newlines"}, "ordered-map": {"dfnID":"ordered-map","dfnText":"ordered map","external":false,"refSections":[{"refs":[{"id":"ref-for-ordered-map"}],"title":"5. Data structures"},{"refs":[{"id":"ref-for-ordered-map\u2460"},{"id":"ref-for-ordered-map\u2461"},{"id":"ref-for-ordered-map\u2462"},{"id":"ref-for-ordered-map\u2463"},{"id":"ref-for-ordered-map\u2464"},{"id":"ref-for-ordered-map\u2465"},{"id":"ref-for-ordered-map\u2466"},{"id":"ref-for-ordered-map\u2467"},{"id":"ref-for-ordered-map\u2468"},{"id":"ref-for-ordered-map\u2460\u24ea"},{"id":"ref-for-ordered-map\u2460\u2460"},{"id":"ref-for-ordered-map\u2460\u2461"},{"id":"ref-for-ordered-map\u2460\u2462"},{"id":"ref-for-ordered-map\u2460\u2463"},{"id":"ref-for-ordered-map\u2460\u2464"},{"id":"ref-for-ordered-map\u2460\u2465"},{"id":"ref-for-ordered-map\u2460\u2466"},{"id":"ref-for-ordered-map\u2460\u2467"},{"id":"ref-for-ordered-map\u2460\u2468"},{"id":"ref-for-ordered-map\u2461\u24ea"},{"id":"ref-for-ordered-map\u2461\u2460"},{"id":"ref-for-ordered-map\u2461\u2461"},{"id":"ref-for-ordered-map\u2461\u2462"},{"id":"ref-for-ordered-map\u2461\u2463"}],"title":"5.2. Maps"},{"refs":[{"id":"ref-for-ordered-map\u2461\u2464"},{"id":"ref-for-ordered-map\u2461\u2465"},{"id":"ref-for-ordered-map\u2461\u2466"},{"id":"ref-for-ordered-map\u2461\u2467"},{"id":"ref-for-ordered-map\u2461\u2468"}],"title":"6. JSON"}],"url":"#ordered-map"}, "ordered-set": {"dfnID":"ordered-set","dfnText":"ordered sets","external":false,"refSections":[{"refs":[{"id":"ref-for-ordered-set"}],"title":"5. Data structures"},{"refs":[{"id":"ref-for-ordered-set\u2460"},{"id":"ref-for-ordered-set\u2461"},{"id":"ref-for-ordered-set\u2462"},{"id":"ref-for-ordered-set\u2463"},{"id":"ref-for-ordered-set\u2464"},{"id":"ref-for-ordered-set\u2465"}],"title":"5.1. Lists"},{"refs":[{"id":"ref-for-ordered-set\u2466"},{"id":"ref-for-ordered-set\u2467"},{"id":"ref-for-ordered-set\u2468"},{"id":"ref-for-ordered-set\u2460\u24ea"},{"id":"ref-for-ordered-set\u2460\u2460"},{"id":"ref-for-ordered-set\u2460\u2461"},{"id":"ref-for-ordered-set\u2460\u2462"},{"id":"ref-for-ordered-set\u2460\u2463"},{"id":"ref-for-ordered-set\u2460\u2464"},{"id":"ref-for-ordered-set\u2460\u2465"},{"id":"ref-for-ordered-set\u2460\u2466"},{"id":"ref-for-ordered-set\u2460\u2467"},{"id":"ref-for-ordered-set\u2460\u2468"}],"title":"5.1.3. Sets"},{"refs":[{"id":"ref-for-ordered-set\u2461\u24ea"},{"id":"ref-for-ordered-set\u2461\u2460"}],"title":"5.2. Maps"}],"url":"#ordered-set"}, "parse-a-json-string-to-a-javascript-value": {"dfnID":"parse-a-json-string-to-a-javascript-value","dfnText":"parse a JSON string to a JavaScript value","external":false,"refSections":[{"refs":[{"id":"ref-for-parse-a-json-string-to-a-javascript-value"}],"title":"6. JSON"}],"url":"#parse-a-json-string-to-a-javascript-value"}, "parse-a-json-string-to-an-infra-value": {"dfnID":"parse-a-json-string-to-an-infra-value","dfnText":"parse a JSON string to an Infra value","external":false,"refSections":[{"refs":[{"id":"ref-for-parse-a-json-string-to-an-infra-value"}],"title":"6. JSON"}],"url":"#parse-a-json-string-to-an-infra-value"}, "parse-json-bytes-to-a-javascript-value": {"dfnID":"parse-json-bytes-to-a-javascript-value","dfnText":"parse JSON bytes to a JavaScript value","external":false,"refSections":[],"url":"#parse-json-bytes-to-a-javascript-value"}, "parse-json-bytes-to-an-infra-value": {"dfnID":"parse-json-bytes-to-an-infra-value","dfnText":"parse JSON bytes to an Infra value","external":false,"refSections":[],"url":"#parse-json-bytes-to-an-infra-value"}, "queue": {"dfnID":"queue","dfnText":"queues","external":false,"refSections":[{"refs":[{"id":"ref-for-queue"},{"id":"ref-for-queue\u2460"},{"id":"ref-for-queue\u2461"},{"id":"ref-for-queue\u2462"}],"title":"5.1.2. Queues"}],"url":"#queue"}, "queue-dequeue": {"dfnID":"queue-dequeue","dfnText":"dequeue","external":false,"refSections":[{"refs":[{"id":"ref-for-queue-dequeue"}],"title":"5.1.2. Queues"}],"url":"#queue-dequeue"}, "queue-enqueue": {"dfnID":"queue-enqueue","dfnText":"enqueue","external":false,"refSections":[],"url":"#queue-enqueue"}, "scalar-value": {"dfnID":"scalar-value","dfnText":"scalar value","external":false,"refSections":[{"refs":[{"id":"ref-for-scalar-value"},{"id":"ref-for-scalar-value\u2460"},{"id":"ref-for-scalar-value\u2461"}],"title":"4.7. Strings"}],"url":"#scalar-value"}, "scalar-value-string": {"dfnID":"scalar-value-string","dfnText":"scalar value string","external":false,"refSections":[{"refs":[{"id":"ref-for-scalar-value-string"},{"id":"ref-for-scalar-value-string\u2460"},{"id":"ref-for-scalar-value-string\u2461"},{"id":"ref-for-scalar-value-string\u2462"},{"id":"ref-for-scalar-value-string\u2463"},{"id":"ref-for-scalar-value-string\u2464"},{"id":"ref-for-scalar-value-string\u2465"}],"title":"4.7. Strings"}],"url":"#scalar-value-string"}, "serialize-a-javascript-value-to-a-json-string": {"dfnID":"serialize-a-javascript-value-to-a-json-string","dfnText":"serialize a JavaScript value to a JSON string","external":false,"refSections":[{"refs":[{"id":"ref-for-serialize-a-javascript-value-to-a-json-string"}],"title":"6. JSON"}],"url":"#serialize-a-javascript-value-to-a-json-string"}, "serialize-a-javascript-value-to-json-bytes": {"dfnID":"serialize-a-javascript-value-to-json-bytes","dfnText":"serialize a JavaScript value to JSON bytes","external":false,"refSections":[],"url":"#serialize-a-javascript-value-to-json-bytes"}, "serialize-an-infra-value-to-a-json-string": {"dfnID":"serialize-an-infra-value-to-a-json-string","dfnText":"serialize an Infra value to a JSON string","external":false,"refSections":[{"refs":[{"id":"ref-for-serialize-an-infra-value-to-a-json-string"},{"id":"ref-for-serialize-an-infra-value-to-a-json-string\u2460"}],"title":"6. JSON"}],"url":"#serialize-an-infra-value-to-a-json-string"}, "serialize-an-infra-value-to-json-bytes": {"dfnID":"serialize-an-infra-value-to-json-bytes","dfnText":"serialize an Infra value to JSON bytes","external":false,"refSections":[{"refs":[{"id":"ref-for-serialize-an-infra-value-to-json-bytes"}],"title":"6. JSON"}],"url":"#serialize-an-infra-value-to-json-bytes"}, "set-append": {"dfnID":"set-append","dfnText":"append","external":false,"refSections":[{"refs":[{"id":"ref-for-set-append"}],"title":"5. Data structures"},{"refs":[{"id":"ref-for-set-append\u2460"}],"title":"5.1. Lists"},{"refs":[{"id":"ref-for-set-append\u2461"},{"id":"ref-for-set-append\u2462"}],"title":"5.1.3. Sets"}],"url":"#set-append"}, "set-intersection": {"dfnID":"set-intersection","dfnText":"intersection","external":false,"refSections":[],"url":"#set-intersection"}, "set-prepend": {"dfnID":"set-prepend","dfnText":"prepend","external":false,"refSections":[{"refs":[{"id":"ref-for-set-prepend"}],"title":"5.1. Lists"}],"url":"#set-prepend"}, "set-replace": {"dfnID":"set-replace","dfnText":"replace","external":false,"refSections":[{"refs":[{"id":"ref-for-set-replace"},{"id":"ref-for-set-replace\u2460"}],"title":"5.1. Lists"},{"refs":[{"id":"ref-for-set-replace\u2461"}],"title":"5.1.3. Sets"}],"url":"#set-replace"}, "set-subset": {"dfnID":"set-subset","dfnText":"subset","external":false,"refSections":[{"refs":[{"id":"ref-for-set-subset"}],"title":"5.1.3. Sets"}],"url":"#set-subset"}, "set-superset": {"dfnID":"set-superset","dfnText":"superset","external":false,"refSections":[{"refs":[{"id":"ref-for-set-superset"}],"title":"5.1.3. Sets"}],"url":"#set-superset"}, "set-union": {"dfnID":"set-union","dfnText":"union","external":false,"refSections":[],"url":"#set-union"}, "skip-ascii-whitespace": {"dfnID":"skip-ascii-whitespace","dfnText":"skip ASCII whitespace","external":false,"refSections":[{"refs":[{"id":"ref-for-skip-ascii-whitespace"},{"id":"ref-for-skip-ascii-whitespace\u2460"}],"title":"4.7. Strings"}],"url":"#skip-ascii-whitespace"}, "split-on-ascii-whitespace": {"dfnID":"split-on-ascii-whitespace","dfnText":"split a\nstring input on ASCII whitespace","external":false,"refSections":[{"refs":[{"id":"ref-for-split-on-ascii-whitespace"}],"title":"4.7. Strings"}],"url":"#split-on-ascii-whitespace"}, "split-on-commas": {"dfnID":"split-on-commas","dfnText":"split a string\ninput on commas","external":false,"refSections":[{"refs":[{"id":"ref-for-split-on-commas"}],"title":"4.7. Strings"}],"url":"#split-on-commas"}, "stack": {"dfnID":"stack","dfnText":"stacks","external":false,"refSections":[{"refs":[{"id":"ref-for-stack"},{"id":"ref-for-stack\u2460"},{"id":"ref-for-stack\u2461"},{"id":"ref-for-stack\u2462"},{"id":"ref-for-stack\u2463"},{"id":"ref-for-stack\u2464"}],"title":"5.1.1. Stacks"}],"url":"#stack"}, "stack-peek": {"dfnID":"stack-peek","dfnText":"peek","external":false,"refSections":[],"url":"#stack-peek"}, "stack-pop": {"dfnID":"stack-pop","dfnText":"pop","external":false,"refSections":[{"refs":[{"id":"ref-for-stack-pop"}],"title":"5.1.1. Stacks"}],"url":"#stack-pop"}, "stack-push": {"dfnID":"stack-push","dfnText":"push","external":false,"refSections":[],"url":"#stack-push"}, "strictly-split": {"dfnID":"strictly-split","dfnText":"strictly split a string","external":false,"refSections":[],"url":"#strictly-split"}, "string": {"dfnID":"string","dfnText":"string","external":false,"refSections":[{"refs":[{"id":"ref-for-string"}],"title":"3.3. Declaration"},{"refs":[{"id":"ref-for-string\u2460"},{"id":"ref-for-string\u2461"}],"title":"3.5. Variables"},{"refs":[{"id":"ref-for-string\u2462"},{"id":"ref-for-string\u2463"},{"id":"ref-for-string\u2464"},{"id":"ref-for-string\u2465"}],"title":"3.8. Conditional statements"},{"refs":[{"id":"ref-for-string\u2466"},{"id":"ref-for-string\u2467"},{"id":"ref-for-string\u2468"}],"title":"4.5. Byte sequences"},{"refs":[{"id":"ref-for-string\u2460\u24ea"},{"id":"javascript-string"},{"id":"ref-for-string\u2460\u2460"},{"id":"ref-for-string\u2460\u2461"},{"id":"ref-for-string\u2460\u2462"},{"id":"ref-for-string\u2460\u2463"},{"id":"ref-for-string\u2460\u2464"},{"id":"ref-for-string\u2460\u2465"},{"id":"ref-for-string\u2460\u2466"},{"id":"ref-for-string\u2460\u2467"},{"id":"ref-for-string\u2460\u2468"},{"id":"ref-for-string\u2461\u24ea"},{"id":"ref-for-string\u2461\u2460"},{"id":"ref-for-string\u2461\u2461"},{"id":"ref-for-string\u2461\u2462"},{"id":"ref-for-string\u2461\u2463"},{"id":"ref-for-string\u2461\u2464"},{"id":"ref-for-string\u2461\u2465"},{"id":"ref-for-string\u2461\u2466"},{"id":"ref-for-string\u2461\u2467"},{"id":"ref-for-string\u2461\u2468"},{"id":"ref-for-string\u2462\u24ea"},{"id":"ref-for-string\u2462\u2460"},{"id":"ref-for-string\u2462\u2461"},{"id":"ref-for-string\u2462\u2462"},{"id":"ref-for-string\u2462\u2463"},{"id":"ref-for-string\u2462\u2464"},{"id":"ref-for-string\u2462\u2465"},{"id":"ref-for-string\u2462\u2466"},{"id":"ref-for-string\u2462\u2467"},{"id":"ref-for-string\u2462\u2468"},{"id":"ref-for-string\u2463\u24ea"},{"id":"ref-for-string\u2463\u2460"},{"id":"ref-for-string\u2463\u2461"},{"id":"ref-for-string\u2463\u2462"},{"id":"ref-for-string\u2463\u2463"},{"id":"ref-for-string\u2463\u2464"},{"id":"ref-for-string\u2463\u2465"},{"id":"ref-for-string\u2463\u2466"},{"id":"ref-for-string\u2463\u2467"},{"id":"ref-for-string\u2463\u2468"},{"id":"ref-for-string\u2464\u24ea"},{"id":"ref-for-string\u2464\u2460"},{"id":"ref-for-string\u2464\u2461"},{"id":"ref-for-string\u2464\u2462"},{"id":"ref-for-string\u2464\u2463"},{"id":"ref-for-string\u2464\u2464"},{"id":"ref-for-string\u2464\u2465"},{"id":"ref-for-string\u2464\u2466"},{"id":"ref-for-string\u2464\u2467"},{"id":"ref-for-string\u2464\u2468"},{"id":"ref-for-string\u2465\u24ea"},{"id":"ref-for-string\u2465\u2460"},{"id":"ref-for-string\u2465\u2461"},{"id":"ref-for-string\u2465\u2462"},{"id":"ref-for-string\u2465\u2463"},{"id":"ref-for-string\u2465\u2464"},{"id":"ref-for-string\u2465\u2465"}],"title":"4.7. Strings"},{"refs":[{"id":"ref-for-string\u2465\u2466"},{"id":"ref-for-string\u2465\u2467"},{"id":"ref-for-string\u2465\u2468"}],"title":"5.1. Lists"},{"refs":[{"id":"ref-for-string\u2466\u24ea"},{"id":"ref-for-string\u2466\u2460"},{"id":"ref-for-string\u2466\u2461"},{"id":"ref-for-string\u2466\u2462"},{"id":"ref-for-string\u2466\u2463"},{"id":"ref-for-string\u2466\u2464"},{"id":"ref-for-string\u2466\u2465"},{"id":"ref-for-string\u2466\u2466"},{"id":"ref-for-string\u2466\u2467"},{"id":"ref-for-string\u2466\u2468"}],"title":"6. JSON"}],"url":"#string"}, "string-code-point-length": {"dfnID":"string-code-point-length","dfnText":"code point length","external":false,"refSections":[{"refs":[{"id":"ref-for-string-code-point-length"}],"title":"4.5. Byte sequences"},{"refs":[{"id":"ref-for-string-code-point-length\u2460"},{"id":"ref-for-string-code-point-length\u2461"},{"id":"ref-for-string-code-point-length\u2462"}],"title":"4.7. Strings"},{"refs":[{"id":"ref-for-string-code-point-length\u2463"},{"id":"ref-for-string-code-point-length\u2464"}],"title":"7. Forgiving base64"}],"url":"#string-code-point-length"}, "string-concatenate": {"dfnID":"string-concatenate","dfnText":"concatenate","external":false,"refSections":[{"refs":[{"id":"ref-for-string-concatenate"}],"title":"4.7. Strings"}],"url":"#string-concatenate"}, "string-ends-with": {"dfnID":"string-ends-with","dfnText":"ends with","external":false,"refSections":[{"refs":[{"id":"ref-for-string-ends-with"}],"title":"4.7. Strings"}],"url":"#string-ends-with"}, "string-is": {"dfnID":"string-is","dfnText":"is","external":false,"refSections":[{"refs":[{"id":"ref-for-string-is"},{"id":"ref-for-string-is\u2460"},{"id":"ref-for-string-is\u2461"},{"id":"ref-for-string-is\u2462"}],"title":"4.7. Strings"}],"url":"#string-is"}, "string-length": {"dfnID":"string-length","dfnText":"length","external":false,"refSections":[{"refs":[{"id":"ref-for-string-length"},{"id":"ref-for-string-length\u2460"},{"id":"ref-for-string-length\u2461"},{"id":"ref-for-string-length\u2462"},{"id":"ref-for-string-length\u2463"},{"id":"ref-for-string-length\u2464"}],"title":"4.7. Strings"}],"url":"#string-length"}, "string-position-variable": {"dfnID":"string-position-variable","dfnText":"position variable","external":false,"refSections":[{"refs":[{"id":"ref-for-string-position-variable"},{"id":"ref-for-string-position-variable\u2460"},{"id":"ref-for-string-position-variable\u2461"},{"id":"ref-for-string-position-variable\u2462"},{"id":"ref-for-string-position-variable\u2463"}],"title":"4.7. Strings"},{"refs":[{"id":"ref-for-string-position-variable\u2464"}],"title":"7. Forgiving base64"}],"url":"#string-position-variable"}, "string-starts-with": {"dfnID":"string-starts-with","dfnText":"starts with","external":false,"refSections":[{"refs":[{"id":"ref-for-string-starts-with"}],"title":"4.7. Strings"}],"url":"#string-starts-with"}, "strip-and-collapse-ascii-whitespace": {"dfnID":"strip-and-collapse-ascii-whitespace","dfnText":"strip and collapse ASCII whitespace","external":false,"refSections":[],"url":"#strip-and-collapse-ascii-whitespace"}, "strip-leading-and-trailing-ascii-whitespace": {"dfnID":"strip-leading-and-trailing-ascii-whitespace","dfnText":"strip leading and trailing ASCII whitespace","external":false,"refSections":[{"refs":[{"id":"ref-for-strip-leading-and-trailing-ascii-whitespace"}],"title":"4.7. Strings"}],"url":"#strip-leading-and-trailing-ascii-whitespace"}, "strip-newlines": {"dfnID":"strip-newlines","dfnText":"strip newlines","external":false,"refSections":[],"url":"#strip-newlines"}, "struct": {"dfnID":"struct","dfnText":"struct","external":false,"refSections":[{"refs":[{"id":"ref-for-struct"}],"title":"3.4. Parameters"},{"refs":[{"id":"ref-for-struct\u2460"}],"title":"5.3. Structs"},{"refs":[{"id":"ref-for-struct\u2461"},{"id":"ref-for-struct\u2462"}],"title":"5.3.1. Tuples"}],"url":"#struct"}, "struct-item": {"dfnID":"struct-item","dfnText":"items","external":false,"refSections":[{"refs":[{"id":"ref-for-struct-item"},{"id":"ref-for-struct-item\u2460"},{"id":"ref-for-struct-item\u2461"}],"title":"3.5. Variables"},{"refs":[{"id":"ref-for-struct-item\u2462"},{"id":"ref-for-struct-item\u2463"}],"title":"5.1. Lists"},{"refs":[{"id":"ref-for-struct-item\u2464"}],"title":"5.3. Structs"},{"refs":[{"id":"ref-for-struct-item\u2465"},{"id":"ref-for-struct-item\u2466"}],"title":"5.3.1. Tuples"}],"url":"#struct-item"}, "struct-name": {"dfnID":"struct-name","dfnText":"name","external":false,"refSections":[{"refs":[{"id":"ref-for-struct-name"}],"title":"3.5. Variables"},{"refs":[{"id":"ref-for-struct-name\u2460"},{"id":"ref-for-struct-name\u2461"},{"id":"ref-for-struct-name\u2462"}],"title":"5.3.1. Tuples"}],"url":"#struct-name"}, "surrogate": {"dfnID":"surrogate","dfnText":"surrogate","external":false,"refSections":[{"refs":[{"id":"ref-for-surrogate"}],"title":"4.6. Code points"},{"refs":[{"id":"ref-for-surrogate\u2460"},{"id":"ref-for-surrogate\u2461"},{"id":"ref-for-surrogate\u2462"}],"title":"4.7. Strings"}],"url":"#surrogate"}, "svg-namespace": {"dfnID":"svg-namespace","dfnText":"SVG namespace","external":false,"refSections":[],"url":"#svg-namespace"}, "the-exclusive-range": {"dfnID":"the-exclusive-range","dfnText":"The range","external":false,"refSections":[{"refs":[{"id":"ref-for-the-exclusive-range"},{"id":"ref-for-the-exclusive-range\u2460"}],"title":"4.7. Strings"},{"refs":[{"id":"ref-for-the-exclusive-range\u2461"}],"title":"5.1. Lists"}],"url":"#the-exclusive-range"}, "the-range": {"dfnID":"the-range","dfnText":"The range","external":false,"refSections":[{"refs":[{"id":"ref-for-the-range"}],"title":"5.1.3. Sets"},{"refs":[{"id":"ref-for-the-range\u2460"}],"title":"6. JSON"}],"url":"#the-range"}, "tracking-vector": {"dfnID":"tracking-vector","dfnText":"tracking vector","external":false,"refSections":[],"url":"#tracking-vector"}, "trailing-surrogate": {"dfnID":"trailing-surrogate","dfnText":"trailing surrogate","external":false,"refSections":[{"refs":[{"id":"ref-for-trailing-surrogate"}],"title":"4.6. Code points"}],"url":"#trailing-surrogate"}, "tuple": {"dfnID":"tuple","dfnText":"tuple","external":false,"refSections":[{"refs":[{"id":"ref-for-tuple"},{"id":"ref-for-tuple\u2460"},{"id":"ref-for-tuple\u2461"}],"title":"3.5. Variables"},{"refs":[{"id":"ref-for-tuple\u2462"}],"title":"5.2. Maps"},{"refs":[{"id":"ref-for-tuple\u2463"},{"id":"ref-for-tuple\u2464"},{"id":"ref-for-tuple\u2465"},{"id":"ref-for-tuple\u2466"},{"id":"ref-for-tuple\u2467"},{"id":"ref-for-tuple\u2468"}],"title":"5.3.1. Tuples"}],"url":"#tuple"}, "user-agent": {"dfnID":"user-agent","dfnText":"user agent","external":false,"refSections":[{"refs":[{"id":"ref-for-user-agent"},{"id":"ref-for-user-agent\u2460"}],"title":"2.3. Terminology"}],"url":"#user-agent"}, "willful-violation": {"dfnID":"willful-violation","dfnText":"willful violation","external":false,"refSections":[{"refs":[{"id":"ref-for-willful-violation"}],"title":"2.1. Conformance"},{"refs":[{"id":"ref-for-willful-violation\u2460"}],"title":"2.2. Compliance with other specifications"}],"url":"#willful-violation"}, "xlink-namespace": {"dfnID":"xlink-namespace","dfnText":"XLink namespace","external":false,"refSections":[],"url":"#xlink-namespace"}, "xml-namespace": {"dfnID":"xml-namespace","dfnText":"XML namespace","external":false,"refSections":[],"url":"#xml-namespace"}, "xmlns-namespace": {"dfnID":"xmlns-namespace","dfnText":"XMLNS namespace","external":false,"refSections":[],"url":"#xmlns-namespace"}, }; document.addEventListener("DOMContentLoaded", ()=>{ genAllDfnPanels(); document.body.addEventListener("click", (e) => { // If not handled already, just hide all dfn panels. hideAllDfnPanels(); }); }); window.addEventListener("resize", () => { // Pin any visible dfn panel queryAll(".dfn-panel.on, .dfn-panel.activated").forEach(el=>positionDfnPanel(el)); }); function genAllDfnPanels() { for(const panelData of Object.values(dfnPanelData)) { const dfnID = panelData.dfnID; const dfn = document.getElementById(dfnID); if(!dfn) { console.log(`Can't find dfn#${dfnID}.`, panelData); continue; } dfn.panelData = panelData; insertDfnPopupAction(dfn); } } function genDfnPanel(dfn, { dfnID, url, dfnText, refSections, external }) { const dfnPanel = mk.aside({ class: "dfn-panel on", id: `infopanel-for-${dfnID}`, "data-for": dfnID, "aria-labelled-by":`infopaneltitle-for-${dfnID}`, }, mk.span({id:`infopaneltitle-for-${dfnID}`, style:"display:none"}, `Info about the '${dfnText}' ${external?"external":""} reference.`), mk.a({href:url, class:"dfn-link"}, url), refSections.length == 0 ? [] : mk.b({}, "Referenced in:"), mk.ul({}, ...refSections.map(section=> mk.li({}, ...section.refs.map((ref, refI)=> [ mk.a({ href: `#${ref.id}` }, (refI == 0) ? section.title : `(${refI + 1})` ), " ", ] ), ), ), ), genLinkingSyntaxes(dfn), ); dfnPanel.addEventListener('click', (event) => { if (event.target.nodeName == 'A') { scrollToTargetAndHighlight(event); pinDfnPanel(dfnPanel); } event.stopPropagation(); refocusOnTarget(event); }); dfnPanel.addEventListener('keydown', (event) => { if(event.keyCode == 27) { // Escape key hideDfnPanel({dfnPanel}); event.stopPropagation(); event.preventDefault(); } }); dfnPanel.dfn = dfn; dfn.dfnPanel = dfnPanel; return dfnPanel; } function hideAllDfnPanels() { // Delete the currently-active dfn panel. queryAll(".dfn-panel").forEach(dfnPanel=>hideDfnPanel({dfnPanel})); } function showDfnPanel(dfn) { hideAllDfnPanels(); // Only display one at a time. dfn.setAttribute("aria-expanded", "true"); const dfnPanel = genDfnPanel(dfn, dfn.panelData); // Give the dfn a unique tabindex, and then // give all the tabbable panel bits successive indexes. let tabIndex = 100; dfn.tabIndex = tabIndex++; const tabbable = dfnPanel.querySelectorAll(":is(a, button)"); for (const el of tabbable) { el.tabIndex = tabIndex++; } append(document.body, dfnPanel); positionDfnPanel(dfnPanel); } function positionDfnPanel(dfnPanel) { const dfn = dfnPanel.dfn; const dfnPos = getBounds(dfn); dfnPanel.style.top = dfnPos.bottom + "px"; dfnPanel.style.left = dfnPos.left + "px"; const panelPos = dfnPanel.getBoundingClientRect(); const panelMargin = 8; const maxRight = document.body.parentNode.clientWidth - panelMargin; if (panelPos.right > maxRight) { const overflowAmount = panelPos.right - maxRight; const newLeft = Math.max(panelMargin, dfnPos.left - overflowAmount); dfnPanel.style.left = newLeft + "px"; } } function pinDfnPanel(dfnPanel) { // Switch it to "activated" state, which pins it. dfnPanel.classList.add("activated"); dfnPanel.style.position = "fixed"; dfnPanel.style.left = null; dfnPanel.style.top = null; } function hideDfnPanel({dfn, dfnPanel}) { if(!dfnPanel) dfnPanel = dfn.dfnPanel; if(!dfn) dfn = dfnPanel.dfn; dfn.dfnPanel = undefined; dfnPanel.dfn = undefined; dfn.setAttribute("aria-expanded", "false"); dfn.tabIndex = undefined; dfnPanel.remove() } function toggleDfnPanel(dfn) { if(dfn.dfnPanel) { hideDfnPanel(dfn); } else { showDfnPanel(dfn); } } function insertDfnPopupAction(dfn) { dfn.setAttribute('role', 'button'); dfn.setAttribute('aria-expanded', 'false') dfn.tabIndex = 0; dfn.classList.add('has-dfn-panel'); dfn.addEventListener('click', (event) => { toggleDfnPanel(dfn); event.stopPropagation(); }); dfn.addEventListener('keypress', (event) => { const kc = event.keyCode; // 32->Space, 13->Enter if(kc == 32 || kc == 13) { toggleDfnPanel(dfn); event.stopPropagation(); event.preventDefault(); } }); } function refocusOnTarget(event) { const target = event.target; setTimeout(() => { // Refocus on the event.target element. // This is needed after browser scrolls to the destination. target.focus(); }); } // TODO: shared util // Returns the root-level absolute position {left and top} of element. function getBounds(el, relativeTo=document.body) { const relativeRect = relativeTo.getBoundingClientRect(); const elRect = el.getBoundingClientRect(); const top = elRect.top - relativeRect.top; const left = elRect.left - relativeRect.left; return { top, left, bottom: top + elRect.height, right: left + elRect.width, } } function scrollToTargetAndHighlight(event) { let hash = event.target.hash; if (hash) { hash = decodeURIComponent(hash.substring(1)); const dest = document.getElementById(hash); if (dest) { dest.classList.add('highlighted'); setTimeout(() => dest.classList.remove('highlighted'), 1000); } } } // Functions, divided by link type, that wrap an autolink's // contents with the appropriate outer syntax. // Alternately, a string naming another type they format // the same as. function needsFor(type) { switch(type) { case "descriptor": case "value": case "element-attr": case "attr-value": case "element-state": case "method": case "constructor": case "argument": case "attribute": case "const": case "dict-member": case "event": case "enum-value": case "stringifier": case "serializer": case "iterator": case "maplike": case "setlike": case "state": case "mode": case "context": case "facet": return true; default: return false; } } function refusesFor(type) { switch(type) { case "property": case "element": case "interface": case "namespace": case "callback": case "dictionary": case "enum": case "exception": case "typedef": case "http-header": case "permission": return true; default: return false; } } function linkFormatterFromType(type) { switch(type) { case 'scheme': case 'permission': case 'dfn': return (text) => `[=${text}=]`; case 'abstract-op': return (text) => `[\$${text}\$]`; case 'function': case 'at-rule': case 'selector': case 'value': return (text) => `''${text}''`; case 'http-header': return (text) => `[:${text}:]`; case 'interface': case 'constructor': case 'method': case 'argument': case 'attribute': case 'callback': case 'dictionary': case 'dict-member': case 'enum': case 'enum-value': case 'exception': case 'const': case 'typedef': case 'stringifier': case 'serializer': case 'iterator': case 'maplike': case 'setlike': case 'extended-attribute': case 'event': case 'idl': return (text) => `{{${text}}}`; case 'element-state': case 'element-attr': case 'attr-value': case 'element': return (element) => `<{${element}}>`; case 'grammar': return (text) => `${text} (within a <pre class=prod>)`; case 'type': return (text)=> `<<${text}>>`; case 'descriptor': case 'property': return (text) => `'${text}'`; default: return; }; }; function genLinkingSyntaxes(dfn) { if(dfn.tagName != "DFN") return; const type = dfn.getAttribute('data-dfn-type'); if(!type) { console.log(`<dfn> doesn't have a data-dfn-type:`, dfn); return []; } // Return a function that wraps link text based on the type const linkFormatter = linkFormatterFromType(type); if(!linkFormatter) { console.log(`<dfn> has an unknown data-dfn-type:`, dfn); return []; } let ltAlts; if(dfn.hasAttribute('data-lt')) { ltAlts = dfn.getAttribute('data-lt') .split("|") .map(x=>x.trim()); } else { ltAlts = [dfn.textContent.trim()]; } if(type == "type") { // lt of "<foo>", but "foo" is the interior; // <<foo/bar>> is how you write it with a for, // not <foo/<bar>> or whatever. for(var i = 0; i < ltAlts.length; i++) { const lt = ltAlts[i]; const match = /<(.*)>/.exec(lt); if(match) { ltAlts[i] = match[1]; } } } let forAlts; if(dfn.hasAttribute('data-dfn-for')) { forAlts = dfn.getAttribute('data-dfn-for') .split(",") .map(x=>x.trim()); } else { forAlts = ['']; } let linkingSyntaxes = []; if(!needsFor(type)) { for(const lt of ltAlts) { linkingSyntaxes.push(linkFormatter(lt)); } } if(!refusesFor(type)) { for(const f of forAlts) { linkingSyntaxes.push(linkFormatter(`${f}/${ltAlts[0]}`)) } } return [ mk.b({}, 'Possible linking syntaxes:'), mk.ul({}, ...linkingSyntaxes.map(link => { const copyLink = async () => await navigator.clipboard.writeText(link); return mk.li({}, mk.div({ class: 'link-item' }, mk.button({ class: 'copy-icon', title: 'Copy', type: 'button', _onclick: copyLink, tabindex: 0, }, mk.span({ class: 'icon' }) ), mk.span({}, link) ) ); }) ) ]; } } </script> <script>/* Boilerplate: script-ref-hints */ "use strict"; { let refsData = { "#128-bit-unsigned-integer": {"displayText":"128-bit unsigned integer","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"128-bit unsigned integer","type":"dfn","url":"#128-bit-unsigned-integer"}, "#16-bit-unsigned-integer": {"displayText":"16-bit unsigned integer","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"16-bit unsigned integer","type":"dfn","url":"#16-bit-unsigned-integer"}, "#abort-when": {"displayText":"abort when","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"abort when","type":"dfn","url":"#abort-when"}, "#ascii-alpha": {"displayText":"ascii alpha","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"ascii alpha","type":"dfn","url":"#ascii-alpha"}, "#ascii-alphanumeric": {"displayText":"ascii alphanumeric","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"ascii alphanumeric","type":"dfn","url":"#ascii-alphanumeric"}, "#ascii-byte": {"displayText":"ascii byte","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"ascii byte","type":"dfn","url":"#ascii-byte"}, "#ascii-code-point": {"displayText":"ascii code point","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"ascii code point","type":"dfn","url":"#ascii-code-point"}, "#ascii-digit": {"displayText":"ascii digit","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"ascii digit","type":"dfn","url":"#ascii-digit"}, "#ascii-lower-alpha": {"displayText":"ascii lower alpha","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"ascii lower alpha","type":"dfn","url":"#ascii-lower-alpha"}, "#ascii-lower-hex-digit": {"displayText":"ascii lower hex digit","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"ascii lower hex digit","type":"dfn","url":"#ascii-lower-hex-digit"}, "#ascii-lowercase": {"displayText":"ascii lowercase","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"ascii lowercase","type":"dfn","url":"#ascii-lowercase"}, "#ascii-string": {"displayText":"ascii string","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"ascii string","type":"dfn","url":"#ascii-string"}, "#ascii-upper-alpha": {"displayText":"ascii upper alpha","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"ascii upper alpha","type":"dfn","url":"#ascii-upper-alpha"}, "#ascii-upper-hex-digit": {"displayText":"ascii upper hex digit","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"ascii upper hex digit","type":"dfn","url":"#ascii-upper-hex-digit"}, "#ascii-uppercase": {"displayText":"ascii uppercase","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"ascii uppercase","type":"dfn","url":"#ascii-uppercase"}, "#ascii-whitespace": {"displayText":"ascii whitespace","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"ascii whitespace","type":"dfn","url":"#ascii-whitespace"}, "#assert": {"displayText":"assert","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"assert","type":"dfn","url":"#assert"}, "#boolean": {"displayText":"boolean","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"boolean","type":"dfn","url":"#boolean"}, "#byte": {"displayText":"byte","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"byte","type":"dfn","url":"#byte"}, "#byte-lowercase": {"displayText":"byte-lowercase","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"byte-lowercase","type":"dfn","url":"#byte-lowercase"}, "#byte-sequence": {"displayText":"byte sequence","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"byte sequence","type":"dfn","url":"#byte-sequence"}, "#byte-sequence-length": {"displayText":"length","export":true,"for_":["byte sequence"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"length","type":"dfn","url":"#byte-sequence-length"}, "#byte-sequence-prefix": {"displayText":"prefix","export":true,"for_":["byte sequence"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"prefix","type":"dfn","url":"#byte-sequence-prefix"}, "#byte-value": {"displayText":"value","export":true,"for_":["byte"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"value","type":"dfn","url":"#byte-value"}, "#c0-control": {"displayText":"c0 control","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"c0 control","type":"dfn","url":"#c0-control"}, "#code-point": {"displayText":"code point","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"code point","type":"dfn","url":"#code-point"}, "#code-point-substring": {"displayText":"code point substring","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"code point substring","type":"dfn","url":"#code-point-substring"}, "#code-point-substring-by-positions": {"displayText":"code point substring by positions","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"code point substring by positions","type":"dfn","url":"#code-point-substring-by-positions"}, "#code-point-value": {"displayText":"value","export":true,"for_":["code point"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"value","type":"dfn","url":"#code-point-value"}, "#code-unit": {"displayText":"code unit","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"code unit","type":"dfn","url":"#code-unit"}, "#code-unit-less-than": {"displayText":"code unit less than","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"code unit less than","type":"dfn","url":"#code-unit-less-than"}, "#code-unit-prefix": {"displayText":"code unit prefix","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"code unit prefix","type":"dfn","url":"#code-unit-prefix"}, "#code-unit-substring": {"displayText":"code unit substring","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"code unit substring","type":"dfn","url":"#code-unit-substring"}, "#code-unit-substring-by-positions": {"displayText":"code unit substring by positions","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"code unit substring by positions","type":"dfn","url":"#code-unit-substring-by-positions"}, "#code-unit-suffix": {"displayText":"code unit suffix","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"code unit suffix","type":"dfn","url":"#code-unit-suffix"}, "#collect-a-sequence-of-code-points": {"displayText":"collect a sequence of code points","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"collect a sequence of code points","type":"dfn","url":"#collect-a-sequence-of-code-points"}, "#convert-a-json-derived-javascript-value-to-an-infra-value": {"displayText":"convert a json-derived javascript value to an infra value","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"convert a json-derived javascript value to an infra value","type":"dfn","url":"#convert-a-json-derived-javascript-value-to-an-infra-value"}, "#convert-an-infra-value-to-a-json-compatible-javascript-value": {"displayText":"convert an infra value to a json-compatible javascript value","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"convert an infra value to a json-compatible javascript value","type":"dfn","url":"#convert-an-infra-value-to-a-json-compatible-javascript-value"}, "#forgiving-base64-decode": {"displayText":"forgiving-base64 decode","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"forgiving-base64 decode","type":"dfn","url":"#forgiving-base64-decode"}, "#forgiving-base64-encode": {"displayText":"forgiving-base64 encode","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"forgiving-base64 encode","type":"dfn","url":"#forgiving-base64-encode"}, "#if-aborted": {"displayText":"if aborted","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"if aborted","type":"dfn","url":"#if-aborted"}, "#implementation": {"displayText":"implementation","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"implementation","type":"dfn","url":"#implementation"}, "#implementation-defined": {"displayText":"implementation-defined","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"implementation-defined","type":"dfn","url":"#implementation-defined"}, "#isomorphic-decode": {"displayText":"isomorphic decode","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"isomorphic decode","type":"dfn","url":"#isomorphic-decode"}, "#isomorphic-encode": {"displayText":"isomorphic encode","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"isomorphic encode","type":"dfn","url":"#isomorphic-encode"}, "#isomorphic-string": {"displayText":"isomorphic string","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"isomorphic string","type":"dfn","url":"#isomorphic-string"}, "#iteration-break": {"displayText":"break","export":true,"for_":["iteration"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"break","type":"dfn","url":"#iteration-break"}, "#iteration-continue": {"displayText":"continue","export":true,"for_":["iteration"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"continue","type":"dfn","url":"#iteration-continue"}, "#iteration-while": {"displayText":"while","export":true,"for_":["iteration"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"while","type":"dfn","url":"#iteration-while"}, "#javascript-string-convert": {"displayText":"convert","export":true,"for_":["JavaScript string","string"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"convert","type":"dfn","url":"#javascript-string-convert"}, "#leading-surrogate": {"displayText":"leading surrogate","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"leading surrogate","type":"dfn","url":"#leading-surrogate"}, "#list": {"displayText":"list","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"list","type":"dfn","url":"#list"}, "#list-append": {"displayText":"append","export":true,"for_":["list"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"append","type":"dfn","url":"#list-append"}, "#list-clone": {"displayText":"clone","export":true,"for_":["list","queue","set","stack"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"clone","type":"dfn","url":"#list-clone"}, "#list-contain": {"displayText":"contain","export":true,"for_":["list","queue","set","stack"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"contain","type":"dfn","url":"#list-contain"}, "#list-extend": {"displayText":"extend","export":true,"for_":["list"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"extend","type":"dfn","url":"#list-extend"}, "#list-is-empty": {"displayText":"is empty","export":true,"for_":["list","queue","set","stack"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"is empty","type":"dfn","url":"#list-is-empty"}, "#list-item": {"displayText":"item","export":true,"for_":["list","queue","set","stack"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"item","type":"dfn","url":"#list-item"}, "#list-iterate": {"displayText":"for each","export":true,"for_":["list","set"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"for each","type":"dfn","url":"#list-iterate"}, "#list-prepend": {"displayText":"prepend","export":true,"for_":["list"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"prepend","type":"dfn","url":"#list-prepend"}, "#list-remove": {"displayText":"remove","export":true,"for_":["list","set"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"remove","type":"dfn","url":"#list-remove"}, "#list-size": {"displayText":"size","export":true,"for_":["list","queue","set","stack"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"size","type":"dfn","url":"#list-size"}, "#list-sort-in-ascending-order": {"displayText":"sorting","export":true,"for_":["list","queue","set","stack"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"sorting","type":"dfn","url":"#list-sort-in-ascending-order"}, "#map-entry": {"displayText":"entry","export":true,"for_":["map"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"entry","type":"dfn","url":"#map-entry"}, "#map-exists": {"displayText":"contain","export":true,"for_":["map"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"contain","type":"dfn","url":"#map-exists"}, "#map-get": {"displayText":"get","export":true,"for_":["map"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"get","type":"dfn","url":"#map-get"}, "#map-getting-the-keys": {"displayText":"keys","export":true,"for_":["map"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"keys","type":"dfn","url":"#map-getting-the-keys"}, "#map-getting-the-values": {"displayText":"values","export":true,"for_":["map"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"values","type":"dfn","url":"#map-getting-the-values"}, "#map-iterate": {"displayText":"for each","export":true,"for_":["map"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"for each","type":"dfn","url":"#map-iterate"}, "#map-key": {"displayText":"key","export":true,"for_":["map"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"key","type":"dfn","url":"#map-key"}, "#map-remove": {"displayText":"remove","export":true,"for_":["map"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"remove","type":"dfn","url":"#map-remove"}, "#map-set": {"displayText":"set","export":true,"for_":["map"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"set","type":"dfn","url":"#map-set"}, "#map-size": {"displayText":"size","export":true,"for_":["map"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"size","type":"dfn","url":"#map-size"}, "#map-value": {"displayText":"value","export":true,"for_":["map"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"value","type":"dfn","url":"#map-value"}, "#ordered-map": {"displayText":"ordered map","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"ordered map","type":"dfn","url":"#ordered-map"}, "#ordered-set": {"displayText":"ordered set","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"ordered set","type":"dfn","url":"#ordered-set"}, "#parse-a-json-string-to-a-javascript-value": {"displayText":"parse a json string to a javascript value","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"parse a json string to a javascript value","type":"dfn","url":"#parse-a-json-string-to-a-javascript-value"}, "#parse-a-json-string-to-an-infra-value": {"displayText":"parse a json string to an infra value","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"parse a json string to an infra value","type":"dfn","url":"#parse-a-json-string-to-an-infra-value"}, "#queue": {"displayText":"queue","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"queue","type":"dfn","url":"#queue"}, "#queue-dequeue": {"displayText":"dequeue","export":true,"for_":["queue"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"dequeue","type":"dfn","url":"#queue-dequeue"}, "#scalar-value": {"displayText":"scalar value","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"scalar value","type":"dfn","url":"#scalar-value"}, "#scalar-value-string": {"displayText":"scalar value string","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"scalar value string","type":"dfn","url":"#scalar-value-string"}, "#serialize-a-javascript-value-to-a-json-string": {"displayText":"serialize a javascript value to a json string","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"serialize a javascript value to a json string","type":"dfn","url":"#serialize-a-javascript-value-to-a-json-string"}, "#serialize-an-infra-value-to-a-json-string": {"displayText":"serialize an infra value to a json string","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"serialize an infra value to a json string","type":"dfn","url":"#serialize-an-infra-value-to-a-json-string"}, "#serialize-an-infra-value-to-json-bytes": {"displayText":"serialize an infra value to json bytes","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"serialize an infra value to json bytes","type":"dfn","url":"#serialize-an-infra-value-to-json-bytes"}, "#set-append": {"displayText":"append","export":true,"for_":["set"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"append","type":"dfn","url":"#set-append"}, "#set-prepend": {"displayText":"prepend","export":true,"for_":["set"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"prepend","type":"dfn","url":"#set-prepend"}, "#set-replace": {"displayText":"replace","export":true,"for_":["set"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"replace","type":"dfn","url":"#set-replace"}, "#set-subset": {"displayText":"subset","export":true,"for_":["set"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"subset","type":"dfn","url":"#set-subset"}, "#set-superset": {"displayText":"superset","export":true,"for_":["set"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"superset","type":"dfn","url":"#set-superset"}, "#skip-ascii-whitespace": {"displayText":"skip ascii whitespace","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"skip ascii whitespace","type":"dfn","url":"#skip-ascii-whitespace"}, "#split-on-ascii-whitespace": {"displayText":"split on ascii whitespace","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"split on ascii whitespace","type":"dfn","url":"#split-on-ascii-whitespace"}, "#split-on-commas": {"displayText":"split on commas","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"split on commas","type":"dfn","url":"#split-on-commas"}, "#stack": {"displayText":"stack","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"stack","type":"dfn","url":"#stack"}, "#stack-pop": {"displayText":"pop","export":true,"for_":["stack"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"pop","type":"dfn","url":"#stack-pop"}, "#string": {"displayText":"string","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"string","type":"dfn","url":"#string"}, "#string-code-point-length": {"displayText":"code point length","export":true,"for_":["ASCII string","JavaScript string","isomorphic string","scalar value string","string"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"code point length","type":"dfn","url":"#string-code-point-length"}, "#string-concatenate": {"displayText":"concatenation","export":true,"for_":["string"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"concatenation","type":"dfn","url":"#string-concatenate"}, "#string-ends-with": {"displayText":"ends with","export":true,"for_":["string"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"ends with","type":"dfn","url":"#string-ends-with"}, "#string-is": {"displayText":"identical to","export":true,"for_":["string"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"identical to","type":"dfn","url":"#string-is"}, "#string-length": {"displayText":"length","export":true,"for_":["ASCII string","JavaScript string","isomorphic string","scalar value string","string"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"length","type":"dfn","url":"#string-length"}, "#string-position-variable": {"displayText":"position variable","export":true,"for_":["string"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"position variable","type":"dfn","url":"#string-position-variable"}, "#string-starts-with": {"displayText":"starts with","export":true,"for_":["string"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"starts with","type":"dfn","url":"#string-starts-with"}, "#strip-leading-and-trailing-ascii-whitespace": {"displayText":"strip leading and trailing ascii whitespace","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"strip leading and trailing ascii whitespace","type":"dfn","url":"#strip-leading-and-trailing-ascii-whitespace"}, "#struct": {"displayText":"struct","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"struct","type":"dfn","url":"#struct"}, "#struct-item": {"displayText":"item","export":true,"for_":["struct","tuple"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"item","type":"dfn","url":"#struct-item"}, "#struct-name": {"displayText":"name","export":true,"for_":["struct","tuple"],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"name","type":"dfn","url":"#struct-name"}, "#surrogate": {"displayText":"surrogate","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"surrogate","type":"dfn","url":"#surrogate"}, "#the-exclusive-range": {"displayText":"the exclusive range","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"the exclusive range","type":"dfn","url":"#the-exclusive-range"}, "#the-range": {"displayText":"the range","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"the range","type":"dfn","url":"#the-range"}, "#trailing-surrogate": {"displayText":"trailing surrogate","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"trailing surrogate","type":"dfn","url":"#trailing-surrogate"}, "#tuple": {"displayText":"tuple","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"tuple","type":"dfn","url":"#tuple"}, "#user-agent": {"displayText":"user agent","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"user agent","type":"dfn","url":"#user-agent"}, "#willful-violation": {"displayText":"willful violation","export":true,"for_":[],"level":"","normative":true,"shortname":"infra","spec":"infra","status":"local","text":"willful violation","type":"dfn","url":"#willful-violation"}, "https://dom.spec.whatwg.org/#characterdata": {"displayText":"CharacterData","export":true,"for_":[],"level":"1","normative":true,"shortname":"dom","spec":"dom","status":"current","text":"CharacterData","type":"interface","url":"https://dom.spec.whatwg.org/#characterdata"}, "https://encoding.spec.whatwg.org/#utf-8-decode": {"displayText":"UTF-8 decode","export":true,"for_":[],"level":"1","normative":true,"shortname":"encoding","spec":"encoding","status":"current","text":"utf-8 decode","type":"dfn","url":"https://encoding.spec.whatwg.org/#utf-8-decode"}, "https://encoding.spec.whatwg.org/#utf-8-encode": {"displayText":"UTF-8 encode","export":true,"for_":[],"level":"1","normative":true,"shortname":"encoding","spec":"encoding","status":"current","text":"utf-8 encode","type":"dfn","url":"https://encoding.spec.whatwg.org/#utf-8-encode"}, "https://fetch.spec.whatwg.org/#http-whitespace": {"displayText":"HTTP whitespace","export":true,"for_":[],"level":"1","normative":true,"shortname":"fetch","spec":"fetch","status":"current","text":"http whitespace","type":"dfn","url":"https://fetch.spec.whatwg.org/#http-whitespace"}, "https://tc39.github.io/ecma262/#realm": {"displayText":"realm","export":true,"for_":[],"level":"262","normative":true,"shortname":"ecma","spec":"ecma-262","status":"anchor-block","text":"realm","type":"dfn","url":"https://tc39.github.io/ecma262/#realm"}, "https://tc39.github.io/ecma262/#sec-array.prototype.sort": {"displayText":"sort()","export":true,"for_":["Array"],"level":"262","normative":true,"shortname":"ecma","spec":"ecma-262","status":"anchor-block","text":"sort()","type":"method","url":"https://tc39.github.io/ecma262/#sec-array.prototype.sort"}, "https://tc39.github.io/ecma262/#sec-arraycreate": {"displayText":"ArrayCreate","export":true,"for_":[],"level":"262","normative":true,"shortname":"ecma","spec":"ecma-262","status":"anchor-block","text":"ArrayCreate","type":"abstract-op","url":"https://tc39.github.io/ecma262/#sec-arraycreate"}, "https://tc39.github.io/ecma262/#sec-call": {"displayText":"Call","export":true,"for_":[],"level":"262","normative":true,"shortname":"ecma","spec":"ecma-262","status":"anchor-block","text":"Call","type":"abstract-op","url":"https://tc39.github.io/ecma262/#sec-call"}, "https://tc39.github.io/ecma262/#sec-createdatapropertyorthrow": {"displayText":"CreateDataPropertyOrThrow","export":true,"for_":[],"level":"262","normative":true,"shortname":"ecma","spec":"ecma-262","status":"anchor-block","text":"CreateDataPropertyOrThrow","type":"abstract-op","url":"https://tc39.github.io/ecma262/#sec-createdatapropertyorthrow"}, "https://tc39.github.io/ecma262/#sec-ecmascript-language-types-boolean-type": {"displayText":"is a Boolean","export":true,"for_":[],"level":"262","normative":true,"shortname":"ecma","spec":"ecma-262","status":"anchor-block","text":"is a boolean","type":"dfn","url":"https://tc39.github.io/ecma262/#sec-ecmascript-language-types-boolean-type"}, "https://tc39.github.io/ecma262/#sec-ecmascript-language-types-number-type": {"displayText":"is a Number","export":true,"for_":[],"level":"262","normative":true,"shortname":"ecma","spec":"ecma-262","status":"anchor-block","text":"is a number","type":"dfn","url":"https://tc39.github.io/ecma262/#sec-ecmascript-language-types-number-type"}, "https://tc39.github.io/ecma262/#sec-ecmascript-language-types-string-type": {"displayText":"The String Type","export":true,"for_":[],"level":"262","normative":true,"shortname":"ecma","spec":"ecma-262","status":"anchor-block","text":"the string type","type":"dfn","url":"https://tc39.github.io/ecma262/#sec-ecmascript-language-types-string-type"}, "https://tc39.github.io/ecma262/#sec-get-o-p": {"displayText":"Get","export":true,"for_":[],"level":"262","normative":true,"shortname":"ecma","spec":"ecma-262","status":"anchor-block","text":"Get","type":"abstract-op","url":"https://tc39.github.io/ecma262/#sec-get-o-p"}, "https://tc39.github.io/ecma262/#sec-isarray": {"displayText":"IsArray","export":true,"for_":[],"level":"262","normative":true,"shortname":"ecma","spec":"ecma-262","status":"anchor-block","text":"IsArray","type":"abstract-op","url":"https://tc39.github.io/ecma262/#sec-isarray"}, "https://tc39.github.io/ecma262/#sec-json.parse": {"displayText":"%JSON.parse%","export":true,"for_":[],"level":"262","normative":true,"shortname":"ecma","spec":"ecma-262","status":"anchor-block","text":"%json.parse%","type":"dfn","url":"https://tc39.github.io/ecma262/#sec-json.parse"}, "https://tc39.github.io/ecma262/#sec-json.stringify": {"displayText":"%JSON.stringify%","export":true,"for_":[],"level":"262","normative":true,"shortname":"ecma","spec":"ecma-262","status":"anchor-block","text":"%json.stringify%","type":"dfn","url":"https://tc39.github.io/ecma262/#sec-json.stringify"}, "https://tc39.github.io/ecma262/#sec-list-and-record-specification-type": {"displayText":"List","export":true,"for_":[],"level":"262","normative":true,"shortname":"ecma","spec":"ecma-262","status":"anchor-block","text":"list","type":"dfn","url":"https://tc39.github.io/ecma262/#sec-list-and-record-specification-type"}, "https://tc39.github.io/ecma262/#sec-ordinaryobjectcreate": {"displayText":"OrdinaryObjectCreate","export":true,"for_":[],"level":"262","normative":true,"shortname":"ecma","spec":"ecma-262","status":"anchor-block","text":"OrdinaryObjectCreate","type":"abstract-op","url":"https://tc39.github.io/ecma262/#sec-ordinaryobjectcreate"}, "https://tc39.github.io/ecma262/#sec-tolength": {"displayText":"ToLength","export":true,"for_":[],"level":"262","normative":true,"shortname":"ecma","spec":"ecma-262","status":"anchor-block","text":"ToLength","type":"abstract-op","url":"https://tc39.github.io/ecma262/#sec-tolength"}, "https://tc39.github.io/ecma262/#sec-tostring": {"displayText":"ToString","export":true,"for_":[],"level":"262","normative":true,"shortname":"ecma","spec":"ecma-262","status":"anchor-block","text":"ToString","type":"abstract-op","url":"https://tc39.github.io/ecma262/#sec-tostring"}, "https://url.spec.whatwg.org/#concept-host": {"displayText":"host","export":true,"for_":[],"level":"1","normative":true,"shortname":"url","spec":"url","status":"current","text":"host","type":"dfn","url":"https://url.spec.whatwg.org/#concept-host"}, "https://w3c.github.io/hr-time/#dfn-duration": {"displayText":"duration","export":true,"for_":[],"level":"3","normative":true,"shortname":"hr-time","spec":"hr-time-3","status":"current","text":"duration","type":"dfn","url":"https://w3c.github.io/hr-time/#dfn-duration"}, "https://w3c.github.io/hr-time/#dfn-moment": {"displayText":"moment","export":true,"for_":[],"level":"3","normative":true,"shortname":"hr-time","spec":"hr-time-3","status":"current","text":"moment","type":"dfn","url":"https://w3c.github.io/hr-time/#dfn-moment"}, "https://webidl.spec.whatwg.org/#exceptiondef-typeerror": {"displayText":"TypeError","export":true,"for_":[],"level":"1","normative":true,"shortname":"webidl","spec":"webidl","status":"current","text":"TypeError","type":"exception","url":"https://webidl.spec.whatwg.org/#exceptiondef-typeerror"}, }; function mkRefHint(link, ref) { const linkText = link.textContent; let dfnTextElements = ''; if (ref.displayText.toLowerCase() != linkText.toLowerCase()) { // Give the original term if it's being displayed in a different way. // But allow casing differences, they're insignificant. dfnTextElements = mk.li({}, mk.b({}, "Term: "), mk.span({}, ref.displayText) ); } const forList = ref.for_; let forListElements; if(forList.length == 0) { forListElements = []; } else if(forList.length == 1) { forListElements = mk.li({}, mk.b({}, "For: "), mk.span({}, forList[0]), ); } else { forListElements = mk.li({}, mk.b({}, "For: "), mk.ul({}, ...forList.map(forItem => mk.li({}, mk.span({}, forItem) ), ), ), ); } const url = ref.url; const safeUrl = encodeURIComponent(url); const hintPanel = mk.aside({ class: "ref-hint", id: `ref-hint-for-${safeUrl}`, "data-for": url, "aria-labelled-by": `ref-hint-for-${safeUrl}`, }, mk.ul({}, dfnTextElements, mk.li({}, mk.b({}, "URL: "), mk.a({ href: url, class: "ref" }, url), ), mk.li({}, mk.b({}, "Type: "), mk.span({}, `${ref.type}`), ), mk.li({}, mk.b({}, "Spec: "), mk.span({}, `${ref.spec ? ref.spec : ''}`), ), forListElements ), ); hintPanel.forLink = link; setupRefHintEventListeners(link, hintPanel); return hintPanel; } function hideAllRefHints() { queryAll(".ref-hint").forEach(el=>hideRefHint(el)); } function hideRefHint(refHint) { const link = refHint.forLink; link.setAttribute("aria-expanded", "false"); if(refHint.teardownEventListeners) { refHint.teardownEventListeners(); } refHint.remove(); } function showRefHint(link) { if(link.classList.contains("dfn-link")) return; const url = link.getAttribute("href"); const ref = refsData[url]; if(!ref) return; hideAllRefHints(); // Only display one at this time. const refHint = mkRefHint(link, ref); append(document.body, refHint); link.setAttribute("aria-expanded", "true"); positionRefHint(refHint); } function setupRefHintEventListeners(link, refHint) { if (refHint.teardownEventListeners) return; // Add event handlers to hide the refHint after the user moves away // from both the link and refHint, if not hovering either within one second. let timeout = null; const startHidingRefHint = (event) => { if (timeout) { clearTimeout(timeout); } timeout = setTimeout(() => { hideRefHint(refHint); }, 1000); } const resetHidingRefHint = (event) => { if (timeout) clearTimeout(timeout); timeout = null; }; link.addEventListener("mouseleave", startHidingRefHint); link.addEventListener("mouseenter", resetHidingRefHint); link.addEventListener("blur", startHidingRefHint); link.addEventListener("focus", resetHidingRefHint); refHint.addEventListener("mouseleave", startHidingRefHint); refHint.addEventListener("mouseenter", resetHidingRefHint); refHint.addEventListener("blur", startHidingRefHint); refHint.addEventListener("focus", resetHidingRefHint); refHint.teardownEventListeners = () => { // remove event listeners resetHidingRefHint(); link.removeEventListener("mouseleave", startHidingRefHint); link.removeEventListener("mouseenter", resetHidingRefHint); link.removeEventListener("blur", startHidingRefHint); link.removeEventListener("focus", resetHidingRefHint); refHint.removeEventListener("mouseleave", startHidingRefHint); refHint.removeEventListener("mouseenter", resetHidingRefHint); refHint.removeEventListener("blur", startHidingRefHint); refHint.removeEventListener("focus", resetHidingRefHint); }; } function positionRefHint(refHint) { const link = refHint.forLink; const linkPos = getBounds(link); refHint.style.top = linkPos.bottom + "px"; refHint.style.left = linkPos.left + "px"; const panelPos = refHint.getBoundingClientRect(); const panelMargin = 8; const maxRight = document.body.parentNode.clientWidth - panelMargin; if (panelPos.right > maxRight) { const overflowAmount = panelPos.right - maxRight; const newLeft = Math.max(panelMargin, linkPos.left - overflowAmount); refHint.style.left = newLeft + "px"; } } // TODO: shared util // Returns the root-level absolute position {left and top} of element. function getBounds(el, relativeTo=document.body) { const relativeRect = relativeTo.getBoundingClientRect(); const elRect = el.getBoundingClientRect(); const top = elRect.top - relativeRect.top; const left = elRect.left - relativeRect.left; return { top, left, bottom: top + elRect.height, right: left + elRect.width, } } function showRefHintListener(e) { // If the target isn't in a link (or is a link), // just ignore it. let link = e.target.closest("a"); if(!link) return; // If the target is in a ref-hint panel // (aka a link in the already-open one), // also just ignore it. if(link.closest(".ref-hint")) return; // Otherwise, show the panel for the link. showRefHint(link); } function hideAllHintsListener(e) { // If the click is inside a ref-hint panel, ignore it. if(e.target.closest(".ref-hint")) return; // Otherwise, close all the current panels. hideAllRefHints(); } document.addEventListener("DOMContentLoaded", () => { document.body.addEventListener("mousedown", showRefHintListener); document.body.addEventListener("focus", showRefHintListener); document.body.addEventListener("click", hideAllHintsListener); }); window.addEventListener("resize", () => { // Hide any open ref hint. hideAllRefHints(); }); } </script> <script>/* Boilerplate: script-var-click-highlighting */ "use strict"; { /* Color-choosing design: * Colors are ordered by goodness. * On clicking a var, give it the earliest color with the lowest usage in the algorithm. * On re-clicking, re-use the var's most recent color if that's not currently being used elsewhere. */ const COLOR_COUNT = 7; document.addEventListener("click", e=>{ if(e.target.nodeName == "VAR") { highlightSameAlgoVars(e.target); } }); function highlightSameAlgoVars(v) { // Find the algorithm container. let algoContainer = findAlgoContainer(v); // Not highlighting document-global vars, // too likely to be unrelated. if(algoContainer == null) return; const varName = nameFromVar(v); if(!v.hasAttribute("data-var-color")) { const newColor = chooseHighlightColor(algoContainer, v); for(const el of algoContainer.querySelectorAll("var")) { if(nameFromVar(el) == varName) { el.setAttribute("data-var-color", newColor); el.setAttribute("data-var-last-color", newColor); } } } else { for(const el of algoContainer.querySelectorAll("var")) { if(nameFromVar(el) == varName) { el.removeAttribute("data-var-color"); } } } } function findAlgoContainer(el) { while(el != document.body) { if(el.hasAttribute("data-algorithm")) return el; el = el.parentNode; } return null; } function nameFromVar(el) { return el.textContent.replace(/(\s|\xa0)+/g, " ").trim(); } function colorCountsFromContainer(container) { const namesFromColor = Array.from({length:COLOR_COUNT}, x=>new Set()); for(let v of container.querySelectorAll("var[data-var-color]")) { let color = +v.getAttribute("data-var-color"); namesFromColor[color].add(nameFromVar(v)); } return namesFromColor.map(x=>x.size); } function leastUsedColor(colors) { // Find the earliest color with the lowest count. let minCount = Infinity; let minColor = null; for(var i = 0; i < colors.length; i++) { if(colors[i] < minCount) { minColor = i; minCount = colors[i]; } } return minColor; } function chooseHighlightColor(container, v) { const colorCounts = colorCountsFromContainer(container); if(v.hasAttribute("data-var-last-color")) { let color = +v.getAttribute("data-var-last-color"); if(colorCounts[color] == 0) return color; } return leastUsedColor(colorCounts); } } </script>