The String object also has some new tricks in its pockets. You may, for example, check if a string startsWith() or endsWith() a certain value

//ES6 String Extensions

let name = 'Violet'

// startsWith() checks if the string starts with whatever value you pass in as a argument - Case Sensitive console.log(name.startsWith('Vio')); console.log(name.startsWith('vio')); console.log(name.startsWith(''));

// endswith() checks if the string ends with whatever value you pass in as a argument - Case Sensitive console.log(name.endsWith('et')); console.log(name.endsWith('Et'));

// includes() checks if a string includes something console.log(name.includes('Vio')); console.log(name.includes('ole'));

Last Updated: 8/13/2019, 6:55:26 PM