-
Notifications
You must be signed in to change notification settings - Fork 68
/
x15.5.html
1508 lines (1499 loc) · 64.3 KB
/
x15.5.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>15.5 String Objects # Ⓣ Ⓔ ① Ⓐ — Annotated ES5</title><link rel="stylesheet" href="style.css"><link href="x15.4.html" title="15.4 Array Objects " rel="prev">
<link href="spec.html" title="TOC" rel="index">
<link href="x15.6.html" title="15.6 Boolean Objects " 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="x15.4.html">← 15.4 Array Objects </a> –
<a href="spec.html" class="toc-nav">TOC</a> –
<a href="x15.6.html">15.6 Boolean Objects →</a>
<ol class="toc"><li><ol><li><a href="x15.5.html#x15.5" id="x15.5-toc">15.5 String Objects</a>
<b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> <ol><li><a href="x15.5.html#x15.5.1" id="x15.5.1-toc">15.5.1 The String Constructor Called as a Function</a>
<b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> <ol><li><a href="x15.5.html#x15.5.1.1" id="x15.5.1.1-toc">15.5.1.1 String ( [ value ] )</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li></ol></li><li><a href="x15.5.html#x15.5.2" id="x15.5.2-toc">15.5.2 The String Constructor</a>
<b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> <ol><li><a href="x15.5.html#x15.5.2.1" id="x15.5.2.1-toc">15.5.2.1 new String ( [ value ] )</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li></ol></li><li><a href="x15.5.html#x15.5.3" id="x15.5.3-toc">15.5.3 Properties of the String Constructor</a>
<b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> <ol><li><a href="x15.5.html#x15.5.3.1" id="x15.5.3.1-toc">15.5.3.1 String.prototype</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x15.5.html#x15.5.3.2" id="x15.5.3.2-toc">15.5.3.2 String.fromCharCode ( [ char0 [ , char1 [ , … ] ] ] )</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li></ol></li><li><a href="x15.5.html#x15.5.4" id="x15.5.4-toc">15.5.4 Properties of the String Prototype Object</a>
<b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> <ol><li><a href="x15.5.html#x15.5.4.1" id="x15.5.4.1-toc">15.5.4.1 String.prototype.constructor</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x15.5.html#x15.5.4.2" id="x15.5.4.2-toc">15.5.4.2 String.prototype.toString ( )</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x15.5.html#x15.5.4.3" id="x15.5.4.3-toc">15.5.4.3 String.prototype.valueOf ( )</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x15.5.html#x15.5.4.4" id="x15.5.4.4-toc">15.5.4.4 String.prototype.charAt (pos)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x15.5.html#x15.5.4.5" id="x15.5.4.5-toc">15.5.4.5 String.prototype.charCodeAt (pos)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x15.5.html#x15.5.4.6" id="x15.5.4.6-toc">15.5.4.6 String.prototype.concat ( [ string1 [ , string2 [ , … ] ] ] )</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x15.5.html#x15.5.4.7" id="x15.5.4.7-toc">15.5.4.7 String.prototype.indexOf (searchString, position)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x15.5.html#x15.5.4.8" id="x15.5.4.8-toc">15.5.4.8 String.prototype.lastIndexOf (searchString, position)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x15.5.html#x15.5.4.9" id="x15.5.4.9-toc">15.5.4.9 String.prototype.localeCompare (that)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x15.5.html#x15.5.4.10" id="x15.5.4.10-toc">15.5.4.10 String.prototype.match (regexp)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x15.5.html#x15.5.4.11" id="x15.5.4.11-toc">15.5.4.11 String.prototype.replace (searchValue, replaceValue)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x15.5.html#x15.5.4.12" id="x15.5.4.12-toc">15.5.4.12 String.prototype.search (regexp)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x15.5.html#x15.5.4.13" id="x15.5.4.13-toc">15.5.4.13 String.prototype.slice (start, end)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x15.5.html#x15.5.4.14" id="x15.5.4.14-toc">15.5.4.14 String.prototype.split (separator, limit)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x15.5.html#x15.5.4.15" id="x15.5.4.15-toc">15.5.4.15 String.prototype.substring (start, end)</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x15.5.html#x15.5.4.16" id="x15.5.4.16-toc">15.5.4.16 String.prototype.toLowerCase ( )</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x15.5.html#x15.5.4.17" id="x15.5.4.17-toc">15.5.4.17 String.prototype.toLocaleLowerCase ( )</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x15.5.html#x15.5.4.18" id="x15.5.4.18-toc">15.5.4.18 String.prototype.toUpperCase ( )</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x15.5.html#x15.5.4.19" id="x15.5.4.19-toc">15.5.4.19 String.prototype.toLocaleUpperCase ( )</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x15.5.html#x15.5.4.20" id="x15.5.4.20-toc">15.5.4.20 String.prototype.trim ( )</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li></ol></li><li><a href="x15.5.html#x15.5.5" id="x15.5.5-toc">15.5.5 Properties of String Instances</a>
<b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> <ol><li><a href="x15.5.html#x15.5.5.1" id="x15.5.5.1-toc">15.5.5.1 length</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x15.5.html#x15.5.5.2" id="x15.5.5.2-toc">15.5.5.2 [[GetOwnProperty]] ( P )</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li></ol></li></ol></li></ol></li></ol></nav>
<h3 id="x15.5" class="splitme">15.5 String Objects <a href="#x15.5">#</a> <a href="#x15.5-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h3>
<h4 id="x15.5.1">15.5.1 The String Constructor Called as a Function <a href="#x15.5.1">#</a> <a href="#x15.5.1-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h4>
<p>
When
<code><b>String</b></code> is called
as a function rather than as a constructor, it performs a type
conversion.</p>
<h5 id="x15.5.1.1">15.5.1.1 String ( [ value ] ) <a href="#x15.5.1.1">#</a> <a href="#x15.5.1.1-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h5>
<p>
Returns
a String value (not a String object) computed by <a href="x9.html#x9.8">ToString</a>(<i>value</i>).
If <i>value</i> is not
supplied, the empty String <code><b>""</b></code>
is returned.</p>
<h4 id="x15.5.2">15.5.2 The String Constructor <a href="#x15.5.2">#</a> <a href="#x15.5.2-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h4>
<p>
When
<code><b>String</b></code> is called
as part of a <code><b>new</b></code>
expression, it is a constructor: it initialises the newly created
object.</p>
<h5 id="x15.5.2.1">15.5.2.1 new String ( [ value ] ) <a href="#x15.5.2.1">#</a> <a href="#x15.5.2.1-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h5>
<p>
The
[[Prototype]] internal
property of the newly constructed object is set to the standard
built-in String prototype object that is the initial value of
<code><b>String.prototype</b></code>
(<a href="#x15.5.3.1">15.5.3.1</a>).</p>
<p>
The
[[Class]] internal
property of the newly constructed object is set to <code><b>"String"</b></code>.</p>
<p>
The
[[Extensible]] internal
property of the newly constructed object is set to <b>true</b>.</p>
<p>
The
[[PrimitiveValue]] internal
property of the newly constructed object is set to <a href="x9.html#x9.8">ToString</a>(<i>value</i>),
or to the empty String if <i>value</i>
is not supplied.</p>
<h4 id="x15.5.3">15.5.3 Properties of the String Constructor <a href="#x15.5.3">#</a> <a href="#x15.5.3-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h4>
<p>
The
value of the [[Prototype]] internal property of the String
constructor is the standard built-in Function prototype object
(<a href="x15.3.html#x15.3.4">15.3.4</a>).</p>
<p>
Besides
the internal properties and the <code><b>length</b></code>
property (whose value is <b>1</b>), the String constructor has the
following properties:</p>
<h5 id="x15.5.3.1">15.5.3.1 String.prototype <a href="#x15.5.3.1">#</a> <a href="#x15.5.3.1-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h5>
<p>
The
initial value of <code><b>String.prototype</b></code>
is the standard built-in String prototype object (<a href="#x15.5.4">15.5.4</a>).</p>
<p>
This
property has the attributes { [[Writable]]: <b>false</b>,
[[Enumerable]]: <b>false</b>, [[Configurable]]: <b>false</b> }.</p>
<h5 id="x15.5.3.2">15.5.3.2 String.fromCharCode ( [ char0 [ , char1 [ , … ] ] ] ) <a href="#x15.5.3.2">#</a> <a href="#x15.5.3.2-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h5>
<p>
Returns
a String value containing as many characters as the number of
arguments. Each argument specifies one character of the resulting
String, with the first argument specifying the first character, and
so on, from left to right. An argument is converted to a character
by applying the operation <a href="x9.html#x9.7">ToUint16</a> (<a href="x9.html#x9.7">9.7</a>) and regarding the resulting
16-bit integer as the code unit value of a character. If no
arguments are supplied, the result is the empty String.</p>
<p>
The
<code><b>length</b></code> property of
the <code><b>fromCharCode</b></code>
function is <b>1</b>.</p>
<h4 id="x15.5.4">15.5.4 Properties of the String Prototype Object <a href="#x15.5.4">#</a> <a href="#x15.5.4-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h4>
<p>
The
String prototype object is itself a String object (its [[Class]] is
<code><b>"String"</b></code>)
whose value is an empty String.</p>
<p>
The
value of the [[Prototype]] internal property of the String prototype
object is the standard built-in Object prototype object (<a href="x15.2.html#x15.2.4">15.2.4</a>).</p>
<h5 id="x15.5.4.1">15.5.4.1 String.prototype.constructor <a href="#x15.5.4.1">#</a> <a href="#x15.5.4.1-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h5>
<p>
The
initial value of <code><b>String.prototype.constructor</b></code>
is the built-in <code><b>String</b></code>
constructor.</p>
<h5 id="x15.5.4.2">15.5.4.2 String.prototype.toString ( ) <a href="#x15.5.4.2">#</a> <a href="#x15.5.4.2-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h5>
<p>
Returns
this String value. (Note that, for a String object, the <code><b>toString</b></code>
method happens to return the same thing as the <code><b>valueOf</b></code>
method.)</p>
<p>
The
<code><b>toString</b></code> function
is not generic; it throws a <b><a href="x15.11.html#x15.11.6.5" class="term-ref">TypeError</a></b> exception if its <b>this</b>
value is not a String or a String object. Therefore, it cannot be
transferred to other kinds of objects for use as a method.</p>
<h5 id="x15.5.4.3">15.5.4.3 String.prototype.valueOf ( ) <a href="#x15.5.4.3">#</a> <a href="#x15.5.4.3-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h5>
<p>
Returns
this String value.</p>
<p>
The
<code><b>valueOf</b></code> function
is not generic; it throws a <b><a href="x15.11.html#x15.11.6.5" class="term-ref">TypeError</a></b> exception if its <b>this</b>
value is not a String or String object. Therefore, it cannot be
transferred to other kinds of objects for use as a method.</p>
<h5 id="x15.5.4.4">15.5.4.4 String.prototype.charAt (pos) <a href="#x15.5.4.4">#</a> <a href="#x15.5.4.4-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h5>
<p>
Returns
a String containing the character at position <i>pos</i>
in the String resulting from converting this object to a String. If
there is no character at that position, the result is the empty
String. The result is a String value, not a String object.</p>
<p>
If
<i>pos</i> is a value of
Number type that is an integer, then the result of <code><b>x.charAt(</b></code> <i>pos</i><code><b>)</b></code>
is equal to the result of <code><b>x.substring(</b></code> <i>pos</i><code><b>,</b></code>
<i>pos</i><code><b>+1)</b></code>.</p>
<p>
When
the <code><b>charAt</b></code> method
is called with one argument <i>pos</i>,
the following steps are taken:</p>
<ol><li><p>
Call
<a href="x9.html#x9.10">CheckObjectCoercible</a> passing the <b>this</b> value as its argument.</p>
</li>
<li><p>
Let
<i>S</i> be the result of calling <a href="x9.html#x9.8">ToString</a>, giving it the <b>this</b>
value as its argument.</p>
</li>
<li><p>
Let
<i>position</i> be <a href="x9.html#x9.4">ToInteger</a>(<i>pos</i>).</p>
</li>
<li><p>
Let
<i>size</i> be the number of characters in <i>S</i>.</p>
</li>
<li><p>
If
<i>position</i> < 0 or <i>position</i> ≥ <i>size</i>, return
the empty String.</p>
</li>
<li><p>
Return
a String of length 1, containing one character from <i>S</i>,
namely the character at position <i>position</i>, where the first
(leftmost) character in <i>S</i> is considered to be at position 0,
the next one at position 1, and so on.</p>
</li></ol><p><b class="note">NOTE</b> The
<code><b>charAt</b></code> function is
intentionally generic; it does not require that its <b>this</b>
value be a String object. Therefore, it can be transferred to other
kinds of objects for use as a method.</p>
<h5 id="x15.5.4.5">15.5.4.5 String.prototype.charCodeAt (pos) <a href="#x15.5.4.5">#</a> <a href="#x15.5.4.5-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h5>
<p>
Returns
a Number (a nonnegative integer less than 2<sup>16</sup>)
representing the code unit value of the character at position <i>pos</i>
in the String resulting from converting this object to a String. If
there is no character at that position, the result is <b>NaN</b>.</p>
<p>
When
the <code><b>charCodeAt</b></code>
method is called with one argument <i>pos</i>,
the following steps are taken:</p>
<ol><li><p>
Call
<a href="x9.html#x9.10">CheckObjectCoercible</a> passing the <b>this</b> value as its argument.</p>
</li>
<li><p>
Let
<i>S</i> be the result of calling <a href="x9.html#x9.8">ToString</a>, giving it the <b>this</b>
value as its argument.</p>
</li>
<li><p>
Let
<i>position</i> be <a href="x9.html#x9.4">ToInteger</a>(<i>pos</i>).</p>
</li>
<li><p>
Let
<i>size</i> be the number of characters in <i>S</i>.</p>
</li>
<li><p>
If
<i>position</i> < 0 or <i>position</i> ≥ <i>size</i>, return
<b>NaN</b>.</p>
</li>
<li><p>
Return
a value of Number type, whose value is the code unit value of the
character at position <i>position</i> in the String <i>S</i>, where
the first (leftmost) character in <i>S</i> is considered to be at
position 0, the next one at position 1, and so on.</p>
</li></ol><p><b class="note">NOTE</b> The
<code><b>charCodeAt</b></code>
function is intentionally generic; it does not require that its <b>this</b>
value be a String object. Therefore it can be transferred to other
kinds of objects for use as a method.</p>
<h5 id="x15.5.4.6">15.5.4.6 String.prototype.concat ( [ string1 [ , string2 [ , … ] ] ] ) <a href="#x15.5.4.6">#</a> <a href="#x15.5.4.6-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h5>
<p>
When
the <code><b>concat</b></code> method
is called with zero or more arguments <i>string1</i>,
<i>string2</i>, etc., it
returns a String consisting of the characters of this object
(converted to a String) followed by the characters of each of
<i>string1</i>, <i>string2</i>,
etc. (where each argument is converted to a String). The result is a
String value, not a String object. The following steps are taken:</p>
<ol><li><p>
Call
<a href="x9.html#x9.10">CheckObjectCoercible</a> passing the <b>this</b> value as its argument.</p>
</li>
<li><p>
Let
<i>S</i> be the result of calling <a href="x9.html#x9.8">ToString</a>, giving it the <b>this</b>
value as its argument.</p>
</li>
<li><p>
Let
<i>args</i> be an internal list that is a copy of the argument list
passed to this function.</p>
</li>
<li><p>
Let
<i>R</i> be <i>S</i>.</p>
</li>
<li><p>
Repeat,
while <i>args</i> is not empty</p>
<ol><li><p>
Remove
the first element from <i>args</i> and let <i>next</i> be the
value of that element.</p>
</li>
<li><p>
Let
<i>R</i> be the String value consisting of the characters in the
previous value of <i>R</i> followed by the characters of
<a href="x9.html#x9.8">ToString</a>(<i>next</i>).</p>
</li></ol></li>
<li><p>
Return
<i>R</i>.</p>
</li></ol><p>
The
<code><b>length</b></code> property of
the <code><b>concat</b></code> method
is <b>1</b>.</p>
<p><b class="note">NOTE</b> The
<code><b>concat</b></code> function is
intentionally generic; it does not require that its <b>this</b>
value be a String object. Therefore it can be transferred to other
kinds of objects for use as a method.</p>
<h5 id="x15.5.4.7">15.5.4.7 String.prototype.indexOf (searchString, position) <a href="#x15.5.4.7">#</a> <a href="#x15.5.4.7-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h5>
<p>
If
<i>searchString</i>
appears as a substring of the result of converting this object to a
String, at one or more positions that are greater than or equal to
<i>position</i>, then the
index of the smallest such position is returned; otherwise, <code><b>-1</b></code>
is returned. If <i>position</i>
is <b>undefined</b>, 0 is assumed, so as to search all of the
String.</p>
<p>
The
<code><b>indexOf</b></code> method
takes two arguments, <i>searchString </i>and<i> position</i>,
and performs the following steps:</p>
<ol><li><p>
Call
<a href="x9.html#x9.10">CheckObjectCoercible</a> passing the <b>this</b> value as its argument.</p>
</li>
<li><p>
Let
<i>S</i> be the result of calling <a href="x9.html#x9.8">ToString</a>, giving it the <b>this</b>
value as its argument.</p>
</li>
<li><p>
Let
<i>searchStr</i> be <a href="x9.html#x9.8">ToString</a>(<i>searchString</i>).</p>
</li>
<li><p>
Let
<i>pos</i> be <a href="x9.html#x9.4">ToInteger</a>(<i>position</i>). (If <i>position</i> is
<b>undefined</b>, this step produces the value <code><b>0</b></code>).</p>
</li>
<li><p>
Let
<i>len</i> be the number of characters in <i>S</i>.</p>
</li>
<li><p>
Let
<i>start</i> be min(max(<i>pos</i>, 0), <i>len</i>).</p>
</li>
<li><p>
Let
<i>searchLen</i> be the number of characters in <i>searchStr</i>.</p>
</li>
<li><p>
Return
the smallest possible integer <i>k</i> not smaller than <i>start</i>
such that <i>k</i>+<i> searchLen</i> is not greater than <i>len</i>,
and for all nonnegative integers <i>j</i> less than <i>searchLen</i>,
the character at position <i>k</i>+<i>j</i> of <i>S</i> is the same
as the character at position <i>j</i> of <i>searchStr</i>); but if
there is no such integer <i>k</i>, then return the value <code><b>-1</b></code>.</p>
</li></ol><p>
The
<code><b>length</b></code> property of
the <code><b>indexOf</b></code> method
is <b>1</b>.</p>
<p><b class="note">NOTE</b> The
<code><b>indexOf</b></code> function
is intentionally generic; it does not require that its <b>this</b>
value be a String object. Therefore, it can be transferred to other
kinds of objects for use as a method.</p>
<h5 id="x15.5.4.8">15.5.4.8 String.prototype.lastIndexOf (searchString, position) <a href="#x15.5.4.8">#</a> <a href="#x15.5.4.8-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h5>
<p>
If
<i>searchString</i>
appears as a substring of the result of converting this object to a
String at one or more positions that are smaller than or equal to
<i>position</i>, then the
index of the greatest such position is returned; otherwise, <code><b>-1</b></code>
is returned. If <i>position</i>
is <b>undefined</b>, the length of the String value is assumed, so
as to search all of the String.</p>
<p>
The
<code><b>lastIndexOf</b></code> method
takes two arguments, <i>searchString </i>and<i> position</i>,
and performs the following steps:</p>
<ol><li><p>
Call
<a href="x9.html#x9.10">CheckObjectCoercible</a> passing the <b>this</b> value as its argument.</p>
</li>
<li><p>
Let
<i>S</i> be the result of calling <a href="x9.html#x9.8">ToString</a>, giving it the <b>this</b>
value as its argument.</p>
</li>
<li><p>
Let
<i>searchStr</i> be <a href="x9.html#x9.8">ToString</a>(<i>searchString</i>).</p>
</li>
<li><p>
Let
<i>numPos</i> be <a href="x9.html#x9.3">ToNumber</a>(<i>position</i>). (If <i>position</i> is
<b>undefined</b>, this step produces the value <b>NaN</b>).</p>
</li>
<li><p>
If
<i>numPos</i> is <b>NaN</b>, let <i>pos</i> be <b>+</b><span class="symbol"><b>∞</b></span>;
otherwise, let <i>pos</i> be <a href="x9.html#x9.4">ToInteger</a>(<i>numPos</i>).</p>
</li>
<li><p>
Let
<i>len</i> be the number of characters in <i>S</i>.</p>
</li>
<li><p>
Let
<i>start</i> min(max(<i>pos</i>, 0), <i>len</i>).</p>
</li>
<li><p>
Let
<i>searchLen</i> be the number of characters in <i>searchStr</i>.</p>
</li>
<li><p>
Return
the largest possible nonnegative integer <i>k</i> not larger than
<i>start</i> such that <i>k</i>+<i> searchLen</i> is not greater
than <i>len</i>, and for all nonnegative integers <i>j</i> less
than <i>searchLen</i>, the character at position <i>k</i>+<i>j</i>
of <i>S</i> is the same as the character at position <i>j</i> of
<i>searchStr</i>; but if there is no such integer <i>k</i>, then
return the value <code><b>-1</b></code>.</p>
</li></ol><p>
The
<code><b>length</b></code> property of
the <code><b>lastIndexOf</b></code>
method is <b>1</b>.</p>
<p><b class="note">NOTE</b> The
<code><b>lastIndexOf</b></code>
function is intentionally generic; it does not require that its <b>this</b>
value be a String object. Therefore, it can be transferred to other
kinds of objects for use as a method.</p>
<h5 id="x15.5.4.9">15.5.4.9 String.prototype.localeCompare (that) <a href="#x15.5.4.9">#</a> <a href="#x15.5.4.9-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h5>
<p>
When
the <code><b>localeCompare</b></code>
method is called with one argument <i>that</i>,
it returns a Number other than <b>NaN</b> that represents the result
of a locale-sensitive String comparison of the this value (converted
to a String) with <i>that</i>
(converted to a String). The two Strings are <i>S</i>
and <i>That</i>. The two
Strings are compared in an implementation-defined fashion. The
result is intended to order String values in the sort order
specified by the system default locale, and will be negative, zero,
or positive, depending on whether <i>S</i>
comes before <i>That</i>
in the sort order, the Strings are equal, or <i>S</i>
comes after <i>That</i>
in the sort order, respectively.</p>
<p>
Before
perform the comparisons the following steps are performed to prepare
the Strings:</p>
<ol><li><p>
Call
<a href="x9.html#x9.10">CheckObjectCoercible</a> passing the <b>this</b> value as its argument.</p>
</li>
<li><p>
Let
<i>S</i> be the result of calling <a href="x9.html#x9.8">ToString</a>, giving it the <b>this</b>
value as its argument.</p>
</li>
<li><p>
Let
<i>That</i> be <a href="x9.html#x9.8">ToString</a>(<i>that</i>).</p>
</li></ol><p>
The
<code><b>localeCompare</b></code>
method, if considered as a function of two arguments <b>this</b> and
<i>that</i>, is a
consistent comparison function (as defined in <a href="x15.4.html#x15.4.4.11">15.4.4.11</a>) on the set
of all Strings.</p>
<p>
The
actual return values are implementation-defined to permit
implementers to encode additional information in the value, but the
function is required to define a total ordering on all Strings and
to return <code><b>0</b></code> when
comparing Strings that are considered canonically equivalent by the
Unicode standard.</p>
<p>
If no
language-sensitive comparison at all is available from the host
environment, this function may perform a bitwise comparison.</p>
<p class="sp"><b class="note">NOTE 1</b> The <code><b>localeCompare</b></code>
method itself is not directly suitable as an argument to
<code><b><a href="x15.4.html#x15.4.4.11">Array.prototype.sort</a></b></code>
because the latter requires a function of two arguments.</p>
<p class="sp"><b class="note">NOTE 2</b> This function is intended to rely on whatever language-sensitive
comparison functionality is available to the ECMAScript environment
from the host environment, and to compare according to the rules of
the host environment’s current locale. It is strongly recommended
that this function treat Strings that are canonically equivalent
according to the Unicode standard as identical (in other words,
compare the Strings as if they had both been converted to Normalised
Form C or D first). It is also recommended that this function not
honour Unicode compatibility equivalences or decompositions.</p>
<p class="sp"><b class="note">NOTE 3</b> The second parameter to this function is likely to be used in a
future version of this standard; it is recommended that
implementations do not use this parameter position for anything
else.</p>
<p class="sp"><b class="note">NOTE 4</b> The <code><b>localeCompare</b></code>
function is intentionally generic; it does not require that its <b>this</b>
value be a String object. Therefore, it can be transferred to other
kinds of objects for use as a method.</p>
<h5 id="x15.5.4.10">15.5.4.10 String.prototype.match (regexp) <a href="#x15.5.4.10">#</a> <a href="#x15.5.4.10-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h5>
<p>
When
the <code><b>match</b></code> method
is called with argument <i>regexp</i>,
the following steps are taken:</p>
<ol><li value="1"><p>
Call
<a href="x9.html#x9.10">CheckObjectCoercible</a> passing the <b>this</b> value as its argument.</p>
</li>
<li><p>
Let
<i>S</i> be the result of calling <a href="x9.html#x9.8">ToString</a>, giving it the <b>this</b>
value as its argument.</p>
</li>
<li><p>
If
<a href="x8.html#Type">Type</a>(<i>regexp</i>) is Object and the value of the [[Class]]
internal property of <i>regexp</i> is <code><b>"RegExp"</b></code>,
then let <i>rx</i> be <i>regexp</i>;</p>
</li>
<li><p>
Else,
let <i>rx</i> be a new RegExp object created as if by the
expression <code><b>new
RegExp(</b></code> <i>regexp</i><code><b>)</b></code>
where <code><b>RegExp</b></code> is
the standard built-in constructor with that name.</p>
</li>
<li><p>
Let
<i>global</i> be the result of calling the [[Get]] internal method
of <i>rx</i> with argument <code><b>"global"</b></code>.</p>
</li>
<li><p>
Let
<i>exec</i> be the standard built-in function <code><b><a href="x15.10.html#x15.10.6.2">RegExp.prototype.exec</a></b></code>
(see <a href="x15.10.html#x15.10.6.2">15.10.6.2</a>)</p>
</li>
<li><p>
If
<i>global</i> is not <b>true</b>, then</p>
<ol><li><p>
Return
the result of calling the [[Call]] internal method of <i>exec</i>
with <i>rx</i> as the <b>this</b> value and argument list
containing <i>S</i>.</p>
</li></ol></li></ol><ol start="8"><li><p>
Else,
<i>global</i> is <b>true</b></p>
<ol><li><p>
Call
the [[Put]] internal method of <i>rx</i> with arguments
<code><b>"lastIndex"</b></code>
and 0.</p>
</li>
<li><p>
Let
<i>A</i> be a new array created as if by the expression <code><b>new
Array()</b></code> where <code><b>Array</b></code>
is the standard built-in constructor with that name.</p>
</li>
<li><p>
Let
<i>previousLastIndex</i> be 0.</p>
</li>
<li><p>
Let
<i>n</i> be 0.</p>
</li>
<li><p>
Let
<i>lastMatch</i> be <b>true</b>.</p>
</li>
<li><p>
Repeat,
while <i>lastMatch</i> is <b>true</b></p>
<ol><li><p>
Let
<i>result</i> be the result of calling the [[Call]] internal
method of <i>exec</i> with <i>rx</i> as the <b>this</b> value and
argument list containing <i>S</i>.</p>
</li>
<li><p>
If
<i>result</i> is <b>null</b>, then set <i>lastMatch</i> to <b>false</b>.</p>
</li>
<li><p>
Else,
<i>result</i> is not <b>null</b></p>
<ol><li><p>
Let
<i>thisIndex</i> be the result of calling the [[Get]] internal
method of <i>rx</i> with argument <code><b>"lastIndex"</b></code>.</p>
</li>
<li><p>
If
<i>thisIndex</i> = <i>previousLastIndex</i> then</p>
<ol><li><p>
Call
the [[Put]] internal method of <i>rx</i> with arguments
<code><b>"lastIndex"</b></code>
and <i>thisIndex</i>+1.</p>
</li>
<li><p>
Set
<i>previousLastIndex</i> to <i>thisIndex</i>+1.</p>
</li></ol></li>
<li><p>
Else,
set <i>previousLastIndex</i> to <i>thisIndex</i>.</p>
</li>
<li><p>
Let
<i>matchStr</i> be the result of calling the [[Get]] internal
method of <i>result</i> with argument <code><b>"0"</b></code>.</p>
</li>
<li><p>
Call
the [[DefineOwnProperty]] internal method of <i>A</i> with
arguments <a href="x9.html#x9.8">ToString</a>(<i>n</i>), the <a href="x8.html#x8.10">Property Descriptor</a>
{[[Value]]: <i>matchStr</i>, [[Writable]]: <b>true</b>,
[[Enumerable]]: <b>true</b>, [[configurable]]: <b>true</b>}, and
<b>false</b>.</p>
</li>
<li><p>
Increment
<i>n</i>.</p>
</li></ol></li></ol></li>
<li><p>
If
<i>n</i> = 0, then return <b>null</b>.</p>
</li>
<li><p>
Return
<i>A</i>.</p>
</li></ol></li></ol><p><b class="note">NOTE</b> The
<code><b>match</b></code> function is
intentionally generic; it does not require that its <b>this</b>
value be a String object. Therefore, it can be transferred to other
kinds of objects for use as a method.</p>
<h5 id="x15.5.4.11">15.5.4.11 String.prototype.replace (searchValue, replaceValue) <a href="#x15.5.4.11">#</a> <a href="#x15.5.4.11-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h5>
<p>
First
set <i>string</i> according to the following steps:</p>
<ol><li><p>
Call
<a href="x9.html#x9.10">CheckObjectCoercible</a> passing the <b>this</b> value as its argument.</p>
</li>
<li><p>
Let
<i>string</i> be the result of calling <a href="x9.html#x9.8">ToString</a>, giving it the <b>this</b>
value as its argument.</p>
</li></ol><p>
If
<i>searchValue</i> is a
regular expression (an object whose [[Class]] internal property is
<code><b>"RegExp"</b></code>),
do the following: If <i>searchValue</i>.global
is <b>false</b>, then search <i>string</i>
for the first match of the regular expression <i>searchValue</i>.
If <i>searchValue</i>.global
is <b>true</b>, then search <i>string</i>
for all matches of the regular expression <i>searchValue</i>.
Do the search in the same manner as in <code><b><a href="#x15.5.4.10">String.prototype.match</a></b></code>,
including the update of <i>searchValue</i>.<code><b>lastIndex</b></code>.
Let <i>m</i> be the
number of left capturing parentheses in <i>searchValue</i>
(using <i>NcapturingParens</i>
as specified in <a href="x15.10.html#x15.10.2.1">15.10.2.1</a>).</p>
<p>
If
<i>searchValue</i> is not
a regular expression, let <i>searchString</i>
be <a href="x9.html#x9.8">ToString</a>(<i>searchValue</i>)
and search <i>string</i>
for the first occurrence of <i>searchString</i>.
Let <i>m</i> be 0.</p>
<p>
If
<i>replaceValue</i> is a
function, then for each matched substring, call the function with
the following <i>m</i> +
3 arguments. Argument 1 is the substring that matched. If
<i>searchValue</i> is a
regular expression, the next <i>m</i>
arguments are all of the <a href="x15.10.html#captures">captures</a> in the <a href="x15.10.html#MatchResult">MatchResult</a> (see
<a href="x15.10.html#x15.10.2.1">15.10.2.1</a>). Argument <i>m</i>
+ 2 is the offset within <i>string</i>
where the match occurred, and argument <i>m</i>
+ 3 is <i>string</i>. The
result is a String value derived from the original input by
replacing each matched substring with the corresponding return value
of the function call, converted to a String if need be.</p>
<p>
Otherwise,
let <i>newstring</i>
denote the result of converting <i>replaceValue</i>
to a String. The result is a String value derived from the original
input String by replacing each matched substring with a String
derived from <i>newstring</i>
by replacing characters in <i>newstring</i>
by replacement text as specified in Table 22. These <code><b>$</b></code>
replacements are done left-to-right, and, once such a replacement is
performed, the new replacement text is not subject to further
replacements. For example, <code><b>"$1,$2".replace(/(\$(\d))/g,
"$$1-$1$2")</b></code> returns <code><b>"$1-$11,$1-$22"</b></code>.
A <code><b>$</b></code> in <i>newstring</i>
that does not match any of the forms below is left as is.</p>
<center>
<table width="708" border="1" bordercolor="#000000" cellpadding="0" cellspacing="0" rules="ROWS"><caption>Table 22 — Replacement Text Symbol Substitutions</caption>
<colgroup><col width="132"><col width="574"></colgroup><tbody><tr valign="TOP"><td width="132" bgcolor="#c0c0c0">
<p class="sm-btm">
<span class="table-header">Characters</span></p>
</td>
<td width="574" bgcolor="#c0c0c0">
<p class="sm-btm">
<span class="table-header">Replacement
text</span></p>
</td>
</tr><tr valign="TOP"><td width="132">
<p>
<code><b>$$</b></code></p>
</td>
<td width="574">
<p>
<code><b>$</b></code></p>
</td>
</tr><tr valign="TOP"><td width="132">
<p>
<code><b>$&</b></code></p>
</td>
<td width="574">
<p>
The
matched substring.</p>
</td>
</tr><tr valign="TOP"><td width="132">
<p>
<code><b>$‘</b></code></p>
</td>
<td width="574">
<p>
The
portion of <i>string</i>
that precedes the matched substring.</p>
</td>
</tr><tr valign="TOP"><td width="132">
<p>
<code><b>$’</b></code></p>
</td>
<td width="574">
<p>
The
portion of <i>string</i>
that follows the matched substring.</p>
</td>
</tr><tr valign="TOP"><td width="132">
<p>
<code><b>$n</b></code></p>
</td>
<td width="574">
<p>
The
<i>n</i><sup>th</sup>
capture, where <i>n</i>
is a single digit in the range 1
to 9 and <code><b>$</b></code> <i>n</i>
is not followed by a decimal digit. If <i>n</i><span class="symbol">≤</span><i>m</i>
and the <i>n</i>th
capture is <b>undefined</b>, use the empty String instead. If
<i>n</i>><i>m</i>,
the result is implementation-defined.</p>
</td>
</tr><tr valign="TOP"><td width="132">
<p>
<code><b>$nn</b></code></p>
</td>
<td width="574">
<p>
The
<i>nn</i><sup>th</sup>
capture, where <i>nn</i>
is a two-digit decimal number in the range 01
to 99. If <i>nn</i><span class="symbol">≤</span><i>m</i>
and the <i>nn</i><sup>th</sup>
capture is <b>undefined</b>, use the empty String instead. If
<i>nn</i>><i>m</i>,
the result is implementation-defined.</p>
</td>
</tr></tbody></table></center>
<p><b class="note">NOTE</b> The
<code><b>replace</b></code> function
is intentionally generic; it does not require that its <b>this</b>
value be a String object. Therefore, it can be transferred to other
kinds of objects for use as a method.</p>
<h5 id="x15.5.4.12">15.5.4.12 String.prototype.search (regexp) <a href="#x15.5.4.12">#</a> <a href="#x15.5.4.12-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h5>
<p>
When
the search method is called with argument <i>regexp</i>,
the following steps are taken:</p>
<ol><li><p>
Call
<a href="x9.html#x9.10">CheckObjectCoercible</a> passing the <b>this</b> value as its argument.</p>
</li>
<li><p>
Let
<i>string</i> be the result of calling <a href="x9.html#x9.8">ToString</a>, giving it the <b>this</b>
value as its argument.</p>
</li>
<li><p>
If
<a href="x8.html#Type">Type</a>(<i>regexp</i>) is Object and the value of the [[Class]]
internal property of <i>regexp</i> is <code><b>"RegExp"</b></code>,
then let <i>rx</i> be <i>regexp</i>;</p>
</li>
<li><p>
Else,
let <i>rx</i> be a new RegExp object created as if by the
expression <code><b>new
RegExp(</b></code> <i>regexp</i><code><b>)</b></code>
where <code><b>RegExp</b></code> is
the standard built-in constructor with that name.</p>
</li>
<li><p>
Search
the value <i>string</i> from its beginning for an occurrence of the
regular expression pattern <i>rx</i>. Let <i>result</i> be a Number
indicating the offset within <i>string</i> where the pattern
matched, or –1 if there was no match. The<i> </i><code><b>lastIndex</b></code>
and <code><b>global</b></code>
properties of regexp are ignored when performing the search. The
<code><b>lastIndex</b></code>
property of regexp is left unchanged.</p>
</li>
<li><p>
Return
<i>result</i>.</p>
</li></ol><p><b class="note">NOTE</b> The
<code><b>search</b></code> function is
intentionally generic; it does not require that its <b>this</b>
value be a String object. Therefore, it can be transferred to other
kinds of objects for use as a method.</p>
<h5 id="x15.5.4.13">15.5.4.13 String.prototype.slice (start, end) <a href="#x15.5.4.13">#</a> <a href="#x15.5.4.13-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h5>
<p>
The
<code><b>slice</b></code> method takes
two arguments, <i>start</i>
and <i>end</i>, and
returns a substring of the result of converting this object to a
String, starting from character position <i>start</i>
and running to, but not including, character position <i>end</i>
(or through the end of the String if <i>end</i>
is <b>undefined</b>). If <i>start</i>
is negative, it is treated as <i>sourceLength</i>+<i>start </i>where <i>sourceLength</i>
is the length of the String. If <i>end</i>
is negative, it is treated as <i>sourceLength</i>+<i>end</i>
where <i>sourceLength</i>
is the length of the String. The result is a String value, not a
String object. The following steps are taken:</p>
<ol><li><p>
Call
<a href="x9.html#x9.10">CheckObjectCoercible</a> passing the <b>this</b> value as its argument.</p>
</li>
<li><p>
Let
<i>S</i> be the result of calling <a href="x9.html#x9.8">ToString</a>, giving it the <b>this</b>
value as its argument.</p>
</li>
<li><p>
Let
<i>len</i> be the number of characters in <i>S</i>.</p>
</li>
<li><p>
Let
<i>intStart</i> be <a href="x9.html#x9.4">ToInteger</a>(<i>start</i>).</p>
</li>
<li><p>
If
<i>end</i> is <b>undefined</b>, let <i>intEnd</i> be <i>len</i>;
else let <i>intEnd</i> be <a href="x9.html#x9.4">ToInteger</a>(<i>end</i>).</p>
</li>
<li><p>
If
<i> intStart </i>is negative, let <i>from</i> be max(<i>len</i> + <i>intStart</i>,0); else let <i>from</i> be min(<i>intStart</i>,<i>len</i>).</p>
</li>
<li><p>
If
<i>intEnd</i> is negative, let <i>to</i> be max(<i>len</i> +<i>intEnd</i>,0); else let <i>to</i> be min(<i>intEnd</i>,<i> len</i>).</p>
</li>
<li><p>
Let
<i>span</i> be max(<i>to</i> –<i> from</i>,0).</p>
</li>
<li><p>
Return
a String containing <i>span</i> consecutive characters from <i>S</i>
beginning with the character at position <i>from</i>.</p>
</li></ol><p>
The
<code><b>length</b></code> property of
the <code><b>slice</b></code> method
is <b>2</b>.</p>
<p><b class="note">NOTE</b> The
<code><b>slice</b></code> function is
intentionally generic; it does not require that its <b>this</b>
value be a String object. Therefore it can be transferred to other
kinds of objects for use as a method.</p>
<h5 id="x15.5.4.14">15.5.4.14 String.prototype.split (separator, limit) <a href="#x15.5.4.14">#</a> <a href="#x15.5.4.14-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h5>
<p>
Returns
an Array object into which substrings of the result of converting
this object to a String have been stored. The substrings are
determined by searching from left to right for occurrences of
<i>separator</i>; these
occurrences are not part of any substring in the returned array, but
serve to divide up the String value. The value of <i>separator</i>
may be a String of any length or it may be a RegExp object (i.e., an
object whose [[Class]] internal property is <code><b>"RegExp"</b></code>;
see <a href="x15.10.html#x15.10">15.10</a>).</p>
<p>
The
value of <i>separator</i>
may be an empty String, an empty regular expression, or a regular
expression that can match an empty String. In this case, <i>separator</i>
does not match the empty substring at the beginning or end of the
input String, nor does it match the empty substring at the end of
the previous separator match. (For example, if <i>separator</i>
is the empty String, the String is split up into individual
characters; the length of the result array equals the length of the
String, and each substring contains one character.) If <i>separator</i>
is a regular expression, only the first match at a given position of
the <b>this</b> String is considered, even if backtracking could
yield a non-empty-substring match at that position. (For example,
<code><b>"ab".split(/a*?/)</b></code>
evaluates to the array <code><b>["a","b"]</b></code>,
while <code><b>"ab".split(/a*/)</b></code>
evaluates to the array<code><b>["","b"]</b></code>.)</p>
<p>
If
the <b>this</b> object is (or converts to) the empty String, the
result depends on whether <i>separator</i>
can match the empty String. If it can, the result array contains no
<a href="x15.4.html#array-element">elements</a>. Otherwise, the result array contains one element, which is
the empty String.</p>
<p>If
<i>separator</i> is a
regular expression that contains capturing parentheses, then each
time <i>separator</i> is
matched the results (including any <b>undefined</b> results) of the
capturing parentheses are spliced into the output array.
For example,</p>
<p class="code-example">
<code><b>"A<B>bold</B>and<CODE>coded</CODE>".split(/<(\/)?([^<>]+)>/)</b></code></p>
<p>evaluates
to the array</p>
<p class="code-example">
<code><b>["A",
undefined, "B", "bold", "/", "B",
"and", undefined,<br> "CODE", "coded",
"/", "CODE", ""]</b></code></p>
<p>
If
<i>separator</i> is
<b>undefined</b>, then the result array contains just one String,
which is the <b>this</b> value (converted to a String). If <i>limit</i>
is not <b>undefined</b>, then the output array is truncated so that
it contains no more than <i>limit</i>
<a href="x15.4.html#array-element">elements</a>.</p>
<p>
When
the <code><b>split</b></code> method
is called, the following steps are taken:</p>
<ol><li><p>
Call
<a href="x9.html#x9.10">CheckObjectCoercible</a> passing the <b>this</b> value as its argument.</p>
</li>
<li><p>
Let
<i>S</i> be the result of calling <a href="x9.html#x9.8">ToString</a>, giving it the <b>this</b>
value as its argument.</p>
</li>
<li><p>
Let
<i>A</i> be a new array created as if by the expression <code><b>new
Array()</b></code>where <code><b>Array</b></code>
is the standard built-in constructor with that name.</p>
</li>
<li><p>
Let
<i>lengthA</i> be 0.</p>
</li>
<li><p>
If
<i>limit</i> is <b>undefined</b>, let <i>lim</i> = 2<sup>32</sup>–1;
else let <i>lim</i> = <a href="x9.html#x9.6">ToUint32</a>(<i>limit</i>).</p>
</li>
<li><p>
Let
<i>s</i> be the number of characters in <i>S</i>.</p>
</li>