JavaScript

[์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ] ๋ฐฐ์—ด(array)์„ ์œ ์šฉํ•˜๊ฒŒ ํ™œ์šฉํ•  ์ˆ˜ ์žˆ๋Š” join ํ•จ์ˆ˜ ๊ฐœ๋… ๋ฐ ์‚ฌ์šฉ๋ฒ•

martinooo 2024. 6. 25. 18:46

 

 

 

๐Ÿคท‍โ™‚๏ธ ๋ณธ๋ก ์— ์•ž์„œ


๋ฐฐ์—ด์€ javascript์—์„œ ๊ฐ€์žฅ ์ค‘์š”ํ•œ ๋ฐ์ดํ„ฐ ์ž๋ฃŒ๊ตฌ์กฐ ์ค‘ ํ•˜๋‚˜์ž…๋‹ˆ๋‹ค.

๋ฐฐ์—ด์— ๋‚ด์žฅํ•จ์ˆ˜๋ฅผ ํ™œ์šฉํ•˜๋Š” ๊ฒƒ์€ javascript์—์„œ ์ค‘์š”ํ•œ ๋ถ€๋ถ„ ์ค‘ ํ•˜๋‚˜์ด๋ฉฐ join() ๋ฐฐ์—ด ๋ฉ”์„œ๋“œ๋Š” ๋ฐฐ์—ด์„ ํ•ฉ์น˜๋Š” ๊ฒƒ์— ๊ฐ€์žฅ ์ค‘์š”ํ•œ ๋‚ด์žฅํ•จ์ˆ˜ ์ค‘ ํ•˜๋‚˜์ž…๋‹ˆ๋‹ค.

join() ๋ฐฐ์—ด ๋ฉ”์„œ๋“œ๋ฅผ ๋” ์ž˜ ํ™œ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

 

๋ฐฐ์—ด(array)์„ ์ฒ˜๋ฆฌํ•˜๋Š” ์ธ๊ธฐ ์žˆ๋Š” ๋ฉ”์„œ๋“œ map(), forEach() ๊ฐœ๋…๊ณผ ์ฐจ์ด์ 

https://cometruedream.tistory.com/253

 

[์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ] ๋ฐฐ์—ด(array)์„ ์ฒ˜๋ฆฌํ•˜๋Š” ์ธ๊ธฐ์žˆ๋Š” ๋ฉ”์†Œ๋“œ map(), forEach() ๊ฐœ๋…๊ณผ ์ฐจ์ด์ 

๐Ÿคท‍โ™‚๏ธ ๋ณธ๋ก ์— ์•ž์„œ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋Š” ํ˜„์žฌ ์›น/์•ฑ ๊ฐœ๋ฐœ ํŠธ๋ Œ๋“œ์—์„œ ํ•„์ˆ˜์ ์œผ๋กœ ์‚ฌ์šฉ๋˜๋Š” ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์ž…๋‹ˆ๋‹ค. ์—ฌ๋Ÿฌ ์•„์ดํ…œ์„ ์ €์žฅํ•˜๋Š”๋ฐ ์‚ฌ์šฉ๋˜๋Š” ๋ฐฐ์—ด๊ณผ ์ด๋ฅผ ํŒŒ์‹ฑํ•˜๋ฉฐ ์ƒˆ๋กœ์šด ๋ฐ์ดํ„ฐ๋ฅผ

cometruedream.tistory.com

 

๐Ÿคท‍โ™‚๏ธ ๋ฐฐ์—ด(array) join() ์ด๋ž€?


์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ๋ฐฐ์—ด ์กฐ์ธ(join)์€ ๋ฐฐ์—ด์˜ ์š”์†Œ๋ฅผ ํ•˜๋‚˜์˜ ๋ฌธ์ž์—ด๋กœ ํ•ฉ์ณ์ค๋‹ˆ๋‹ค.

์ด ๊ธฐ๋Šฅ์€ ๋ฐฐ์—ด ๋‚ด์žฅํ•จ์ˆ˜ ์ค‘ ๊ฐ€์žฅ ์œ ์šฉํ•˜๊ฒŒ ํ™œ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๋ฉ”์„œ๋“œ ์ค‘ ํ•˜๋‚˜์ž…๋‹ˆ๋‹ค.

 

join() ๋ฉ”์„œ๋“œ์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์ดํ•ดํ•˜๋ฉด

๐Ÿ’ก ํ”„๋กœ์ ํŠธ๋ฅผ ์ง„ํ–‰ํ•˜๋‹ค ๋ณด๋ฉด ๋ฐฐ์—ด์˜ ์š”์†Œ๋ฅผ ๋ฌธ์ž์—ด๋กœ ๋งŒ๋“  ๊ฒฐ๊ณผ๋ฅผ ๋ณด์—ฌ์ฃผ๋Š” ์ƒํ™ฉ์ด ์žˆ์Šต๋‹ˆ๋‹ค.
๊ฐ ์š”์†Œ๋ฅผ join() ๋ฉ”์„œ๋“œ๋กœ ๋ฐฐ์—ด์˜ ์š”์†Œ๋ฅผ ๊ตฌ๋ถ„ํ•˜๋Š” ๊ตฌ๋ถ„์ž๋ฅผ ํ™œ์šฉํ•ด์„œ ๋ฐฐ์—ด์˜ ์š”์†Œ๋ฅผ ๋ฌธ์ž์—ด๋กœ ๋งŒ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. 

 

 

 

1. ๋ฐฐ์—ด(array) join() ์˜ˆ์‹œ?

๋ฐฐ์—ด ์กฐ์ธ(join) ๋ฉ”์„œ๋“œ ์˜ˆ์‹œ์ž…๋‹ˆ๋‹ค.

const sports = ['์ถ•๊ตฌ', '์•ผ๊ตฌ', '๋†๊ตฌ'];
const result = sports.join(',');

console.log(result);
// "์ถ•๊ตฌ,์•ผ๊ตฌ,๋†๊ตฌ"

 

์œ„ ์˜ˆ์‹œ์—์„œ sports ๋ฐฐ์—ด์— ์š”์†Œ๋ฅผ join() ๋ฉ”์„œ๋“œ๋ฅผ ํ™œ์šฉํ•ด์„œ ๊ฐ ์š”์†Œ๋ฅผ ๊ตฌ๋ถ„ํ•˜๋Š” ๊ตฌ๋ถ„์ž๋ฅผ ์‰ผํ‘œ๋กœ ์‚ฌ์šฉํ•œ ๋ฌธ์ž์—ด ๊ฒฐ๊ณผ๋ฌผ์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

 

2. ๋ฐฐ์—ด(array) join() ์˜ˆ์‹œ 2?

๋ฐฐ์—ด ์กฐ์ธ(join) ๋ฉ”์„œ๋“œ ์˜ˆ์‹œ 2์ž…๋‹ˆ๋‹ค.

const fruits = ['์ถ•๊ตฌ', '์•ผ๊ตฌ', '๋†๊ตฌ'];
const result = fruits.join(', ');

console.log(result);
// "์ถ•๊ตฌ, ์•ผ๊ตฌ, ๋†๊ตฌ"

 

๊ตฌ๋ถ„์ž ์‰ผํ‘œ, ๊ณต๋ฐฑ์„ ์‚ฌ์šฉํ•œ ๋ฌธ์ž์—ด ๊ฒฐ๊ณผ๋ฌผ์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

๋ณด์‹œ๋Š” ๊ฒƒ์ฒ˜๋Ÿผ ๊ฒฐ๊ณผ๋ฌผ์— ๊ณต๋ฐฑ์ด ์ƒ๊น๋‹ˆ๋‹ค.

 

3. ๋ฐฐ์—ด(array) join() ํ™œ์šฉ๋ฒ•?

split() ํ•จ์ˆ˜๋Š” ๋ฌธ์ž์—ด์„ ๋ฐฐ์—ด๋กœ ๋ถ„ํ• ํ•˜๋Š” ๋ฉ”์„œ๋“œ์ž…๋‹ˆ๋‹ค.

join() ๋ฐฐ์—ด์„ ๋ฌธ์ž์—ด๋กœ ๊ฒฐํ•ฉํ•˜๋Š” ๋ฉ”์„œ๋“œ์ด๋ฉฐ ์ด ๋‘˜์„ ํ™œ์šฉํ•ด์„œ ์›ํ•˜๋Š” ๊ฒฐ๊ณผ๋ฌผ์„ ๋„์ถœํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋˜ํ•œ ์ด ๋‘˜ ๋ฉ”์„œ๋“œ๋Š” ์„œ๋กœ ์ƒํ˜ธ๋ณด์™„์ ์ธ ๊ธฐ๋Šฅ์œผ๋กœ ์ž์ฃผ ๊ฐ™์ด ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.

const url = "https://www.example.com/search?q=javascript+array+join&sort=date";

const queryString = url.split("?")[1];
console.log(queryString)
// q=javascript+array+join&sort=date

const queryParameters = queryString.split("&")[0];
// ['q=javascript+array+join', 'sort=date']

const findQueryQkey = queryParameters.split("=")[1];
const queryKey = findQueryQkey.split('+');
const result = queryKey.join(', ')

console.log(result)
// javascript, array, join

 

์œ„ ์ฝ”๋“œ์—์„œ ์ฃผ์–ด์ง„ url์— ์ฟผ๋ฆฌ์ŠคํŠธ๋ง q์— ๊ฐ’๋“ค์„ ์ฐพ๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค.

url.split("?")[1] url ๊ตฌ๋ถ„์ž? ๊ตฌ๋ถ„ํ•ด์„œ ๋ฌธ์ž์—ด์„ ๋ฐฐ์—ด๋กœ ๋ถ„ํ• ํ•˜๊ณ  ๋ถ„ํ™œ๋œ ๋ฐฐ์—ด์˜ ์ฒซ๋ฒˆ์งธ ์ธ๋ฑ์Šค ์š”์†Œ ๊ฐ’์„ ๊ฐ€์ ธ์˜ต๋‹ˆ๋‹ค.

queryString.split("&") ๊ฐ€์ ธ์˜จ ๊ฐ’์„ ๋‹ค์‹œ & ๊ตฌ๋ถ„์ž๋กœ ๋ฌธ์ž์—ด์„ ๋ฐฐ์—ด๋กœ ๋ถ„ํ™œํ•˜๊ณ  queryParameters.split("=") = ๊ตฌ๋ถ„์ž๋กœ ๋ฌธ์ž์—ด๋กœ ๋ถ„ํ™œํ•˜๊ณ  findQueryQkey.split('+') + ๊ตฌ๋ถ„์ž๋กœ ๋ฌธ์ž์—ด์„ ๋ถ„ํ™œํ•˜๊ณ  queryKey.join(', ') ๋ฐฐ์—ด์„ ํ•ฉ์ณ์„œ ์›ํ•˜๋Š” ๊ฐ’์„ ๋„์ถœํ–ˆ์Šต๋‹ˆ๋‹ค.

์œ„์— ์˜ˆ์ œ์ฒ˜๋Ÿผ split(), join() ๋ฉ”์„œ๋“œ๋ฅผ ํ™œ์šฉํ•ด์„œ ์›ํ•˜๋Š” ๊ฒฐ๊ณผ๊ฐ’์„ ๋„์ถœํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

 

JavaScript [์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ] ํ™œ์šฉ๊ฐ€์น˜๊ฐ€ ์ข‹์€ ๋‚ด์žฅํ•จ์ˆ˜์™€ every(), some() ํ•จ์ˆ˜์˜ ๊ฐœ๋… ๋ฐ ํ™œ์šฉ๋ฒ•

https://cometruedream.tistory.com/250

 

[์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ] ํ™œ์šฉ๊ฐ€์น˜๊ฐ€ ์ข‹์€ ๋‚ด์žฅํ•จ์ˆ˜์™€ every(), some() ํ•จ์ˆ˜์˜ ๊ฐœ๋… ๋ฐ ํ™œ์šฉ๋ฒ•

๐Ÿคท‍โ™‚๏ธ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ๋‚ด์žฅ ํ•จ์ˆ˜๋ž€?์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋ฅผ ํšจ์œจ์ ์œผ๋กœ ํ™œ์šฉํ•˜๋ ค๋ฉด ๋‚ด์žฅ ํ•จ์ˆ˜๋ฅผ ์ž˜ ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.๋‚ด์žฅ ํ•จ์ˆ˜๋Š” ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ์—์„œ ๋ฏธ๋ฆฌ ์„ ์–ธ๋œ ํ•จ์ˆ˜๋กœ, ํ˜ธ์ถœ๋งŒ์œผ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต

cometruedream.tistory.com

 


 

์žฌ๋ฐŒ๋Š” ์˜ค๋Š˜์˜ ๋ ๋ณ„ ์šด์„ธ ๋ณด๊ณ  ๊ฐ€์„ธ์š”! 

 

 

https://cometruedream.tistory.com/247

 

[React] Tailwind ํ•œ์ค„, ๋‘์ค„, ์„ธ์ค„ ํšจ๊ณผ className ์ปค์Šคํ…€

๐Ÿคท‍โ™‚๏ธ Tailwind ํ•œ์ค„, ๋‘์ค„, ์„ธ์ค„ ํšจ๊ณผํ”„๋กœ์ ํŠธ ์ง„ํ–‰์ค‘ ๋ฐฐ๋„ˆ ๋งํฌ์— URL ๊ธธ์ด๊ฐ€ ๋„ˆ๋ฌด ๊ธธ์–ด์„œ 3์ค„ ํšจ๊ณผ ์ฒ˜๋ฆฌ๋ฅผ ํ•ด์•ผ ํ–ˆ์Šต๋‹ˆ๋‹ค. React + Tailwind CSS ์…‹ํŒ…๋œ ํ”„๋กœ์ ํŠธ ์—ฌ์„œ CSS ํŒŒ์ผ & style ํƒœ๊ทธ๋ฅผ ์‚ฌ์šฉํ•˜

cometruedream.tistory.com

 

 

https://cometruedream.tistory.com/243

 

NestJS Lifecycle (์ƒ๋ช…์ฃผ๊ธฐ) ๊ฐœ๋…

๐Ÿคท‍โ™‚๏ธ ๋ณธ๋ก ์— ์•ž์„œ Nest JS ๊ฐœ๋…?Nest JS๋Š” Node JS ๊ธฐ๋ฐ˜์œผ๋กœ ํ•œ ์„œ๋ฒ„ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ํ”„๋ ˆ์ž„์›Œํฌ ์ž…๋‹ˆ๋‹ค. ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋Š” ์ƒ๋‹นํžˆ ์˜ค๋žซ๋™์•ˆ Express ๊ธฐ๋ฐ˜์œผ๋กœ ์„œ๋ฒ„ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ฐœ๋ฐœ์—์„œ ์••๋„์ ์ธ ์ 

cometruedream.tistory.com

 

 

https://cometruedream.tistory.com/242

 

๋ฆฌ์•กํŠธ Vite Proxy ํ™œ์šฉํ•œ CORS ์˜ค๋ฅ˜ ํ•ด๊ฒฐ

๐Ÿคท‍โ™‚๏ธ ๋ณธ๋ก ์— ์•ž์„œํ”„๋ก ํŠธ์—”๋“œ ๋ฒˆ๋“ค๋Ÿฌ ๊ฐœ๋…๊ณผ webpack vs vite ๋น„๊ต์— ๋Œ€ํ•ด์„œ ๊ณต๋ถ€๋ฅผ ํ•˜๊ณ  ๊ธ€์„ ๋ณด์‹œ๋ฉด ๋” ๋งŽ์€ ๋„์›€์ด ๋ฉ๋‹ˆ๋‹ค^^ํ”„๋ก ํŠธ์—”๋“œ ๊ฐœ๋ฐœ์„ ์œ„ํ•œ ๋ฒˆ๋“ค๋Ÿฌ ๊ฐœ๋…๊ณผ webpack vs vite ๋น„๊ตhttps://comet

cometruedream.tistory.com

 

 

https://cometruedream.tistory.com/241

 

React ํด๋”๊ตฌ์กฐ FSD ๊ธฐ๋Šฅ ๋ถ„ํ™œ ์„ค๊ณ„ ์•„ํ‚คํ…์ฒ˜

๐Ÿคท‍โ™‚๏ธ ๋ณธ๋ก ์— ์•ž์„œํ”„๋กœ์ ํŠธ๋ฅผ ์‹œ์ž‘ํ•˜๊ธฐ์— ์•ž์„œ ํด๋” ๊ตฌ์กฐ, ์„ค๊ณ„์— ๋Œ€ํ•œ ์•„ํ‚คํ…์ฒ˜๋ฅผ ๋งŒ๋“œ๋Š” ๊ฒƒ์€ ์ƒ๋‹นํžˆ ์–ด๋ ต๋‹ค. ์ด๋ฒˆ ํ”„๋กœ์ ํŠธ์— React FSD ํด๋”๊ตฌ์กฐ ์•„ํ‚คํ…์ฒ˜๋ฅผ ์„ค๊ณ„ํ•  ์˜ˆ์ •์ด๋ผ์„œ FSD ์•„ํ‚คํ…

cometruedream.tistory.com

 

 

https://cometruedream.tistory.com/244

 

์‰ฝ๊ฒŒ ์ดํ•ดํ•˜๊ณ  ์‚ฌ์šฉํ• ์ˆ˜ ์žˆ๋Š” Prisma ๋ช…๋ น์–ด ์ •๋ฆฌ

๐Ÿคท‍โ™‚๏ธ Prisma ๋ช…๋ น์–ด ๋ณธ๋ก ์— ์•ž์„œ Prisma๋ž€?Nest JS ํ”„๋ ˆ์ž„์›Œํฌ์™€ Prisma ORM์„ ํ™œ์šฉํ•ด์„œ ํ”„๋กœ์ ํŠธ๋ฅผ ์ง„ํ–‰ํ•˜๋ฉด์„œ Prisma๋Š” Node JS ๊ธฐ๋ฐ˜์— ํ”„๋ ˆ์ž„์›Œํฌ/๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์™€ ์ƒํ˜ธ์ž‘์šฉ์ด ์ž˜๋˜๋ฉฐ Prisma + DB ์—ฐ๋™์œผ

cometruedream.tistory.com