JavaScript_04_문자열의 properties & method

charl hi·2021년 8월 4일

JavaScript

목록 보기
4/6

문자열은 '' 또는 ""

Properties - .lenth

  • str.lenth
  • 문자열 길이
  • 'hello world' .lenth
    -> 11

Method - .toUpperCase()

  • str.toUpperCase()
  • 대문자로
  • 'hello world'.toUpperCase()
    -> HELLO WORLD

Method - .indexOf(내용)

  • str.indexOf('찾는 내용')

  • 찾는 내용의 위치

  • 'hello world'.indexOf('o')
    -> 4
    -> 01234... 4번째에 위치한다.

  • 'hello world'.indexOf('world')
    -> 6
    -> 01234... 6번째에 위치한다.

  • 없으면 -1



Ref

0개의 댓글