<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>Just-gomin.log</title>
        <link>https://velog.io/</link>
        <description>고민은 고민일 뿐. 고민 말고 그냥 고.</description>
        <lastBuildDate>Sat, 11 Nov 2023 11:32:32 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <image>
            <title>Just-gomin.log</title>
            <url>https://velog.velcdn.com/images/just_gomin/profile/85ba9d93-8600-4e16-a03a-0aefab4d3caf/social_profile.png</url>
            <link>https://velog.io/</link>
        </image>
        <copyright>Copyright (C) 2019. Just-gomin.log. All rights reserved.</copyright>
        <atom:link href="https://v2.velog.io/rss/just_gomin" rel="self" type="application/rss+xml"/>
        <item>
            <title><![CDATA[psql command not found 해결하기(2023.11.11)]]></title>
            <link>https://velog.io/@just_gomin/psql-command-not-found-%ED%95%B4%EA%B2%B0%ED%95%98%EA%B8%B02023.11.11</link>
            <guid>https://velog.io/@just_gomin/psql-command-not-found-%ED%95%B4%EA%B2%B0%ED%95%98%EA%B8%B02023.11.11</guid>
            <pubDate>Sat, 11 Nov 2023 11:32:32 GMT</pubDate>
            <description><![CDATA[<p><img src="https://velog.velcdn.com/images/just_gomin/post/ab4c8111-8947-4546-8dd8-a4d25cfac51c/image.svg" alt=""></p>
<h1 id="💡-psql-command-not-found">💡 &#39;psql&#39; command not found</h1>
<h2 id="📌-문제-상황-인지">📌 문제 상황 인지</h2>
<p>Postgres.app의 업그레이드(to ver.2.6.8) 이 후 잘 사용하던 <code>psql</code> 명령어를 찾지 못하겠다고 한다.</p>
<p><img src="https://velog.velcdn.com/images/just_gomin/post/28d8a0c5-648d-4657-9085-aa434cccf34e/image.png" alt=""></p>
<p>으레 그렇듯 <code>경로 문제</code>겠거니 했다.</p>
<h2 id="📌-원인을-찾자">📌 원인을 찾자</h2>
<p><code>~/.zshrc</code>에는 기존 경로는 다음과 같이 설정 했었다.</p>
<pre><code>export PATH=&quot;/Applications/Postgres.app/Contents/Versions/latest/bin:$PATH&quot;</code></pre><p>또한 <code>Postgres.app</code> 의 <code>Server Settings</code> 을 통해서도 알 수 있다.</p>
<p><img src="https://velog.velcdn.com/images/just_gomin/post/03c61154-654f-4e2b-9318-e2c29224c4ae/image.png" alt=""></p>
<p>Version에서 변경이 된 것 같아 <code>/Applications/Postgres.app/Contents/Versions</code>로 이동해봤다.</p>
<p>해당 경로에는 기존 PostgreSQL 버전인 <code>15</code> 경로만 남아있었다.</p>
<p><img src="https://velog.velcdn.com/images/just_gomin/post/4da63897-da78-405b-aa20-d1cb1f123810/image.png" alt=""></p>
<p>현재 PostgreSQL의 최신 버전이 <code>16</code>버전이기 때문에 이런 문제가 발생한 것 같다.</p>
<h2 id="📌-해결-하기">📌 해결 하기</h2>
<p>15버전 경로를 <code>~/.zshrc</code>에 추가해줬다.</p>
<pre><code>export PATH=&quot;/Applications/Postgres.app/Contents/Versions/15/bin:$PATH&quot; # PostgreSQL ver.15
</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[JavaScript Array 알아보기 - 순회]]></title>
            <link>https://velog.io/@just_gomin/JavaScript-Array-%EC%95%8C%EC%95%84%EB%B3%B4%EA%B8%B0-%EC%88%9C%ED%9A%8C</link>
            <guid>https://velog.io/@just_gomin/JavaScript-Array-%EC%95%8C%EC%95%84%EB%B3%B4%EA%B8%B0-%EC%88%9C%ED%9A%8C</guid>
            <pubDate>Tue, 31 Oct 2023 14:17:03 GMT</pubDate>
            <description><![CDATA[<p><img src="https://velog.velcdn.com/images/just_gomin/post/a4f9dd87-8edb-4d93-8098-193ab034f5bc/image.svg" alt=""></p>
<h1 id="💡-array-순회-하기">💡 Array 순회 하기</h1>
<h2 id="📌-순회">📌 순회</h2>
<p>순회란 데이터를 하나 하나 살펴보는 것을 의미 합니다.</p>
<p>단순히 조회만 해볼 수도 있고, 하나 하나 살펴보며 데이터를 조작하기도 합니다.</p>
<h2 id="📌-array-순회-방법">📌 Array 순회 방법</h2>
<p>코드 상에서 사용할 변수는 다음과 같습니다.</p>
<pre><code class="language-javascript">let sampleArr = [1,2,3,4,5,6,7,8,9,10];</code></pre>
<h3 id="👉-for-문">👉 <code>for</code> 문</h3>
<pre><code class="language-javascript">for (let index = 0; index &lt; sampleArr.length; index++) {
    sampleArr[index].value += 2; // index: [INDEX], sampleArr[index]: [VALUE]
}
// sampleArr: [3,4,5,6,7,8,9,10,11,12];</code></pre>
<h3 id="👉-forof-문을-사용한-순회">👉 for...of 문을 사용한 순회</h3>
<pre><code class="language-javascript">for (const sample of sampleArr) {
    sample.value += 2;
}
// sampleArr: [3,4,5,6,7,8,9,10,11,12];</code></pre>
<p><code>for...of</code> 문은 배열의 원소를 하나 하나 반환합니다.</p>
<h3 id="👉-forin-문을-사용한-순회">👉 for...in 문을 사용한 순회</h3>
<pre><code class="language-javascript">for (const property in sampleArr) {
    sampleArr[property].value += 2; // property: [INDEX], sampleArr[property]: sampleClass { value: [VALUE] }
}
// sampleArr: [3,4,5,6,7,8,9,10,11,12];</code></pre>
<p><code>for...in</code> 문은 배열 객체의 키를 반환합니다. 원소 자체를 반환하는 것이 아니기 때문에 유의해서 사용해야합니다.</p>
<h3 id="👉-while-문">👉 <code>while</code> 문</h3>
<pre><code class="language-javascript">let whileIndex = 0;
while (whileIndex &lt; sampleArr.length) {
    sampleArr[whileIndex].value += 2; // whileIndex: [whileINDEX], sampleArr[whileIndex]: [VALUE]
    whileIndex++;
}
// sampleArr: [3,4,5,6,7,8,9,10,11,12];</code></pre>
<h3 id="👉-dowhile-문">👉 <code>do...while</code> 문</h3>
<pre><code class="language-javascript">let doWhileIndex = 0;
do {
    sampleArr[doWhileIndex].value += 2; // doWhileIndex: [Index], sampleArr[doWhileIndex]: [VALUE]
    doWhileIndex++;
} while (doWhileIndex &lt; sampleArr.length);
// sampleArr: [3,4,5,6,7,8,9,10,11,12];</code></pre>
<p><code>do...while</code> 문을 이용한 순회는 무조건 한번은 수행합니다.</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[JavaScript Array 알아보기 - 스택 & 큐로 사용하기]]></title>
            <link>https://velog.io/@just_gomin/JavaScript-Array-%EC%95%8C%EC%95%84%EB%B3%B4%EA%B8%B0-%EC%8A%A4%ED%83%9D-%ED%81%90%EB%A1%9C-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0</link>
            <guid>https://velog.io/@just_gomin/JavaScript-Array-%EC%95%8C%EC%95%84%EB%B3%B4%EA%B8%B0-%EC%8A%A4%ED%83%9D-%ED%81%90%EB%A1%9C-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0</guid>
            <pubDate>Tue, 31 Oct 2023 14:16:20 GMT</pubDate>
            <description><![CDATA[<p><img src="https://velog.velcdn.com/images/just_gomin/post/a3c8c179-e396-4303-ac2f-1a529788ac3c/image.svg" alt=""></p>
<h1 id="💡-array-stack--queue-로-사용하기">💡 Array stack &amp; queue 로 사용하기</h1>
<h2 id="📌-stack-with-js-array">📌 Stack With JS Array</h2>
<p><code>Stack</code> 은 <code>Last In First Out</code> 의 특징을 지닌 자료구조로 가장 마지막에 추가된 데이터가 가장 먼저 반출됩니다.</p>
<p>Stack에는 두 가지 주요 기능이 있는데, 데이터를 입력하는 기능인 <code>PUSH</code>와 데이터를 출력하는 기능인 <code>POP</code>입니다.</p>
<p>JS의 Array를 이용해 <code>PUSH</code>와 <code>POP</code>을 다루는 것은 Array의 메소드를 이용한 두 가지 조합이 가능합니다.</p>
<ol>
<li><code>push</code> 와 <code>pop</code>을 사용하는 조합 =&gt; 배열의 끝에서 데이터의 입출이 진행됩니다.</li>
<li><code>unshift</code>와 <code>shift</code>를 사용하는 조합 =&gt; 배열의 앞에서 데이터의 입출이 진행됩니다.</li>
</ol>
</br>

<h3 id="👉-push--pop">👉 <code>push</code> &amp; <code>pop</code></h3>
<pre><code class="language-javascript">const stack = [];

console.log(&quot;PUSH ------------------------------&quot;);
for (let i = 1; i &lt;= 5; i++) {
    console.log(i);
    stack.push(i);
}

console.log(&quot;POP ------------------------------&quot;);
for (let i = 1; i &lt;= 5; i++) {
    let popped = stack.pop();
    console.log(popped);
}

/*
    OUTPUT
    PUSH ------------------------------
    1
    2
    3
    4
    5
    POP ------------------------------
    5
    4
    3
    2
    1
*/</code></pre>
</br>

<h3 id="👉-unshift와shift">👉 unshift<code>와</code>shift`</h3>
<pre><code class="language-javascript">const stack = [];

console.log(&quot;PUSH ------------------------------&quot;);
for (let i = 1; i &lt;= 5; i++) {
    console.log(i);
    stack.unshift(i);
}

console.log(&quot;POP ------------------------------&quot;);
for (let i = 1; i &lt;= 5; i++) {
    let popped = stack.shift();
    console.log(popped);
}</code></pre>
</br>

<h2 id="📌-queue-with-js-array">📌 Queue With JS Array</h2>
<p><code>Queue</code> 는 <code>First In First Out</code> 의 특징을 갖는 자료구조로 가장 처음에 들어온 데이터가 가장 처음으로 반출됩니다.</p>
<p>Queue에는 두 가지 주요 기능이 있는데, 데이터를 입력하는 기능인 <code>Enqueue</code>와 데이터를 출력하는 기능인 <code>Dequeue</code>입니다.</p>
<p>JS의 Array를 이용해 <code>Enqueue</code>와 <code>Dequeue</code>를 다루는 것은, Stack에서와 마찬가지로 2가지의 조합이 가능합니다.</p>
<ol>
<li><code>push</code> 와 <code>shift</code>를 사용하는 조합 =&gt; 데이터의 입력은 배열의 끝에서, 데이터의 출력은 배열의 앞에서 진행됩니다.</li>
<li><code>unshift</code> 와 <code>pop</code>을 사용하는 조합 =&gt; 데이터의 입력은 배열의 앞에서, 데이터의 출력은 배열의 뒤에서 진행됩니다.</li>
</ol>
</br>

<h3 id="👉-push--shift">👉 <code>push</code> &amp; <code>shift</code></h3>
<pre><code class="language-javascript">const queue = [];

console.log(&quot;Enqueue ------------------------------&quot;);
for (let i = 1; i &lt;= 5; i++) {
    console.log(i);
    queue.push(i);
}

console.log(&quot;Dequeue ------------------------------&quot;);
for (let i = 1; i &lt;= 5; i++) {
    let dequeued = queue.shift();
    console.log(dequeued);
}

/*
    OUTPUT
    Enqueue ------------------------------
    1
    2
    3
    4
    5
    Dequeue ------------------------------
    1
    2
    3
    4
    5
*/</code></pre>
</br>

<h3 id="👉-unshift--pop">👉 <code>unshift</code> &amp; <code>pop</code></h3>
<pre><code class="language-javascript">const queue = [];

console.log(&quot;Enqueue ------------------------------&quot;);
for (let i = 1; i &lt;= 5; i++) {
    console.log(i);
    queue.unshift(i);
}

console.log(&quot;Dequeue ------------------------------&quot;);
for (let i = 1; i &lt;= 5; i++) {
    let dequeued = queue.pop();
    console.log(dequeued);
}

/*
    OUTPUT
    Enqueue ------------------------------
    1
    2
    3
    4
    5
    Dequeue ------------------------------
    1
    2
    3
    4
    5
*/</code></pre>
]]></description>
        </item>
        <item>
            <title><![CDATA[JavaScript Array 알아보기 - Sort & Filter]]></title>
            <link>https://velog.io/@just_gomin/JavaScript-Array-%EC%95%8C%EC%95%84%EB%B3%B4%EA%B8%B0-Sort-Filter</link>
            <guid>https://velog.io/@just_gomin/JavaScript-Array-%EC%95%8C%EC%95%84%EB%B3%B4%EA%B8%B0-Sort-Filter</guid>
            <pubDate>Tue, 31 Oct 2023 14:14:53 GMT</pubDate>
            <description><![CDATA[<p><img src="https://velog.velcdn.com/images/just_gomin/post/dcabf177-4219-48e9-a8d1-f9f2b63bd834/image.svg" alt=""></p>
<h1 id="💡-array-sort--filter">💡 Array sort &amp; filter</h1>
<h2 id="📌-arrayprototypesort">📌 Array.prototype.sort</h2>
<p>배열 내의 원소를 정렬 시키는 함수 입니다.</p>
<p>정렬된 <strong>새로운 배열을 반환하는 것이 아닌, 원본 배열을 정렬</strong> 시키는 함수 입니다.</p>
</br>

<h2 id="📌-arrayprototypesortcomparefunction">📌 Array.prototype.sort([compareFunction])</h2>
<pre><code class="language-typescript">// file: typescript/lib/lib.es5.d.ts
interface Array&lt;T&gt; {
    ...

    /**
     * Sorts an array in place.
     * This method mutates the array and returns a reference to the same array.
     * @param compareFn Function used to determine the order of the elements. It is expected to return
     * a negative value if the first argument is less than the second argument, zero if they&#39;re equal, and a positive
     * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order.
     * ```ts
     * [11,2,22,1].sort((a, b) =&gt; a - b)
     * ```
     */
    sort(compareFn?: (a: T, b: T) =&gt; number): this;

    ...
}</code></pre>
<p><code>compareFunction</code>은 두 개의 인자를 받아 서로 비교해 순서를 정하는 함수로,</br>
일관성 있게 <code>0보다 작은 수</code>, <code>0</code>, <code>0보다 큰 수</code> 중 하나를 반환 해야합니다.</p>
</br>

<h3 id="👉-comparefunction이-주어지지-않은-경우">👉 compareFunction이 주어지지 않은 경우</h3>
<p>원소를 <code>문자열 변환</code> 시켜, 문자열 유니코드를 오름차순으로 정렬시킵니다.</p>
<pre><code class="language-javascript">    [10, 9, 8, 7, 6, 5, 4, 3, 2, 1].sort(); // [1, 10, 2, 3, 4, 5, 6, 7, 8, 9]
    [&#39;하&#39;, &#39;파&#39;, &#39;타&#39;, &#39;카&#39;, &#39;차&#39;, &#39;자&#39;, &#39;아&#39;, &#39;사&#39;, &#39;바&#39;, &#39;마&#39;, &#39;라&#39;, &#39;다&#39;, &#39;나&#39;, &#39;가&#39;].sort();
    // [&#39;가&#39;, &#39;나&#39;, &#39;다&#39;,&#39;라&#39;, &#39;마&#39;, &#39;바&#39;,&#39;사&#39;, &#39;아&#39;, &#39;자&#39;,&#39;차&#39;, &#39;카&#39;, &#39;타&#39;,&#39;파&#39;, &#39;하&#39;]</code></pre>
</br>

<h3 id="👉-comparefunction이-주어진-경우">👉 compareFunction이 주어진 경우</h3>
<ul>
<li>compareFunction(a, b) &gt; 0 : a가 b보다 먼저 위치합니다.</li>
<li>compareFunction(a, b) = 0 : a와 b의 순서가 바뀌지 않습니다.</li>
<li>compareFunction(a, b) &lt; 0 : b가 a보다 먼저 위치합니다.</li>
</ul>
</br>

<pre><code class="language-javascript">[10, 9, 8, 7, 6, 5, 4, 3, 2, 1].sort((a, b) =&gt; a - b); // [1, 2, 3, 4,  5, 6, 7, 8, 9, 10]

[&#39;하&#39;, &#39;파&#39;, &#39;타&#39;, &#39;카&#39;, &#39;차&#39;, &#39;자&#39;, &#39;아&#39;, &#39;사&#39;, &#39;바&#39;, &#39;마&#39;, &#39;라&#39;, &#39;다&#39;, &#39;나&#39;, &#39;가&#39;].sort((a, b) =&gt; a &gt; b ? 1 : -1);
// [&#39;가&#39;, &#39;나&#39;, &#39;다&#39;,&#39;라&#39;, &#39;마&#39;, &#39;바&#39;,&#39;사&#39;, &#39;아&#39;, &#39;자&#39;,&#39;차&#39;, &#39;카&#39;, &#39;타&#39;,&#39;파&#39;, &#39;하&#39;]</code></pre>
</br>

<pre><code class="language-javascript">[10, 9, 8, 7, 6, 5, 4, 3, 2, 1].sort((a, b) =&gt; b - a); // [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]

[&#39;하&#39;, &#39;파&#39;, &#39;타&#39;, &#39;카&#39;, &#39;차&#39;, &#39;자&#39;, &#39;아&#39;, &#39;사&#39;, &#39;바&#39;, &#39;마&#39;, &#39;라&#39;, &#39;다&#39;, &#39;나&#39;, &#39;가&#39;].sort((a, b) =&gt; b &gt; a ? 1 : -1);
// [&#39;하&#39;, &#39;파&#39;, &#39;타&#39;, &#39;카&#39;, &#39;차&#39;, &#39;자&#39;, &#39;아&#39;, &#39;사&#39;, &#39;바&#39;, &#39;마&#39;, &#39;라&#39;, &#39;다&#39;, &#39;나&#39;, &#39;가&#39;]</code></pre>
</br>

<p>객체를 정렬하는 예제를 작성 해보겠습니다.</p>
<p>이름을 기준으로 오름차순 정렬을 진행하고, 이름이 같은 경우 가격을 기준으로 오름차순 정렬을 진행하는 예제 입니다.</p>
<pre><code class="language-javascript">let items = [
    { &#39;name&#39;: &#39;d&#39;, price: 121 },
    { &#39;name&#39;: &#39;c&#39;, price: 150 },
    { &#39;name&#39;: &#39;a&#39;, price: 103 },
    { &#39;name&#39;: &#39;a&#39;, price: 107 },
    { &#39;name&#39;: &#39;d&#39;, price: 87 },
    { &#39;name&#39;: &#39;b&#39;, price: 99 },
];

items.sort((a, b) =&gt; {
    if (a.name == b.name) {
        return a.price - b.price;
    }

    return a.name &gt; b.name ? 1 : -1;
}); 
/*
items: [
  { name: &#39;a&#39;, price: 103 },
  { name: &#39;a&#39;, price: 107 },
  { name: &#39;b&#39;, price: 99 },
  { name: &#39;c&#39;, price: 150 },
  { name: &#39;d&#39;, price: 87 },
  { name: &#39;d&#39;, price: 121 }
]
*/
</code></pre>
<h2 id="📌-arrayprototypefilterpredicate">📌 Array.prototype.filter([predicate])</h2>
<pre><code class="language-typescript">// file: typescript/lib/lib.es5.d.ts
interface Array&lt;T&gt; {
    ...

    /**
     * Returns the elements of an array that meet the condition specified in a callback function.
     * @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.
     * @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.
     */
    filter&lt;S extends T&gt;(predicate: (value: T, index: number, array: T[]) =&gt; value is S, thisArg?: any): S[];
    /**
     * Returns the elements of an array that meet the condition specified in a callback function.
     * @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.
     * @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.
     */
    filter(predicate: (value: T, index: number, array: T[]) =&gt; unknown, thisArg?: any): T[];

    ...
}</code></pre>
<p><code>filter</code> 는 주어진 배열의 일부에 대한 얕은 복사본을 생성하고, 인수로 전달된 함수 <code>predicate</code> 에서 통과한 요소들만을 포함 시킵니다.</p>
<p><code>predicate</code> 는 결과 배열에서 원소가 포함 되었으면 하는 경우 <code>true</code>를 반환하고, 포함 되지 않았으면 하는 경우 <code>false</code>를 반환 해야합니다.</p>
<pre><code class="language-javascript">let numberArr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1];

let oddArr = numberArr.filter(function (v, i, arr) {
    return v % 2;
}); // [ 9, 7, 5, 3, 1 ]

let evenArr = numberArr.filter((v, i, arr) =&gt; {
    return v % 2 === 0;
}); // [ 10, 8, 6, 4, 2 ]</code></pre>
]]></description>
        </item>
        <item>
            <title><![CDATA[JavaScript Array 알아보기 - 생성자]]></title>
            <link>https://velog.io/@just_gomin/JavaScript-Array-%EC%95%8C%EC%95%84%EB%B3%B4%EA%B8%B0-%EC%83%9D%EC%84%B1%EC%9E%90</link>
            <guid>https://velog.io/@just_gomin/JavaScript-Array-%EC%95%8C%EC%95%84%EB%B3%B4%EA%B8%B0-%EC%83%9D%EC%84%B1%EC%9E%90</guid>
            <pubDate>Tue, 03 Oct 2023 13:15:40 GMT</pubDate>
            <description><![CDATA[<p><img src="https://velog.velcdn.com/images/just_gomin/post/0d545387-ce14-45e3-9403-ae0ebfc143cb/image.svg" alt=""></p>
<p>새로운 Array를 생성 합니다. Array를 생성할 때는 대괄호(<code>[ ]</code>)를 이용하거나, 생성자를 이용할 수 있습니다.</p>
<h2 id=""><code>[]</code></h2>
<pre><code class="language-javascript">let array = []; // [], length: 0</code></pre>
</br>

<p>대괄호를 이용해 생성한 배열로, 길이 0의 배열이 생성됩니다.</p>
<h2 id="array-constructor">Array() constructor</h2>
<h3 id="arrayconstructor-interface">ArrayConstructor Interface</h3>
</br>

<pre><code class="language-typescript">// file: node_modules/typescript/lib/lib.es5.d.ts
interface ArrayConstructor {
    new (arrayLength?: number): any[];
    new &lt;T&gt;(arrayLength: number): T[];
    new &lt;T&gt;(...items: T[]): T[];
    (arrayLength?: number): any[];
    &lt;T&gt;(arrayLength: number): T[];
    &lt;T&gt;(...items: T[]): T[];
    isArray(arg: any): arg is any[];
    readonly prototype: any[];
}

declare var Array: ArrayConstructor;</code></pre>
</br>

<p>TypeScript에 정의된 Array 생성자 Interface를 참고하면 다음과 같이 정리할 수 있습니다.</p>
<ul>
<li><code>Array()</code> 생성자를 사용할 때 인자로 숫자 1개를 넣는 경우 해당 수를 길이로 갖는 배열을 생성합니다.</li>
<li>1개의 숫자가 아닌 값을 넣는 경우, 해당 값을 포함한 길이 1의 배열을 생성합니다.</li>
<li>1개 이상의 값을 넣는 경우, 해당 값들을 원소로 하는 배열을 생성합니다.</li>
<li><code>new</code> 키워드는 생략 가능 합니다.</li>
</ul>
</br>

<h3 id="code-of-arrayconstructor">Code of ArrayConstructor</h3>
<p>위에서 살펴본 Interface와 특징들을 이용해 실제 코드 상에서 배열을 생성하면 어떤 원소들과 길이를 갖는지 확인해봤습니다.</p>
</br>

<pre><code class="language-javascript">let array;

array = Array(); // [], length: 0

array = new Array(); // [], length: 0

array = Array(10); // [ &lt;10 empty items&gt; ], length: 10

array = new Array(10); // [ &lt;10 empty items&gt; ], length: 10

array = Array(&#39;a&#39;); // [ &#39;a&#39; ], length: 1

array = new Array(&#39;a&#39;); // [ &#39;a&#39; ], length: 1

array = Array(10, 20, 30); // [ 10, 20, 30 ], length: 3

array = new Array(10, 20, 30); // [ 10, 20, 30 ], length: 3

array = Array([10, 20, 30]); // [ [ 10, 20, 30 ] ], length: 1

array = new Array([10, 20, 30]); // [ [ 10, 20, 30 ] ], length: 1

array = Array(...[10, 20, 30]); // [ 10, 20, 30 ], length: 3

array = new Array(...[10, 20, 30]); // [ 10, 20, 30 ], length: 3</code></pre>
<p>위에서 살펴 본대로, 아무것도 주어지지 않은 경우 빈 배열을 생성합니다. 숫자 1개만 주어진 경우 해당 숫자 만큼의 길이를 갖는 배열을 생성합니다. 1개 이상의 데이터가 주어지면 해당 데이터들을 원소로 갖는 배열을 생성합니다.</p>
<h2 id="arrayfrom--arrayof">Array.from() &amp; Array.of()</h2>
<h3 id="arraylike--arrayconstructor-interface">ArrayLike &amp; ArrayConstructor Interface</h3>
<pre><code class="language-typescript">// file: node_modules/typescript/lib/lib.es5.d.ts
interface ArrayLike&lt;T&gt; {
    readonly length: number;
    readonly [n: number]: T;
}</code></pre>
<pre><code class="language-typescript">// file: node_modules/typescript/lib/lib.es2015.iterable.d.ts
interface ArrayConstructor {
    /**
     * Creates an array from an array-like object.
     * @param arrayLike An array-like object to convert to an array.
     */
    from&lt;T&gt;(arrayLike: ArrayLike&lt;T&gt;): T[];

    /**
     * Creates an array from an iterable object.
     * @param arrayLike An array-like object to convert to an array.
     * @param mapfn A mapping function to call on every element of the array.
     * @param thisArg Value of &#39;this&#39; used to invoke the mapfn.
     */
    from&lt;T, U&gt;(arrayLike: ArrayLike&lt;T&gt;, mapfn: (v: T, k: number) =&gt; U, thisArg?: any): U[];

    /**
     * Returns a new array from a set of elements.
     * @param items A set of elements to include in the new array object.
     */
    of&lt;T&gt;(...items: T[]): T[];
}</code></pre>
</br>

<p>TypeScript에 정의된 <code>Array.from</code> &amp; <code>Array.of</code> 생성자 Interface를 참고하면 다음과 같이 정리할 수 있습니다.</p>
</br>

<ul>
<li><code>from</code> 메소드를 이용하면, <code>ArrayLike</code>, 즉 길이 정보와, 인덱스에 대한 값을 갖는 객체를 이용해 배열을 생성할 수 있습니다. 또한, 원소의 각 값마다 생성시에 적용될 함수를 부여해 값 생성을 진행 시킬 수 있습니다.</li>
<li><code>of</code> 메소드를 사용한 생성자는 주어진 인수들을 모두 배열의 원소로 사용합니다.</li>
</ul>
</br>

<h3 id="arrayfrom">Array.from()</h3>
</br>

<p><code>from</code> 메소드를 통해 배열을 생성하는 코드들 입니다.</p>
</br>

<pre><code class="language-javascript">let array;

// array = Array.from(); // TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))

array = Array.from(10); // [], length: 0

array = Array.from([10, 20, 30]); // [ 10, 20, 30 ] , length: 3

array = Array.from({ length: 5 }); // [ undefined, undefined, undefined, undefined, undefined ], length: 5

array = Array.from({ length: 5, 0: 0, 1: 1, 2: 2, 4: 4 }); // [ 0, 1, 2, undefined, 4 ], length: 5

array = Array.from({ length: 5 }, (v, k) =&gt; v); // [ undefined, undefined, undefined, undefined, undefined ], length: 5

array = Array.from({ length: 5 }, (v, k) =&gt; k); // [ 0, 1, 2, 3, 4 ], length: 5

array = Array.from({ length: 5, 0: 0, 1: 1, 2: 2, 3: 3, 4: 4 }, (v, k) =&gt; v + k); // [0, 2, 4, 6, 8], length: 5

array = Array.from([1, 2, 3, 4, 5], (v, k) =&gt; v + k); // [ 1, 3, 5, 7, 9 ] , length: 5</code></pre>
</br>

<h3 id="arrayof">Array.of()</h3>
</br>

<p><code>of</code> 메소드를 통해 배열을 생성하는 코드들 입니다.</p>
</br>

<pre><code class="language-javascript">let array;

array = Array.of(); // [], length: 0

array = Array.of(1); // [ 1 ], length: 1

array = Array.of(10, 20, 30); // [ 10, 20, 30 ], length: 3

array = Array.of([10, 20, 30]); // [ [ 10, 20, 30 ] ], length: 1

array = Array.of(...[10, 20, 30]); // [ 10, 20, 30 ], length: 3</code></pre>
]]></description>
        </item>
        <item>
            <title><![CDATA[JavaScript Array 알아보기]]></title>
            <link>https://velog.io/@just_gomin/JavaScript-Array-%EC%95%8C%EC%95%84%EB%B3%B4%EA%B8%B0</link>
            <guid>https://velog.io/@just_gomin/JavaScript-Array-%EC%95%8C%EC%95%84%EB%B3%B4%EA%B8%B0</guid>
            <pubDate>Tue, 03 Oct 2023 12:49:13 GMT</pubDate>
            <description><![CDATA[<p><img src="https://velog.velcdn.com/images/just_gomin/post/8bb1ebdb-bef1-48c7-8155-dc89c75f6556/image.svg" alt=""></p>
<p>JavaScript의 Array는 기본적인 자료 구조로, 다수의 데이터를 다루기에 적절합니다. 또한 Array를 선언할 때 길이를 정해줄 수도, 정해주지 않을 수도 있고 <code>push</code>, <code>pop</code>, <code>shift</code>, <code>unshift</code>와 같은 메서드들 덕분에 스택 혹은 큐처럼 활용도 가능합니다.</p>
</br>

<p>이러한 특징들 덕에 <a href="https://github.com/Just-gomin/Algorithm_Study/tree/master/GroupStudy/JavaScript_Algorithm">알고리즘 스터디</a>를 진행하며 Array와 그 메서드들을 자주 사용하게 되는데, 종류가 다양하여 헷갈리는 부분들이 많아 정리의 필요를 느꼈습니다.</p>
</br>

<p><a href="https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Array">MDN Array 문서</a> 의 순서와는 무관하게, 개인적으로 사용 빈도가 높은 순으로 정리했습니다.</p>
</br>

<ol>
<li><a href="https://velog.io/@just_gomin/JavaScript-Array-%EC%95%8C%EC%95%84%EB%B3%B4%EA%B8%B0-%EC%83%9D%EC%84%B1%EC%9E%90">배열의 생성자</a></li>
<li><a href="https://velog.io/@just_gomin/JavaScript-Array-%EC%95%8C%EC%95%84%EB%B3%B4%EA%B8%B0-Sort-Filter">배열의 sort &amp; filter</a></li>
<li><a href="https://velog.io/@just_gomin/JavaScript-Array-%EC%95%8C%EC%95%84%EB%B3%B4%EA%B8%B0-%EC%8A%A4%ED%83%9D-%ED%81%90%EB%A1%9C-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0">배열을 스택 &amp; 큐로 사용하기</a></li>
<li><a href="https://velog.io/@just_gomin/JavaScript-Array-%EC%95%8C%EC%95%84%EB%B3%B4%EA%B8%B0-%EC%88%9C%ED%9A%8C">배열의 순회</a></li>
<li>[그외 유용한 배열의 함수]: 포스팅 예정</li>
</ol>
</br>

<h2 id="참고-자료">참고 자료</h2>
<ul>
<li>MDN JavaScript Array : <a href="https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Array">https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Array</a></li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[블로그 (다시) 시작하기]]></title>
            <link>https://velog.io/@just_gomin/%EB%B8%94%EB%A1%9C%EA%B7%B8-%EB%8B%A4%EC%8B%9C-%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0</link>
            <guid>https://velog.io/@just_gomin/%EB%B8%94%EB%A1%9C%EA%B7%B8-%EB%8B%A4%EC%8B%9C-%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0</guid>
            <pubDate>Mon, 21 Aug 2023 05:41:54 GMT</pubDate>
            <description><![CDATA[<p>관심은 있었지만, 제대로 운영해본적 없는 블로그 운영을 다시 시작해보려 합니다.😅</p>
<p>이글은 블로그를 다시 시작하는 첫글이기에 좀 더 의미 있게 포스팅 하고 싶었습니다....만,</p>
<p><strong>크게 의미를 두고 무슨 내용으로 채워야할까를 고민하니, 계속해서 이 핑계 저 핑계 대며 시간을 끌게 되더라구요...</strong><br/><br/></p>
<pre><code>💡 해야할 일이 정해졌다면 가볍게 시작해서 알차게 끝내는게 역시 가장 좋은 것 같습니다.</code></pre><br/>

<p>그래서 일단 <strong>just-gomin</strong> 이라 지은 제 별칭에 맞게 저지르고 보려고 첫글을 작성 해버리겠습니다.</p>
<p>이렇게 시작을 하니 제겐 마음이 가볍고 조금 신선한 느낌입니다.</p>
<p>이번 블로그는 <strong>개발 얘기, 제가 가끔 만드는 노션 템플릿 소개와 공유, 개인적인 생각정리 얘기</strong>들을 주로 올릴 것 같습니다.
아마 카테고리는 제가 다양한 경험을 할 수록 점점 늘어나겠죠...? 관심있는게 많으니까!<br/><br/></p>
<p>지금 그리고 앞으로 제 블로그를 방문하시는 분들 환영하고 잘 부탁드리겠습니다🥳</p>
]]></description>
        </item>
    </channel>
</rss>