× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

ES6 String contains, starts with, ends with to ES5

Dan
Aug 27, 2015
<pre><code class="language-javascript">String.prototype.contains = String.prototype.contains || function(str) { return this.indexOf(str) &gt;= 0; }; String.prototype.startsWith = String.prototype.startsWith || function(prefix) { return this.indexOf(prefix) === 0; }; String.prototype.endsWith = String.prototype.endsWith || function(suffix) { return this.indexOf(suffix, this.length - suffix.length) &gt;= 0; };</code></pre> <p> </p>
comments powered by Disqus