@@ -411,6 +411,12 @@ Array.from = $A;
411
411
* or `-1` if `item` doesn't exist in the array. `Array#indexOf` compares
412
412
* items using *strict equality* (`===`).
413
413
*
414
+ * `Array#indexOf` acts as an ECMAScript 5 [polyfill](http://remysharp.com/2010/10/08/what-is-a-polyfill/).
415
+ * It is only defined if not already present in the user's browser, and it
416
+ * is meant to behave like the native version as much as possible. Consult
417
+ * the [ES5 specification](http://es5.github.com/#x15.4.4.14) for more
418
+ * information.
419
+ *
414
420
* ##### Examples
415
421
*
416
422
* [3, 5, 6, 1, 20].indexOf(1)
@@ -460,6 +466,12 @@ Array.from = $A;
460
466
*
461
467
* Returns the position of the last occurrence of `item` within the
462
468
* array — or `-1` if `item` doesn't exist in the array.
469
+ *
470
+ * `Array#lastIndexOf` acts as an ECMAScript 5 [polyfill](http://remysharp.com/2010/10/08/what-is-a-polyfill/).
471
+ * It is only defined if not already present in the user's browser, and it
472
+ * is meant to behave like the native version as much as possible. Consult
473
+ * the [ES5 specification](http://es5.github.com/#x15.4.4.15) for more
474
+ * information.
463
475
**/
464
476
function lastIndexOf ( item , i ) {
465
477
if ( this == null ) throw new TypeError ( ) ;
@@ -529,6 +541,7 @@ Array.from = $A;
529
541
// methods with our own behavior. This has very little performance impact.
530
542
// It violates the spec by suppressing `TypeError`s for certain methods,
531
543
// but that's an acceptable trade-off.
544
+
532
545
function wrapNative ( method ) {
533
546
return function ( ) {
534
547
if ( arguments . length === 0 ) {
@@ -554,6 +567,24 @@ Array.from = $A;
554
567
//
555
568
// This means that they behave a little differently from other methods in
556
569
// `Enumerable`/`Array` that don't collide with ES5, but that's OK.
570
+
571
+ /**
572
+ * Array#map([iterator = Prototype.K[, context]]) -> Array
573
+ * - iterator (Function): The iterator function to apply to each element
574
+ * in the enumeration.
575
+ * - context (Object): An optional object to use as `this` within
576
+ * calls to the iterator.
577
+ *
578
+ * Returns the result of applying `iterator` to each item in the array. If
579
+ * no iterator is provided, the elements are simply copied to the returned
580
+ * array.
581
+ *
582
+ * `Array#map` acts as an ECMAScript 5 [polyfill](http://remysharp.com/2010/10/08/what-is-a-polyfill/).
583
+ * It is only defined if not already present in the user's browser, and it
584
+ * is meant to behave like the native version as much as possible. Consult
585
+ * the [ES5 specification](http://es5.github.com/#x15.4.4.19) for more
586
+ * information.
587
+ **/
557
588
function map ( iterator ) {
558
589
if ( this == null ) throw new TypeError ( ) ;
559
590
iterator = iterator || Prototype . K ;
@@ -575,6 +606,22 @@ Array.from = $A;
575
606
map = wrapNative ( Array . prototype . map ) ;
576
607
}
577
608
609
+ /**
610
+ * Array#filter(iterator[, context]) -> Array
611
+ * - iterator (Function): An iterator function to use to test the
612
+ * elements.
613
+ * - context (Object): An optional object to use as `this` within
614
+ * calls to the iterator.
615
+ *
616
+ * Returns a new array containing all the items in this array for which
617
+ * `iterator` returned a truthy value.
618
+ *
619
+ * `Array#filter` acts as an ECMAScript 5 [polyfill](http://remysharp.com/2010/10/08/what-is-a-polyfill/).
620
+ * It is only defined if not already present in the user's browser, and it
621
+ * is meant to behave like the native version as much as possible. Consult
622
+ * the [ES5 specification](http://es5.github.com/#x15.4.4.20) for more
623
+ * information.
624
+ **/
578
625
function filter ( iterator ) {
579
626
if ( this == null || ! Object . isFunction ( iterator ) )
580
627
throw new TypeError ( ) ;
@@ -599,6 +646,24 @@ Array.from = $A;
599
646
filter = Array . prototype . filter ;
600
647
}
601
648
649
+ /**
650
+ * Array#some([iterator = Prototype.K[, context]]) -> Array
651
+ * - iterator (Function): An optional function to use to evaluate each
652
+ * element in the enumeration; the function should return the value to
653
+ * test. If this is not provided, the element itself is tested.
654
+ * - context (Object): An optional object to use as `this` within
655
+ * calls to the iterator.
656
+ *
657
+ * Returns the result of applying `iterator` to each item in the array. If
658
+ * no iterator is provided, the elements are simply copied to the returned
659
+ * array.
660
+ *
661
+ * `Array#some` acts as an ECMAScript 5 [polyfill](http://remysharp.com/2010/10/08/what-is-a-polyfill/).
662
+ * It is only defined if not already present in the user's browser, and it
663
+ * is meant to behave like the native version as much as possible. Consult
664
+ * the [ES5 specification](http://es5.github.com/#x15.4.4.17) for more
665
+ * information.
666
+ **/
602
667
function some ( iterator ) {
603
668
if ( this == null ) throw new TypeError ( ) ;
604
669
iterator = iterator || Prototype . K ;
@@ -618,6 +683,25 @@ Array.from = $A;
618
683
var some = wrapNative ( Array . prototype . some ) ;
619
684
}
620
685
686
+
687
+ /**
688
+ * Array#every([iterator = Prototype.K[, context]]) -> Boolean
689
+ * - iterator (Function): An optional function to use to evaluate each
690
+ * element in the enumeration; the function should return the value to
691
+ * test. If this is not provided, the element itself is tested.
692
+ * - context (Object): An optional object to use as `this` within
693
+ * calls to the iterator.
694
+ *
695
+ * Determines whether at least one element is truthy (boolean-equivalent to
696
+ * `true`), either directly or through computation by the provided iterator.
697
+ *
698
+ * `Array#every` acts as an ECMAScript 5 [polyfill](http://remysharp.com/2010/10/08/what-is-a-polyfill/).
699
+ * It is only defined if not already present in the user's browser, and it
700
+ * is meant to behave like the native version as much as possible. Consult
701
+ * the [ES5 specification](http://es5.github.com/#x15.4.4.16) for more
702
+ * information.
703
+ *
704
+ **/
621
705
function every ( iterator ) {
622
706
if ( this == null ) throw new TypeError ( ) ;
623
707
iterator = iterator || Prototype . K ;
0 commit comments