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

๋ฌธ์ž์—ด ๋งค์„œ๋“œ2

[JAVASCRIPT] ๋ฌธ์ž์—ด ๋ฉ”์„œ๋“œ : replace( ) / replaceAll( ) ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ : ๋ฌธ์ž์—ด ๋ฉ”์„œ๋“œ : replace() ์ด๋ฒˆ ์‹œ๊ฐ„์—๋Š” ๋ฌธ์ž์—ด ๋ฉ”์„œ๋“œ์ธ replace()์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค! ๐Ÿ˜ #1. replace( ) replace() ๋ฉ”์„œ๋“œ๋Š” String.prototype.replace()์˜ ์•ฝ์ž๋กœ ๋ฌธ์ž์—ด์„ ์น˜ํ™˜ํ•˜๊ฑฐ๋‚˜ ๋ณ€ํ™˜ ํ•  ๋•Œ ์‚ฌ์šฉํ•˜๋Š” ๋ฉ”์„œ๋“œ์ž…๋‹ˆ๋‹ค. ์ฆ‰ ๋ฌธ์ž์—ด์„ ๋ถ€๋ถ„ ๋ฌธ์ž์—ด๋กœ ๊ตฌ๋ถ„ํ•˜๊ณ  ๋ณ€ํ™˜ํ•˜์—ฌ ์ƒˆ๋กœ์šด ๋ฐฐ์—ด๋กœ ๋ฐ˜ํ™˜ํ•ด์ค๋‹ˆ๋‹ค. ! replace( ) ์‚ฌ์šฉ ๋ฐฉ๋ฒ• ! "๋ฌธ์ž์—ด"replace("์ฐพ์„ ๋ฌธ์ž์—ด", "๋ณ€๊ฒฝํ•  ๋ฌธ์ž์—ด"); "๋ฌธ์ž์—ด"replace("์ฐพ์„ ๋ฌธ์ž์—ด", "๋ณ€๊ฒฝํ•  ๋ฌธ์ž์—ด"); "๋ฌธ์ž์—ด"replace(์ •๊ทœ์‹); "๋ฌธ์ž์—ด"replace(์ •๊ทœ์‹, "๋ณ€๊ฒฝํ•  ๋ฌธ์ž์—ด"); const str1 = "javascript reference"; const cirrentStr.. 2022. 8. 18.
[JAVASCRIPT] ๋ฌธ์ž์—ด ๋ฉ”์„œ๋“œ : split( ) ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ : ๋ฌธ์ž์—ด ๋ฉ”์„œ๋“œ : split() ์ด๋ฒˆ ์‹œ๊ฐ„์—๋Š” ๋ฌธ์ž์—ด ๋ฉ”์„œ๋“œ์ธ split()์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค! ๐Ÿ˜ #1. split( ) slice() ๋ฉ”์„œ๋“œ๋Š” ๋ฌธ์ž์—ด์—์„œ ์›ํ•˜๋Š” ๊ฐ’์„ ์ถ”์ถœํ•œ ๋’ค ์ƒˆ๋กœ์šด ๋ฌธ์ž์—ด๋กœ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. ์ฆ‰ ๋ฌธ์ž์—ด์„ ๋ถ„ํ• ํ•˜์—ฌ ๋ถ€๋ถ„ ๋ฌธ์ž์—ด ๋ฐฐ์—ด์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค ๐Ÿ“– ์•„๋ž˜์˜ ์ฝ”๋“œ ์˜ˆ์ œ์™€ ์ฃผ์„์„ ํ†ตํ•ด ๋” ์ž์„ธํžˆ ์•Œ์•„๋ด…์‹œ๋‹ค! ๐Ÿ“– ! split( ) ์‚ฌ์šฉ ๋ฐฉ๋ฒ• ! "๋ฌธ์ž์—ด".split(๊ตฌ๋ถ„์ž(separator)); "๋ฌธ์ž์—ด".split(์ •๊ทœ์‹ ํ‘œํ˜„); "๋ฌธ์ž์—ด".split(๊ตฌ๋ถ„์ž, ๊ฐฏ์ˆ˜); //๊ฐฏ์ˆ˜๋ฅผ ์„ค์ •ํ•  ์ˆ˜ ์žˆ๋‹ค. const str1 = "javascript reference"; const currentStr1 = str1.split(''); //['j','a','v','a','s','c',.. 2022. 8. 18.
728x90
๋ฐ˜์‘ํ˜•

Lucky Charms Rainbow
js
html
css