728x90 ๋ฐ์ํ javascript5 Javascript Undefined boolean check Undefined Undefined๋ ์ ์ญ ๊ฐ์ฒด์ ์์ฑ, ์ฆ ์ ์ญ ๋ฒ์์์์ ๋ณ์์ ๋๋ค. ์ต์ ๋ธ๋ผ์ฐ์ ์์ undefined๋ ์ค์ ๋ถ๊ฐ, ์ฐ๊ธฐ๋ถ๊ฐํ ์์ฑใ ๋น๋๋ค. ๊ทธ๋ ์ง ์๋๋ผ๋ ๋ฎ์ด์ฐ๋๊ฑด ํผํ๋๊ฒ ์ข์ต๋๋ค. ๋ณ์๊ฐ ๊ฐ์ ํ ๋น๋ฐ์ง ๋ชปํ ๊ฒฝ์ฐ undefined ๋ฐํ, ํจ์์ ๊ฐ์ ๋ช ์์ ์ผ๋ก ๋ฐํํ์ง์์ผ๋ฉด undefined ๋ฐํํฉ๋๋ค. - ์๋ ๋งํฌ ์ฐธ๊ณ Undefined Check console.log(undefined === '') // false console.log(undefined !== '') // true console.log(typeof undefined) // "undefined" console.log(undefined === undefined) // true const a = {} con.. 2023. 3. 14. Javascript ์ ๊ทํํ์ ํ์ดํ(-) example Javascript ์ ๊ทํํ์ ํ์ดํ(-) example ์ ๊ทํํ์์ด๋ 1. ์ ๊ท์ ๋๋ ์ ๊ทํํ์ 2.๋ฌธ์์ด์์ ํน์ ๋ฌธ์ ์กฐํฉ์ ์ฐพ๊ธฐ์ํํจํด 3.์ ๊ทํํ์๋ฆฌํฐ๋ด(/.../), ๊ฐ์ฒด ์์ฑ์(new RegExp('...')) 1.์ ๊ทํํ์ ํ์ดํ(-) ์ฌ์ ์๋ฒํธ let string = "1234567890" // 1 string.replace(/[^0-9]/g, "") // 2 .replace(/^(\d{3})(\d{2})(\d{5})$/g, "$1-$2-$3") // 3 ์ ๊ทํํ์ ํ์ดํ์ ์ฌ์ ์๋ฒํธ๋ก ์์ฑํ ๊ฒฝ์ฐ ์ ์ฝ๋์ฒ๋ผ ์ฌ์ฉ 1. ๋ฐ์ดํฐ์ ๋ ฅ 2.0~9๋ฅผ ์ ์ธํ ๋๋จธ์ง๋ ์์ ๊ธฐ 3. {3} 3์๋ฆฌ {2} 2์๋ฆฌ {5} 5์๋ฆฌ ํ์ธ ํ ์์๋๋ก ์ ๊ทํํ์ ํ์ดํ ์์ฑ ์กฐ๊ธ ๋ ์ข๊ฒ ๋ฐ๊ฟ๋ณด๋ฉด 1-1.. 2022. 11. 8. BH] Javascript - npm ์ผ๊ด ์ ๋ฐ์ดํธ BH] ์๋ ํ์ธ์. npm ์ผ๊ด ์ ๋ฐ์ดํธ ๋ํด์ ์ ์ด๋ณผ๊ฒ์. ํ๋ก์ ํธ๋ฅผ ๊ด๋ฆฌํ๋ค ๋ณด๋ฉด package.json ํ์ผ์ ์ ์ด๋ ํ ๋ฒ์ด ์์ ์ด๊ฒ ๋ ๊ฑฐ์์. ๋ณธ์ธ์ด ์ง์ ๋ง๋ ์ฝ๋๋ค๋ ๋ง๊ฒ ์ง๋ง, ์๊ฐ ๊ด๋ฆฌ๋ฅผ ์ํด์ ์ ์ ํ๊ฒ ํจํค์ง๋ฅผ ์ฌ์ฉํ๊ธฐ๋ ํฉ๋๋ค. ๊ทธ๋ฌ๋ ๊ทธ์ ๋ฐ๋ฅธ ๋ฒ์ ๊ด๋ฆฌ๋ ์ํด์ค์ผ ํ ๊ฒ์ผ๋ก ์๊ฐํฉ๋๋ค. ํ๋ํ๋ ์์กด์ฑ์ ๋ณด๋ฅผ ๋ณด๋ฉด์ ๊ฐ ํจํค์ง๋ง๋ค ์ต์ ๋ฒ์ ํ์ธํ๊ณ ์ ๋ฐ์ดํธํ๊ณ ... ๋ ํ๋ ๋ณด๊ณ ...๋ฑ๋ฑ ์์งํ ๋งค์ผ ์ด์ง๊ฑฐ๋ฆฌ๋ ์ํ๊ฒ ์ง๋ง ํ์ํ ๋๋ ํ๋ํ๋ ์ฒดํฌํ๊ธฐ๊ฐ ์๋นํ ๊ท์ฐฎ์ต๋๋ค. ์๋ฌด๋๋ ์ผ๊ด ์ ๋ฐ์ดํธ๋ฅผ ํ ์ ์์ผ๋ฉด ์ข๊ฒ ์ฃ ? > npm install -g npm-check-updates > ncu -์ ๋ฐ์ดํธ ๋ฆฌ์คํธ ํ์ธ ex) acorn ^7.1.1 → ^8.4.1 async ^3.2... 2021. 9. 6. BH] Javascript - ํ์ดํ ํจ์ ๊ธฐ๋ณธ [BH] ์๋ ํ์ธ์. Javascript ํ์ดํ ํจ์์ ๋ํด์ ์ ์ด๋ณผ๊ฒ์. ์ผ๋ฐ์ ์ธ ํจ์(function)์ ํ์ดํ ํจ์๋ ํ์คํ ๋ค๋ฅธ ๊ฒ ๊ฐ์ต๋๋ค. ๋ญ๊ฐ ๋ค๋ฅผ๊น์?.. ํํ๊ฐ ๋ค๋ฆ ๋๋ค. ํจ์ ํํ์ let createFunc = function() { alert('create'); } ํ์ดํ ํจ์ ํํ์ let createFunc = () => { alert('create'); } ํ์ดํ ํจ์ ์ถ์ฝ ๋ฐฉ์ let createFunc = () => alert('create') ํ์ดํ ํจ์๋ ๋ญ๊ฐ ๊ฐ๊ฒฐํด๋ณด์ด๋๊ตฐ์. ๋! See the Pen ํ์ดํํจ์ by junyoung (@junyunga) on CodePen. ๋ ๋ค๋ฅธ ์ฐจ์ด์ ์ ํ์ดํ ํจ์์๋ this๊ฐ ์์ต๋๋ค. this๊ฐ ์์ผ๋ this.A๋ฅผ ํด๋ .. 2021. 8. 20. BH] Javascript - replace, replaceAll ๋ฌธ์์ด ์นํ [BH] ์๋ ํ์ธ์. Javascript ํน์ ๋ฌธ์์ด ์นํ์ ๋ํด์ ์ ์ด๋ณผ๊ฒ์. replace ํจ์๋ ํน์ ๋ฌธ์๋ฅผ ์ ํํ์ฌ ์นํ์์ผ ์ค๋๋ค. String.replace('originValue','newValue') ๋จ, ๋์๋ฌธ์ ๊ตฌ๋ณํ์ ์ผ ํด์. ์๋ ์์ค ํ์ธ See the Pen replace by junyoung (@junyunga) on CodePen. ํน์ ๋ฌธ์๋ฅผ ๋ฐ๊พธ๋ ๊ฒ์ด ๊ฐ๋ฅํด์ก์ด์. ๊ทธ๋ ์ง๋ง ํน์ ๋ฌธ์ ํ๋๋ง ์นํ์ด ๋ฉ๋๋ค. ์์ ๊ฐ์ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ์ํด์๋ replaceAll ํจ์๋ฅผ ์ฌ์ฉํ์๋ฉด ๋ผ์. String.replaceAll('originValue','newValue') ์๋ ์์ค ํ์ธ See the Pen replaceAll by junyoung (@junyunga) on CodeP.. 2021. 8. 19. ์ด์ 1 ๋ค์ 728x90 ๋ฐ์ํ LIST