DEV Community

Discussion on: Javascript String Methods: A Cheat Sheet for Developer

Collapse
 
frankwisniewski profile image
Frank Wisniewski

Using the string methods is not always crowned with success, especially when UTF-8 strings are used.

"use strict";
const str = "πŸ™Œorld";
let myArray =  str.split('') 
console.log(myArray)
// ['\uD83D', '\uDE4C', 'o', 'r', 'l', 'd']
console.log(str.length) // 6 !!
console.log (myArray.length) // 6 !!
console.log (myArray.join('-'))
// οΏ½-οΏ½-o-r-l-d
Enter fullscreen mode Exit fullscreen mode