-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjavascript_ecma_262_5th_ed.info-2
More file actions
7788 lines (5313 loc) · 293 KB
/
javascript_ecma_262_5th_ed.info-2
File metadata and controls
7788 lines (5313 loc) · 293 KB
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
ã“れ㯠javascript_ecma_262_5th_ed.infoã€es5.texi より makeinfo
ãƒãƒ¼ã‚¸ãƒ§ãƒ³ 4.8 ã«ã‚ˆã£ã¦ä½œæˆã•れã¾ã—ãŸã€‚
File: javascript_ecma_262_5th_ed.info, Node: 1163 Applying the Additive Operators to Numbers, Next: 117 Bitwise Shift Operators, Prev: 1162 The Subtraction Operator -, Up: Top
190 11.6.3 (#sec-11.6.3) Applying the Additive Operators to Numbers
*******************************************************************
The `+' operator performs addition when applied to two operands of
numeric type, producing the sum of the operands. The `-' operator
performs subtraction, producing the difference of two numeric operands.
Addition is a commutative operation, but not always associative.
The result of an addition is determined using the rules of IEEE 754
binary double-precision arithmetic:
* If either operand is NaN, the result is NaN.
* The sum of two infinities of opposite sign is NaN.
* The sum of two infinities of the same sign is the infinity of that
sign.
* The sum of an infinity and a finite value is equal to the infinite
operand.
* The sum of two negative zeros is −0. The sum of two positive
zeros, or of two zeros of opposite sign, is +0.
* The sum of a zero and a nonzero finite value is equal to the
nonzero operand.
* The sum of two nonzero finite values of the same magnitude and
opposite sign is +0.
* In the remaining cases, where neither an infinity, nor a zero, nor
NaN is involved, and the operands have the same sign or have
different magnitudes, the sum is computed and rounded to the
nearest representable value using IEEE 754 round-to-nearest mode.
If the magnitude is too large to represent, the operation
overflows and the result is then an infinity of appropriate sign.
The ECMAScript language requires support of gradual underflow as
defined by IEEE 754.
The `-' operator performs subtraction when applied to two operands
of numeric type, producing the difference of its operands; the left
operand is the minuend and the right operand is the subtrahend. Given
numeric operands a and b, it is always the case that
`<var>a</var>-<var>b</var>' produces the same result as `<var>a</var>
+(-<var>b</var>)'.
File: javascript_ecma_262_5th_ed.info, Node: 117 Bitwise Shift Operators, Next: 1171 The Left Shift Operator <<, Prev: 1163 Applying the Additive Operators to Numbers, Up: Top
191 11.7 (#sec-11.7) Bitwise Shift Operators
********************************************
* Menu:
* Syntax::
File: javascript_ecma_262_5th_ed.info, Node: Syntax, Up: 117 Bitwise Shift Operators
191.1 Syntax
============
ShiftExpression : AdditiveExpression ShiftExpression `<<'
AdditiveExpression ShiftExpression `>>' AdditiveExpression
ShiftExpression `>>>' AdditiveExpression
File: javascript_ecma_262_5th_ed.info, Node: 1171 The Left Shift Operator <<, Next: 1172 The Signed Right Shift Operator >>, Prev: 117 Bitwise Shift Operators, Up: Top
192 11.7.1 (#sec-11.7.1) The Left Shift Operator ( `<<' )
*********************************************************
Performs a bitwise left shift operation on the left operand by the
amount specified by the right operand.
1. Let lref be the result of evaluating ShiftExpression.
2. Let lval be GetValue (#sec-8.7.1)(lref).
3. Let rref be the result of evaluating AdditiveExpression.
4. Let rval be GetValue (#sec-8.7.1)(rref).
5. Let lnum be ToInt32 (#sec-9.5)(lval).
6. Let rnum be ToUint32 (#sec-9.6)(rval).
7. Let shiftCount be the result of masking out all but the least
significant 5 bits of rnum, that is, compute rnum & 0x1F.
8. Return the result of left shifting lnum by shiftCount bits. The
result is a signed 32-bit integer.
File: javascript_ecma_262_5th_ed.info, Node: 1172 The Signed Right Shift Operator >>, Next: 1173 The Unsigned Right Shift Operator >>>, Prev: 1171 The Left Shift Operator <<, Up: Top
193 11.7.2 (#sec-11.7.2) The Signed Right Shift Operator ( `>>' )
*****************************************************************
Performs a sign-filling bitwise right shift operation on the left
operand by the amount specified by the right operand.
The production ShiftExpression : ShiftExpression `>>'
AdditiveExpression is evaluated as follows:
1. Let lref be the result of evaluating ShiftExpression.
2. Let lval be GetValue (#sec-8.7.1)(lref).
3. Let rref be the result of evaluating AdditiveExpression.
4. Let rval be GetValue (#sec-8.7.1)(rref).
5. Let lnum be ToInt32 (#sec-9.5)(lval).
6. Let rnum be ToUint32 (#sec-9.6)(rval).
7. Let shiftCount be the result of masking out all but the least
significant 5 bits of rnum, that is, compute rnum & 0x1F.
8. Return the result of performing a sign-extending right shift of
lnum by shiftCount bits. The most significant bit is propagated.
The result is a signed 32-bit integer.
File: javascript_ecma_262_5th_ed.info, Node: 1173 The Unsigned Right Shift Operator >>>, Next: 118 Relational Operators, Prev: 1172 The Signed Right Shift Operator >>, Up: Top
194 11.7.3 (#sec-11.7.3) The Unsigned Right Shift Operator ( `>>>' )
********************************************************************
Performs a zero-filling bitwise right shift operation on the left
operand by the amount specified by the right operand.
The production ShiftExpression : ShiftExpression `>>>'
AdditiveExpression is evaluated as follows:
1. Let lref be the result of evaluating ShiftExpression.
2. Let lval be GetValue (#sec-8.7.1)(lref).
3. Let rref be the result of evaluating AdditiveExpression.
4. Let rval be GetValue (#sec-8.7.1)(rref).
5. Let lnum be ToUint32 (#sec-9.6)(lval).
6. Let rnum be ToUint32 (#sec-9.6)(rval).
7. Let shiftCount be the result of masking out all but the least
significant 5 bits of rnum, that is, compute rnum & 0x1F.
8. Return the result of performing a zero-filling right shift of lnum
by shiftCount bits. Vacated bits are filled with zero. The result
is an unsigned 32-bit integer.
File: javascript_ecma_262_5th_ed.info, Node: 118 Relational Operators, Next: 1181 The Less-than Operator <, Prev: 1173 The Unsigned Right Shift Operator >>>, Up: Top
195 11.8 (#sec-11.8) Relational Operators
*****************************************
* Menu:
* Syntax::
* Semantics::
File: javascript_ecma_262_5th_ed.info, Node: Syntax, Next: Semantics, Up: 118 Relational Operators
195.1 Syntax
============
RelationalExpression : ShiftExpression RelationalExpression `<'
ShiftExpression RelationalExpression `>' ShiftExpression
RelationalExpression `<=' ShiftExpression RelationalExpression `>='
ShiftExpression RelationalExpression `instanceof' ShiftExpression
RelationalExpression `in' ShiftExpression RelationalExpressionNoIn :
ShiftExpression RelationalExpressionNoIn `<' ShiftExpression
RelationalExpressionNoIn `>' ShiftExpression RelationalExpressionNoIn
`<=' ShiftExpression RelationalExpressionNoIn `>=' ShiftExpression
RelationalExpressionNoIn `instanceof' ShiftExpression NOTE The
“NoIn†variants are needed to avoid confusing the `in' operator in
a relational expression with the `in' operator in a `for' statement.
File: javascript_ecma_262_5th_ed.info, Node: Semantics, Prev: Syntax, Up: 118 Relational Operators
195.2 Semantics
===============
The result of evaluating a relational operator is always of type
Boolean, reflecting whether the relationship named by the operator
holds between its two operands.
The RelationalExpressionNoIn productions are evaluated in the same
manner as the RelationalExpression productions except that the
contained RelationalExpressionNoIn is evaluated instead of the
contained RelationalExpression.
File: javascript_ecma_262_5th_ed.info, Node: 1181 The Less-than Operator <, Next: 1182 The Greater-than Operator >, Prev: 118 Relational Operators, Up: Top
196 11.8.1 (#sec-11.8.1) The Less-than Operator ( `<' )
*******************************************************
The production RelationalExpression : RelationalExpression `<'
ShiftExpression is evaluated as follows:
1. Let lref be the result of evaluating RelationalExpression.
2. Let lval be GetValue (#sec-8.7.1)(lref).
3. Let rref be the result of evaluating ShiftExpression.
4. Let rval be GetValue (#sec-8.7.1)(rref).
5. Let r be the result of performing abstract relational comparison
lval < rval. (see 11.8.5 (#sec-11.8.5))
6. If r is undefined, return false. Otherwise, return r.
File: javascript_ecma_262_5th_ed.info, Node: 1182 The Greater-than Operator >, Next: 1183 The Less-than-or-equal Operator <=, Prev: 1181 The Less-than Operator <, Up: Top
197 11.8.2 (#sec-11.8.2) The Greater-than Operator ( `>' )
**********************************************************
The production RelationalExpression : RelationalExpression `>'
ShiftExpression is evaluated as follows:
1. Let lref be the result of evaluating RelationalExpression.
2. Let lval be GetValue (#sec-8.7.1)(lref).
3. Let rref be the result of evaluating ShiftExpression.
4. Let rval be GetValue (#sec-8.7.1)(rref).
5. Let r be the result of performing abstract relational comparison
rval < lval with LeftFirst equal to false. (see 11.8.5
(#sec-11.8.5)).
6. If r is undefined, return false. Otherwise, return r.
File: javascript_ecma_262_5th_ed.info, Node: 1183 The Less-than-or-equal Operator <=, Next: 1184 The Greater-than-or-equal Operator >=, Prev: 1182 The Greater-than Operator >, Up: Top
198 11.8.3 (#sec-11.8.3) The Less-than-or-equal Operator ( `<=' )
*****************************************************************
The production RelationalExpression : RelationalExpression `<='
ShiftExpression is evaluated as follows:
1. Let lref be the result of evaluating RelationalExpression.
2. Let lval be GetValue (#sec-8.7.1)(lref).
3. Let rref be the result of evaluating ShiftExpression.
4. Let rval be GetValue (#sec-8.7.1)(rref).
5. Let r be the result of performing abstract relational comparison
rval < lval with LeftFirst equal to false. (see 11.8.5
(#sec-11.8.5)).
6. If r is true or undefined, return false. Otherwise, return true.
File: javascript_ecma_262_5th_ed.info, Node: 1184 The Greater-than-or-equal Operator >=, Next: 1185 The Abstract Relational Comparison Algorithm, Prev: 1183 The Less-than-or-equal Operator <=, Up: Top
199 11.8.4 (#sec-11.8.4) The Greater-than-or-equal Operator ( `>=' )
********************************************************************
The production RelationalExpression : RelationalExpression `>='
ShiftExpression is evaluated as follows:
1. Let lref be the result of evaluating RelationalExpression.
2. Let lval be GetValue (#sec-8.7.1)(lref).
3. Let rref be the result of evaluating ShiftExpression.
4. Let rval be GetValue (#sec-8.7.1)(rref).
5. Let r be the result of performing abstract relational comparison
lval < rval. (see 11.8.5 (#sec-11.8.5))
6. If r is true or undefined, return false. Otherwise, return true.
File: javascript_ecma_262_5th_ed.info, Node: 1185 The Abstract Relational Comparison Algorithm, Next: 1186 The instanceof operator, Prev: 1184 The Greater-than-or-equal Operator >=, Up: Top
200 11.8.5 (#sec-11.8.5) The Abstract Relational Comparison Algorithm
*********************************************************************
The comparison x < y, where x and y are values, produces true, false,
or undefined (which indicates that at least one operand is NaN). In
addition to x and y the algorithm takes a Boolean flag named LeftFirst
as a parameter. The flag is used to control the order in which
operations with potentially visible side-effects are performed upon x
and y. It is necessary because ECMAScript specifies left to right
evaluation of expressions. The default value of LeftFirst is true and
indicates that the x parameter corresponds to an expression that occurs
to the left of the y parameter’s corresponding expression. If
LeftFirst is false, the reverse is the case and operations must be
performed upon y before x. Such a comparison is performed as follows:
1. If the LeftFirst flag is true, then
1. Let px be the result of calling ToPrimitive (#sec-9.1)(x,
hint Number).
2. Let py be the result of calling ToPrimitive (#sec-9.1)(y,
hint Number).
2. Else the order of evaluation needs to be reversed to preserve left
to right evaluation
1. Let py be the result of calling ToPrimitive (#sec-9.1)(y,
hint Number).
2. Let px be the result of calling ToPrimitive (#sec-9.1)(x,
hint Number).
3. If it is not the case that both Type (#def-type)(px) is String and
Type (#def-type)(py) is String, then
1. Let nx be the result of calling ToNumber (#sec-9.3)(px).
Because px and py are primitive values evaluation order is
not important.
2. Let ny be the result of calling ToNumber (#sec-9.3)(py).
3. If nx is NaN, return undefined.
4. If ny is NaN, return undefined.
5. If nx and ny are the same Number value, return false.
6. If nx is +0 and ny is −0, return false.
7. If nx is −0 and ny is +0, return false.
8. If nx is +∞, return false.
9. If ny is +∞, return true.
10. If ny is −∞, return false.
11. If nx is −∞, return true.
12. If the mathematical value of nx is less than the mathematical
value of ny —note that these mathematical values are both
finite and not both zero—return true. Otherwise, return
false.
4. Else, both px and py are Strings
1. If py is a prefix of px, return false. (A String value p is a
prefix of String value q if q can be the result of
concatenating p and some other String r. Note that any String
is a prefix of itself, because r may be the empty String.)
2. 3. Let k be the smallest nonnegative integer such that the
character at position k within px is different from the
character at position k within py. (There must be such a k,
for neither String is a prefix of the other.)
4. Let m be the integer that is the code unit value for the
character at position k within px.
5. Let n be the integer that is the code unit value for the
character at position k within py.
6. If m < n, return true. Otherwise, return false.
NOTE 1 Step 3 differs from step 7 in the algorithm for the addition
operator `+' (11.6.1 (#sec-11.6.1)) in using and instead of or.
NOTE 2 The comparison of Strings uses a simple lexicographic
ordering on sequences of code unit values. There is no attempt to use
the more complex, semantically oriented definitions of character or
string equality and collating order defined in the Unicode
specification. Therefore String values that are canonically equal
according to the Unicode standard could test as unequal. In effect this
algorithm assumes that both Strings are already in normalised form.
Also, note that for strings containing supplementary characters,
lexicographic ordering on sequences of UTF-16 code unit values differs
from that on sequences of code point values.
File: javascript_ecma_262_5th_ed.info, Node: 1186 The instanceof operator, Next: 1187 The in operator, Prev: 1185 The Abstract Relational Comparison Algorithm, Up: Top
201 11.8.6 (#sec-11.8.6) The `instanceof' operator
**************************************************
The production RelationalExpression: RelationalExpression `instanceof'
ShiftExpression is evaluated as follows:
1. Let lref be the result of evaluating RelationalExpression.
2. Let lval be GetValue (#sec-8.7.1)(lref).
3. Let rref be the result of evaluating ShiftExpression.
4. Let rval be GetValue (#sec-8.7.1)(rref).
5. If Type (#def-type)(rval) is not Object, throw a TypeError
exception.
6. If rval does not have a [[HasInstance]] internal method, throw a
TypeError exception.
7. Return the result of calling the [[HasInstance]] internal method
of rval with argument lval.
File: javascript_ecma_262_5th_ed.info, Node: 1187 The in operator, Next: 119 Equality Operators, Prev: 1186 The instanceof operator, Up: Top
202 11.8.7 (#sec-11.8.7) The `in' operator
******************************************
The production RelationalExpression : RelationalExpression `in'
ShiftExpression is evaluated as follows:
1. Let lref be the result of evaluating RelationalExpression.
2. Let lval be GetValue (#sec-8.7.1)(lref).
3. Let rref be the result of evaluating ShiftExpression.
4. Let rval be GetValue (#sec-8.7.1)(rref).
5. If Type (#def-type)(rval) is not Object, throw a TypeError
exception.
6. Return the result of calling the [[HasProperty]] internal method
of rval with argument ToString (#sec-9.8)(lval).
File: javascript_ecma_262_5th_ed.info, Node: 119 Equality Operators, Next: 1191 The Equals Operator ==, Prev: 1187 The in operator, Up: Top
203 11.9 (#sec-11.9) Equality Operators
***************************************
* Menu:
* Syntax::
* Semantics::
File: javascript_ecma_262_5th_ed.info, Node: Syntax, Next: Semantics, Up: 119 Equality Operators
203.1 Syntax
============
EqualityExpression : RelationalExpression EqualityExpression `=='
RelationalExpression EqualityExpression `!=' RelationalExpression
EqualityExpression `===' RelationalExpression EqualityExpression `!=='
RelationalExpression EqualityExpressionNoIn : RelationalExpressionNoIn
EqualityExpressionNoIn `==' RelationalExpressionNoIn
EqualityExpressionNoIn `!=' RelationalExpressionNoIn
EqualityExpressionNoIn `===' RelationalExpressionNoIn
EqualityExpressionNoIn `!==' RelationalExpressionNoIn
File: javascript_ecma_262_5th_ed.info, Node: Semantics, Prev: Syntax, Up: 119 Equality Operators
203.2 Semantics
===============
The result of evaluating an equality operator is always of type
Boolean, reflecting whether the relationship named by the operator
holds between its two operands.
The EqualityExpressionNoIn productions are evaluated in the same
manner as the EqualityExpression productions except that the contained
EqualityExpressionNoIn and RelationalExpressionNoIn are evaluated
instead of the contained EqualityExpression and RelationalExpression,
respectively.
File: javascript_ecma_262_5th_ed.info, Node: 1191 The Equals Operator ==, Next: 1192 The Does-not-equals Operator !=, Prev: 119 Equality Operators, Up: Top
204 11.9.1 (#sec-11.9.1) The Equals Operator ( `==' )
*****************************************************
The production EqualityExpression : EqualityExpression `=='
RelationalExpression is evaluated as follows:
1. Let lref be the result of evaluating EqualityExpression.
2. Let lval be GetValue (#sec-8.7.1)(lref).
3. Let rref be the result of evaluating RelationalExpression.
4. Let rval be GetValue (#sec-8.7.1)(rref).
5. Return the result of performing abstract equality comparison rval
== lval. (see 11.9.3 (#sec-11.9.3)).
File: javascript_ecma_262_5th_ed.info, Node: 1192 The Does-not-equals Operator !=, Next: 1193 The Abstract Equality Comparison Algorithm, Prev: 1191 The Equals Operator ==, Up: Top
205 11.9.2 (#sec-11.9.2) The Does-not-equals Operator ( `!=' )
**************************************************************
The production EqualityExpression : EqualityExpression `!='
RelationalExpression is evaluated as follows:
1. Let lref be the result of evaluating EqualityExpression.
2. Let lval be GetValue (#sec-8.7.1)(lref).
3. Let rref be the result of evaluating RelationalExpression.
4. Let rval be GetValue (#sec-8.7.1)(rref).
5. Let r be the result of performing abstract equality comparison
rval == lval. (see 11.9.3 (#sec-11.9.3)).
6. If r is true, return false. Otherwise, return true.
File: javascript_ecma_262_5th_ed.info, Node: 1193 The Abstract Equality Comparison Algorithm, Next: 1194 The Strict Equals Operator ===, Prev: 1192 The Does-not-equals Operator !=, Up: Top
206 11.9.3 (#sec-11.9.3) The Abstract Equality Comparison Algorithm
*******************************************************************
The comparison x == y, where x and y are values, produces true or
false. Such a comparison is performed as follows:
1. If Type (#def-type)(x) is the same as Type (#def-type)(y), then
1. If Type (#def-type)(x) is Undefined, return true.
2. If Type (#def-type)(x) is Null, return true.
3. If Type (#def-type)(x) is Number, then
1. If x is NaN, return false.
2. If y is NaN, return false.
3. If x is the same Number value as y, return true.
4. If x is +0 and y is −0, return true.
5. If x is −0 and y is +0, return true.
6. Return false.
4. If Type (#def-type)(x) is String, then return true if x and y
are exactly the same sequence of characters (same length and
same characters in corresponding positions). Otherwise,
return false.
5. If Type (#def-type)(x) is Boolean, return true if x and y are
both true or both false. Otherwise, return false.
6. Return true if x and y refer to the same object. Otherwise,
return false.
2. If x is null and y is undefined, return true.
3. If x is undefined and y is null, return true.
4. If Type (#def-type)(x) is Number and Type (#def-type)(y) is
String, return the result of the comparison x == ToNumber
(#sec-9.3)(y).
5. If Type (#def-type)(x) is String and Type (#def-type)(y) is
Number, return the result of the comparison ToNumber (#sec-9.3)(x)
== y.
6. If Type (#def-type)(x) is Boolean, return the result of the
comparison ToNumber (#sec-9.3)(x) == y.
7. If Type (#def-type)(y) is Boolean, return the result of the
comparison x == ToNumber (#sec-9.3)(y).
8. If Type (#def-type)(x) is either String or Number and Type
(#def-type)(y) is Object, return the result of the comparison x ==
ToPrimitive (#sec-9.1)(y).
9. If Type (#def-type)(x) is Object and Type (#def-type)(y) is either
String or Number, return the result of the comparison ToPrimitive
(#sec-9.1)(x) == y.
10. Return false.
NOTE 1 Given the above definition of equality:
* String comparison can be forced by: `"" + a == "" + b'.
* Numeric comparison can be forced by: `+a == +b'.
* Boolean comparison can be forced by: `!a == !b'.
NOTE 2 The equality operators maintain the following invariants:
* `<var>A</var> != <var>B</var>' is equivalent to `!(<var>A</var> ==
<var>B</var>)'.
* `<var>A</var> == <var>B</var>' is equivalent to `<var>B</var> ==
<var>A</var>', except in the order of evaluation of A and B.
NOTE 3 The equality operator is not always transitive. For example,
there might be two distinct String objects, each representing the same
String value; each String object would be considered equal to the
String value by the `==' operator, but the two String objects would not
be equal to each other.
NOTE 4 Comparison of Strings uses a simple equality test on
sequences of code unit values. There is no attempt to use the more
complex, semantically oriented definitions of character or string
equality and collating order defined in the Unicode specification.
Therefore Strings values that are canonically equal according to the
Unicode standard could test as unequal. In effect this algorithm
assumes that both Strings are already in normalised form.
File: javascript_ecma_262_5th_ed.info, Node: 1194 The Strict Equals Operator ===, Next: 1195 The Strict Does-not-equal Operator !==, Prev: 1193 The Abstract Equality Comparison Algorithm, Up: Top
207 11.9.4 (#sec-11.9.4) The Strict Equals Operator ( `===' )
*************************************************************
The production EqualityExpression : EqualityExpression `==='
RelationalExpression is evaluated as follows:
1. Let lref be the result of evaluating EqualityExpression.
2. Let lval be GetValue (#sec-8.7.1)(lref).
3. Let rref be the result of evaluating RelationalExpression.
4. Let rval be GetValue (#sec-8.7.1)(rref).
5. Return the result of performing the strict equality comparison
rval === lval. (See 11.9.6 (#sec-11.9.6))
File: javascript_ecma_262_5th_ed.info, Node: 1195 The Strict Does-not-equal Operator !==, Next: 1196 The Strict Equality Comparison Algorithm, Prev: 1194 The Strict Equals Operator ===, Up: Top
208 11.9.5 (#sec-11.9.5) The Strict Does-not-equal Operator ( `!==' )
*********************************************************************
The production EqualityExpression : EqualityExpression `!=='
RelationalExpression is evaluated as follows:
1. Let lref be the result of evaluating EqualityExpression.
2. Let lval be GetValue (#sec-8.7.1)(lref).
3. Let rref be the result of evaluating RelationalExpression.
4. Let rval be GetValue (#sec-8.7.1)(rref).
5. Let r be the result of performing strict equality comparison rval
=== lval. (See 11.9.6 (#sec-11.9.6))
6. If r is true, return false. Otherwise, return true.
File: javascript_ecma_262_5th_ed.info, Node: 1196 The Strict Equality Comparison Algorithm, Next: 1110 Binary Bitwise Operators, Prev: 1195 The Strict Does-not-equal Operator !==, Up: Top
209 11.9.6 (#sec-11.9.6) The Strict Equality Comparison Algorithm
*****************************************************************
The comparison x === y, where x and y are values, produces true or
false. Such a comparison is performed as follows:
1. If Type (#def-type)(x) is different from Type (#def-type)(y),
return false.
2. If Type (#def-type)(x) is Undefined, return true.
3. If Type (#def-type)(x) is Null, return true.
4. If Type (#def-type)(x) is Number, then
1. If x is NaN, return false.
2. If y is NaN, return false.
3. If x is the same Number value as y, return true.
4. If x is +0 and y is −0, return true.
5. If x is −0 and y is +0, return true.
6. Return false.
5. If Type (#def-type)(x) is String, then return true if x and y are
exactly the same sequence of characters (same length and same
characters in corresponding positions); otherwise, return false.
6. If Type (#def-type)(x) is Boolean, return true if x and y are both
true or both false; otherwise, return false.
7. Return true if x and y refer to the same object. Otherwise, return
false.
NOTE This algorithm differs from the SameValue Algorithm (9.12)
(#sec-9.12) in its treatment of signed zeroes and NaNs.
File: javascript_ecma_262_5th_ed.info, Node: 1110 Binary Bitwise Operators, Next: 1111 Binary Logical Operators, Prev: 1196 The Strict Equality Comparison Algorithm, Up: Top
210 11.10 (#sec-11.10) Binary Bitwise Operators
***********************************************
* Menu:
* Syntax::
* Semantics::
File: javascript_ecma_262_5th_ed.info, Node: Syntax, Next: Semantics, Up: 1110 Binary Bitwise Operators
210.1 Syntax
============
BitwiseANDExpression : EqualityExpression BitwiseANDExpression `&'
EqualityExpression BitwiseANDExpressionNoIn : EqualityExpressionNoIn
BitwiseANDExpressionNoIn `&' EqualityExpressionNoIn
BitwiseXORExpression : BitwiseANDExpression BitwiseXORExpression `^'
BitwiseANDExpression BitwiseXORExpressionNoIn : BitwiseANDExpressionNoIn
BitwiseXORExpressionNoIn `^' BitwiseANDExpressionNoIn
BitwiseORExpression : BitwiseXORExpression BitwiseORExpression `|'
BitwiseXORExpression BitwiseORExpressionNoIn : BitwiseXORExpressionNoIn
BitwiseORExpressionNoIn `|' BitwiseXORExpressionNoIn
File: javascript_ecma_262_5th_ed.info, Node: Semantics, Prev: Syntax, Up: 1110 Binary Bitwise Operators
210.2 Semantics
===============
The production A : A @ B, where @ is one of the bitwise operators in
the productions above, is evaluated as follows:
1. Let lref be the result of evaluating A.
2. Let lval be GetValue (#sec-8.7.1)(lref).
3. Let rref be the result of evaluating B.
4. Let rval be GetValue (#sec-8.7.1)(rref).
5. Let lnum be ToInt32 (#sec-9.5)(lval).
6. Let rnum be ToInt32 (#sec-9.5)(rval).
7. Return the result of applying the bitwise operator @ to lnum and
rnum. The result is a signed 32 bit integer.
File: javascript_ecma_262_5th_ed.info, Node: 1111 Binary Logical Operators, Next: 1112 Conditional Operator ?, Prev: 1110 Binary Bitwise Operators, Up: Top
211 11.11 (#sec-11.11) Binary Logical Operators
***********************************************
* Menu:
* Syntax::
* Semantics::
File: javascript_ecma_262_5th_ed.info, Node: Syntax, Next: Semantics, Up: 1111 Binary Logical Operators
211.1 Syntax
============
LogicalANDExpression : BitwiseORExpression LogicalANDExpression `&&'
BitwiseORExpression LogicalANDExpressionNoIn : BitwiseORExpressionNoIn
LogicalANDExpressionNoIn `&&' BitwiseORExpressionNoIn
LogicalORExpression : LogicalANDExpression LogicalORExpression `||'
LogicalANDExpression LogicalORExpressionNoIn : LogicalANDExpressionNoIn
LogicalORExpressionNoIn `||' LogicalANDExpressionNoIn
File: javascript_ecma_262_5th_ed.info, Node: Semantics, Prev: Syntax, Up: 1111 Binary Logical Operators
211.2 Semantics
===============
The production LogicalANDExpression : LogicalANDExpression `&&'
BitwiseORExpression is evaluated as follows:
1. Let lref be the result of evaluating LogicalANDExpression.
2. Let lval be GetValue (#sec-8.7.1)(lref).
3. If ToBoolean (#sec-9.2)(lval) is false, return lval.
4. Let rref be the result of evaluating BitwiseORExpression.
5. Return GetValue (#sec-8.7.1)(rref).
The production LogicalORExpression : LogicalORExpression `||'
LogicalANDExpression is evaluated as follows:
1. Let lref be the result of evaluating LogicalORExpression.
2. Let lval be GetValue (#sec-8.7.1)(lref).
3. If ToBoolean (#sec-9.2)(lval) is true, return lval.
4. Let rref be the result of evaluating LogicalANDExpression.
5. Return GetValue (#sec-8.7.1)(rref).
The LogicalANDExpressionNoIn and LogicalORExpressionNoIn productions
are evaluated in the same manner as the LogicalANDExpression and
LogicalORExpression productions except that the contained
LogicalANDExpressionNoIn, BitwiseORExpressionNoIn and
LogicalORExpressionNoIn are evaluated instead of the contained
LogicalANDExpression, BitwiseORExpression and LogicalORExpression,
respectively.
NOTE The value produced by a `&&' or `||' operator is not
necessarily of type Boolean. The value produced will always be the
value of one of the two operand expressions.
File: javascript_ecma_262_5th_ed.info, Node: 1112 Conditional Operator ?, Next: 1113 Assignment Operators, Prev: 1111 Binary Logical Operators, Up: Top
212 11.12 (#sec-11.12) Conditional Operator ( `?' `:' )
*******************************************************
* Menu:
* Syntax::
* Semantics::
File: javascript_ecma_262_5th_ed.info, Node: Syntax, Next: Semantics, Up: 1112 Conditional Operator ?
212.1 Syntax
============
ConditionalExpression : LogicalORExpression LogicalORExpression `?'
AssignmentExpression `:' AssignmentExpression ConditionalExpressionNoIn
: LogicalORExpressionNoIn LogicalORExpressionNoIn `?'
AssignmentExpression `:' AssignmentExpressionNoIn
File: javascript_ecma_262_5th_ed.info, Node: Semantics, Prev: Syntax, Up: 1112 Conditional Operator ?
212.2 Semantics
===============
The production ConditionalExpression : LogicalORExpression `?'
AssignmentExpression `:' AssignmentExpression is evaluated as follows:
1. Let lref be the result of evaluating LogicalORExpression.
2. If ToBoolean (#sec-9.2)(GetValue (#sec-8.7.1)(lref)) is true, then
1. Let trueRef be the result of evaluating the first
AssignmentExpression.
2. Return GetValue (#sec-8.7.1)(trueRef).
3. Else
1. Let falseRef be the result of evaluating the second
AssignmentExpression.
2. Return GetValue (#sec-8.7.1)(falseRef).
NOTE The grammar for a ConditionalExpression in ECMAScript is a
little bit different from that in C and Java, which each allow the
second subexpression to be an Expression but restrict the third
expression to be a ConditionalExpression. The motivation for this
difference in ECMAScript is to allow an assignment expression to be
governed by either arm of a conditional and to eliminate the confusing
and fairly useless case of a comma expression as the centre expression.
File: javascript_ecma_262_5th_ed.info, Node: 1113 Assignment Operators, Next: 11131 Simple Assignment =, Prev: 1112 Conditional Operator ?, Up: Top
213 11.13 (#sec-11.13) Assignment Operators
*******************************************
* Menu:
* Syntax::
* Semantics::
File: javascript_ecma_262_5th_ed.info, Node: Syntax, Next: Semantics, Up: 1113 Assignment Operators
213.1 Syntax
============
AssignmentExpression : ConditionalExpression LeftHandSideExpression
AssignmentOperator AssignmentExpression AssignmentExpressionNoIn :
ConditionalExpressionNoIn LeftHandSideExpression AssignmentOperator
AssignmentExpressionNoIn AssignmentOperator : one of `= *= /= %=
+= -= <<= >>= >>>= &= ^= |='
File: javascript_ecma_262_5th_ed.info, Node: Semantics, Prev: Syntax, Up: 1113 Assignment Operators
213.2 Semantics
===============
The AssignmentExpressionNoIn productions are evaluated in the same
manner as the AssignmentExpression productions except that the
contained ConditionalExpressionNoIn and AssignmentExpressionNoIn are
evaluated instead of the contained ConditionalExpression and
AssignmentExpression, respectively.
File: javascript_ecma_262_5th_ed.info, Node: 11131 Simple Assignment =, Next: 11132 Compound Assignment <var>op</var>=, Prev: 1113 Assignment Operators, Up: Top
214 11.13.1 (#sec-11.13.1) Simple Assignment ( `=' )
****************************************************
The production AssignmentExpression : LeftHandSideExpression `='
AssignmentExpression is evaluated as follows:
1. Let lref be the result of evaluating LeftHandSideExpression.
2. Let rref be the result of evaluating AssignmentExpression.
3. Let rval be GetValue (#sec-8.7.1)(rref).
4. Throw a SyntaxError exception if the following conditions are all
true:
* Type (#def-type)(lref) is Reference (#sec-8.7) is true
* IsStrictReference (#def-IsStrictReference)(lref) is true
* Type (#def-type)(GetBase (#def-GetBase)(lref)) is Enviroment
Record
* GetReferencedName (#def-GetReferencedName)(lref) is either
"eval" or "arguments"
5. Call PutValue (#sec-8.7.2)(lref, rval).
6. Return rval.
NOTE When an assignment occurs within strict mode code
(#sec-10.1.1), its LeftHandSide must not evaluate to an unresolvable
reference (#def-IsUnresolvableReference). If it does a ReferenceError
exception is thrown upon assignment. The LeftHandSide also may not be a
reference to a data property with the attribute value
{[[Writable]]:false}, to an accessor property with the attribute value
{[[Set]]:undefined}, nor to a non-existent property of an object whose
[[Extensible]] internal property has the value false. In these cases a
TypeError exception is thrown.
File: javascript_ecma_262_5th_ed.info, Node: 11132 Compound Assignment <var>op</var>=, Next: 1114 Comma Operator, Prev: 11131 Simple Assignment =, Up: Top
215 11.13.2 (#sec-11.13.2) Compound Assignment ( `<var>op</var>=' )
*******************************************************************
The production AssignmentExpression : LeftHandSideExpression @ `='
AssignmentExpression, where @ represents one of the operators indicated
above, is evaluated as follows:
1. 2. Let lval be GetValue (#sec-8.7.1)(lref).
3. Let rref be the result of evaluating AssignmentExpression.
4. Let rval be GetValue (#sec-8.7.1)(rref).
5. Let r be the result of applying operator @ to lval and rval.
6. Throw a SyntaxError exception if the following conditions are all
true:
* Type (#def-type)(lref) is Reference (#sec-8.7) is true
* IsStrictReference (#def-IsStrictReference)(lref) is true
* Type (#def-type)(GetBase (#def-GetBase)(lref)) is Enviroment
Record
* GetReferencedName (#def-GetReferencedName)(lref) is either
"eval" or "arguments"
7. Call PutValue (#sec-8.7.2)(lref, r).
8. Return r.
NOTE See NOTE 11.13.1 (#sec-11.13.1).
File: javascript_ecma_262_5th_ed.info, Node: 1114 Comma Operator, Next: 12 Statements, Prev: 11132 Compound Assignment <var>op</var>=, Up: Top
216 11.14 (#sec-11.14) Comma Operator ( `,' )
*********************************************
* Menu: