Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

startswith in javascript

if (!String.prototype.startsWith) {
    Object.defineProperty(String.prototype, 'startsWith', {
        value: function(search, rawPos) {
            var pos = rawPos > 0 ? rawPos|0 : 0;
            return this.substring(pos, pos + search.length) === search;
        }
    });
}
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #startswith #javascript
ADD COMMENT
Topic
Name
3+1 =