반응형
Node.js에는 많은 자바스크립트 함수들이 있습니다. 가장 자주쓰는 함수는 String, Array, Math 등이 있습니다.
오늘은 Node js String 함수(substr, substring, length, indexOf, split)에 대해서 알아보겠습니다.
안녕하세요 프로그래머 블랙디입니다.
Substr 함수 예제
반응형
const str = 'BlackD';
console.log(str.substr(1,2));
//output: "la"
console.log(str.substr(2));
//output: "ackD"
Substring 함수 예제
const str = 'BlackD';
console.log(str.substr(1,3));
//output: "la"
console.log(str.substr(2));
//output: "ackD"
length 함수 예제
const str = 'BlackD';
console.log(str.length);
//output: 6
indexOf 함수 예제
const str = 'BlackD';
console.log(str.indexOf('k'));
//output: 5
//없으면 : -1
split 함수 예제
const str = 'Black D';
console.log(str.split(' '));
//output: ["Black", "D"]
이상으로 Nodejs String 함수들에 대해서 알아보았습니다.
이상 BlackD 였습니다.
반응형
'IT & 테크' 카테고리의 다른 글
[삼성전자] 갤럭시 S25 컬러 미쳤다 (1) | 2025.01.27 |
---|---|
[Spring boot] Spring REST API Excel down / REST Controller에서 엑셀 다운로드 하기/ REST API Download Excel file (0) | 2020.10.11 |
[캠핑용품] 캠핑용 랜턴! 오아올라이트! 가성비 끝판왕! 무드등! (0) | 2020.07.26 |
[최신] Visual Studio Code / Vscode 설치 방법 (0) | 2020.07.25 |
[Kotlin] 코틀린 first, last 함수란? kotlin first, last 함수 예제 (0) | 2020.03.01 |