[코테준비] .split()

J.H. KIM·2021년 10월 15일
0

코테준비

목록 보기
1/1

.split() method

split()은 문자열을 분할하는 메서드 이다.




  • 예시01
    const name = my,name,is,kim;
    console.log(string.split(','));

    • 결과값:
      my
      name
      is
      kim


  • 예시02
    const name = my,name,is,kim;
    console.log(string.split(',', 3));

    • 결과값:
      my
      name
      is




  • 주의할 점
    '예시02'에서 limit값이 3이여서 0,1,2,3 이라 생각해 4번째 까지 나올 거라 예상했지만 숫자 그대로 3번째 까지만 출력하였다.
profile
NEWBIE

0개의 댓글