holdanddeepdive/javascript-deep-dive

32장 String

Opened this issue · 0 comments

  • String의 래퍼객체는 읽기 전용이다.

    • 배열에는 원본 배열을 직접 변경하는 mutator method와 새로운 배열을 생성하여 반환하는 accessor method가 있다.(변경자/접근자)
    • 하지만 String 객체의 메서드는 언제나 새로운 문자열을 반환한다.
    • 문자열은 변경 불가능한 원시값이기 때문이다.
    • String 래퍼 객체도 읽기 전용 객체로 제공됨
  • charAt, charCodeAt, charPointAt

const icons = '☃★♲';

console.log(icons.charAt(1));
console.log(icons.charCodeAt(1));
console.log(icons.codePointAt(1));
  • charAt (Full support)
    • charAt() 함수는 문자열에서 특정 인덱스에 위치하는 유니코드 단일문자를 반환합니다.
  • charCodeAt (Full support)
    • charCodeAt() 메서드는 주어진 인덱스에 대한 UTF-16 코드를 나타내는 0부터 65535 사이의 정수를 반환합니다.
    • 9733
  • charPointAt (IE 빼고 Full support)
    • 9733
      스크린샷 2022-04-23 오후 6 10 16