-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathx10.html
1719 lines (1713 loc) · 75.7 KB
/
x10.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>10 Executable Code and Execution Contexts # Ⓣ Ⓔ ① Ⓐ — Annotated ES5</title><link rel="stylesheet" href="style.css"><link href="x9.html" title="9 Type Conversion and Testing " rel="prev">
<link href="spec.html" title="TOC" rel="index">
<link href="x11.html" title="11 Expressions " 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="x9.html">← 9 Type Conversion and Testing </a> –
<a href="spec.html" class="toc-nav">TOC</a> –
<a href="x11.html">11 Expressions →</a>
<ol class="toc"><li><a href="x10.html#x10" id="x10-toc">10 Executable Code and Execution Contexts</a>
<b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> <ol><li><a href="x10.html#x10.1" id="x10.1-toc">10.1 Types of Executable Code</a>
<b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> <ol><li><a href="x10.html#x10.1.1" id="x10.1.1-toc">10.1.1 Strict Mode Code</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li></ol></li><li><a href="x10.html#x10.2" id="x10.2-toc">10.2 Lexical Environments</a>
<b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> <ol><li><a href="x10.html#x10.2.1" id="x10.2.1-toc">10.2.1 Environment Records</a>
<b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> <ol><li><a href="x10.html#x10.2.1.1" id="x10.2.1.1-toc">10.2.1.1 Declarative Environment Records</a>
<b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> <ol><li><a href="x10.html#x10.2.1.1.1" id="x10.2.1.1.1-toc">10.2.1.1.1 HasBinding(N)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x10.html#x10.2.1.1.2" id="x10.2.1.1.2-toc">10.2.1.1.2 CreateMutableBinding (N, D)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x10.html#x10.2.1.1.3" id="x10.2.1.1.3-toc">10.2.1.1.3 SetMutableBinding (N,V,S)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x10.html#x10.2.1.1.4" id="x10.2.1.1.4-toc">10.2.1.1.4 GetBindingValue(N,S)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x10.html#x10.2.1.1.5" id="x10.2.1.1.5-toc">10.2.1.1.5 DeleteBinding (N)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x10.html#x10.2.1.1.6" id="x10.2.1.1.6-toc">10.2.1.1.6 ImplicitThisValue()</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x10.html#x10.2.1.1.7" id="x10.2.1.1.7-toc">10.2.1.1.7 CreateImmutableBinding (N)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x10.html#x10.2.1.1.8" id="x10.2.1.1.8-toc">10.2.1.1.8 InitializeImmutableBinding (N,V)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li></ol></li><li><a href="x10.html#x10.2.1.2" id="x10.2.1.2-toc">10.2.1.2 Object Environment Records</a>
<b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> <ol><li><a href="x10.html#x10.2.1.2.1" id="x10.2.1.2.1-toc">10.2.1.2.1 HasBinding(N)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x10.html#x10.2.1.2.2" id="x10.2.1.2.2-toc">10.2.1.2.2 CreateMutableBinding (N, D)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x10.html#x10.2.1.2.3" id="x10.2.1.2.3-toc">10.2.1.2.3 SetMutableBinding (N,V,S)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x10.html#x10.2.1.2.4" id="x10.2.1.2.4-toc">10.2.1.2.4 GetBindingValue(N,S)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x10.html#x10.2.1.2.5" id="x10.2.1.2.5-toc">10.2.1.2.5 DeleteBinding (N)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x10.html#x10.2.1.2.6" id="x10.2.1.2.6-toc">10.2.1.2.6 ImplicitThisValue()</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li></ol></li></ol></li><li><a href="x10.html#x10.2.2" id="x10.2.2-toc">10.2.2 Lexical Environment Operations</a>
<b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> <ol><li><a href="x10.html#x10.2.2.1" id="x10.2.2.1-toc">10.2.2.1 GetIdentifierReference (lex, name, strict)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x10.html#x10.2.2.2" id="x10.2.2.2-toc">10.2.2.2 NewDeclarativeEnvironment (E)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x10.html#x10.2.2.3" id="x10.2.2.3-toc">10.2.2.3 NewObjectEnvironment (O, E)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li></ol></li><li><a href="x10.html#x10.2.3" id="x10.2.3-toc">10.2.3 The Global Environment</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li></ol></li><li><a href="x10.html#x10.3" id="x10.3-toc">10.3 Execution Contexts</a>
<b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> <ol><li><a href="x10.html#x10.3.1" id="x10.3.1-toc">10.3.1 Identifier Resolution</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li></ol></li><li><a href="x10.html#x10.4" id="x10.4-toc">10.4 Establishing an Execution Context</a>
<b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> <ol><li><a href="x10.html#x10.4.1" id="x10.4.1-toc">10.4.1 Entering Global Code</a>
<b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> <ol><li><a href="x10.html#x10.4.1.1" id="x10.4.1.1-toc">10.4.1.1 Initial Global Execution Context</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li></ol></li><li><a href="x10.html#x10.4.2" id="x10.4.2-toc">10.4.2 Entering Eval Code</a>
<b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> <ol><li><a href="x10.html#x10.4.2.1" id="x10.4.2.1-toc">10.4.2.1 Strict Mode Restrictions</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li></ol></li><li><a href="x10.html#x10.4.3" id="x10.4.3-toc">10.4.3 Entering Function Code</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li></ol></li><li><a href="x10.html#x10.5" id="x10.5-toc">10.5 Declaration Binding Instantiation</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x10.html#x10.6" id="x10.6-toc">10.6 Arguments Object</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li></ol></li></ol></nav>
<h2 id="x10">10 Executable Code and Execution Contexts <a href="#x10">#</a> <a href="#x10-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h2>
<h3 id="x10.1">10.1 Types of Executable Code <a href="#x10.1">#</a> <a href="#x10.1-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h3>
<p>
There
are three types of ECMAScript executable code:</p>
<ul><li><p><dfn id="global-code"><i>Global code</i></dfn> is source text that
is treated as an ECMAScript <i><a href="x14.html#x14">Program</a></i>.
The global code of a particular <i><a href="x14.html#x14">Program</a></i>
does not include any source text that is parsed as part of a
<i><a href="x13.html#x13">FunctionBody</a></i>.</p>
</li>
<li><p><dfn id="eval-code"><i>Eval code</i></dfn> is the source text
supplied to the built-in <code><b><a href="x15.1.html#x15.1.2.1">eval</a></b></code> function. More precisely, if the parameter to the built-in <code><b><a href="x15.1.html#x15.1.2.1">eval</a></b></code> function is a String, it is treated as an ECMAScript <i><a href="x14.html#x14">Program</a></i>.
The eval code for a particular invocation of <code><b>eval</b></code>
is the <a href="#global-code">global code</a> portion of that <i><a href="x14.html#x14">Program</a></i>.</p>
</li>
<li><p><dfn id="function-code"><i>Function code</i></dfn> is source text that
is parsed as part of a <i><a href="x13.html#x13">FunctionBody</a></i>.
The <i>function code</i>
of a particular <i><a href="x13.html#x13">FunctionBody</a></i>
does not include any source text that is parsed as part of a nested
<i><a href="x13.html#x13">FunctionBody</a></i>. <i>Function
code</i> also denotes the
source text supplied when <a href="x15.3.html#x15.3.2" class="term-ref">using the built-in <code><b>Function</b></code> object as a constructor</a>. More precisely, the last parameter
provided to the <code><b>Function</b></code>
constructor is converted to a String and treated as the
<i><a href="x13.html#x13">FunctionBody</a></i>. If more
than one parameter is provided to the <code><b>Function</b></code>
constructor, all parameters except the last one are converted to
Strings and concatenated together, separated by commas. The
resulting String is interpreted as the <i>FormalParameterList</i>
for the <i><a href="x13.html#x13">FunctionBody</a></i>
defined by the last parameter. The function code for a particular
instantiation of a <code><b>Function</b></code>
does not include any source text that is parsed as part of a nested
<i><a href="x13.html#x13">FunctionBody</a></i>.</p>
</li></ul><h4 id="x10.1.1">10.1.1 Strict Mode Code <a href="#x10.1.1">#</a> <a href="#x10.1.1-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h4>
<p>
An
ECMAScript <i><a href="x14.html#x14">Program</a></i>
syntactic unit may be processed using either unrestricted or strict
mode syntax and semantics. When processed using strict mode the
three types of ECMAScript code are referred to as strict global
code, strict eval code, and strict function code. Code is
interpreted as <a href="#x10.1.1" class="term-ref">strict mode code</a> in the following situations:</p>
<ul><li><p>
<a href="#global-code">Global code</a> is strict global code if it begins with a Directive Prologue
that contains a Use Strict Directive (see <a href="x14.html#x14.1">14.1</a>).</p>
</li>
<li><p>
<a href="#eval-code">Eval code</a> is strict eval code if it begins with a Directive Prologue
that contains a Use Strict Directive or if the call to eval is a
direct call (see <a href="x15.1.html#x15.1.2.1.1">15.1.2.1.1</a>) to the <a href="x15.1.html#x15.1.2.1">eval function</a> that is contained
in <a href="#x10.1.1" class="term-ref">strict mode code</a>.
</p>
</li>
<li><p>
<a href="#function-code">Function code</a> that is part of a <i><a href="x13.html#x13">FunctionDeclaration</a></i>,
<i><a href="x13.html#x13">FunctionExpression</a></i>,
or accessor <i>PropertyAssignment</i>
is strict function code if its <i><a href="x13.html#x13">FunctionDeclaration</a></i>,
<i><a href="x13.html#x13">FunctionExpression</a></i>,
or <i>PropertyAssignment</i>
is contained in <a href="#x10.1.1" class="term-ref">strict mode code</a> or if the function code begins
with a Directive Prologue that contains a Use Strict Directive.</p>
</li>
<li><p>
<a href="#function-code">Function code</a> that is supplied as the last argument to the built-in Function
constructor is strict function code if the last argument is a
String that when processed as a <i><a href="x13.html#x13">FunctionBody</a></i>
begins with a Directive Prologue that contains a Use Strict
Directive.</p>
</li></ul><h3 id="x10.2">10.2 Lexical Environments <a href="#x10.2">#</a> <a href="#x10.2-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h3>
<p>
A
<i>Lexical Environment</i> is a <a href="x8.html#specification-type">specification type</a> used to define
the association of <i>Identifiers</i>
to specific variables and functions based upon the lexical nesting
structure of ECMAScript code. A Lexical Environment consists of an
<a href="#x10.2.1">Environment Record</a> and a possibly null reference to an <i>outer</i>
Lexical Environment. Usually a Lexical Environment is associated
with some specific syntactic structure of ECMAScript code such as a
<i><a href="x13.html#x13">FunctionDeclaration</a></i>,
a <i>WithStatement</i>,
or a <i>Catch </i>clause
of a <i>TryStatement</i>
and a new Lexical Environment is created each time such code is
evaluated.</p>
<p>
An
<a href="#x10.2.1"><i>Environment Record</i></a> records the identifier bindings that are
created within the scope of its associated Lexical Environment.</p>
<p>
The
<dfn id="outer-environment-reference">outer environment reference</dfn> is used to model the logical nesting of
Lexical Environment values. The outer reference of a (inner) Lexical
Environment is a reference to the Lexical Environment that logically
surrounds the inner Lexical Environment. An outer Lexical
Environment may, of course, have its own outer Lexical Environment.
A Lexical Environment may serve as the outer environment for
multiple inner Lexical Environments. For example, if a
<i><a href="x13.html#x13">FunctionDeclaration</a></i>
contains two nested <i>FunctionDeclarations</i>
then the Lexical Environments of each of the nested functions will
have as their outer Lexical Environment the Lexical Environment of
the current execution of the surrounding function.</p>
<p>
Lexical
Environments and Environment Record values are purely specification
mechanisms and need not correspond to any specific artefact of an
ECMAScript implementation. It is impossible for an ECMAScript
program to directly access or manipulate such values.</p>
<h4 id="x10.2.1">10.2.1 Environment Records <a href="#x10.2.1">#</a> <a href="#x10.2.1-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h4>
<p>
There
are two kinds of Environment Record values used in this
specification: <i>declarative environment records</i> and <i>object
environment records</i>. <dfn id="declarative-environment-record">Declarative environment records</dfn> are used
to define the effect of ECMAScript language syntactic elements such
as <i>FunctionDeclarations</i>,
<i>VariableDeclarations</i>,
and <i>Catch</i> clauses
that directly associate <b>identifier</b> bindings with ECMAScript
language values. <dfn id="object-environment-record">Object environment records</dfn> are used to define the
effect of ECMAScript elements such as <i><a href="x14.html#x14">Program</a></i>
and <i>WithStatement</i>
that associate <b>identifier</b> bindings with the properties of
some object.</p>
<p>
For
specification purposes Environment Record values can be thought of
as existing in a simple object-oriented hierarchy where Environment
Record is an abstract class with two concrete subclasses,
declarative environment record
and object environment record. The
abstract class includes the abstract specification methods defined
in Table 17. These abstract methods have distinct concrete
algorithms for each of the concrete subclasses.
</p>
<center>
<table width="690" border="1" bordercolor="#000000" cellpadding="8" cellspacing="0" rules="ROWS"><caption>Table 17 — Abstract Methods of Environment Records</caption>
<colgroup><col width="211"><col width="445"></colgroup><tbody><tr valign="TOP"><td width="211" height="11" bgcolor="#c0c0c0">
<p>
<i><b><span class="table-header">Method</span></b></i></p>
</td>
<td width="445" bgcolor="#c0c0c0">
<p>
<i><b><span class="table-header">Purpose</span></b></i></p>
</td>
</tr><tr valign="TOP"><td width="211">
<p>
HasBinding(N)</p>
</td>
<td width="445">
<p>
Determine
if an environment record has a binding for an identifier. Return
<b>true</b> if it
does and <b>false</b>
if it does not. The String value <i>N</i>
is the text of the identifier.</p>
</td>
</tr><tr valign="TOP"><td width="211" height="43">
<p>
CreateMutableBinding(N,
D)</p>
</td>
<td width="445">
<p>
Create
a new mutable binding in an environment record. The String value
<i>N</i> is the text
of the bound name. If the optional Boolean argument <i>D</i>
is <b>true</b> the binding is may be subsequently deleted.
</p>
</td>
</tr><tr valign="TOP"><td width="211" height="76">
<p>
SetMutableBinding(N,V,
S)</p>
</td>
<td width="445">
<p>
Set
the value of an already existing mutable binding in an
environment record. The String value <i>N</i>
is the text of the bound name. <i>V</i>
is the value for the binding and may be a value of any
ECMAScript <a href="x8.html#language-type">language type</a>. <i>S</i>
is a Boolean flag. If <i>S</i>
is <b>true</b> and
the binding cannot be set throw a <b><a href="x15.11.html#x15.11.6.5" class="term-ref">TypeError</a></b> exception. <i>S</i>
is used to identify strict mode references.</p>
</td>
</tr><tr valign="TOP"><td width="211">
<p>
GetBindingValue(N,S)</p>
</td>
<td width="445">
<p>
Returns
the value of an already existing binding from an environment
record. The String value <i>N</i>
is the text of the bound name. <i>S</i>
is used to identify strict mode references. If <i>S</i>
is <b>true</b> and
the binding does not exist or is uninitialized throw a
<b><a href="x15.11.html#x15.11.6.3" class="term-ref">ReferenceError</a></b> exception.
</p>
</td>
</tr><tr valign="TOP"><td width="211" height="58">
<p>
DeleteBinding(N)</p>
</td>
<td width="445">
<p>
Delete
a binding from an environment record. The String value <i>N</i>
is the text of the bound name If a binding for <i>N</i>
exists, remove the binding and return <b>true</b>. If the
binding exists but cannot be removed return <b>false</b>. If the
binding does not exist return <b>true</b>.</p>
</td>
</tr><tr valign="TOP"><td width="211">
<p>ImplicitThisValue()</p>
</td>
<td width="445">
<p>Returns
the value to use as the <b>this</b> value on calls to function
objects that are obtained as binding values from this
environment record.
</p>
</td>
</tr></tbody></table></center>
<h5 id="x10.2.1.1">10.2.1.1 Declarative Environment Records <a href="#x10.2.1.1">#</a> <a href="#x10.2.1.1-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h5>
<p>
Each
declarative environment record is associated with an ECMAScript
program scope containing variable and/or function declarations. A
declarative environment record binds the set of identifiers defined
by the declarations contained within its scope.</p>
<p class="sm-btm">
In
addition to the mutable bindings supported by all Environment
Records, declarative environment records also provide for immutable
bindings. An <dfn id="immutable-binding">immutable binding</dfn> is one where the association between
an identifier and a value may not be modified once it has been
established. Creation and initialization of immutable binding are
distinct steps so it is possible for such bindings to exist in
either an initialized or uninitialized state. Declarative
environment records support the methods listed in Table 18 in
addition to the Environment Record abstract specification methods:</p>
<center>
<table width="698" border="1" bordercolor="#000000" cellpadding="8" cellspacing="0" rules="ROWS"><caption>Table 18 — Additional Methods of Declarative Environment Records</caption>
<colgroup><col width="219"><col width="445"></colgroup><tbody><tr valign="TOP"><td width="219" height="8" bgcolor="#c0c0c0">
<p>
<i><b><span class="table-header">Method</span></b></i></p>
</td>
<td width="445" bgcolor="#c0c0c0">
<p>
<i><b><span class="table-header">Purpose</span></b></i></p>
</td>
</tr><tr valign="TOP"><td width="219">
<p>
<a href="#x10.2.1.1.7">CreateImmutableBinding</a>(N)</p>
</td>
<td width="445">
<p>
Create
a new but uninitialized <a href="#immutable-binding">immutable binding</a> in an environment
record. The String value <i>N</i>
is the text of the bound name.</p>
</td>
</tr><tr valign="TOP"><td width="219">
<p><a href="#x10.2.1.1.8">InitializeImmutableBinding</a>(N,V)</p>
</td>
<td width="445">
<p>Set
the value of an already existing but uninitialized <a href="#immutable-binding">immutable binding</a> in an environment record. The String value <i>N</i>
is the text of the bound name. <i>V</i>
is the value for the binding and is a value of any ECMAScript
<a href="x8.html#language-type">language type</a>.
</p>
</td>
</tr></tbody></table></center>
<p>
The
behaviour of the concrete specification methods for Declarative
Environment Records are defined by the following algorithms.</p>
<h6 id="x10.2.1.1.1">10.2.1.1.1 HasBinding(N) <a href="#x10.2.1.1.1">#</a> <a href="#x10.2.1.1.1-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h6>
<p>
The
concrete environment record method HasBinding for declarative
environment records simply determines if the argument identifier is
one of the identifiers bound by the record:</p>
<ol><li><p>
Let
<i>envRec </i>be the declarative environment record for which the
method was invoked.</p>
</li>
<li><p>
If
<i>envRec</i> has a binding for the name that is the value of <i>N</i>,
return <b>true</b>.</p>
</li>
<li><p>
If
it does not have such a binding, return <b>false</b></p>
</li></ol><h6 id="x10.2.1.1.2">10.2.1.1.2 CreateMutableBinding (N, D) <a href="#x10.2.1.1.2">#</a> <a href="#x10.2.1.1.2-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h6>
<p>
The
concrete Environment Record method CreateMutableBinding for
declarative environment records creates a new mutable binding for
the name <i>N</i> that is
initialized to the value <b>undefined</b>. A binding must not
already exist in this Environment Record for <i>N</i>.
If Boolean argument <i>D</i>
is provided and has the value <b>true</b> the new binding is marked
as being subject to deletion.</p>
<ol><li><p>
Let
<i>envRec </i>be the declarative environment record for which the
method was invoked.</p>
</li>
<li><p>
Assert:
<i>envRec</i> does not already have a binding for <i>N</i>.</p>
</li>
<li><p>
Create
a mutable binding in <i>envRec</i> for <i>N</i> and set its bound
value to <b>undefined</b>. If <i>D</i> is true record that the
newly created binding may be deleted by a subsequent DeleteBinding
call.</p>
</li></ol><h6 id="x10.2.1.1.3">10.2.1.1.3 SetMutableBinding (N,V,S) <a href="#x10.2.1.1.3">#</a> <a href="#x10.2.1.1.3-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h6>
<p>
The
concrete Environment Record method SetMutableBinding for declarative
environment records attempts to change the bound value of the
current binding of the identifier whose name is the value of the
argument <i>N</i> to the
value of argument <i>V</i>.
A binding for <i>N</i>
must already exist. If the binding is an <a href="#immutable-binding">immutable binding</a>, a
<b>TypeError</b> is
thrown
if <i>S</i> is <b>true</b>.
</p>
<ol><li><p>
Let
<i>envRec</i> be the declarative environment record for which the
method was invoked.</p>
</li>
<li><p>
Assert:
<i>envRec</i> must have a binding for <i>N</i>.</p>
</li>
<li><p>
If
the binding for <i>N</i> in <i>envRec</i> is a mutable binding,
change its bound value to <i>V</i>.</p>
</li>
<li><p>
Else
this must be an attempt to change the value of an <a href="#immutable-binding">immutable binding</a>
so
if <i>S</i> is <b>true</b>
throw a
<b><a href="x15.11.html#x15.11.6.5" class="term-ref">TypeError</a></b>
exception.</p>
</li>
</ol><h6 id="x10.2.1.1.4">10.2.1.1.4 GetBindingValue(N,S) <a href="#x10.2.1.1.4">#</a> <a href="#x10.2.1.1.4-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h6>
<p>
The
concrete Environment Record method GetBindingValue for declarative
environment records simply returns the value of its bound identifier
whose name is the value of the argument <i>N</i>.
The binding must already exist. If <i>S</i>
is <b>true</b> and the binding is an uninitialized <a href="#immutable-binding">immutable binding</a>
throw a <b><a href="x15.11.html#x15.11.6.3" class="term-ref">ReferenceError</a></b> exception.</p>
<ol><li><p>
Let
<i>envRec</i> be the declarative environment record for which the
method was invoked.</p>
</li>
<li><p>
Assert:
<i>envRec</i> has a binding for <i>N</i>.</p>
</li>
<li><p>
If
the binding for <i>N</i> in <i>envRec</i> is an uninitialized
<a href="#immutable-binding">immutable binding</a>, then</p>
<ol><li><p>
If
<i>S</i> is <b>false</b>, return the value <b>undefined</b>,
otherwise throw a <b><a href="x15.11.html#x15.11.6.3" class="term-ref">ReferenceError</a></b> exception.</p>
</li></ol></li>
<li><p>
Else,
return the value currently bound to <i>N</i> in <i>envRec</i>.</p>
</li></ol><h6 id="x10.2.1.1.5">10.2.1.1.5 DeleteBinding (N) <a href="#x10.2.1.1.5">#</a> <a href="#x10.2.1.1.5-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h6>
<p>
The
concrete Environment Record method DeleteBinding for declarative
environment records can only delete bindings that have been
explicitly designated as being subject to deletion.</p>
<ol><li><p>
Let
<i>envRec</i> be the declarative environment record for which the
method was invoked.</p>
</li>
<li><p>
If
<i>envRec</i> does not have a binding for the name that is the
value of <i>N</i>, return <b>true</b>.</p>
</li>
<li><p>
If
the binding for <i>N</i> in <i>envRec</i> is cannot be deleted,
return <b>false</b>.</p>
</li>
<li><p>
Remove
the binding for <i>N</i> from <i>envRec</i>.</p>
</li>
<li><p>
Return
<b>true</b>.</p>
</li></ol><h6 id="x10.2.1.1.6">10.2.1.1.6 ImplicitThisValue() <a href="#x10.2.1.1.6">#</a> <a href="#x10.2.1.1.6-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h6>
<p>
Declarative
Environment Records always return <b>undefined</b> as their
ImplicitThisValue.</p>
<ol><li><p>
Return
<b>undefined</b>.</p>
</li></ol><h6 id="x10.2.1.1.7">10.2.1.1.7 CreateImmutableBinding (N) <a href="#x10.2.1.1.7">#</a> <a href="#x10.2.1.1.7-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h6>
<p>
The
concrete Environment Record method CreateImmutableBinding for
declarative environment records creates a new <a href="#immutable-binding">immutable binding</a> for
the name <i>N</i> that is
initialized to the value <b>undefined</b>. A binding must not
already exist in this environment record for <i>N</i>.</p>
<ol><li><p>
Let
<i>envRec </i>be the declarative environment record for which the
method was invoked.</p>
</li>
<li><p>
Assert:
<i>envRec </i>does not already have a binding for <i>N</i>.</p>
</li>
<li><p>
Create
an <a href="#immutable-binding">immutable binding</a> in <i>envRec</i> for <i>N</i> and record that
it is uninitialized.</p>
</li></ol><h6 id="x10.2.1.1.8">10.2.1.1.8 InitializeImmutableBinding (N,V) <a href="#x10.2.1.1.8">#</a> <a href="#x10.2.1.1.8-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h6>
<p>
The
concrete Environment Record method InitializeImmutableBinding for
declarative environment records is used to set the bound value of
the current binding of the identifier whose name is the value of the
argument <i>N</i> to the
value of argument <i>V</i>.
An uninitialized <a href="#immutable-binding">immutable binding</a> for <i>N</i>
must already exist.
</p>
<ol><li><p>
Let
<i>envRec </i>be the declarative environment record for which the
method was invoked.</p>
</li>
<li><p>
Assert:
<i>envRec</i> must have an uninitialized <a href="#immutable-binding">immutable binding</a> for N.</p>
</li>
<li><p>
Set
the bound value for <i>N</i> in <i>envRec</i> to <i>V</i>.</p>
</li>
<li><p>
Record
that the <a href="#immutable-binding">immutable binding</a> for <i>N</i> in <i>envRec</i> has been
initialized.</p>
</li></ol><h5 id="x10.2.1.2">10.2.1.2 Object Environment Records <a href="#x10.2.1.2">#</a> <a href="#x10.2.1.2-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h5>
<p>
Each
object environment record is associated with an object called its
<i>binding object</i>. An object environment record binds the set of
identifier names that directly correspond to the property names of
its binding object. Property names that are not an <i>IdentifierName </i>are not included in the set of bound identifiers. Both
own and inherited properties are included in the set regardless of
the setting of their [[Enumerable]] attribute. Because properties
can be dynamically added and deleted from objects, the set of
identifiers bound by an object environment record may potentially
change as a side-effect of any operation that adds or deletes
properties. Any bindings that are created as a result of such a
side-effect are considered to be a mutable binding even if the
Writable attribute of the corresponding property has the value
<b>false</b>. Immutable bindings do not exist for object environment
records.</p>
<p>
Object
environment records can be configured to provide their binding
object as an implicit this value for use in function calls. This
capability is used to specify the behaviour of With Statement
(<a href="x12.html#x12.10">12.10</a>) induced bindings. The capability is controlled by a
<i>provideThis</i>
Boolean value that is associated with each object environment
record. By default, the value of <i>provideThis</i>
is <b>false</b> for any object environment record.</p>
<p>
The
behaviour of the concrete specification methods for Object
Environment Records is defined by the following algorithms.</p>
<h6 id="x10.2.1.2.1">10.2.1.2.1 HasBinding(N) <a href="#x10.2.1.2.1">#</a> <a href="#x10.2.1.2.1-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h6>
<p>
The
concrete Environment Record method HasBinding for object environment
records determines if its associated <a href="#x10.2.1.2">binding object</a> has a property
whose name is the value of the argument <i>N</i>:</p>
<ol><li><p>
Let
<i>envRec </i>be the object environment record for which the method
was invoked.</p>
</li>
<li><p>
Let
<i>bindings </i>be the <a href="#x10.2.1.2">binding object</a> for <i>envRec</i>.</p>
</li>
<li><p>
Return
the result of calling the [[HasProperty]] internal method of
<i>bindings</i>, passing <i>N</i> as the property name.</p>
</li></ol><h6 id="x10.2.1.2.2">10.2.1.2.2 CreateMutableBinding (N, D) <a href="#x10.2.1.2.2">#</a> <a href="#x10.2.1.2.2-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h6>
<p>
The
concrete Environment Record method CreateMutableBinding for object
environment records creates in an environment record’s associated
<a href="#x10.2.1.2">binding object</a> a property whose name is the String value and
initializes it to the value <b>undefined</b>. A property named <i>N</i>
must not already exist in the <a href="#x10.2.1.2">binding object</a>. If Boolean argument <i>D</i>
is provided and has the value <b>true</b> the new property’s
[[Configurable]] attribute is set to <b>true</b>, otherwise it is
set to <b>false</b>.</p>
<ol><li><p>
Let
<i>envRec</i> be the object environment record for which the method
was invoked.</p>
</li>
<li><p>
Let
<i>bindings</i> be the <a href="#x10.2.1.2">binding object</a> for <i>envRec</i>.</p>
</li>
<li><p>
Assert:
The result of calling the [[HasProperty]] internal method of
<i>bindings</i>, passing <i>N</i> as the property name, is <b>false</b>.</p>
</li>
<li><p>
If
D is <b>true</b> then let <i>configValue</i> be <b>true</b>
otherwise let <i>configValue</i> be <b>false</b>.</p>
</li>
<li><p>
Call
the [[DefineOwnProperty]] internal method of <i>bindings</i>,
passing <i>N</i>, <a href="x8.html#x8.10">Property Descriptor</a> {[[Value]]:<b>undefined</b>,
[[Writable]]: <b>true</b>, [[Enumerable]]: <b>true</b> ,
[[Configurable]]: <i>configValue</i>}, and
<b>true</b>
as
arguments.</p>
</li>
</ol><h6 id="x10.2.1.2.3">10.2.1.2.3 SetMutableBinding (N,V,S) <a href="#x10.2.1.2.3">#</a> <a href="#x10.2.1.2.3-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h6>
<p>
The
concrete Environment Record method SetMutableBinding for object
environment records attempts to set the value of the environment
record’s associated <a href="#x10.2.1.2">binding object</a>’s property whose name is the
value of the argument <i>N</i>
to the value of argument <i>V</i>.
A property named <i>N</i>
should already exist but if it does not or is not currently
writable, error handling is determined by the value of the Boolean
argument <i>S</i>.</p>
<ol><li><p>
Let
<i>envRec</i> be the object environment record for which the method
was invoked.</p>
</li>
<li><p>
Let
<i>bindings</i> be the <a href="#x10.2.1.2">binding object</a> for <i>envRec</i>.</p>
</li>
<li><p>
Call
the [[Put]] internal method of <i>bindings</i> with arguments <i>N</i>,
<i>V</i>, and <i>S</i>.</p>
</li></ol><h6 id="x10.2.1.2.4">10.2.1.2.4 GetBindingValue(N,S) <a href="#x10.2.1.2.4">#</a> <a href="#x10.2.1.2.4-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h6>
<p>
The
concrete Environment Record method GetBindingValue for object
environment records returns the value of its associated <a href="#x10.2.1.2">binding object</a>’s property whose name is the String value of the argument
identifier <i>N</i>. The
property should already exist but if it does not the result depends
upon the value of the <i>S</i>
argument:</p>
<ol><li><p>
Let
<i>envRec</i> be the object environment record for which the method
was invoked.</p>
</li>
<li><p>
Let
<i>bindings</i> be the <a href="#x10.2.1.2">binding object</a> for <i>envRec</i>.</p>
</li>
<li><p>
Let
<i>value</i> be the result of calling the [[HasProperty]] internal
method of <i>bindings</i>, passing <i>N</i> as the property name.</p>
</li>
<li><p>
If
<i>value</i> is <b>false</b>, then</p>
<ol><li><p>
If
<i>S</i> is <b>false</b>, return the value <b>undefined</b>,
otherwise throw a <b>ReferenceError </b>exception.</p>
</li></ol></li>
<li><p>
Return
the result of calling the [[Get]] internal method of <i>bindings</i>,
passing <i>N</i> for the argument.</p>
</li></ol><h6 id="x10.2.1.2.5">10.2.1.2.5 DeleteBinding (N) <a href="#x10.2.1.2.5">#</a> <a href="#x10.2.1.2.5-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h6>
<p>
The
concrete Environment Record method DeleteBinding for object
environment records can only delete bindings that correspond to
properties of the environment object whose [[Configurable]]
attribute have the value <b>true</b>.</p>
<ol><li><p>
Let
<i>envRec</i> be the object environment record for which the method
was invoked.</p>
</li>
<li><p>
Let
<i>bindings </i>be the <a href="#x10.2.1.2">binding object</a> for <i>envRec</i>.</p>
</li>
<li><p>
Return
the result of calling the [[Delete]] internal method of <i>bindings</i>,
passing <i>N</i> and <b>false</b> as arguments.</p>
</li></ol><h6 id="x10.2.1.2.6">10.2.1.2.6 ImplicitThisValue() <a href="#x10.2.1.2.6">#</a> <a href="#x10.2.1.2.6-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h6>
<p>
Object
Environment Records return <b>undefined</b> as their
ImplicitThisValue unless their <i>provideThis</i>
flag is <b>true</b>.</p>
<ol><li><p>
Let
<i>envRec</i> be the object environment record for which the method
was invoked.</p>
</li>
<li><p>
If
the <i>provideThis</i> flag of <i>envRec</i> is <b>true</b>, return
the <a href="#x10.2.1.2">binding object</a> for <i>envRec</i>.</p>
</li>
<li><p>
Otherwise,
return <b>undefined</b>.</p>
</li></ol><h4 id="x10.2.2">10.2.2 Lexical Environment Operations <a href="#x10.2.2">#</a> <a href="#x10.2.2-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h4>
<p>
The
following abstract operations are used in this specification to
operate upon lexical environments:</p>
<h5 id="x10.2.2.1">10.2.2.1 GetIdentifierReference (lex, name, strict) <a href="#x10.2.2.1">#</a> <a href="#x10.2.2.1-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h5>
<p>
The
abstract operation GetIdentifierReference is called with a <a href="#x10.2">Lexical Environment</a> <i>lex</i>,
an identifier String <i>name</i>,
and a Boolean flag <i>strict. </i>The value of <i>lex </i>may be <b>null</b>. When called, the following steps are
performed:</p>
<ol><li><p>
If
<i>lex</i> is the value <b>null</b>, then</p>
<ol><li><p>
Return
a value of type <a href="x8.html#x8.7">Reference</a> whose base value is <b>undefined</b>,
whose referenced name is <i>name</i>, and whose strict mode flag
is <i>strict</i>.</p>
</li></ol></li>
<li><p>
Let
<i>envRec</i> be <i>lex</i>’s environment record.</p>
</li>
<li><p>
Let
<i>exists </i>be the result of calling the HasBinding(<i>N</i>)
concrete method of <i>envRec</i> passing <i>name</i> as the
argument <i>N</i>.</p>
</li>
<li><p>
If
<i>exists </i>is <code><b>true</b></code>,
then</p>
<ol><li><p>
Return
a value of type <a href="x8.html#x8.7">Reference</a> whose base value is <i>envRec</i>, whose
referenced name is <i>name</i>, and whose strict mode flag is
<i>strict.</i></p>
</li></ol></li>
<li><p>
Else</p>
<ol><li><p>
Let
<i>outer </i>be the value of <i>lex’s</i> <a href="#outer-environment-reference">outer environment reference</a>.</p>
</li>
<li><p>
Return
the result of calling GetIdentifierReference passing <i>outer</i>,
<i>name</i>, and <i>strict</i> as arguments.</p>
</li></ol></li></ol><h5 id="x10.2.2.2">10.2.2.2 NewDeclarativeEnvironment (E) <a href="#x10.2.2.2">#</a> <a href="#x10.2.2.2-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h5>
<p>
When
the abstract operation NewDeclarativeEnvironment is called with
either a <a href="#x10.2">Lexical Environment</a> or <b>null</b> as argument <i>E </i>the following steps are performed:</p>
<ol><li><p>
Let
<i>env</i> be a new <a href="#x10.2">Lexical Environment</a>.</p>
</li>
<li><p>
Let
<i>envRec</i> be a new <a href="#declarative-environment-record">declarative environment record</a> containing no
bindings.</p>
</li>
<li><p>
Set
<i>env’s</i> environment record to be <i>envRec</i>.</p>
</li>
<li><p>
Set
the outer lexical environment reference of <i>env</i> to <i>E</i>.</p>
</li>
<li><p>
Return
<i>env</i>.</p>
</li></ol><h5 id="x10.2.2.3">10.2.2.3 NewObjectEnvironment (O, E) <a href="#x10.2.2.3">#</a> <a href="#x10.2.2.3-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h5>
<p>
When
the abstract operation NewObjectEnvironmentis called with an Object
<i>O</i> and a <a href="#x10.2">Lexical Environment</a> <i>E </i>(or
<b>null)</b> as arguments, the following steps are performed:</p>
<ol><li><p>
Let
<i>env</i> be a new <a href="#x10.2">Lexical Environment</a>.</p>
</li>
<li><p>
Let
<i>envRec</i> be a new <a href="#object-environment-record">object environment record</a> containing <i>O</i>
as the <a href="#x10.2.1.2">binding object</a>.</p>
</li>
<li><p>
Set
<i>env’s</i> environment record to be <i>envRec</i>.</p>
</li>
<li><p>
Set
the outer lexical environment reference of <i>env</i> to <i>E</i>.</p>
</li>
<li><p>
Return
<i>env</i>.</p>
</li></ol><h4 id="x10.2.3">10.2.3 The Global Environment <a href="#x10.2.3">#</a> <a href="#x10.2.3-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h4>
<p>
The
<i>global environment</i> is a unique <a href="#x10.2">Lexical Environment</a> which is
created before any ECMAScript code is executed. The global
environment’s <a href="#x10.2.1">Environment Record</a> is an <a href="#object-environment-record">object environment record</a>
whose <a href="#x10.2.1.2">binding object</a> is the <a href="x15.1.html#x15.1" class="term-ref">global object</a> (<a href="x15.1.html#x15.1">15.1</a>). The global
environment’s <a href="#outer-environment-reference">outer environment reference</a> is <b>null</b>.</p>
<p>
As
ECMAScript code is executed, additional properties may be added to
the <a href="x15.1.html#x15.1" class="term-ref">global object</a> and the initial properties may be modified.
</p>
<h3 id="x10.3">10.3 Execution Contexts <a href="#x10.3">#</a> <a href="#x10.3-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h3>
<p>
When
control is transferred to ECMAScript executable code, control is
entering an <i>execution context</i>. Active execution contexts
logically form a stack. The top execution context on this logical
stack is the running execution context. A new execution context is
created whenever control is transferred from the executable code
associated with the currently running execution context to
executable code that is not associated with that execution context.
The newly created execution context is pushed onto the stack and
becomes the running execution context.</p>
<p>
An
execution context contains whatever state is necessary to track the
execution progress of its associated code. In addition, each
execution context has the state components listed in Table 19.</p>
<center>
<table width="690" border="1" bordercolor="#000000" cellpadding="8" cellspacing="0" rules="ROWS"><caption>Table 19 —Execution Context State Components</caption>
<colgroup><col width="161"><col width="495"></colgroup><tbody><tr valign="TOP"><td width="161" height="11" bgcolor="#c0c0c0">
<p>
<i><b><span class="table-header">Component</span></b></i></p>
</td>
<td width="495" bgcolor="#c0c0c0">
<p>
<i><b><span class="table-header">Purpose</span></b></i></p>
</td>
</tr><tr valign="TOP"><td width="161">
<p>
LexicalEnvironment</p>
</td>
<td width="495">
<p>
Identifies
the <a href="#x10.2">Lexical Environment</a> used to resolve identifier references
made by code within this execution context.</p>
</td>
</tr><tr valign="TOP"><td width="161">
<p>
VariableEnvironment</p>
</td>
<td width="495">
<p>
Identifies
the <a href="#x10.2">Lexical Environment</a> whose environment record holds bindings
created by <i>VariableStatements</i>
and <i>FunctionDeclarations</i>
within this execution context.</p>
</td>
</tr><tr valign="TOP"><td width="161">
<p>ThisBinding</p>
</td>
<td width="495">
<p>The
value associated with the <code><b>this</b></code>
keyword within ECMAScript code associated with this execution
context.</p>
</td>
</tr></tbody></table></center>
<p>
The
LexicalEnvironment and VariableEnvironment components of an
execution context are always <a href="#x10.2">Lexical Environment</a>s. When an execution
context is created its LexicalEnvironment and VariableEnvironment
components initially have the same value. The value of the
VariableEnvironment component never changes while the value of the
LexicalEnvironment component may change during execution of code
within an execution context.</p>
<p>
In
most situations only the running execution context (the top of the
execution context stack) is directly manipulated by algorithms
within this specification. Hence when the terms
“LexicalEnvironment”, “VariableEnvironment” and
“ThisBinding” are used without qualification they are in
reference to those components of the running execution context.</p>
<p>
An
execution context is purely a specification mechanism and need not
correspond to any particular artefact of an ECMAScript
implementation. It is impossible for an ECMAScript program to
access an execution context.
</p>
<h4 id="x10.3.1">10.3.1 Identifier Resolution <a href="#x10.3.1">#</a> <a href="#x10.3.1-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h4>
<p>
Identifier
resolution is the process of determining the binding of an
<i>Identifier</i> using
the <a href="#x10.2">LexicalEnvironment</a> of the running execution context. During
execution of ECMAScript code, the syntactic production
<i>PrimaryExpression</i>
<b>:</b>
<i>Identifier</i> is
evaluated using the following algorithm:</p>
<ol><li><p>
Let
<i>env</i> be the running execution context’s <a href="#x10.2">LexicalEnvironment</a>.</p>
</li>
<li><p>
If
the syntactic production that is being evaluated is contained in a
<a href="#x10.1.1" class="term-ref">strict mode code</a>, then let <i>strict</i> be <b>true</b>, else let
<i>strict</i> be <b>false</b>.</p>
</li>
<li><p>
Return
the result of calling <a href="#x10.2.2.1">GetIdentifierReference</a> function passing <i>env</i>,
<i>Identifier</i>, and <i>strict</i> as arguments.</p>
</li></ol><p>
The
result of evaluating an identifier is always a value of type
<a href="x8.html#x8.7">Reference</a> with its referenced name component equal to the <i>Identifier</i>
String.</p>
<h3 id="x10.4">10.4 Establishing an Execution Context <a href="#x10.4">#</a> <a href="#x10.4-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h3>
<p>
Evaluation
of <a href="#global-code">global code</a> or code using the eval function (<a href="x15.1.html#x15.1.2.1">15.1.2.1</a>)
establishes and enters a new execution context. Every invocation of
an ECMAScript code function (<a href="x13.html#x13.2.1">13.2.1</a>) also establishes and enters a
new execution context, even if a function is calling itself
recursively. Every return exits an execution context. A thrown
exception may also exit one or more execution contexts.</p>
<p>
When
control enters an execution context, the execution context’s
ThisBinding is set, its VariableEnvironment and initial
LexicalEnvironment are defined, and declaration binding
instantiation (<a href="#x10.5">10.5</a>) is performed. The exact manner in which these
actions occur depend on the type of code being entered.</p>
<h4 id="x10.4.1">10.4.1 Entering Global Code <a href="#x10.4.1">#</a> <a href="#x10.4.1-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h4>
<p>
The
following steps are performed when control enters the execution
context for <a href="#global-code">global code</a>:</p>
<ol><li><p>
Initialize
the execution context using the <a href="#global-code">global code</a> as described in
<a href="#x10.4.1.1">10.4.1.1</a>.</p>
</li>
<li><p>
Perform
Declaration Binding Instantiation as described in <a href="#x10.5">10.5</a> using the
<a href="#global-code">global code</a>.</p>
</li></ol><h5 id="x10.4.1.1">10.4.1.1 Initial Global Execution Context <a href="#x10.4.1.1">#</a> <a href="#x10.4.1.1-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h5>
<p>
The
following steps are performed to initialize a global execution
context for ECMAScript code <i>C</i>:</p>
<ol><li><p>
Set
the VariableEnvironment to the <a href="#x10.2.3">Global Environment</a>.</p>
</li>
<li><p>
Set
the LexicalEnvironment to the <a href="#x10.2.3">Global Environment</a>.</p>
</li>
<li><p>
Set
the ThisBinding to the <a href="x15.1.html#x15.1" class="term-ref">global object</a>.</p>
</li></ol><h4 id="x10.4.2">10.4.2 Entering Eval Code <a href="#x10.4.2">#</a> <a href="#x10.4.2-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h4>
<p>
The
following steps are performed when control enters the execution
context for <a href="#eval-code">eval code</a>:</p>
<ol><li><p>
If
there is no calling context or if the <a href="#eval-code">eval code</a> is not being
evaluated by a direct call (<a href="x15.1.html#x15.1.2.1.1">15.1.2.1.1</a>) to the eval function then,</p>
<ol><li><p>
Initialize
the execution context as if it was a global execution context
using the <a href="#eval-code">eval code</a> as <i>C</i> as described in <a href="#x10.4.1.1">10.4.1.1</a>.</p>
</li></ol></li>
<li><p>
Else,</p>
<ol><li><p>
Set