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

์ „์ฒด ๊ธ€79

javascript byte ์ˆ˜ ๊ณ„์‚ฐ euc-kr byte ๊ตฌํ•˜๊ธฐ ํ•œ๊ธ€ ํ•œ ๊ธ€์ž๋‹น 2byte ๊ธฐ์ค€ ๋ฐ”์ดํŠธ ์ˆ˜ ๊ณ„์‚ฐ function calcByteEuckr(str) { return str .split('') .map(s => s.charCodeAt(0))// ์œ ๋‹ˆ์ฝ”๋“œ ๊ฐ’์œผ๋กœ ๋ณ€ํ™˜ .reduce((prev, c) => (prev + ((c === 10) ? 2 : ((c >> 7) ? 2 : 1))), 0); // c ๊ฐ’์ด 0~127์‚ฌ์ด์— ์žˆ์œผ๋ฉด 1๋ฐ”์ดํŠธ } ์ตœ๋Œ€ byte ๋งŒํผ๋งŒ ๋ฌธ์ž์—ด ์ž๋ฅด๊ธฐ function getLimitedByteEuckrText(str, maxByte) { if (!str) return; let b; for (b = i = 0; (c = str.charCodeAt(i)); ) { b += (c === 10) ? 2 : .. 2022. 6. 21.
Vue.js xlsx ์—‘์…€ ๋‹ค์šด๋กœ๋“œ Vue ์—‘์…€ ๋‹ค์šด๋กœ๋“œ ์„œ๋ฒ„๋ฅผ ๊ฑฐ์น˜์ง€ ์•Š๊ณ  ํ™”๋ฉด ์ƒ์—์„œ xlsx ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•ด ์—‘์…€ ๋‹ค์šด๋กœ๋“œ๋ฅผ ํ•˜๋Š” ๋ฐฉ๋ฒ•์ด๋‹ค. xlsx ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์„ค์น˜ npm install --save xlsx xlsx ๋ฅผ ์‚ฌ์šฉํ•œ ์—‘์…€ ๋‹ค์šด๋กœ๋“œ ๊ธฐ๋Šฅ ๊ตฌํ˜„ import xlsx from 'xlsx'; ... excelDownload() { const fileName = 'excelFile';// ํŒŒ์ผ๋ช… const sheetName = 'sheet1';// ์‹œํŠธ๋ช… const header = [['์ด๋ฆ„', '๋‚˜์ด', '์ด๋ฉ”์ผ']];// ์ปฌ๋Ÿผ๋ช… const list = [{ name: 'ํ™๊ธธ๋™', age: 15, email: 'ํ™๊ธธ๋™@naver.com' }, { name: '๊น€๊ธธ๋™', age: 44, email: '๊น€๊ธธ๋™@naver.com'.. 2022. 6. 16.
vue router / query vs params vue router ๋ทฐ๋กœ ์‹ฑ๊ธ€ ํŽ˜์ด์ง€ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๊ตฌํ˜„ํ•  ๋•Œ ํ™”๋ฉด ์ „ํ™˜ ๋ฐ ํŽ˜์ด์ง€ ์ด๋™์„ ์œ„ํ•ด ์‚ฌ์šฉํ•˜๋Š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์ด๋‹ค. ์›น์—์„œ ๋ผ์šฐํŒ…์€ ํŽ˜์ด์ง€ ๊ฐ„์˜ ์ด๋™ ๋ฐฉ๋ฒ•์„ ๋œปํ•˜๋Š”๋ฐ ๋ทฐ๋Š” ํ™”๋ฉด ์ด๋™ ์‹œ DOM์„ ์ƒˆ๋กœ ๊ฐฑ์‹ ํ•˜์ง€ ์•Š๊ณ  ๋ณ€๊ฒฝ๋œ ์ปดํฌ๋„ŒํŠธ๋งŒ ๊ฐฑ์‹ ํ•˜์—ฌ ๊นœ๋นก์ž„ ์—†์ด ๋งค๋„๋Ÿฝ๊ฒŒ ์ „ํ™˜๋˜๋Š” ์žฅ์ ์ด ์žˆ๋‹ค. ํŽ˜์ด์ง€ ์ด๋™ ํƒœ๊ทธ๋กœ ํ™”๋ฉด์—์„œ ํƒœ๊ทธ๋กœ ์น˜ํ™˜๋˜์–ด ์‹คํ–‰๋œ๋‹ค. :to ์†์„ฑ path: ์ด๋™ํ•˜๋ ค๋Š” ๊ฒฝ๋กœ name: ์ด๋™ํ•˜๋ ค๋Š” ๊ฒฝ๋กœ๋ฅผ ๋ผ์šฐํ„ฐ์— ์„ค์ •๋œ ์ด๋ฆ„์œผ๋กœ ์ง€์ • query: query string ํ˜•ํƒœ๋กœ ์ „๋‹ฌ๋˜๋Š” ํŒŒ๋ผ๋ฏธํ„ฐ, GET ๋ฐฉ์‹ params: name ์†์„ฑ์„ ์ง€์ •ํ•˜์—ฌ ์ด๋™ํ•  ๋•Œ(path๊ฐ€ ์•„๋‹Œ) ์ „๋‹ฌ๋  ํŒŒ๋ผ๋ฏธํ„ฐ, POST ๋ฐฉ์‹ query vs. params ๐Ÿง params๋ฅผ ์‚ฌ์šฉํ•˜๋ ค๋ฉด path๊ฐ€ ์•„๋‹Œ name์œผ๋กœ ์ด๋™.. 2022. 6. 14.
LeetCode - Missing Number https://leetcode.com/problems/missing-number/ Missing Number - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com ์กฐ๊ฑด n == nums.length ์ด๊ณ  nums์˜ ๋ชจ๋“  ์ˆซ์ž๋Š” ์ค‘๋ณต์ด ์—†๋‹ค. nums ๋ฐฐ์—ด์˜ ๊ฐ’์€ 0 a+b, 0); return (nums.length) * (nums.length + 1) / 2 - sum; }; ๊ฐœ์„  ์ฝ”๋“œ 2 - ๋น„ํŠธ XOR์€ ๊ฐ’์ด ๋‘ ๋ฒˆ ์ ์šฉ๋˜๋ฉด ์ดˆ๊ธฐ ๊ฐ’์œผ๋กœ ๋Œ์•„์˜จ๋‹ค. - ์ˆœ์„œ๊ฐ€ .. 2022. 5. 30.
git branch ๋”ฐ์„œ ๊ฐœ๋ฐœํ•˜๊ธฐ / ์ถฉ๋Œ ๋Œ€์ฒ˜ํ•˜๊ธฐ git ์‚ฌ์šฉํ•˜๊ธฐ ๊ฐœ๋ฐœ ์‹œ ํ˜•์ƒ๊ด€๋ฆฌ๋กœ git์„ ์‚ฌ์šฉํ•œ๋‹ค๋ฉด ๊ธฐ๋Šฅ ๋ณ„๋กœ branch๋ฅผ ๋”ฐ์„œ ๊ฐœ๋ฐœ ํ›„ ์›๋ณธ ์†Œ์Šค์— mergeํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ์‚ฌ์šฉํ•œ๋‹ค. vscode์— git scm์„ ์„ค์น˜ํ•˜์—ฌ ๋ช…๋ น์–ด ๊ธฐ๋ฐ˜์œผ๋กœ git branch ๊ด€๋ จ ๋ช…๋ น์–ด๋ฅผ ๋‹ค๋ฃจ์–ด๋ดค๋‹ค. git branch ๋”ฐ์„œ ๊ฐœ๋ฐœํ•˜๊ณ  ์ถฉ๋Œ ๋Œ€์ฒ˜ํ•˜๊ธฐ ๐Ÿ“Œbranch ์ƒ์„ฑ git branch [๋งŒ๋“ค๋ธŒ๋žœ์น˜๋ช…] [๋ถ„๊ธฐํ• ๋ธŒ๋žœ์น˜๋ช…] ๐Ÿ“Œ๋‹ค๋ฅธ branch ์†Œ์Šค pull ๋ฐ›๊ธฐ git pull origin [๋‹ค๋ฅธ๋ธŒ๋žœ์น˜๋ช…] 1. ์—ฌ๊ธฐ์„œ ์ถฉ๋Œ ๋ฐœ์ƒ ์‹œ ํ˜„์žฌ branch ์ˆ˜์ •ํ•œ ํŒŒ์ผ์„ ๋จผ์ € commit & push ํ•œ๋‹ค.(ํ˜„์žฌ branch์— ์˜ฌ๋ฆฐ๋‹ค.) 2. ๋‹ค์‹œ ์œ„ ๋ช…๋ น์–ด๋กœ ๋‹ค๋ฅธ branch๋ฅผ pull ๋ฐ›์œผ๋ฉด Automatic Merge Failed ๋˜๋ฉฐ ์ถฉ๋Œ๋‚œ ํŒŒ์ผ๊ณผ ํŒŒ์ผ ๋‚ด ์ถฉ๋Œ ์œ„.. 2022. 5. 20.
Object.freeze ๊ฐ์ฒด ๋™๊ฒฐ / ๊ฐ์ฒด ์ฝ๊ธฐ ์†๋„ Object.freeze() ๊ฐ์ฒด์— ์ƒˆ๋กœ์šด ์†์„ฑ์„ ์ถ”๊ฐ€ํ•˜๊ฑฐ๋‚˜ ์ œ๊ฑฐํ•  ์ˆ˜ ์—†๋Š” ์ƒํƒœ๋กœ ๋ฐ”๊พธ์–ด immutableํ•œ Object๋ฅผ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋‹ค. ํ”„๋กœํ† ํƒ€์ž… ๊ฐ์ฒด๋ฅผ ๋™๊ฒฐํ•˜๋Š” ํ•จ์ˆ˜ ๋™๊ฒฐ๋œ ๊ฐ์ฒด๋Š” ์†์„ฑ์„ ์ถ”๊ฐ€, ์‚ญ์ œํ•˜๋Š” ๋“ฑ ๋ณ€๊ฒฝ ๋ถˆ๊ฐ€ ๊ฐ์ฒด๋ฅผ ๋ณ€๊ฒฝํ•˜๋ ค๋Š” ์‹œ๋„ ์‹œ TypeError ์˜ˆ์™ธ ๋ฐœ์ƒ ๊ฐ์ฒด์˜ ๋ถˆ๋ณ€์„ฑ ์œ ์ง€ ์–•์€ ๋ณต์‚ฌ(1 depth๊นŒ์ง€๋งŒ)๋ฅผ ํ•˜๋ฏ€๋กœ ์ค‘์ฒฉ๋œ ๊ฐ์ฒด๋Š” ๋™๊ฒฐ๋˜์ง€ ์•Š์Œ Object.isFrozen() ๋ฉ”์†Œ๋“œ๋กœ ๊ฐ์ฒด ๋™๊ฒฐ ์—ฌ๋ถ€ ํ™•์ธ ๊ฐ€๋Šฅ const info = { name: 'Anna', age: 19 }; Object.freeze(info); info.age = 20; // ๋ณ€๊ฒฝ๋˜์ง€ ์•Š์Œ info.email = 'hello@gmail.com'; // ์ถ”๊ฐ€๋˜์ง€ ์•Š์Œ const vs. Object.freeze.. 2022. 5. 12.
ES6 Syntax ๋ชฉ์ฐจ Restructing(๊ตฌ์กฐ ๋ถ„ํ•ด ํ• ๋‹น) Spread Operator(์ „๊ฐœ ๊ตฌ๋ฌธ) Default Parameters(๊ธฐ๋ณธ ๊ฐ’ ๋งค๊ฐœ๋ณ€์ˆ˜) Template Literal(ํ…œํ”Œ๋ฆฟ ๋ฆฌํ„ฐ๋Ÿด) Arrow Function(ํ™”์‚ดํ‘œ ํ•จ์ˆ˜) for of ... loop 1. Restructuring(๊ตฌ์กฐ ๋ถ„ํ•ด ํ• ๋‹น) ๋ฐฐ์—ด์ด๋‚˜ ๊ฐ์ฒด์˜ ์†์„ฑ์„ ํ•ด์ฒดํ•˜์—ฌ ๊ทธ ๊ฐ’์„ ๊ฐœ๋ณ„ ๋ณ€์ˆ˜์— ๋‹ด์„ ์ˆ˜ ์žˆ๊ฒŒ ํ•˜๋Š” ํ‘œํ˜„์‹ 1-1. ๊ฐ์ฒด โœ” ๊ตฌ๋ฌธ ES5 ์—์„œ๋Š” ๊ฐ ๋ณ€์ˆ˜์— ๊ฐ’์„ ํ• ๋‹นํ•ด์•ผ ํ–ˆ๋‹ค. var info = { myName: 'Anna', myAge: 10 }; var myName = info.myName; var myAge = info.myAge; console.log(myName, myAge);// Anna 10 ES6 ์—์„œ๋Š” ์ค‘๊ด„ํ˜ธ ์•ˆ์—.. 2022. 5. 3.
ํด๋ผ์šฐ๋“œ ์ปดํ“จํŒ…๊ณผ IaaS/PaaS/SaaS 2022. 5. 1.
TypeScript TypeScript ๋ž€? Javascript ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•˜์—ฌ ์ •์  ํƒ€์ž… ๋ฌธ๋ฒ•์„ ์ถ”๊ฐ€ํ•œ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด JavaScript ์˜ ์ƒ์œ„ ์ง‘ํ•ฉ์œผ๋กœ Microsoft ์—์„œ ๊ฐœ๋ฐœํ–ˆ๋‹ค. ๋”ฐ๋ผ์„œ JavaScript์˜ ๋ชจ๋“  ๊ธฐ๋Šฅ์„ TypeScript ์—์„œ๋„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. ES6 ์‹ ๊ทœ ๋ฌธ๋ฒ•์„ ํฌํ•จํ•˜๊ณ  ํด๋ž˜์Šค, ์ธํ„ฐํŽ˜์ด์Šค, ์ƒ์†, ๋ชจ๋“ˆ ๋“ฑ์˜ ๊ฐ์ฒด ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ํŒจํ„ด์„ ์ œ๊ณตํ•œ๋‹ค. TypeScript ์ปดํŒŒ์ผ๋Ÿฌ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ TypeScript(.ts) ํŒŒ์ผ์„ Javascript(.js) ํŒŒ์ผ๋กœ ๋ณ€ํ™˜ํ•˜์—ฌ ์‹คํ–‰ํ•œ๋‹ค. TypeScript vs. JavaScript ๐Ÿง ์†๋„, ์•ˆ์ •์„ฑ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋Š” ๋™์  ํƒ€์ž… ์–ธ์–ด๋กœ ๋Ÿฐํƒ€์ž„ ์†๋„๋Š” ๋น ๋ฅด์ง€๋งŒ, ํƒ€์ž… ์•ˆ์ •์„ฑ์€ ๋ณด์žฅ๋˜์ง€ ์•Š๋Š”๋‹ค. ํƒ€์ž…์Šคํฌ๋ฆฝํŠธ๋Š” ์ •์  ํƒ€์ž… ์–ธ์–ด๋กœ ์ปดํŒŒ์ผ ์‹œ๊ฐ„์ด ๊ธธ์ง€๋งŒ, ์•ˆ์ •.. 2022. 4. 28.
์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ๋น„๋™๊ธฐ ์ฒ˜๋ฆฌ / Promise / async / await / fetch ๋น„๋™๊ธฐ ์ฒ˜๋ฆฌ ๊ตฌ์กฐ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋Š” ์›๋ž˜ ์‹ฑ๊ธ€ ์Šค๋ ˆ๋“œ ๊ธฐ๋ฐ˜ ์–ธ์–ด์ด๋ฉฐ ๋™๊ธฐ์ ์œผ๋กœ ์‹คํ–‰๋œ๋‹ค. ํ˜ธ์ถœ ์Šคํƒ(Call Stack)์ด ํ•˜๋‚˜์—ฌ์„œ ์Šคํƒ ๋‚ด์— ์Œ“์ธ ์ž‘์—…์„ ์ˆœ์„œ๋Œ€๋กœ ์ฒ˜๋ฆฌํ•œ๋‹ค. ํ•˜์ง€๋งŒ, ์‹œ๊ฐ„์ด ์˜ค๋ž˜ ๊ฑธ๋ฆฌ๋Š” ์ฝ”๋“œ๊ฐ€ ์žˆ์œผ๋ฉด ๊ทธ ์ž‘์—…์ด ๋๋‚˜๊ณ  ์ฝœ๋ฐฑํ•  ๋•Œ๊นŒ์ง€ ๊ธฐ๋‹ค๋ ธ๋‹ค๊ฐ€ ๋‹ค์Œ ์ž‘์—…์„ ์ฒ˜๋ฆฌํ•˜๊ฒŒ ๋œ๋‹ค. ๊ทธ ์‹œ๊ฐ„ ๋™์•ˆ์€ ๋Œ€๊ธฐํ•ด์•ผ ํ•˜๋ฏ€๋กœ ๋น„๋™๊ธฐ์ ์œผ๋กœ ์ฒ˜๋ฆฌํ•˜๋Š” ๋ฐฉ๋ฒ•์ด ํ•„์š”ํ•˜๋‹ค. setTimeout() ์œผ๋กœ ์ผ์ • ์‹œ๊ฐ„ ๋™์•ˆ ์ž‘์—…์„ ์ง€์—ฐ์‹œํ‚ค๋Š” ์˜ˆ์‹œ์ด๋‹ค. ์ด ์˜ˆ์ œ๋ฅผ ์‹คํ–‰ํ•˜๋ฉด 3์ดˆ ๋’ค์— '3์ดˆ ์ง€์—ฐ!'์ด๋ผ๋Š” ๋ฌธ๊ตฌ๋ฅผ ์ฐ๋Š”๋‹ค. setTimeout(function() { console.log('3์ดˆ ์ง€์—ฐ!'); }, 3000); ์ง€๊ธˆ์€ 3์ดˆ์งœ๋ฆฌ ์ฝ”๋“œ์ด์ง€๋งŒ, ์„œ๋ฒ„์—์„œ ๋Œ€๋Ÿ‰์˜ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ›์•„์˜ค๋Š” ๋“ฑ์˜ ์ฒ˜๋ฆฌ๊ฐ€ ํ•„์š”ํ•  ๋•Œ๋Š” ๋” ์‹œ๊ฐ„์ด ๊ธธ์–ด์ง€๊ฒŒ ๋œ๋‹ค.. 2022. 4. 20.