Skip to content

Commit b07fd94

Browse files
Add polyfill information to documentation for String#startsWith and String#endsWith.
1 parent 9e058b4 commit b07fd94

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

src/prototype/lang/string.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -771,11 +771,19 @@ Object.extend(String.prototype, (function() {
771771

772772
/**
773773
* String#startsWith(substring[, position]) -> Boolean
774-
* - substring (String): The characters to be searched for at the start of this string.
775-
* - [position] (Number): The position in this string at which to begin searching for `substring`; defaults to 0.
774+
* - substring (String): The characters to be searched for at the start of
775+
* this string.
776+
* - [position] (Number): The position in this string at which to begin
777+
* searching for `substring`; defaults to 0.
776778
*
777779
* Checks if the string starts with `substring`.
778780
*
781+
* `String#startsWith` acts as an ECMAScript 6 [polyfill](http://remysharp.com/2010/10/08/what-is-a-polyfill/).
782+
* It is only defined if not already present in the user's browser, and it
783+
* is meant to behave like the native version as much as possible. Consult
784+
* the [ES6 specification](http://wiki.ecmascript.org/doku.php?id=harmony%3Aspecification_drafts) for more
785+
* information.
786+
*
779787
* ##### Example
780788
*
781789
* 'Prototype JavaScript'.startsWith('Pro');
@@ -792,12 +800,20 @@ Object.extend(String.prototype, (function() {
792800

793801
/**
794802
* String#endsWith(substring[, position]) -> Boolean
795-
* - substring (String): The characters to be searched for at the end of this string.
796-
* - [position] (Number): Search within this string as if this string were only this long;
797-
* defaults to this string's actual length, clamped within the range established by this string's length.
803+
* - substring (String): The characters to be searched for at the end of
804+
* this string.
805+
* - [position] (Number): Search within this string as if this string were
806+
* only this long; defaults to this string's actual length, clamped
807+
* within the range established by this string's length.
798808
*
799809
* Checks if the string ends with `substring`.
800810
*
811+
* `String#endsWith` acts as an ECMAScript 6 [polyfill](http://remysharp.com/2010/10/08/what-is-a-polyfill/).
812+
* It is only defined if not already present in the user's browser, and it
813+
* is meant to behave like the native version as much as possible. Consult
814+
* the [ES6 specification](http://wiki.ecmascript.org/doku.php?id=harmony%3Aspecification_drafts) for more
815+
* information.
816+
*
801817
* ##### Example
802818
*
803819
* 'slaughter'.endsWith('laughter')

0 commit comments

Comments
 (0)