New instance methods

Includes (), startsWith(), endsWith()

// includes() returns a Boolean value startsWith() endsWith()
let s = 'hello world'
console.log(s.includes('o'));
console.log(s.includes('p'));
console.log(s.startsWith('hello'));
console.log(s.endsWith('world'));

// The second parameter indicates that the search position starts from o0
console.log( s.startsWith('world'.6));
console.log( s.startsWith('world'.7));
Copy the code

repeat()

// repeat()
console.log('x'.repeat(3));
console.log('hello'.repeat(3));
Copy the code

padStart() padEnd()

console.log('x'.padStart(5.'ab')); // The total length is filled from the starting position
 // The format of the prompt string
console.log('17'.padStart(10.'YYYY-MM-DD'));//YYYY-MM-17
console.log('12-06'.padStart(10.'YYYY-MM-DD'));//YYYY-12-06
Copy the code