新增的实例方法
includes() ,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'));
console.log( s.startsWith('world',6));
console.log( s.startsWith('world',7));
repeat()
console.log('x'.repeat(3));
console.log('hello'.repeat(3));
padStart() padEnd()
console.log('x'.padStart(5,'ab'));
console.log('17'.padStart(10,'YYYY-MM-DD'));
console.log('12-06'.padStart(10,'YYYY-MM-DD'));
转载请注明原文地址:https://ipadbbs.8miu.com/read-51094.html