String extension method

Extended string methods:
1. Includes ( 'character string', start): detecting if the current string contains the specified substring, returns a Boolean value (from the start to the right look, comprising start)
2. startsWith ( 'character string ', start): detecting whether a current string in the beginning of the substring is specified, returns a Boolean value (from the right to find start, comprising Start)
3. endsWith (' character string ', start): detecting a current character whether the end of the string is the string substring specified, returns a Boolean value (from start to find the left and does not contain start)

	let str = 'how do you do';
	console.log(str.includes('do',4));
	console.log(str.startsWith('do',4));
	console.log(str.endsWith('do',6));
4. repeat() :  重复指定次数的字符串 ,
	参数: <= -1时,报错,
	     小数时,会自动取整
		 字符时,会自动转为数字,如果转为NaN时,按0算
5. 模板字符串   `...${变量}....`

Guess you like

Origin blog.csdn.net/weixin_45052104/article/details/90926505