javascript substring messes emoji

JavaScript
Array.from(str) splits your string into individual unicode characters without breaking them between bytes.
Source

Also in JavaScript: