๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
JAVASCRIPT

[JAVASCRIPT] ๋ฌธ์ž์—ด ๋ฉ”์„œ๋“œ : charAt( )

by _ํ† ๋งคํ†  2022. 8. 23.
728x90

์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ : ๋ฌธ์ž์—ด ๋ฉ”์„œ๋“œ : charAt()

์ด๋ฒˆ ์‹œ๊ฐ„์—๋Š” ๋ฌธ์ž์—ด ๋ฉ”์„œ๋“œ์ธ charAt()์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค! ๐Ÿ˜


#1. charAt( )

charAt() ๋ฉ”์„œ๋“œ๋Š” ์ง€์ •ํ•œ ์ธ๋ฑ์Šค์˜ ๋ฌธ์ž๋ฅผ ์ถ”์ถœํ•˜์—ฌ ๋ฌธ์ž์—ด์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

! charAt( ) ์‚ฌ์šฉ ๋ฐฉ๋ฒ• !
"๋ฌธ์ž์—ด".charAt(์ˆซ์ž);

const str1 = "javascript reference";
    
const currentStr1 = str1.charAt();       // j
const currentStr2 = str1.charAt("0");    // j
const currentStr3 = str1.charAt("1");    // a
const currentStr4 = str1.charAt("2");    // v

! point ! ๋Œ€์†Œ๋ฌธ์ž๋ฅผ ๊ตฌ๋ถ„ํ•˜๋ฉฐ ์œ„์น˜๊ฐ’์„ ์ž‘์„ฑํ•˜์ง€ ์•Š์„ ๋• ์ž๋™์œผ๋กœ 0๋ฒˆ์งธ ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค.

728x90

๋Œ“๊ธ€


Lucky Charms Rainbow
js
html
css