유니코드

해피데빙·2022년 11월 14일
0

substr - deprecated
substring - 사용

const str = "abc🧑🏿‍🤝‍🧑🏻";
console.log(str.length); // 15
console.log(str.substring(0, 3)); // abc
console.log(str.substring(0, 5)); // abc🧑
console.log(str.substring(0, 7)); // abc🧑🏿
console.log(str.substring(0, 10)); // abc🧑🏿‍🤝
console.log(str.substring(0, 13)); // abc🧑🏿‍🤝‍🧑
console.log(str.substring(0, 15)); // abc🧑🏿‍🤝‍🧑🏻

substring 사용하면 예상한 것과 결과가 다름

profile
노션 : https://garrulous-gander-3f2.notion.site/c488d337791c4c4cb6d93cb9fcc26f17

0개의 댓글