ES6 Tutorial - #12 String API
String that begins with a pattern 00:23 substring(start, end) https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring 01:48 indexOf(pattern, start) https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf 02:27 lastIndexOf(pattern, start) https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf 03:28 startsWith(pattern, position) https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith String that ends with a pattern 04:32 substr(start, length) https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr 06:10 indexOf(pattern, start) [See above] 07:21 endsWith(pattern, length) https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith String that contains a pattern 09:17 search(regexp) https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/search 10:00 indexOf(pattern, start) [See above] 10:22 includes(pattern, position) https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes String that is repeated 11:07 Array CTOR + Array.prototype.join https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join 12:26 repeat(times) https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat Let's review the newly-added methods of the native String API in JavaScript under ES6. Over the years, developers came up with ingenious ways to work with strings (either extending the prototype or building a dedicated util library, like Underscore) with some being more effective than others. Now that the spec is out, we no longer have to guess. Nonetheless, let's go over those different approaches for the sake of review, as well as cover the new shiny and convenient methods as we move along.
Download
0 formatsNo download links available.