Debug
-
[코드스테이츠 TIL] 문자열 String method , DebugStudy/JavaScript 2019. 10. 31. 22:42
[ 문자열 String ] 문자열은 index로 접근은 가능하지만 쓸 수는 없다 (read only) let str = 'codestates' str[0] = 'g' //str === 'codestates' 이렇게 했을 경우 변수 str은 godestates가 아니라 codestates 그대로 있다 숫자와 문자열에 '+ 연산자'를 사용할 경우 결과는 문자열로 변환된다 console.log(123 + '456') //'123456' str.indexOf('searchValue') : 찾고자 하는 문자열과 처음으로 일치하는 index를 리턴한다. 일치하는 문자열이 없으면 -1을 반환한다. 'Blue Whale'.indexOf('Blue'); // returns 0 'Blue Whale'.indexOf('Bl..