ES6 in Depth
  • Introduction
  • Installation
  • Block Scope
    • Constant
    • Use cases
  • Template String
    • New String Methods
    • Tagged Template Literal
  • New Number Methods
  • Arrow Function
    • Default Parameters
    • Lexical This Scope
    • Where not to use arrow function
  • Object Enhancement
  • New Array Methods
    • For Of
  • Spread Operator
  • Destructuring
    • Array Destructuring
  • Class
  • Symbols
  • New Data Structures
    • Set
    • Map
    • WeakSet
    • WeakMap
    • Iterators
    • Generators
  • Promise
  • Import Export
Powered by GitBook
On this page

Was this helpful?

  1. Template String

New String Methods

let str = "I am string";
console.log(str.startsWith("I")); // true
// starts with after n character
console.log(str.startsWith("am", 2)); // true


console.log(str.endsWith("ng")); // true
// take 1st 10 char
console.log(str.endsWith("rin", 10)); // true


console.log(str.repeat(2)); // I am stringI am string
console.log(str.includes('rin')); // true (it's case sensitive)
PreviousTemplate StringNextTagged Template Literal

Last updated 4 years ago

Was this helpful?