-
Notifications
You must be signed in to change notification settings - Fork 68
/
x8.html
2386 lines (2383 loc) · 93.4 KB
/
x8.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html class="split chapter"><head><meta charset="utf-8"><title>8 Types # Ⓣ Ⓔ ① Ⓐ — Annotated ES5</title><link rel="stylesheet" href="style.css"><link href="x7.html" title="7 Lexical Conventions " rel="prev">
<link href="spec.html" title="TOC" rel="index">
<link href="x9.html" title="9 Type Conversion and Testing " rel="next">
</head><body><div class="head">
<h2 id="top">Annotated ECMAScript 5.1 <span id="timestamp"></span></h2>
<div id="mascot-treehouse">
<img id="mascot" align="left" src="js-mascot.svg" alt=""><img id="bubble" src="bubble.svg" alt=""></div>
<p id="slogan">‟Ex igne vita”</p>
<div id="annotations"></div>
<script src="timestamp.js"></script></div>
<nav>
<a href="x7.html">← 7 Lexical Conventions </a> –
<a href="spec.html" class="toc-nav">TOC</a> –
<a href="x9.html">9 Type Conversion and Testing →</a>
<ol class="toc"><li><a href="x8.html#x8" id="x8-toc">8 Types</a>
<b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> <ol><li><a href="x8.html#x8.1" id="x8.1-toc">8.1 The Undefined Type</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x8.html#x8.2" id="x8.2-toc">8.2 The Null Type</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x8.html#x8.3" id="x8.3-toc">8.3 The Boolean Type</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x8.html#x8.4" id="x8.4-toc">8.4 The String Type</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x8.html#x8.5" id="x8.5-toc">8.5 The Number Type</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x8.html#x8.6" id="x8.6-toc">8.6 The Object Type</a>
<b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> <ol><li><a href="x8.html#x8.6.1" id="x8.6.1-toc">8.6.1 Property Attributes</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x8.html#x8.6.2" id="x8.6.2-toc">8.6.2 Object Internal Properties and Methods</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li></ol></li><li><a href="x8.html#x8.7" id="x8.7-toc">8.7 The Reference Specification Type</a>
<b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> <ol><li><a href="x8.html#x8.7.1" id="x8.7.1-toc">8.7.1 GetValue (V)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x8.html#x8.7.2" id="x8.7.2-toc">8.7.2 PutValue (V, W)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li></ol></li><li><a href="x8.html#x8.8" id="x8.8-toc">8.8 The List Specification Type</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x8.html#x8.9" id="x8.9-toc">8.9 The Completion Specification Type</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x8.html#x8.10" id="x8.10-toc">8.10 The Property Descriptor and Property Identifier Specification Types</a>
<b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> <ol><li><a href="x8.html#x8.10.1" id="x8.10.1-toc">8.10.1 IsAccessorDescriptor ( Desc )</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x8.html#x8.10.2" id="x8.10.2-toc">8.10.2 IsDataDescriptor ( Desc )</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x8.html#x8.10.3" id="x8.10.3-toc">8.10.3 IsGenericDescriptor ( Desc )</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x8.html#x8.10.4" id="x8.10.4-toc">8.10.4 FromPropertyDescriptor ( Desc )</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x8.html#x8.10.5" id="x8.10.5-toc">8.10.5 ToPropertyDescriptor ( Obj )</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li></ol></li><li><a href="x8.html#x8.11" id="x8.11-toc">8.11 The Lexical Environment and Environment Record Specification Types</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x8.html#x8.12" id="x8.12-toc">8.12 Algorithms for Object Internal Methods</a>
<b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> <ol><li><a href="x8.html#x8.12.1" id="x8.12.1-toc">8.12.1 [[GetOwnProperty]] (P)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x8.html#x8.12.2" id="x8.12.2-toc">8.12.2 [[GetProperty]] (P)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x8.html#x8.12.3" id="x8.12.3-toc">8.12.3 [[Get]] (P)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x8.html#x8.12.4" id="x8.12.4-toc">8.12.4 [[CanPut]] (P)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x8.html#x8.12.5" id="x8.12.5-toc">8.12.5 [[Put]] ( P, V, Throw )</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x8.html#x8.12.6" id="x8.12.6-toc">8.12.6 [[HasProperty]] (P)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x8.html#x8.12.7" id="x8.12.7-toc">8.12.7 [[Delete]] (P, Throw)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x8.html#x8.12.8" id="x8.12.8-toc">8.12.8 [[DefaultValue]] (hint)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x8.html#x8.12.9" id="x8.12.9-toc">8.12.9 [[DefineOwnProperty]] (P, Desc, Throw)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li></ol></li></ol></li></ol></nav>
<h2 id="x8">8 Types <a href="#x8">#</a> <a href="#x8-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h2>
<p>
Algorithms
within this specification manipulate values each of which has an
associated type. The possible value types are exactly those defined
in this clause. Types are further subclassified into ECMAScript
<a href="#language-type">language types</a> and <a href="#specification-type">specification types</a>.</p>
<p>
An
ECMAScript <dfn id="language-type">language type</dfn> corresponds to values that are directly
manipulated by an ECMAScript programmer using the ECMAScript
language. The ECMAScript language types are
<a href="#x8.1">Undefined</a>,
<a href="#x8.2">Null</a>,
<a href="#x8.3">Boolean</a>,
<a href="#x8.4">String</a>,
<a href="#x8.5">Number</a>,
and
<a href="#x8.6">Object</a>.</p>
<p>
A
<dfn id="specification-type">specification type</dfn> corresponds to meta-values that are used within
algorithms to describe the semantics of ECMAScript language
constructs and ECMAScript <a href="#language-type">language types</a>. The specification types
are
<a href="#x8.7">Reference</a>,
<a href="#x8.8">List</a>,
<a href="#x8.9">Completion</a>,
<a href="#x8.10">Property Descriptor</a>,
<a href="#property-identifier">Property Identifier</a>,
<a href="x10.html#x10.2">Lexical Environment</a>,
and
<a href="x10.html#x10.2.1">Environment Record</a>.
Specification type values are specification artefacts that do not
necessarily correspond to any specific entity within an ECMAScript
implementation. Specification type values may be used to describe
intermediate results of ECMAScript expression evaluation but such
values cannot be stored as properties of objects or values of
ECMAScript language variables.</p>
<p>
Within
this specification, the notation <dfn id="Type">“Type(<i>x</i>)”</dfn>
is used as shorthand for “the
type of <i>x</i>”
where “type” refers
to the ECMAScript language and specification types defined in this
clause.</p>
<h3 id="x8.1">8.1 The Undefined Type <a href="#x8.1">#</a> <a href="#x8.1-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h3>
<p>
The
Undefined type has exactly one value, called <b>undefined</b>. Any
variable that has not been assigned a value has the value <b>undefined</b>.</p>
<h3 id="x8.2">8.2 The Null Type <a href="#x8.2">#</a> <a href="#x8.2-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h3>
<p>
The
Null type has exactly one value, called <b>null</b>.</p>
<h3 id="x8.3">8.3 The Boolean Type <a href="#x8.3">#</a> <a href="#x8.3-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h3>
<p>
The
Boolean type represents a logical entity having two values, called
<b>true </b>and <b>false</b>.</p>
<h3 id="x8.4">8.4 The String Type <a href="#x8.4">#</a> <a href="#x8.4-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h3>
<p>
The
String type is the set of all finite ordered sequences of zero or
more 16-bit unsigned integer values (“elements”). The String
type is generally used to represent textual data in a running
ECMAScript program, in which case each element in the String is
treated as a code unit value (see <a href="x6.html#x6">Clause 6</a>). Each element is
regarded as occupying a position within the sequence. These
positions are indexed with nonnegative integers. The first element
(if any) is at position 0, the next element (if any) at position 1,
and so on. The length of a String is the number of elements (i.e.,
16-bit values) within it. The empty String has length zero and
therefore contains no elements.</p>
<p>
When
a String contains actual textual data, each element is considered to
be a single UTF-16 code unit. Whether or not this is the actual
storage format of a String, the characters within a String are
numbered by their initial code unit element position as though they
were represented using UTF-16. All operations on Strings (except as
otherwise stated) treat them as sequences of undifferentiated 16-bit
unsigned integers; they do not ensure the resulting String is in
normalised form, nor do they ensure language-sensitive results.</p>
<p><b class="note">NOTE</b> The
rationale behind this design was to keep the implementation of
Strings as simple and high-performing as possible. The intent is
that textual data coming into the execution environment from outside
(e.g., user input, text read from a file or received over the
network, etc.) be converted to Unicode Normalised Form C before the
running program sees it. Usually this would occur at the same time
incoming text is converted from its original character encoding to
Unicode (and would impose no additional overhead). Since it is
recommended that ECMAScript source code be in Normalised Form C,
string literals are guaranteed to be normalised (if source text is
guaranteed to be normalised), as long as they do not contain any
Unicode escape sequences.</p>
<h3 id="x8.5">8.5 The Number Type <a href="#x8.5">#</a> <a href="#x8.5-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h3>
<p>
The
Number type has exactly 18437736874454810627
(that is, 2<sup>64</sup><span class="symbol">−</span>2<sup>53</sup>+3)
values, representing the double-precision 64-bit format IEEE 754
values as specified in the IEEE Standard for Binary Floating-Point
Arithmetic, except that the 9007199254740990
(that is, 2<sup>53</sup><span class="symbol">−</span>2)
distinct “Not-a-Number” values of the IEEE Standard are
represented in ECMAScript as a single special <b>NaN</b> value.
(Note that the <b>NaN</b> value is produced by the program
expression <code><b>NaN</b></code>.)
In some implementations, external code might be able to detect a
difference between various Not-a-Number values, but such behaviour
is implementation-dependent; to ECMAScript code, all NaN values are
indistinguishable from each other.</p>
<p>
There
are two other special values, called <b>positive Infinity</b> and
<b>negative Infinity</b>. For brevity, these values are also
referred to for expository purposes by the symbols <b>+</b><span class="symbol"><b>∞</b></span>
and <span class="symbol"><b>−∞</b></span>, respectively.
(Note that these two infinite Number values are produced by the
program expressions <code><b>+Infinity</b></code>
(or simply <code><b>Infinity</b></code>)
and <code><b>-Infinity</b></code>.)</p>
<p>
The
other 18437736874454810624
(that is, 2<sup>64</sup><span class="symbol">−</span>2<sup>53</sup>)
values are called the finite numbers. Half of these are positive
numbers and half are negative numbers; for every finite positive
Number value there is a corresponding negative value having the same
magnitude.</p>
<p>
Note
that there is both a <b>positive zero</b> and a <b>negative zero</b>.
For brevity, these values are also referred to for expository
purposes by the symbols <b>+0</b>
and <span class="symbol"><b>−</b></span><b>0</b>,
respectively. (Note that these two different zero Number values are
produced by the program expressions <code><b>+0</b></code>
(or simply <code><b>0</b></code>) and
<code><b>-0</b></code>.)</p>
<p>
The
18437736874454810622
(that is, 2<sup>64</sup><span class="symbol">−</span>2<sup>53</sup><span class="symbol">−</span>2)
finite nonzero values are of two kinds:</p>
<p>
18428729675200069632
(that is, 2<sup>64</sup><span class="symbol">−</span>2<sup>54</sup>)
of them are normalised, having the form</p>
<p class="code-example">
<i>s</i>
<span class="symbol">×</span> <i>m</i> <span class="symbol">×</span>
2<sup><i>e</i></sup></p>
<p>
where
<i>s</i> is +1
or <span class="symbol">−</span>1,
<i>m</i> is a positive
integer less than 2<sup>53</sup>
but not less than 2<sup>52</sup>,
and <i>e</i> is an
integer ranging from <span class="symbol">−</span>1074
to 971, inclusive.</p>
<p>
The
remaining 9007199254740990
(that is, 2<sup>53</sup><span class="symbol">−</span>2)
values are denormalised, having the form</p>
<p class="code-example">
<i>s</i>
<span class="symbol">×</span> <i>m</i> <span class="symbol">×</span>
2<sup><i>e</i></sup></p>
<p>
where
<i>s</i>
is +1 or <span class="symbol">−</span>1,
<i>m</i> is a positive
integer less than 2<sup>52</sup>,
and <i>e</i> is <span class="symbol">−</span>1074.</p>
<p>
Note
that all the positive and negative integers whose magnitude is no
greater than 2<sup>53</sup>
are representable in the Number type (indeed, the integer 0
has two representations, <code><b>+0</b></code>
and <code><b>-0</b></code>).</p>
<p>
A
finite number has an <i>odd significand</i> if it is nonzero and the
integer <i>m</i> used to
express it (in one of the two forms shown above) is odd. Otherwise,
it has an <i>even significand</i>.</p>
<p>
In
this specification, the phrase “the
Number value for <i>x</i>”
where <i>x</i> represents
an exact nonzero real mathematical quantity (which might even be an
irrational number such as <span class="symbol">π</span>)
means a Number value chosen in the following manner. Consider the
set of all finite values of the Number type, with <span class="symbol"><b>−</b></span><b>0</b>
removed and with two additional values added to it that are not
representable in the Number type, namely 2<sup>1024</sup>
(which is +1 <span class="symbol">×</span>
2<sup>53</sup><span class="symbol">×</span>
2<sup>971</sup>)
and <span class="symbol">−</span>2<sup>1024</sup>
(which is <span class="symbol">−</span>1
<span class="symbol">×</span>
2<sup>53</sup><span class="symbol">×</span>
2<sup>971</sup>).
Choose the member of this set that is closest in value to <i>x</i>.
If two values of the set are equally close, then the one with an
even significand is chosen; for this purpose, the two extra values
2<sup>1024</sup>
and <span class="symbol">−</span>2<sup>1024</sup>
are considered to have even significands. Finally, if 2<sup>1024</sup>
was chosen, replace it with <b>+</b><span class="symbol"><b>∞</b></span>;
if <span class="symbol">−</span>2<sup>1024</sup>
was chosen, replace it with <span class="symbol"><b>−∞</b></span>;
if <b>+0</b> was chosen,
replace it with <span class="symbol"><b>−</b></span><b>0</b>
if and only if <i>x</i>
is less than zero; any other chosen value is used unchanged. The
result is the Number value for <i>x</i>.
(This procedure corresponds exactly to the behaviour of the IEEE 754
“round to nearest” mode.)</p>
<p>
Some
ECMAScript operators deal only with integers in the range <span class="symbol">−</span>2<sup>31</sup>
through 2<sup>31</sup><span class="symbol">−</span>1,
inclusive, or in the range 0
through 2<sup>32</sup><span class="symbol">−</span>1,
inclusive. These operators accept any value of the Number type but
first convert each such value to one of 2<sup>32</sup>
integer values. See the descriptions of the <a href="x9.html#x9.5">ToInt32</a> and <a href="x9.html#x9.6">ToUint32</a>
operators in <a href="x9.html#x9.5">9.5</a> and <a href="x9.html#x9.6">9.6</a>, respectively.</p>
<h3 id="x8.6">8.6 The Object Type <a href="#x8.6">#</a> <a href="#x8.6-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h3>
<p>
An
Object is a collection of properties.<i> </i>Each property is either
a named data property, a named accessor property, or an internal
property:</p>
<ul><li><p>
A
<i>named data property</i> associates a name with an ECMAScript
language value and a set of Boolean attributes.</p>
</li>
<li><p>
A
<i>named accessor property</i> associates a name with one or two
accessor functions, and a set of Boolean attributes. The accessor
functions are used to store or retrieve an ECMAScript language
value that is associated with the property.
</p>
</li>
<li><p>
An
<i>internal property</i> has no name and is not directly accessible
via ECMAScript language operators. Internal properties exist purely
for specification purposes.
</p>
</li></ul><p>
There
are two kinds of access for named (non-internal) properties: <i>get </i>and <i>put</i>, corresponding to retrieval and assignment,
respectively.</p>
<h4 id="x8.6.1">8.6.1 Property Attributes <a href="#x8.6.1">#</a> <a href="#x8.6.1-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h4>
<p>
Attributes
are used in this specification to define and explain the state of
named properties. A named data property associates a name with the
attributes listed in Table 5</p>
<dl><dd>
<center>
<table width="709" border="2" bordercolor="#000000" cellpadding="8" cellspacing="0"><caption>Table 5 — Attributes of a Named Data Property</caption>
<colgroup><col width="115"><col width="134"><col width="408"></colgroup><tbody><tr valign="TOP"><td width="115" bgcolor="#d8d8d8">
<p>
<i><b>Attribute
Name</b></i></p>
</td>
<td width="134" bgcolor="#d8d8d8">
<p>
<i><b>Value
Domain</b></i></p>
</td>
<td width="408" bgcolor="#d8d8d8">
<p>
<i><b>Description</b></i></p>
</td>
</tr><tr valign="TOP"><td width="115" height="8">
<p>
[[Value]]
</p>
</td>
<td width="134">
<p>
Any
ECMAScript <a href="#language-type">language type</a></p>
</td>
<td width="408">
<p>
The
value retrieved by reading the property.</p>
</td>
</tr><tr valign="TOP"><td width="115" height="17">
<p>
[[Writable]]
</p>
</td>
<td width="134">
<p>
Boolean</p>
</td>
<td width="408">
<p>
If
<b>false</b>, attempts by ECMAScript code to change the
property’s [[Value]] attribute using [[Put]] will not succeed.</p>
</td>
</tr><tr valign="TOP"><td width="115" height="1">
<p>
[[Enumerable]]</p>
</td>
<td width="134">
<p>
Boolean</p>
</td>
<td width="408">
<p>
If
<b>true</b>, the property will be enumerated by a for-in
enumeration (see <a href="x12.html#x12.6.4">12.6.4</a>). Otherwise, the property is said to be
non-enumerable.</p>
</td>
</tr><tr valign="TOP"><td width="115" height="12">
<p>
[[Configurable]]</p>
</td>
<td width="134">
<p>
Boolean</p>
</td>
<td width="408">
<p>
If
<b>false</b>, attempts to delete the property, change the
property to be an accessor property, or change its attributes
(other than [[Value]]) will fail.</p>
</td>
</tr></tbody></table></center>
</dd></dl><p class="sm-btm">
A
named accessor property associates a name with the attributes listed
in Table 6.</p>
<dl><dd>
<center>
<table width="709" border="2" bordercolor="#000000" cellpadding="8" cellspacing="0"><caption>Table 6 — Attributes of a Named Accessor Property</caption>
<colgroup><col width="115"><col width="131"><col width="411"></colgroup><tbody><tr valign="TOP"><td width="115" bgcolor="#c0c0c0">
<p align="CENTER" class="keep">
<i><b>Attribute
Name</b></i></p>
</td>
<td width="131" bgcolor="#c0c0c0">
<p align="CENTER" class="keep">
<i><b>Value
Domain</b></i></p>
</td>
<td width="411" bgcolor="#c0c0c0">
<p align="CENTER" class="keep">
<i><b>Description</b></i></p>
</td>
</tr><tr valign="TOP"><td width="115" height="25">
<p class="keep">
[[Get]]</p>
</td>
<td width="131">
<p class="keep">
Object
<i>or </i>Undefined</p>
</td>
<td width="411">
<p class="keep">
If
the value is an Object it must be a function Object. The
function’s [[Call]] internal method (<a href="#x8.6.2">8.6.2</a>) is called with an
empty arguments list to return the property value each time a
get access of the property is performed.</p>
</td>
</tr><tr valign="TOP"><td width="115" height="25">
<p class="keep">
[[Set]]</p>
</td>
<td width="131">
<p class="keep">
Object
<i>or </i> Undefined</p>
</td>
<td width="411">
<p class="keep">
If
the value is an Object it must be a function Object. The
function’s [[Call]] internal method (<a href="#x8.6.2">8.6.2</a>) is called with an
arguments list containing the assigned value as its sole
argument each time a set access of the property is performed.
The effect of a property's [[Set]] internal method may, but is
not required to, have an effect on the value returned by
subsequent calls to the property's [[Get]] internal method.</p>
</td>
</tr><tr valign="TOP"><td width="115" height="45">
<p class="keep">
[[Enumerable]]</p>
</td>
<td width="131">
<p class="keep">
Boolean</p>
</td>
<td width="411">
<p class="keep">
If
<b>true</b>, the property is to be enumerated by a for-in
enumeration (see <a href="x12.html#x12.6.4">12.6.4</a>). Otherwise, the property is said to be
non-enumerable.</p>
</td>
</tr><tr valign="TOP"><td width="115" height="27">
<p>
[[Configurable]]</p>
</td>
<td width="131">
<p>
Boolean</p>
</td>
<td width="411">
<p>
If
<b>false</b>, attempts to delete the property, change the
property to be a data property, or change its attributes will
fail.</p>
</td>
</tr></tbody></table></center>
</dd></dl><p>
If
the value of an attribute is not explicitly specified by this
specification for a named property, the default value defined in
Table 7 is used.</p>
<dl><dl><dl><dl><dl><dl><dd>
<center>
<table width="278" border="2" bordercolor="#000000" cellpadding="8" cellspacing="0"><caption>Table 7 — Default Attribute Values</caption>
<colgroup><col width="129"><col width="113"></colgroup><tbody><tr valign="TOP"><td width="129" bgcolor="#c0c0c0">
<p align="CENTER" class="keep">
<b>Attribute
Name</b></p>
</td>
<td width="113" bgcolor="#c0c0c0">
<p align="CENTER" class="keep">
<b>Default
Value</b></p>
</td>
</tr><tr valign="TOP"><td width="129">
<p class="keep">
[[Value]]</p>
</td>
<td width="113">
<p class="keep">
<b>undefined</b></p>
</td>
</tr><tr valign="TOP"><td width="129">
<p class="keep">
[[Get]]</p>
</td>
<td width="113">
<p class="keep">
<b>undefined</b></p>
</td>
</tr><tr valign="TOP"><td width="129">
<p class="keep">
[[Set]]</p>
</td>
<td width="113">
<p class="keep">
<b>undefined</b></p>
</td>
</tr><tr valign="TOP"><td width="129">
<p class="keep">
[[Writable]]</p>
</td>
<td width="113">
<p class="keep">
<b>false</b></p>
</td>
</tr><tr valign="TOP"><td width="129">
<p class="keep">
[[Enumerable]]</p>
</td>
<td width="113">
<p class="keep">
<b>false</b></p>
</td>
</tr><tr valign="TOP"><td width="129">
<p>
[[Configurable]]</p>
</td>
<td width="113">
<p>
<b>false</b></p>
</td>
</tr></tbody></table></center>
</dd></dl></dl></dl></dl></dl></dl><h4 id="x8.6.2">8.6.2 Object Internal Properties and Methods <a href="#x8.6.2">#</a> <a href="#x8.6.2-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h4>
<p>
This
specification uses various internal properties to define the
semantics of object values. These internal properties are not part
of the ECMAScript language. They are defined by this specification
purely for expository purposes. An implementation of ECMAScript must
behave as if it produced and operated upon internal properties in
the manner described here. The names of internal properties are
enclosed in double square brackets [[ ]]. When an algorithm uses an
internal property of an object and the object does not implement the
indicated internal property, a <b><a href="x15.11.html#x15.11.6.5" class="term-ref">TypeError</a></b> exception is thrown.</p>
<p>
The
Table 8 summarises the internal properties used by this
specification that are applicable to all ECMAScript objects. The
Table 9 summarises the internal properties used by this
specification that are only applicable to some ECMAScript objects.
The descriptions in these tables indicates their behaviour for
native ECMAScript objects, unless stated otherwise in this document
for particular kinds of native ECMAScript objects. Host objects may
support these internal properties with any implementation-dependent
behaviour as long as it is consistent with the specific host object
restrictions stated in this document.</p>
<p>
The
“Value Type Domain” columns of the following tables define the
types of values associated with internal properties. The type names
refer to the types defined in <a href="#x8">Clause 8</a> augmented by the following
additional names. “<i>any</i>” means the value may be any
ECMAScript <a href="#language-type">language type</a>. “<i>primitive</i>” means Undefined,
Null, Boolean, String, or Number. <dfn id="SpecOp">“<i>SpecOp</i>”</dfn> means the
internal property is an internal method, an implementation provided
procedure defined by an abstract operation specification. “SpecOp”
is followed by a list of descriptive parameter names. If a parameter
name is the same as a type name then the name describes the type of
the parameter. If a “SpecOp” returns a value, its parameter list
is followed by the symbol “→” and the type of the returned
value.</p>
<div align="RIGHT">
<center>
<table width="740" border="1" bordercolor="#000000" cellpadding="8" cellspacing="0" rules="ROWS"><caption>Table 8 — Internal Properties Common to All Objects</caption>
<colgroup><col width="158"><col width="194"><col width="338"></colgroup><tbody><tr valign="TOP"><td width="158" bgcolor="#c0c0c0">
<p>
<i><b><span class="table-header">Internal
Property</span></b></i></p>
</td>
<td width="194" bgcolor="#c0c0c0">
<p>
<i><b><span class="table-header">Value
Type Domain</span></b></i></p>
</td>
<td width="338" bgcolor="#c0c0c0">
<p>
<i><b><span class="table-header">Description</span></b></i></p>
</td>
</tr><tr valign="TOP"><td width="158">
<p class="keep">
[[Prototype]]</p>
</td>
<td width="194">
<p class="keep">
Object
<i>or </i>Null</p>
</td>
<td width="338">
<p class="keep">
The
prototype of this object.</p>
</td>
</tr><tr valign="TOP"><td width="158">
<p class="keep">
[[Class]]</p>
</td>
<td width="194">
<p class="keep">
String</p>
</td>
<td width="338">
<p class="keep">
A
String value indicating a specification defined classification
of objects.</p>
</td>
</tr><tr valign="TOP"><td width="158">
<p class="keep">
[[Extensible]]</p>
</td>
<td width="194">
<p class="keep">
Boolean</p>
</td>
<td width="338">
<p class="keep">
If
<b>true</b>, own properties may be added to the object.</p>
</td>
</tr><tr valign="TOP"><td width="158">
<p class="keep">
[[Get]]</p>
</td>
<td width="194">
<p class="keep">
<a href="#SpecOp">SpecOp</a>(<i>propertyName</i>)
<i><b>→</b></i> any</p>
</td>
<td width="338">
<p class="keep">
Returns
the value of the named property.</p>
</td>
</tr><tr valign="TOP"><td width="158">
<p class="keep">
[[GetOwnProperty]]</p>
</td>
<td width="194">
<p class="keep">
<a href="#SpecOp">SpecOp</a>
(<i>propertyName</i>) <i><b>→</b></i></p>
<p class="keep">
Undefined<i>or</i>
<a href="#x8.10">Property Descriptor</a></p>
</td>
<td width="338">
<p class="keep">
Returns
the <a href="#x8.10">Property Descriptor</a> of the named own property of this
object, or <b>undefined </b>if absent.</p>
</td>
</tr><tr valign="TOP"><td width="158">
<p class="keep">
[[GetProperty]]</p>
</td>
<td width="194">
<p class="keep">
<a href="#SpecOp">SpecOp</a>
(<i>propertyName</i>) <i><b>→</b></i></p>
<p class="keep">
Undefined<i>or </i>
<a href="#x8.10">Property Descriptor</a></p>
</td>
<td width="338">
<p class="keep">
Returns
the <a href="#fully-populated">fully populated</a> <a href="#x8.10">Property Descriptor</a> of the named property of
this object, or <b>undefined </b>if absent.</p>
</td>
</tr><tr valign="TOP"><td width="158">
<p class="keep">
[[Put]]</p>
</td>
<td width="194">
<p class="keep">
<a href="#SpecOp">SpecOp</a>
(<i>propertyName</i>, <i>any, Boolean</i>)</p>
</td>
<td width="338">
<p class="keep">
Sets
the specified named property to the value of the second
parameter. The flag controls failure handling.</p>
</td>
</tr><tr valign="TOP"><td width="158">
<p class="keep">
[[CanPut]]</p>
</td>
<td width="194">
<p class="keep">
<a href="#SpecOp">SpecOp</a>
(<i>propertyName</i>) <i><b>→</b></i>
Boolean</p>
</td>
<td width="338">
<p class="keep">
Returns
a Boolean value indicating whether a [[Put]] operation with
<i>PropertyName</i> can be performed.</p>
</td>
</tr><tr valign="TOP"><td width="158">
<p class="keep">
[[HasProperty]]</p>
</td>
<td width="194">
<p class="keep">
<a href="#SpecOp">SpecOp</a>
(<i>propertyName</i>) <i><b>→</b></i>
<i>Boolean</i></p>
</td>
<td width="338">
<p class="keep">
Returns
a Boolean value indicating whether the object already has a
property with the given name.</p>
</td>
</tr><tr valign="TOP"><td width="158">
<p class="keep">
[[Delete]]</p>
</td>
<td width="194">
<p class="keep">
<a href="#SpecOp">SpecOp</a>
(<i>propertyName, Boolean</i>) <i><b>→</b></i>
Boolean</p>
</td>
<td width="338">
<p class="keep">
Removes
the specified named own property from the object. The flag
controls failure handling.</p>
</td>
</tr><tr valign="TOP"><td width="158">
<p class="keep">
[[DefaultValue]]</p>
</td>
<td width="194">
<p class="keep">
<a href="#SpecOp">SpecOp</a>
(<i>Hint</i>) <i><b>→</b></i>
<i>primitive</i></p>
</td>
<td width="338">
<p class="keep">
Hint
is a String. Returns a default value for the object.</p>
</td>
</tr><tr valign="TOP"><td width="158">
<p class="keep">
[[DefineOwnProperty]]</p>
</td>
<td width="194">
<p class="keep">
<a href="#SpecOp">SpecOp</a>
(<i>propertyName, PropertyDescriptor, Boolean</i>)<i><b>
→</b></i> Boolean</p>
</td>
<td width="338">
<p class="keep">
Creates
or alters the named own property to have the state described by
a <a href="#x8.10">Property Descriptor</a>. The flag controls failure handling.</p>
</td>
</tr></tbody></table></center>
</div>
<p>
Every
object (including host objects) must implement all of the internal
properties listed in Table 8. However, the [[DefaultValue]] internal
method may, for some objects, simply throw a <b><a href="x15.11.html#x15.11.6.5" class="term-ref">TypeError</a></b>
exception.</p>
<p>
All
objects have an internal property called [[Prototype]]. The value of
this property is either <b>null</b> or an object and is used for
implementing inheritance. Whether or not a native object can have a
host object as its [[Prototype]] depends on the implementation.
Every [[Prototype]] chain must have finite length (that is, starting
from any object, recursively accessing the [[Prototype]] internal
property must eventually lead to a <b>null</b> value). Named data
properties of the [[Prototype]] object are inherited (are visible as
properties of the child object) for the purposes of get access, but
not for put access. Named accessor properties are inherited for both
get access and put access.</p>
<p>
Every
ECMAScript object has a Boolean-valued [[Extensible]] internal
property that controls whether or not named properties may be added
to the object. If the value of the [[Extensible]] internal property
is <b>false</b> then additional named properties may not be added to
the object. In addition, if [[Extensible]] is <b>false</b> the
value of the [[Class]] and [[Prototype]] internal properties of the
object may not be modified. Once the value of an [[Extensible]]
internal property has been set to <b>false</b> it may not be
subsequently changed to <b>true</b>.</p>
<p><b class="note">NOTE</b> This
specification defines no ECMAScript language operators or built-in
functions that permit a program to modify an object’s [[Class]] or
[[Prototype]] internal properties or to change the value of
[[Extensible]] from <b>false</b> to <b>true</b>. Implementation
specific extensions that modify [[Class]], [[Prototype]] or
[[Extensible]] must not violate the invariants defined in the
preceding paragraph.</p>
<p>
The
value of the [[Class]] internal property is defined by this
specification for every kind of built-in object. The value of the
[[Class]] internal property of a host object may be any String value
except one of <code><b>"Arguments"</b></code>,
<code><b>"Array"</b></code>,
<code><b>"Boolean"</b></code>,
<code><b>"Date"</b></code>,
<code><b>"Error"</b></code>,
<code><b>"Function"</b></code>,
<code><b>"JSON"</b></code>,
<code><b>"Math"</b></code>,
<code><b>"Number"</b></code>,
<code><b>"Object"</b></code>,
<code><b>"RegExp"</b></code>,
and <code><b>"String"</b></code>.
The value of a [[Class]] internal property is used internally to
distinguish different kinds of objects. Note that this specification
does not provide any means for a program to access that value except
through <code><b><a href="x15.2.html#x15.2.4.2">Object.prototype.toString</a></b></code>
(see <a href="x15.2.html#x15.2.4.2">15.2.4.2</a>).</p>
<p>
Unless
otherwise specified, the common internal methods of native
ECMAScript objects behave as described in <a href="#x8.12">8.12</a>. Array objects have a
slightly different implementation of the [[DefineOwnProperty]]
internal method (see <a href="x15.4.html#x15.4.5.1">15.4.5.1</a>) and String objects have a slightly
different implementation of the [[GetOwnProperty]] internal method
(see <a href="x15.5.html#x15.5.5.2">15.5.5.2</a>). Arguments objects (<a href="x10.html#x10.6">10.6</a>) have different
implementations of [[Get]], [[GetOwnProperty]],
[[DefineOwnProperty]], and [[Delete]]. Function objects (<a href="x15.3.html#x15.3">15.3</a>) have
a different implementation of [[Get]].</p>
<p>
Host
objects may implement these internal methods in any manner unless
specified otherwise; for example, one possibility is that [[Get]]
and [[Put]] for a particular host object indeed fetch and store
property values but [[HasProperty]] always generates <b>false</b>.
However, if any specified manipulation of a host object's internal
properties is not supported by an implementation, that manipulation
must throw a <b><a href="x15.11.html#x15.11.6.5" class="term-ref">TypeError</a></b> exception when attempted.</p>
<p class="sm-btm">
The
[[GetOwnProperty]] internal method of a host object must conform to
the following invariants for each property of the host object:</p>
<ul><li><p>
If a
property is described as a data property and it may return
different values over time, then either or both of the [[Writable]]
and [[Configurable] attributes must be <b>true</b> even if no
mechanism to change the value is exposed via the other internal
methods.</p>
</li>
<li><p>
If a
property is described as a data property and its [[Writable]] and
[[Configurable]] are both <b>false</b>, then the <a href="x9.html#x9.12">SameValue</a>
(according to <a href="x9.html#x9.12">9.12</a>) must be returned for the [[Value]] attribute of
the property on all calls to [[GetOwnProperty]].</p>
</li>
<li><p>
If
the attributes other than [[Writable]] may change over time or if
the property might disappear, then the [[Configurable]] attribute
must be <b>true</b>.</p>
</li>
<li><p>
If
the [[Writable]] attribute may change from <b>false</b> to <b>true</b>,
then the [[Configurable]] attribute must be <b>true</b>.</p>
</li>
<li><p>
If
the value of the host object’s [[Extensible]] internal property
is has been observed by ECMAScript code to be <b>false</b>, then if
a call to [[GetOwnProperty]] describes a property as non-existent
all subsequent calls must also describe that property as
non-existent.</p>
</li></ul><p>
The
[[DefineOwnProperty]] internal method of a host object must not
permit the addition of a new property to a host object if the
[[Extensible]] internal property of that host object has been
observed by ECMAScript code to be <b>false</b>.
</p>
<p>
If
the [[Extensible]] internal property of that host object has been
observed by ECMAScript code to be <b>false</b> then it must not
subsequently become <b>true</b>.</p>
<center>
<table width="765" border="1" bordercolor="#000000" cellpadding="8" cellspacing="0" rules="ROWS"><caption>Table 9 — Internal Properties Only Defined for Some Objects</caption>
<colgroup><col width="153"><col width="143"><col width="418"></colgroup><tbody><tr valign="TOP"><td width="153" bgcolor="#c0c0c0">
<p>
<i><b><span class="table-header">Internal
Property</span></b></i></p>
</td>
<td width="143" bgcolor="#c0c0c0">
<p>
<i><b><span class="table-header">Value
Type Domain</span></b></i></p>
</td>
<td width="418" bgcolor="#c0c0c0">
<p>
<i><b><span class="table-header">Description</span></b></i></p>
</td>
</tr><tr valign="TOP"><td width="153">
<p class="keep">
[[PrimitiveValue]]</p>
</td>
<td width="143">
<p class="keep">
<i>primitive</i></p>
</td>
<td width="418">
<p class="keep">
Internal
state information associated with this object. Of the standard
built-in ECMAScript objects, only Boolean, Date, Number, and
String objects implement [[PrimitiveValue]].</p>
</td>
</tr><tr valign="TOP"><td width="153">
<p class="keep">
[[Construct]]</p>
</td>
<td width="143">
<p class="keep">
<a href="#SpecOp">SpecOp</a>(a
<a href="#x8.8">List</a> of <i>any</i>) <i><b>→</b></i>
Object</p>
</td>
<td width="418">
<p class="keep">
Creates
an object. Invoked via the <code><b>new</b></code>
operator. The arguments to the <a href="#SpecOp">SpecOp</a> are the arguments passed
to the <b>new</b> operator. Objects that implement this internal
method are called <i>constructors</i>.</p>
</td>
</tr><tr valign="TOP"><td width="153">
<p class="keep">
<dfn id="callable">[[Call]]</dfn></p>
</td>
<td width="143">
<p class="keep">
<a href="#SpecOp">SpecOp</a>(<i>any</i>,
a <a href="#x8.8">List</a> of <i>any</i>) <i><b>→</b></i>
<i>any </i>or <a href="#x8.7">Reference</a></p>
</td>
<td width="418">
<p class="keep">
Executes
code associated with the object. Invoked via a function call
expression. The arguments to the <a href="#SpecOp">SpecOp</a> are a this object and a
list containing the arguments passed to the function call
expression. Objects that implement this internal method are
<i>callable</i>. Only callable objects that are host objects may
return <a href="#x8.7">Reference</a> values.</p>
</td>
</tr><tr valign="TOP"><td width="153">
<p class="keep">
[[HasInstance]]</p>
</td>
<td width="143">
<p class="keep">
<a href="#SpecOp">SpecOp</a>(<i>any</i>)
<i><b>→</b></i>
Boolean</p>
</td>
<td width="418">
<p class="keep">
Returns
a Boolean value indicating whether the argument is likely an
Object that was constructed by this object. Of the standard
built-in ECMAScript objects, only Function objects implement
[[HasInstance]].</p>
</td>
</tr><tr valign="TOP"><td width="153">
<p class="keep">
[[Scope]]</p>
</td>
<td width="143">
<p class="keep">
<a href="x10.html#x10.2">Lexical Environment</a></p>
</td>