Project

General

Profile

Download (639 Bytes) Statistics
| Branch: | Tag: | Revision:
1
/***
2
**
3
** Polyfill for older browsers that don't yet have the newer string "includes()" method implemented.
4
** Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes?#Polyfill
5
** Documentation: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
6
**
7
***/
8

    
9
if (!String.prototype.includes) {
10
	String.prototype.includes = function(search, start) {
11
		'use strict';
12
		if (typeof start !== 'number') {
13
			start = 0;
14
		}
15

    
16
		if (start + search.length > this.length) {
17
			return false;
18
		} else {
19
			return this.indexOf(search, start) !== -1;
20
		}
21
	};
22
}
(3-3/3)