This repository has been archived by the owner on Jan 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathspec.html
43 lines (40 loc) · 2.37 KB
/
spec.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!doctype html>
<meta charset="utf8">
<link rel="stylesheet" href="./spec.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/github.min.css">
<script src="./spec.js"></script>
<pre class="metadata">
title: Object.fromEntries
stage: 4
contributors: Darien Maillet Valentine, Jordan Harband, Kevin Gibbons
</pre>
<emu-intro id="sec-intro">
<h1>Introduction</h1>
<p>`Object.fromEntries` takes a list of key-value pairs, such as that produced by `Object.entries`, and returns a new object whose properties are given by those entries. Its argument _iterable_ is expected to be an object that implements an @@iterator method, that returns an iterator object, that produces a two element array-like object, whose first element is a value that will be used as a property key, and whose second element is the value to associate with that property key.</p>
</emu-intro>
<emu-clause id="sec-object.fromentries">
<h1>Object.fromEntries ( iterable )</h1>
<p>When the `fromEntries` method is called with argument _iterable_, the following steps are taken:</p>
<emu-alg>
1. Perform ? RequireObjectCoercible(_iterable_).
1. Let _obj_ be ObjectCreate(%ObjectPrototype%).
1. Assert: _obj_ is an extensible ordinary object with no own properties.
1. Let _stepsDefine_ be the algorithm steps defined in <emu-xref href="#sec-create-data-property-on-object-functions">CreateDataPropertyOnObject Functions</emu-xref>.
1. Let _adder_ be CreateBuiltinFunction(_stepsDefine_, « »).
1. Return ? <a href="https://tc39.github.io/ecma262/#sec-add-entries-from-iterable">AddEntriesFromIterable</a>(_obj_, _iterable_, _adder_).
</emu-alg>
<emu-note>
The function created for _adder_ is never directly accessible to ECMAScript code.
</emu-note>
</emu-clause>
<emu-clause id="sec-create-data-property-on-object-functions">
<h1>CreateDataPropertyOnObject Functions</h1>
<p>A CreateDataPropertyOnObject function is an anonymous built-in function. When a CreateDataPropertyOnObject function is called with arguments _key_ and _value_, the following steps are taken:</p>
<emu-alg>
1. Let _O_ be the *this* value.
1. Assert: Type(_O_) is Object.
1. Assert: _O_ is an extensible ordinary object.
1. Let _propertyKey_ be ? ToPropertyKey(_key_).
1. Perform ! CreateDataPropertyOrThrow(_O_, _propertyKey_, _value_).
<emu-alg>
</emu-clause>