You can also use repeat to generate strings:
'ha'.repeat(3)    //    hahaha
Strings are now iterable. Using the new for...of construct, you can pluck apart a string character by character:
for(let    c    of    'Mastering    Node.js')    {
    console.log(c);
}
//    M
//    a
//    s
//    ...
Alternatively, use the spread operator:
console.log([...'Mastering    Node.js']);

//    ['M',    'a',    's',...]
Searching is also easier. New methods allow common substring seeks without much ceremony:
let    targ    =    'The    rain    in    Spain    lies    mostly    on    the    plain';

console.log(targ.startsWith('The',    0));    //    true

console.log(targ.startsWith('The',    1));    //    false

console.log(targ.endsWith('plain'));    //    true

console.log(targ.includes('rain',    5));    //    false

The second argument to these methods indicates a search offset, defaulting to 0. The is found at position 0, so beginning the search at position 1 fails in the second case.

results matching ""

    No results matching ""