mozilla

Compare Revisions

String.prototype.startsWith()

Change Revisions

Revision 335613:

Revision 335613 by ethertank on

Revision 360385:

Revision 360385 by Havvy on

Title:
String.startsWith
String.startsWith
Slug:
JavaScript/Reference/Global_Objects/String/startsWith
JavaScript/Reference/Global_Objects/String/startsWith
Tags:
"String Methods", "String"
"String Methods", "String"
Content:

Revision 335613
Revision 360385
tt79    <h2 name="See also">
80      Polyfill
81    </h2>
82    <p>
83      You can polyfill String.startsWith with the following snipp
 >et:
84    </p>
85    <pre class="brush: js">
86if (!String.prototype.startsWith) {
87    Object.defineProperty(String.prototype, 'startsWith', {
88        enumerable: false,
89        configurable: false,
90        writable: false,
91        value: function (searchString, position) {
92            position = position || 0;
93             return this.indexOf(searchString, position) === posi
 >tion;
94        }
95    });
96}
97</pre>

Back to History