λ³Έλ¬Έ λ°”λ‘œκ°€κΈ°

λ¬Έμžμ—΄8

[JAVASCRIPT] λ¬Έμžμ—΄ λ©”μ„œλ“œ : charAt( ) μžλ°”μŠ€ν¬λ¦½νŠΈ : λ¬Έμžμ—΄ λ©”μ„œλ“œ : 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 ! λŒ€μ†Œλ¬Έμžλ₯Ό κ΅¬λΆ„ν•˜λ©° μœ„μΉ˜κ°’μ„ μž‘.. 2022. 8. 23.
[JAVASCRIPT] λ¬Έμžμ—΄ λ©”μ„œλ“œ : includes( ) μžλ°”μŠ€ν¬λ¦½νŠΈ : λ¬Έμžμ—΄ λ©”μ„œλ“œ : includes() 이번 μ‹œκ°„μ—λŠ” λ¬Έμžμ—΄ λ©”μ„œλ“œμΈ includes()에 λŒ€ν•΄ μ•Œμ•„λ³΄κ² μŠ΅λ‹ˆλ‹€! 😁 #1. includes( ) includes() λ©”μ„œλ“œλŠ” λ¬Έμžμ—΄ 포함 μ—¬λΆ€λ₯Ό κ²€μƒ‰ν•˜μ—¬, 뢈린(true, false)을 λ°˜ν™˜ν•©λ‹ˆλ‹€. 즉 λ¬Έμžμ—΄μ΄ νŠΉμ • λ¬Έμžμ—΄μ„ ν¬ν•¨ν•˜λŠ”μ§€ ν™•μΈν•˜λŠ” λ©”μ„œλ“œλΌ λ³Ό 수 μžˆμŠ΅λ‹ˆλ‹€! ! includes( ) μ‚¬μš© 방법 ! string.includes( searchString, length ) "λ¬Έμžμ—΄".includes(검색할 λ¬Έμžμ—΄); "λ¬Έμžμ—΄".includes(검색할 λ¬Έμžμ—΄, 검색을 μ‹œμž‘ν•  μœ„μΉ˜); == indexOF()와 거의 κ°™λ‹€. const str1 = "javascript reference"; const currentStr1 = str1.incl.. 2022. 8. 18.
[JAVASCRIPT] λ¬Έμžμ—΄ λ©”μ„œλ“œ : repeat( ) μžλ°”μŠ€ν¬λ¦½νŠΈ : λ¬Έμžμ—΄ λ©”μ„œλ“œ : repeat() 이번 μ‹œκ°„μ—λŠ” λ¬Έμžμ—΄ λ©”μ„œλ“œμΈ repeat()에 λŒ€ν•΄ μ•Œμ•„λ³΄κ² μŠ΅λ‹ˆλ‹€! 😁 #1. repeat( ) repeat() λ©”μ„œλ“œλŠ” λ¬Έμžμ—΄μ„ 주어진 횟수만큼 λ°˜λ³΅ν•΄ 뢙인 μƒˆλ‘œμš΄ λ¬Έμžμ—΄μ„ λ°˜ν™˜ν•©λ‹ˆλ‹€. ! replace( ) μ‚¬μš© 방법 ! "λ¬Έμžμ—΄".replace("νšŸμˆ˜κ°’"); const str1 = "javascript"; const cirrentStr1 = str1.repeat(0); // '' const cirrentStr2 = str1.repeat(1); // javascript const cirrentStr3 = str1.repeat(2); // javascriptjavascript ! point ! λ¬Έμžμ—΄μ˜ 반볡 νšŸμˆ˜κ°’μ€ μ–‘μ˜ μ •μˆ˜μ—¬μ•Ό ν•œλ‹€! 2022. 8. 18.
[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.
[JAVASCRIPT] ν…œν”Œλ¦Ώ λ¬Έμžμ—΄ μžλ°”μŠ€ν¬λ¦½νŠΈ : λ¬Έμžμ—΄ κ²°ν•© : ν…œν”Œλ¦Ώ λ¬Έμžμ—΄ μ§€κΈˆλΆ€ν„° μžλ°”μŠ€ν¬λ¦½νŠΈμ˜ λ¬Έμžμ—΄ κ²°ν•©κ³Ό λ¬Έμžμ—΄ λ©”μ†Œλ“œμΈ ν…œν”Œλ¦Ώ λ¬Έμžμ—΄μ— λŒ€ν•΄ μ•Œμ•„λ΄…μ‹œλ‹€! 1. ν…œν”Œλ¦Ώ λ¬Έμžμ—΄ ν…œν”Œλ¦Ώ λ¬Έμžμ—΄( )은 λ¬Έμžμ—΄ κ²°ν•© λ©”μ„œλ“œλ‘œ λ‚΄μž₯된 ν‘œν˜„μ‹μ„ ν—ˆμš©ν•˜λŠ” λ¬Έμžμ—΄ λ¦¬ν„°λŸ΄μž…λ‹ˆλ‹€. λ¬Έμžμ—΄μ„ κ²°ν•©ν•  λ•Œ λ”°μ˜΄ν‘œ λŒ€μ‹  ` ` (backtick_λ°±ν‹±)을 μ‚¬μš©ν•˜λ©° λ³€μˆ˜λ₯Ό λ„£κ³ μž ν•˜λŠ” 뢀뢄에 ${}λ₯Ό μ‚¬μš©ν•˜μ—¬ λ„£μ–΄μ£Όλ©΄ λ©λ‹ˆλ‹€. λ˜ν•œ κ°„λ‹¨ν•œ μžλ°”μŠ€ν¬λ¦½νŠΈ 문법을 λ¬Έμžμ—΄ μ•ˆμ— μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€. //01. λ¬Έμžμ—΄(string) κ²°ν•© const str1 = "μžλ°”μŠ€ν¬λ¦½νŠΈ"; const str2 = "μ œμ΄ν€˜λ¦¬"; document.querySelector(".sample01_P1").innerHTML = str1 + str2; //02. 숫자(number) κ²°ν•©.. 2022. 8. 18.
[JAVASCRIPT] λ¬Έμžμ—΄ λ©”μ„œλ“œ : indexOf( ) μžλ°”μŠ€ν¬λ¦½νŠΈ : indexOf() λ©”μ„œλ“œ 이번 μ‹œκ°„μ—λŠ” λ¬Έμžμ—΄ λ©”μ„œλ“œ 쀑 ν•˜λ‚˜μΈ indexOf() λ©”μ„œλ“œμ— λŒ€ν•΄ μ•Œμ•„λ³΄κ² μŠ΅λ‹ˆλ‹€.πŸ˜† #1. indexOf( ) indexOf() λ©”μ„œλ“œλŠ” λ¬Έμžμ—΄μ—μ„œ μΆ”μΆœν•˜κ³  싢은 문자의 μœ„μΉ˜λ₯Ό 찾은 ν›„ 숫자둜 ν•΄λ‹Ή λ¬Έμžμ—΄μ„ λ°˜ν™˜ν•©λ‹ˆλ‹€. 즉 νŠΉμ • λ¬Έμžκ°€ λ¬Έμžμ—΄μ˜ μ–΄λŠ index에 μœ„μΉ˜ν•˜λŠ”μ§€ μ°ΎλŠ” λ©”μ„œλ“œλΌκ³  λ³Ό 수 μžˆμŠ΅λ‹ˆλ‹€. ! indexOf() μ‚¬μš©λ²• ! "λ¬Έμžμ—΄".indexOf(검색값) "λ¬Έμžμ—΄".indexOf(검색값, μœ„μΉ˜κ°’) : 처음 값은 μΆ”μΆœν•˜κ³  싢은 λ¬Έμžμ—΄μ„ μž‘μ„±ν•˜κ³  λ§ˆμ§€λ§‰ 값을 κ·Έ λ¬Έμžμ—΄μ„ μ°ΎκΈ° μ‹œμž‘ ν•  μœ„μΉ˜λ‘œ 적으면 λœλ‹€. ✏️예제 μ½”λ“œ const str1 = "javascript reference" const currentStr1 = str1.indexOf("j.. 2022. 8. 17.
[JAVASCRIPT] λ¬Έμžμ—΄ λ©”μ„œλ“œ : Slice(), substring(), substr() μžλ°”μŠ€ν¬λ¦½νŠΈ : λ¬Έμžμ—΄ λ©”μ„œλ“œ slice(), substring(), substr() slice(), substring(), substr()λŠ” λ¬Έμžμ—΄ λ©”μ„œλ“œμ˜ λ³€κ²½ νƒ€μž…μœΌλ‘œ λ¬Έμžμ—΄μ—μ„œ μ›ν•˜λŠ” 값을 μΆ”μΆœν•˜μ—¬ λ¬Έμžμ—΄μ„ λ°˜ν™˜ν•˜λŠ” λ©”μ„œλ“œμž…λ‹ˆλ‹€. #1. slice( ) slice() λ©”μ„œλ“œλŠ” λ¬Έμžμ—΄μ—μ„œ μ›ν•˜λŠ” 값을 μΆ”μΆœν•˜μ—¬ λ¬Έμžμ—΄μ„ λ°˜ν™˜ν•©λ‹ˆλ‹€. ! slice( ) μ‚¬μš© 방법 ! "λ¬Έμžμ—΄"slice(μ‹œμž‘ μœ„μΉ˜) "λ¬Έμžμ—΄"slice(μ‹œμž‘ μœ„μΉ˜, λλ‚˜λŠ” μœ„μΉ˜) const str1 = "javascript reference" const currentStr1 = str1.slice(0); //javascript reference const currentStr2 = str1.slice(1); //avascript refer.. 2022. 8. 17.
728x90
λ°˜μ‘ν˜•

Lucky Charms Rainbow
js
html
css