도리쓰에러쓰

[JavaScript] 주로 사용하는 문자열 메서드 모음 (String Method Collection) 본문

JavaScript/JS

[JavaScript] 주로 사용하는 문자열 메서드 모음 (String Method Collection)

강도리 2022. 3. 23. 00:17

코딩테스트를 진행하면서 가끔 헷갈리는 메서드가 존재하는데 자세하진 않지만 확인용으로 간단하게 작성해보았다.

'dori'[1];	// 'o'
'dori'.includes('or');	// true
'dori'.indexOf('r');	// 2
'dori'.startsWith('i');	// false
'dori'.endsWith('i');	// true
'dori'.slice(0,3);		// 'dor'
'dori'.slice(2);		// 'ri'
'dori'.toUpperCase();	// 'DORI'
'dORi'.toLowerCase();	// 'dori'
'dori'.replace('or', 'hh');	// 'dhhi'
'dori'.repeat(3);		// 'doridoridori'
'do ri'.split('');		// ['d', 'o', ' ', 'r', 'i']
'do ri'.split(' ');		// ['do', 'ri']

 

 

그 외의 다른 문자열 메서드를 알고 싶다면 아래 사이트를 참고하면 좋을 것 같다 !

 

JavaScript String Reference

W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

www.w3schools.com

 

Comments