Chapter 05: 문자열 메서드 (Additional string methods)
💡 도서 모던 자바스크립트 핵심 가이드를 읽고 정리합니다. 5.1 기본적인 문자열 메서드 indexOf() Gets the position of the first occurrence of the specified value in a string. 문자열에서 지정된 값이 처음 나타나는 위치를 반환 const str = "this is a short sentence"; str.indexOf("short"); // Output: 10 활용 예시 // 파일의 확장자 혹은 정규식 검사 등에 많이 사용된다. if ( file.indexOf("xlsx") > -1 ) { // ... } slice() Pulls a specified part of a string as a new string. 문자열의 지정된 부분을 ..