주제

 

split() - 필요한 구분자로 String 객체를 나눔

 

 

 방법

 

str.split('구분자');

 

 

 예제

파일명(테스트.xml)에서 

파일 이름과 파일 확장자를 나누기

 

개발자도구 - console 에서 실행

const file="테스트.xml";
const fileName=file.split('.');
console.log(fileName[0]);
console.log(fileName[1]);
테스트
xml

 

 

 출처

 

MDN Web Docs

https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/String/split

 

+ Recent posts