<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>lifefm_j.log</title>
        <link>https://velog.io/</link>
        <description></description>
        <lastBuildDate>Fri, 11 Nov 2022 12:12:38 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <image>
            <title>lifefm_j.log</title>
            <url>https://images.velog.io/images/lifefm_j/profile/ba2cbcc1-dbf4-4795-8f7d-ed537ecc3001/me2.jpeg</url>
            <link>https://velog.io/</link>
        </image>
        <copyright>Copyright (C) 2019. lifefm_j.log. All rights reserved.</copyright>
        <atom:link href="https://v2.velog.io/rss/lifefm_j" rel="self" type="application/rss+xml"/>
        <item>
            <title><![CDATA[[Git] 로컬과 github 연결 중 오류]]></title>
            <link>https://velog.io/@lifefm_j/Git-%EB%A1%9C%EC%BB%AC%EA%B3%BC-github-%EC%97%B0%EA%B2%B0-%EC%A4%91-%EC%98%A4%EB%A5%98</link>
            <guid>https://velog.io/@lifefm_j/Git-%EB%A1%9C%EC%BB%AC%EA%B3%BC-github-%EC%97%B0%EA%B2%B0-%EC%A4%91-%EC%98%A4%EB%A5%98</guid>
            <pubDate>Fri, 11 Nov 2022 12:12:38 GMT</pubDate>
            <description><![CDATA[<h3 id="상황">상황</h3>
<ul>
<li>로컬과 github 연결 중 아래와 같은 에러가 발생했다.<pre><code class="language-js">git remote add origin &quot;http&quot;
// error: origin 리모트가 이미 있습니다.
</code></pre>
</li>
</ul>
<p>git pull origin main
// fatal: protocol &#39;“https&#39; is not supported</p>
<pre><code>&lt;br&gt;

### 원인
- http url을 적을 때 `&quot;&quot;` 콜론과 함께 적어서 발생
&lt;br&gt;


### 해결 방법
1. 연결을 제거한다.
2. 다시 연결한다.
3. github 파일을 로컬 파일로 불러온다(pull) 
```js
// 재연결
git remote rm origin // 제거 
git remote add origin http // http 주소에 콜론 x
git pull origin main // 반응 굳! 

git add .
git commit -m &quot;Add: 초기세팅 완료&quot;
git push origin main -f</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[Git] github commit history 초기화]]></title>
            <link>https://velog.io/@lifefm_j/Git-git-commit-history-%EC%B4%88%EA%B8%B0%ED%99%94</link>
            <guid>https://velog.io/@lifefm_j/Git-git-commit-history-%EC%B4%88%EA%B8%B0%ED%99%94</guid>
            <pubDate>Wed, 19 Oct 2022 10:20:18 GMT</pubDate>
            <description><![CDATA[<ul>
<li>github 저장소 commit history를 초기화 하고 싶을 때 로컬 git 저장소를 삭제하고 다시 생성하는 방법을 알아보자
(github에서 그동안의 커밋 이력을 다 지우고 싶을 때)</li>
</ul>
<h3 id="📌-git-삭제">📌 git 삭제</h3>
<ul>
<li>.git 폴더가 삭제되면서 git 로컬 저장소가 삭제된다.<pre><code>sudo rm -rf .git</code></pre></li>
<li>(참고) git log 확인해보면 git 저장소가 아니라고 나오면 성공<pre><code>git log</code></pre><br>

</li>
</ul>
<h3 id="📌-새로운-git-저장소-생성초기화">📌 새로운 git 저장소 생성(초기화)</h3>
<ul>
<li>이제 다시 git 초기화를 해줘서 github과 연결해주면 끝!<pre><code class="language-js">git init</code></pre>
<pre><code>git remote add origin &quot;레포 https&quot;</code></pre></li>
</ul>
<pre><code>git add .</code></pre><pre><code>git commit -m “커밋 메세지”</code></pre><pre><code>// 기본 push가 안되면 -f를 추가해주자
git push origin main (-f)</code></pre><br>

<h4 id="참고">참고</h4>
<pre><code>// 만약 git add . 시 아래 같은 에러가 나면
warning: CRLF will be replaced by LF in 파일명

// 아래 명령어를 입력해주고 다시 git add를 해주면 된다.
git config --global core.autocrlf true</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[Git] 로컬과 github 연결하기]]></title>
            <link>https://velog.io/@lifefm_j/Git-%EB%A1%9C%EC%BB%AC%EA%B3%BC-Github-%EC%97%B0%EA%B2%B0</link>
            <guid>https://velog.io/@lifefm_j/Git-%EB%A1%9C%EC%BB%AC%EA%B3%BC-Github-%EC%97%B0%EA%B2%B0</guid>
            <pubDate>Mon, 17 Oct 2022 11:38:38 GMT</pubDate>
            <description><![CDATA[<ul>
<li>로컬과 github 연결하기<pre><code>git remote add origin “레포 https”
</code></pre></li>
</ul>
<pre><code></code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[TIL] 22.09.07]]></title>
            <link>https://velog.io/@lifefm_j/TIL-22.09.07</link>
            <guid>https://velog.io/@lifefm_j/TIL-22.09.07</guid>
            <pubDate>Wed, 07 Sep 2022 09:11:14 GMT</pubDate>
            <description><![CDATA[<blockquote>
<ol>
<li>charCodeAt()<ol start="2">
<li>String.fromCharCode()</li>
</ol>
</li>
</ol>
</blockquote>
<br>

<h3 id="💡-문자열과-유니코드">💡 문자열과 유니코드</h3>
<ul>
<li>특정 문자의 유니코드 찾기<pre><code class="language-js">&quot;Hi&quot;.charCodeAt(1) // 105 (&quot;i&quot;의 유니코드)</code></pre>
</li>
<li>유니코드를 문자로 변환하기<pre><code class="language-js">String.fromCharCode(105) // &quot;i&quot;</code></pre>
</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[TypeScript] 인터페이스란]]></title>
            <link>https://velog.io/@lifefm_j/TypeScript-%EC%9D%B8%ED%84%B0%ED%8E%98%EC%9D%B4%EC%8A%A4%EB%9E%80</link>
            <guid>https://velog.io/@lifefm_j/TypeScript-%EC%9D%B8%ED%84%B0%ED%8E%98%EC%9D%B4%EC%8A%A4%EB%9E%80</guid>
            <pubDate>Mon, 05 Sep 2022 10:17:59 GMT</pubDate>
            <description><![CDATA[<h3 id="💡-인터페이스interface란">💡 인터페이스(interface)란?</h3>
<ul>
<li>객체의 구조와 타입을 정의하는 것<br>

</li>
</ul>
<h3 id="💡-인터페이스의-구조">💡 인터페이스의 구조</h3>
<ul>
<li><p>변수명은 클래스와 구분하기 위해 대문자로 시작할 것 </p>
</li>
<li><p>프로퍼티별 구분은 <code>;</code></p>
<pre><code class="language-ts">interface Person {
readonly name: string;
age: number;

greet(greeting: string): void;
}
</code></pre>
</li>
</ul>
<p>let user1: Person;</p>
<p>user1 = {
  name: &#39;Lily&#39;,
  age: 20,
  greet(greeting: string) {
    console.log(<code>${gretting} ${this.name}</code>);
  },
};</p>
<pre><code>&lt;br&gt;

### 💡 인터페이스 특징
- `readonly` 제어자 사용 가능(public, private은 불가)
- 인터페이스에 readonly를 설정하면 class에도 자동으로 설정된다.
&lt;br&gt;

### 💡 사용자 정의타입과 인터페이스
- 기능과 그 모양은 비슷하나, 가장 큰 차이는 인터페이스는 객체의 타입을 정의하기 위해서만 사용
```ts
interface Person {
  name: string;
  age: number;

  greet(greeting: string): void;
}

type Person = {
  name: string;
  age: number;

  greet(greeting: string): void;
}</code></pre><br>

<h3 id="💡-인터페이스를-사용하는-이유">💡 인터페이스를 사용하는 이유</h3>
<ul>
<li>클래스 간에 기능을 쉽게 공유할 수 있기 때문에 사용한다. </li>
<li>즉, 특정 기능이 공유되어야 할 때 사용하면 유용하다. 왜냐하면 해당 인터페이스를 사용한다면 반드시 그 안에 정의되어있는 메서드를 사용해야 하기 때문에.<br>

</li>
</ul>
<h3 id="💡-인터페이스의-확장">💡 인터페이스의 확장</h3>
<ul>
<li>두 개의 인터페이스를 결합하여 새로운 인터페이스를 만들어 클래스에 적용할 수 있다. <pre><code class="language-ts">interface Named {
readonly name: string;
}
</code></pre>
</li>
</ul>
<p>interface Greeting extends Named { // Greeting + Named인 인터페이스가 생김
  greet(phrase: string): void;
}</p>
<p>class Person implements Greeting {
  name: string;
  age = 30;</p>
<p>  constructor(n: string) {
    this.name = n;
  }</p>
<p>  greet(phrase: string) {
    console.log(phrase + &#39;&#39; + this.name);
  }
}
```</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[[TypeScript] 효율적으로 클래스 필드 속성 초기화하는 방법]]></title>
            <link>https://velog.io/@lifefm_j/TypeScript-%ED%95%84%EB%93%9C-%EC%A0%95%EC%9D%98-%EC%BD%94%EB%93%9C-%EC%88%98-%EC%A4%84%EC%9D%B4%EB%8A%94-%EB%B0%A9%EB%B2%95</link>
            <guid>https://velog.io/@lifefm_j/TypeScript-%ED%95%84%EB%93%9C-%EC%A0%95%EC%9D%98-%EC%BD%94%EB%93%9C-%EC%88%98-%EC%A4%84%EC%9D%B4%EB%8A%94-%EB%B0%A9%EB%B2%95</guid>
            <pubDate>Thu, 01 Sep 2022 08:44:34 GMT</pubDate>
            <description><![CDATA[<ul>
<li>아래와 같이 매개변수에 초기화를 진행하여 코드의 수를 줄일 수 있다. </li>
</ul>
<h3 id="before">Before</h3>
<pre><code class="language-js">class Department {
  private id: string; ✅
  public name: string; ✅
  private employees: string[] = [];

  constructor(id: string, n: string) {
    this.id = id; ✅
    this.name = n; ✅
  }

  describe(this: Department) {
    console.log(&#39;Department&#39; + this.name);
  }

}

const accounting = new Department(&#39;Accounting&#39;);</code></pre>
<h3 id="after">After</h3>
<pre><code class="language-js">class Department {
  //   private id: string; ✅
  //   private name: string; ✅
  private employees: string[] = [];

// public을 붙여야하는 이유는 정확히 동일한 이름으로 속성을 만들고 싶다고 타입스크립트에게 알려주는 명령이기 때문이기도 하다.
  constructor(private id: string, public name: string) {
    //   this.id = id; ✅
    //   this.name = n; ✅
  }

  describe(this: Department) {
    console.log(`Department (${this.id}): ${this.name}`);
  }

}

const accounting = new Department(&#39;d1&#39;, &#39;Accounting&#39;);</code></pre>
]]></description>
        </item>
        <item>
            <title><![CDATA[[TypeScript] 타입스크립트 사용 이유]]></title>
            <link>https://velog.io/@lifefm_j/TypeScript-%ED%83%80%EC%9E%85%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8-%EC%82%AC%EC%9A%A9-%EC%9D%B4%EC%9C%A0</link>
            <guid>https://velog.io/@lifefm_j/TypeScript-%ED%83%80%EC%9E%85%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8-%EC%82%AC%EC%9A%A9-%EC%9D%B4%EC%9C%A0</guid>
            <pubDate>Wed, 31 Aug 2022 08:44:06 GMT</pubDate>
            <description><![CDATA[<h3 id="💡-타입스크립트-사용-이유">💡 타입스크립트 사용 이유</h3>
<ul>
<li>타입을 사용하면 오류를 미리 감지하고 일부 런타임 오류를 방지할 수 있다.</li>
<li>숫자, 문자열 등 정해진 타입의 input 값만을 입력해야 될 때 사용한다.</li>
<li>타입스크립트를 사용하면 타입을 확인하는 코드를 추가할 필요가 없어 효율적이다.<pre><code class="language-js">// javascript의 경우
if(typeof number) {
  throw new(&quot;Error!!&quot;)
}</code></pre>
<br>

</li>
</ul>
<h3 id="💡-타입스크립트와-자바스크립트의-차이">💡 타입스크립트와 자바스크립트의 차이</h3>
<ul>
<li>오류 확인을 언제할 수 있느냐에 차이가 있다.</li>
<li>ts는 개발 도중 컴파일 시 터미널에서 확인되는 반면,  js는 런타임 중에 확인된다.</li>
<li>ts는 브라우저에서 확인할 수 없다.</li>
<li>즉, ts를 사용하면 런타임까지 가지 않고도 오류를 알 수 있어 더 효율적인 개발 환경을 제공해준다.<br>



</li>
</ul>
<h3 id="💡-참고-타입-추론과-명시적-타입-할당">💡 참고) 타입 추론과 명시적 타입 할당</h3>
<ul>
<li>타입 추론<pre><code class="language-js">let age = 29;</code></pre>
</li>
<li>명시적 타입 할당<pre><code class="language-js">const age: number = 29;</code></pre>
</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[TIL] 22.08.31]]></title>
            <link>https://velog.io/@lifefm_j/TIL-220.08.31</link>
            <guid>https://velog.io/@lifefm_j/TIL-220.08.31</guid>
            <pubDate>Wed, 31 Aug 2022 07:49:52 GMT</pubDate>
            <description><![CDATA[<blockquote>
<ol>
<li>나머지 매개변수<ol start="2">
<li>배열 구조 분해 할당에서 변수명 지정</li>
<li>객체 구조 분해 할당에서 나머지 요소</li>
</ol>
</li>
</ol>
</blockquote>
<br>

<h3 id="💡-나머지-매개변수">💡 나머지 매개변수</h3>
<ul>
<li><p>자바스크립트에 es6 변경 사항 중 하나인 나머지 매개변수!</p>
</li>
<li><p><code>언제 쓸까</code> : 매개변수가 몇 개인지 모를 때 뿐만 아니라 알더라도 나머지 매개변수를 사용하는 것이 효율적이다.  </p>
</li>
<li><p>아래와 같이 매개변수의 타입을 하나씩 지정해줘도 된다. </p>
<pre><code class="language-js">const add = (...numbers: [number, number, number]) =&gt; {
return numbers.reduce((curResult, curValue) =&gt; {
      return curResult + curValue;
}, 0);
};
</code></pre>
</li>
</ul>
<p>const addedNumbers = add(5, 10, 2);</p>
<pre><code>&lt;br&gt;

- 하지만 따로 지정하지 않고 `[]`를 넣어주면 개수에 상관없이 사용할 수 있다.
- `...numbers`는 add()에 인수로 들어온 요소들을 배열에 담아준다. 
```js
const add = (...numbers: []) =&gt; {
  console.log(numbers) // [1, 2, 3, 4]

  return numbers.reduce((curResult, curValue) =&gt; {
        return curResult + curValue;
  }, 0);
};

const addedNumbers = add(1, 2, 3, 4);</code></pre><br>

<h3 id="💡-배열-구조-분해-할당에서-변수명-지정">💡 배열 구조 분해 할당에서 변수명 지정</h3>
<ul>
<li>나머지 배열 요소를 <code>...</code>으로 묶어서 또 하나의 배열로 만들어 줄 수 있다.<pre><code class="language-js">const hobbies = [&quot;Hiking&quot;, &quot;Cooking&quot;, &quot;Dancing&quot;, &quot;Sleeping&quot;]
</code></pre>
</li>
</ul>
<p>const [hobby1, hobby2, ...remainingHobbies] = hobbies;
console.log(remainingHobbies) // [&quot;Dancing&quot;, &quot;Sleeping&quot;]</p>
<pre><code>&lt;br&gt;

### 💡 객체 구조 분해 할당에서 나머지 요소
- 객체 구조 분해 할당에서 기존 키값을 내가 원하는 변수명으로 바꿔 사용할 수 있다.
- `:`을 사용해서 지정해주면 된다.
```js
const person = {
      firstName: &#39;Lily&#39;,
      age: 20
};

const { firstName: userName, age } = person;

console.log(userName, age); // &#39;Lily&#39;, 20</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[TIL] 22.08.30]]></title>
            <link>https://velog.io/@lifefm_j/TIL-22.08.30</link>
            <guid>https://velog.io/@lifefm_j/TIL-22.08.30</guid>
            <pubDate>Tue, 30 Aug 2022 08:25:16 GMT</pubDate>
            <description><![CDATA[<blockquote>
<ol>
<li>replace()와 replaceAll()<ol start="2">
<li>객체의 value로 key 값 알아내기 </li>
</ol>
</li>
</ol>
</blockquote>
<br>

<h3 id="💡-replaceall">💡 replaceAll()</h3>
<ul>
<li>이름에서 알 수 있듯이 첫 번째 인수에 해당하는 모든 요소를 대체해준다. </li>
<li>하지만 ES2021에서 등장하여 이전에는 replace()을 사용하여야 했다.<h4 id="replace을-replaceall처럼-사용하는-방법">replace()을 replaceAll()처럼 사용하는 방법</h4>
</li>
<li>정규식을 사용하여 <code>//</code> 안에 검색하고자 하는 문자열을 넣는다.</li>
<li><code>g</code> : 전역 검색</li>
<li><code>i</code> : 대/소문자 구분 안함<pre><code class="language-js">const phoneNum = &quot;010-1234-5678&quot;;
</code></pre>
</li>
</ul>
<p>const newNum = phoneNum.replace(/-/gi,&#39;*&#39;);</p>
<p>console.log(newNum); // 010<em>1234</em>5678</p>
<pre><code>
&lt;br&gt;

### 💡 객체의 value로 key값 알아내기
- key 값을 배열로 만들어 준다. `Object.keys()`
- `Object[key]`와 일치하는 값을 찾아서 리턴한다. `find()`
```js
function getKeyByValue(object, value) {
  return Object.keys(object).find(key =&gt; object[key] === value);
}</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[TIL] 22.08.16]]></title>
            <link>https://velog.io/@lifefm_j/TIL-22.08.16</link>
            <guid>https://velog.io/@lifefm_j/TIL-22.08.16</guid>
            <pubDate>Tue, 16 Aug 2022 10:44:34 GMT</pubDate>
            <description><![CDATA[<blockquote>
<ol>
<li>map()의 옵셔널 매개변수<ol start="2">
<li>filter()의 옵셔널 매개변수</li>
</ol>
</li>
</ol>
</blockquote>
<br>

<h3 id="💡-map의-옵셔널-매개변수">💡 map()의 옵셔널 매개변수</h3>
<ul>
<li><code>currentValue</code> : 처리할 현재 요소.</li>
<li><code>index</code> : 처리할 현재 요소의 인덱스. (optional)</li>
<li><code>array</code> : map()을 호출한 배열. (optional)</li>
</ul>
<pre><code class="language-js">function solution(x, n) {
    return Array(n).fill(x).map((v, i) =&gt; (i + 1) * v)
}</code></pre>
<br>

<h3 id="💡-filter의-옵셔널-매개변수">💡 filter()의 옵셔널 매개변수</h3>
<ul>
<li><code>element</code> : 처리할 현재 요소.</li>
<li><code>index</code> : 처리할 현재 요소의 인덱스. (optional)</li>
<li><code>array</code> : filter를 호출한 배열 (optional)<pre><code class="language-js">function solution(arr) {
   return arr.filter((val,index) =&gt; val != arr[index+1]);
}</code></pre>
<br>

</li>
</ul>
<h3 id="느낀점">느낀점</h3>
<ul>
<li>메서드의 기본 변수로만 구현해왔는데 알고리즘 문제를 풀면서 종종 그 한계가 느껴졌다.</li>
<li>옵셔녈 매개변수를 활용해서 더 효율적이고 깔끔한 코드 작성이 가능한 경우가 있었다. </li>
<li>이제는 옵셔녈 매개변수까지 제대로 익히고, 활용하는 연습을 하자!!!</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[TIL] 22.08.10]]></title>
            <link>https://velog.io/@lifefm_j/TIL-22.08.10</link>
            <guid>https://velog.io/@lifefm_j/TIL-22.08.10</guid>
            <pubDate>Wed, 10 Aug 2022 07:01:29 GMT</pubDate>
            <description><![CDATA[<blockquote>
<ol>
<li>for 문 속도 최적화</li>
</ol>
</blockquote>
<br>

<h3 id="💡-for-문-성능-향상--패턴">💡 for 문 성능 향상  패턴</h3>
<ul>
<li>알고리즘 문제를 풀다가 지금까지 자주 사용했던 for 문의 속도를 향상시키는 방법이 있다는 것을 알게됐다. </li>
<li>i의 범위를 설정할 때 배열의 길이를 사용하는 경우가 많았는데, 이때 매번 array.length에 접근하게 되어 속도 저하를 야기할 수 있다는 것이다. </li>
<li>이를 개선하기 위해서 for 문 내 변수를 하나 더 선언하여 사용할 수 있다.<pre><code class="language-js">// before
const array = [1,2,3,4,5];
for(let i = 0; i &lt; array.length; i++){
  console.log(array[i]);
}</code></pre>
</li>
</ul>
<pre><code class="language-js">// after
const array = [1,2,3,4,5];
for(let i = 0, n = array.length; i &lt; n; i++){
    console.log(array[i]);
}</code></pre>
<br>

<p>출처: <a href="https://aljjabaegi.tistory.com/584">https://aljjabaegi.tistory.com/584</a></p>
]]></description>
        </item>
        <item>
            <title><![CDATA[[TIL] 22.08.04]]></title>
            <link>https://velog.io/@lifefm_j/TIL-22.08.04-2gpofm0b</link>
            <guid>https://velog.io/@lifefm_j/TIL-22.08.04-2gpofm0b</guid>
            <pubDate>Thu, 04 Aug 2022 13:27:25 GMT</pubDate>
            <description><![CDATA[<blockquote>
<ol>
<li>indexOf()와 findIndex()의 차이<ol start="2">
<li>구조분해 할당</li>
</ol>
</li>
</ol>
</blockquote>
<br>

<h3 id="💡-indexof와-findindex의-차이">💡 indexOf()와 findIndex()의 차이</h3>
<p><em><code>indexOf()</code>의 속도가 더 빠르다.</em></p>
<h4 id="indexof">indexOf()</h4>
<ul>
<li>일반 배열일 때 사용<pre><code>배열에서 지정된 요소를 찾을 수 있는 첫 번째 인덱스를 반환하고 존재하지 않으면 -1을 반환합니다.</code></pre><h4 id="findindex">findIndex()</h4>
</li>
<li>객체의 배열일 때 사용<pre><code>주어진 판별 함수를 만족하는 배열의 첫 번째 요소에 대한 인덱스를 반환합니다. 만족하는 요소가 없으면 -1을 반환합니다.</code></pre><br>

</li>
</ul>
<h3 id="💡-구조분해-할당">💡 구조분해 할당</h3>
<ul>
<li>객체 디스트럭처링 할당을 위한 변수에 기본값을 설정할 수 있다.<pre><code class="language-js">const { firstName = &#39;Code&#39;, lastName } = { lastName: &#39;Kim&#39; };
console.log( firstName, lastName); // Code Kim
</code></pre>
</li>
</ul>
<p>const { firstName: fn = &#39;Code&#39;, lastName: ln } = { lastName: &#39;Kim&#39; };
console.log( fn, ln); // Code Kim</p>
<pre><code>- 배열의 요소가 객체인 경우 배열 디스트럭처링 할당과 객체 디스트럭처링 할당을 혼용할 수 있다.
```js
const todos = [
  { id: 1, content: &#39;HTML&#39;, completed: true },
  { id: 2, content: &#39;CSS&#39;, completed: false },
  { id: 3, content: &#39;JS&#39;, completed: false },
];

// todos 배열의 두 번째 요소인 객체로부터 id 프로퍼티만 추출한다.
const [, { id }] = todos;
console.log(id); // 2</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[TIL] 22.08.03]]></title>
            <link>https://velog.io/@lifefm_j/TIL-22.08.03</link>
            <guid>https://velog.io/@lifefm_j/TIL-22.08.03</guid>
            <pubDate>Wed, 03 Aug 2022 06:09:01 GMT</pubDate>
            <description><![CDATA[<blockquote>
<ol>
<li>스프레드 문법<ol start="2">
<li>스프레드 프로퍼티</li>
</ol>
</li>
</ol>
</blockquote>
<br>

<h3 id="💡-스프레드-문법">💡 스프레드 문법</h3>
<ul>
<li>장점 : ES5의 기존 방식보다 더 간결하고 가독성 좋게 표현할 수 있다.</li>
</ul>
<h4 id="✨-concat">✨ concat</h4>
<ul>
<li>두 개의 배열을 합칠 때 </li>
</ul>
<pre><code class="language-js">// ES5
let arr = [1, 2].concat([3, 4]);
console.log(arr); // [1, 2, 3, 4]</code></pre>
<pre><code class="language-js">// ES6
let arr = [...[1, 2], ...[3 ,4]];
console.log(arr); // [1, 2, 3, 4]</code></pre>
<h4 id="✨-splice">✨ splice</h4>
<ul>
<li>배열의 중간에 다른 배열 요소를 추가하고 싶을 때<pre><code class="language-js">// ES5
let arr1 = [1, 4];
let arr2 = [2, 3];
</code></pre>
</li>
</ul>
<p>Array.prototype.splice.apply(arr1, [1, 0].concat(arr2));
console.log(arr1); // [1, 2, 3, 4]</p>
<pre><code>```js
// ES6
let arr1 = [1, 4];
let arr2 = [2, 3];

arr1.splice(1, 0, ...arr2);
console.log(arr1); // [1, 2, 3, 4]</code></pre><h4 id="✨-slice">✨ slice</h4>
<ul>
<li>배열을 복사할 때<pre><code class="language-js">// ES5
let origin = [1, 2];
let copy = origin.slice();
</code></pre>
</li>
</ul>
<p>console.log(copy); // [1, 2]
console.log(copy === origin); // false</p>
<pre><code>```js
// ES6
let origin = [1, 2];
let copy = [...origin];

console.log(copy); // [1, 2]
console.log(copy === origin); // false</code></pre><br>

<h3 id="💡-스프레드-프로퍼티">💡 스프레드 프로퍼티</h3>
<ul>
<li><code>스프레드 프로퍼티</code>는 <code>Object.assign</code> 메서드를 대체할 수 있는 간편한 문법이다.</li>
</ul>
<h4 id="✨-기본-사용법">✨ 기본 사용법</h4>
<pre><code class="language-js">const merged = { x: 1, y: 2, ...{ a: 3, b: 4}};
console.log(merged); // {x: 1, y: 2, a: 3, b: 4}</code></pre>
<h4 id="✨-객체-병합">✨ 객체 병합</h4>
<ul>
<li>프로퍼티가 중복되는 경우 뒤에 위치한 프로퍼티가 우선권을 갖는다.<pre><code class="language-js">const merged = { ...{ x: 1, y: 2 }, ...{ y: 10, x: 3 } };
console.log(merged); // { x: 1, y: 10, z: 3 }</code></pre>
</li>
</ul>
<h4 id="✨-특정-프로퍼티-변경">✨ 특정 프로퍼티 변경</h4>
<pre><code class="language-js">const changed = { ... { x: 1, y: 2 }, y: 100 };
// changed = { ... { x: 1, y: 2 }, ... { y: 100 } }
console.log(changed); // { x: 1, y: 100 }
</code></pre>
<h4 id="✨-특정-프로퍼티-추가">✨ 특정 프로퍼티 추가</h4>
<pre><code class="language-js">const added = { ... { x: 1, y: 2 }, z: 0 };
// added = { ... { x: 1, y: 2 }, ...{ z: 0 } }
console.log(added)l // { x: 1, y: 2, z: 0 }</code></pre>
<h4 id="참고">참고</h4>
<ul>
<li>스프레드 프로퍼티 이전에는 객체를 병합하거나 특정 프로퍼티를 변경, 추가할 때 <code>Object.assign</code> 메서드를 사용했다. <pre><code class="language-js">const merged = Object.assign({}, { x: 1, y: 2 }, { y: 10, z: 3 });
console.log(merged); // {x: 1, y: 10, x: 3}</code></pre>
</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[TIL] 22.08.02]]></title>
            <link>https://velog.io/@lifefm_j/TIL-22.08.02</link>
            <guid>https://velog.io/@lifefm_j/TIL-22.08.02</guid>
            <pubDate>Tue, 02 Aug 2022 08:51:48 GMT</pubDate>
            <description><![CDATA[<blockquote>
<ol>
<li>삼항 연산자 실행문이 두 개일 때</li>
</ol>
</blockquote>
<br>

<h3 id="💡-삼항-연산자-실행문이-두-개일-때">💡 삼항 연산자 실행문이 두 개일 때</h3>
<ul>
<li>조건 충족 시 실행되는 문이 두 개일 때는 어떻게 작성하지?</li>
<li><code>()</code>와 <code>,</code>로 묶어주면 된다.<pre><code class="language-js">n % 2 ===0 ? (n = n / 2, answer++) : (n = n * 3 + 1, answer++)</code></pre>
</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[TIL] 22.08.01]]></title>
            <link>https://velog.io/@lifefm_j/TIL-22.08.01</link>
            <guid>https://velog.io/@lifefm_j/TIL-22.08.01</guid>
            <pubDate>Mon, 01 Aug 2022 07:38:53 GMT</pubDate>
            <description><![CDATA[<blockquote>
<ol>
<li>repeat() 메서드<ol start="2">
<li>CSS 선택자</li>
</ol>
</li>
</ol>
</blockquote>
<br>

<h3 id="💡-repeat-메서드">💡 repeat() 메서드</h3>
<p>repeat() 메서드는 문자열을 주어진 횟수만큼 반복해 붙인 새로운 문자열을 반환한다.</p>
<pre><code class="language-js">&#39;문자열&#39;.repeat(2) // &#39;문자열문자열&#39;</code></pre>
<br>

<h3 id="💡-css-선택자">💡 CSS 선택자</h3>
<ul>
<li>CSS 선택자는 스타일을 적용하고자 하는 HTML 요소를 특정할 때 사용하는 문법이다. <pre><code class="language-css">/* 어트리뷰트 선택자: Input 요소 중에 type 어트리뷰트 값이 &#39;text&#39;인 요소를 모두 선택 */
input[tpye=text] { ... }
</code></pre>
</li>
</ul>
<p>/* 후손 선택자: div 요소의 후손 요소 중 p 요소를 모두 선택 */
div p { ... }</p>
<p>/* 자식 선택자: div 요소의 자식 요소 중 p 요소를 모두 선택 */
div &gt; p { ... }</p>
<p>/* 인접 형제 선택자: p 요소의 형제 요소 중에 p 요소 바로 뒤에 위치하는 ul 요소를 선택 */
p + ul { ... }</p>
<p>/* 일반 형제 선택자: p 요소의 형제 요소 중에 p 요소 뒤에 위치하는 ul 요소를 모두 선택 */
p ~ ul { ... }</p>
<p>/* 가상 요소 선택자: p 요소의 콘텐츠의 앞에 위치하는 공간응 선택. 일반적으로 content 프로퍼티와 함께 사용된다. */
p::before { ... }
```</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[[TIL] 22.07.20]]></title>
            <link>https://velog.io/@lifefm_j/TIL-22.07.20</link>
            <guid>https://velog.io/@lifefm_j/TIL-22.07.20</guid>
            <pubDate>Wed, 20 Jul 2022 13:57:01 GMT</pubDate>
            <description><![CDATA[<blockquote>
<ol>
<li>recoil</li>
<li>마인드</li>
</ol>
</blockquote>
<br>

<h3 id="💡-recoil">💡 recoil</h3>
<ul>
<li>React 전용 전역 상태관리 라이브러리로 2020년 5월 Facebook에서 출시하였다.</li>
<li>애플리케이션이 특정 value에 접근할 때 사용한다.<pre><code class="language-html">// index.tsx
</code></pre>
</li>
</ul>
<RecoilRoot>
    <elements>
    .
    .
    .
</RecoilRoot>
```
#### value 받아오기
- `atom` : Recoil 상태의 단위를 의미한다. 컴포넌트간에 이 상태는 공유되며, 구독 및 업데이트가 가능하다. 특히, atom의 상태가 업데이트되면, 이를 구독하던 컴포넌트들이 모두 리렌더링된다.
- `key` : 고유한 key 값(보통 해당 atom을 생성하는 변수 명으로 지정)
- `default` : atom의 초기값
```tsx
// atoms.ts

<p>import { atom } from &quot;recoil&quot;;</p>
<p>export const isDarkAtom = atom({
    key: &#39;isDark&#39;,
    defauult: false,
 });</p>
<pre><code>#### value 값 수정
```tsx
function App() {
    const isDark = useRecoilValue(isDarkAtom);
    return(
    &lt;&gt;
    &lt;ThemeProvider theme={isDark? : darkTheme : lightTheme}&gt;
    &lt;/ThemeProvider&gt;</code></pre><pre><code class="language-tsx">function App() {
    const setDarkAtom = useSetRecoilState(isDarkAtom);
    const toggleDarkAtom = () =&gt; {
    setDarkAtom(prev=&gt;!preV);

    const isDark = useRecoilValue(isDarkAtom);
    return(
    &lt;&gt;
    &lt;Button onClick={toggleDarkAtom&gt;
    &lt;/Button&gt;</code></pre>
<br>

<h3 id="💡-마인드">💡 마인드</h3>
<ul>
<li>기술은 문제를 해결하기 위해 만들어진다.</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[TIL] 22.07.18]]></title>
            <link>https://velog.io/@lifefm_j/TIL-22.07.18</link>
            <guid>https://velog.io/@lifefm_j/TIL-22.07.18</guid>
            <pubDate>Mon, 18 Jul 2022 13:29:43 GMT</pubDate>
            <description><![CDATA[<blockquote>
<ol>
<li>apexcharts 라이브러리<ol start="2">
<li>react helmet</li>
<li>toFixed()</li>
</ol>
</li>
</ol>
</blockquote>
<br>

<h3 id="💡-apexcharts-라이브러리">💡 apexcharts 라이브러리</h3>
<ul>
<li><a href="https://apexcharts.com/">https://apexcharts.com/</a></li>
<li>다양한 종류의 차트가 많이 있다. </li>
<li>demos를 보며 사람들이 사용한 방법들을 참고하자<br>

</li>
</ul>
<h3 id="💡-react-helmet">💡 react helmet</h3>
<ul>
<li>head로 가는 direct link다. </li>
<li>React에서 <code>&lt;head&gt;</code>의 title, favicon, css 등을 동적으로 변경할 수 있디.<pre><code class="language-js">// App.js
import { HelmetProvider, Helmet } from &#39;react-helmet-async&#39;;
</code></pre>
</li>
</ul>
<p>function App() {
  return (
    <HelmetProvider>
      <Helmet>
        <title>New Title</title>
      </Helmet>
    </HelmetProvider>
  );
}</p>
<p>export default App;</p>
<pre><code>&lt;br&gt;

### 💡 toFixed()
- 소수점을 원하는 자릿수까지 자른 문자열을 반환한다.
```js
3.1415.toFixed(); // &#39;3&#39;
3.1415.toFixed(2); // &#39;3.14&#39;
3.1415.toFixed(5); // &#39;3.14150&#39;</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[TIL] 22.07.14]]></title>
            <link>https://velog.io/@lifefm_j/TIL-22.07.14</link>
            <guid>https://velog.io/@lifefm_j/TIL-22.07.14</guid>
            <pubDate>Thu, 14 Jul 2022 02:37:43 GMT</pubDate>
            <description><![CDATA[<blockquote>
<ol>
<li>react-router 6 <ol start="2">
<li>react-query</li>
</ol>
</li>
</ol>
</blockquote>
<br>

<h3 id="💡-react-router-6">💡 react-router 6</h3>
<ul>
<li>react-router 6버전 변경 내용 요약</li>
<li>useRouteMatch() → useMatch()</li>
<li>Switch → Routes</li>
<li>nested router → Outlet<br>

</li>
</ul>
<h3 id="💡-react-query">💡 react-query</h3>
<ul>
<li>모든 state와 hook을 대체할 수 있음</li>
<li>사용 이유: 리액트 쿼리는 fetch에서 받아온 response data를 캐시에 저장해놓는다. 즉, 화면이 바뀔 때마다 데이터를 요청하지 않는다.</li>
<li><code>npm i react-query</code><br>

</li>
</ul>
<h4 id="before">before</h4>
<ul>
<li>coins.tsx<pre><code class="language-js">const [coins, setCoins] = useState&lt;CoinInterface[]&gt;([]);
const [loading, setLoading] = useState(true);
useEffect(() =&gt; {
  (async () =&gt; {
    const response = await fetch(&#39;https://api.coinpaprika.com/v1/coins&#39;);
    const json = await response.json();
    setCoins(json.slice(0, 100));
    setLoading(false);
  })();
}, []);</code></pre>
</li>
</ul>
<h4 id="after">after</h4>
<ul>
<li>index.tsx<pre><code class="language-js">import React from &#39;react&#39;;
import ReactDOM from &#39;react-dom&#39;;
import { QueryClient, QueryClientProvider } from &#39;react-query&#39;;
import { ThemeProvider } from &#39;styled-components&#39;;
import App from &#39;./App&#39;;
import { theme } from &#39;./theme&#39;;
</code></pre>
</li>
</ul>
<p>const queryClient = new QueryClient();</p>
<p>ReactDOM.render(
  &lt;React.StrictMode&gt;
    <QueryClientProvider client={queryClient}>
      <ThemeProvider theme={theme}>
        <App />
      </ThemeProvider>
    </QueryClientProvider>
  &lt;/React.StrictMode&gt;,
  document.getElementById(&#39;root&#39;)
);</p>
<pre><code>- coins.tsx
```js
  const { isLoading, data } = useQuery&lt;ICoin[]&gt;(&#39;allCoins&#39;, fetchCoins);</code></pre><ul>
<li>api.ts<pre><code class="language-js">export async function fetchCoins() {
return await (await fetch(&#39;https://api.coinpaprika.com/v1/coins&#39;)).json();
}</code></pre>
</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[TIL] 22.07.13]]></title>
            <link>https://velog.io/@lifefm_j/TIL-22.07.13</link>
            <guid>https://velog.io/@lifefm_j/TIL-22.07.13</guid>
            <pubDate>Wed, 13 Jul 2022 11:39:49 GMT</pubDate>
            <description><![CDATA[<blockquote>
<ol>
<li>HTML 특수 문자 코드</li>
<li>temp 임시 객체 활용법</li>
<li>useLocation() </li>
</ol>
</blockquote>
<br>

<h3 id="💡-html-특수-문자-코드">💡 HTML 특수 문자 코드</h3>
<ul>
<li>레이아웃 작업하면서 <code>&gt;</code>와 같은 화살표가 필요할 때가 있었다. <code>&gt;</code>를 사용하는 것은 태그로 인식하여 오류 발생 위험이 있으니 앞으로 특수 문자 코드를 이용하면 되겠다.</li>
</ul>
<table>
<thead>
<tr>
<th align="center">특수 문자</th>
<th align="center">코드</th>
</tr>
</thead>
<tbody><tr>
<td align="center">&uarr;</td>
<td align="center">&amp;uarr</td>
</tr>
<tr>
<td align="center">&darr;</td>
<td align="center">&amp;darr</td>
</tr>
<tr>
<td align="center">&larr;</td>
<td align="center">&amp;larr</td>
</tr>
<tr>
<td align="center">&rarr;</td>
<td align="center">&amp;rarr</td>
</tr>
<tr>
<td align="center">&harr;</td>
<td align="center">&amp;harr</td>
</tr>
<tr>
<td align="center">&lt;</td>
<td align="center">&amp; lt</td>
</tr>
<tr>
<td align="center">&gt;</td>
<td align="center">&amp; gt</td>
</tr>
<tr>
<td align="center">(공백)</td>
<td align="center">&amp;    #10</td>
</tr>
<tr>
<td align="center"><br></td>
<td align="center"></td>
</tr>
</tbody></table>
<h3 id="💡-temp-임시-객체-활용법">💡 temp 임시 객체 활용법</h3>
<ul>
<li>서버에서 받아온 데이터를 console.log를 사용하여 콘솔 창 객체에 저장한다.<pre><code class="language-js">Object.keys(temp1).map(v=&gt;typeof v).join()</code></pre>
<br>

</li>
</ul>
<h3 id="💡-uselocation">💡 useLocation()</h3>
<ul>
<li><code>useLocation()</code>은 현재 머물고 있는 페이지에 대한 정보를 알려주는 hook이다.</li>
<li>경로 정보를 담고있는 객체이다.<pre><code class="language-js">const location = useLocation();
</code></pre>
</li>
</ul>
<p>useEffect(() =&gt; {
    console.log(location);
}, [location]);</p>
<pre><code>
```js
{
  pathname: &#39;&#39;, // 현재 경로 값
  search: &#39;&#39;, // 현재 경로의 query parameter 값
  hash: &#39;&#39;,
  state: null,
  key: &#39;default&#39;
}</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[JavaScript] 모던 자바스크립트 Deep Dive 18장 함수와 일급 객체]]></title>
            <link>https://velog.io/@lifefm_j/JavaScript-%EB%AA%A8%EB%8D%98-%EC%9E%90%EB%B0%94%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8-Deep-Dive-18%EC%9E%A5-%ED%95%A8%EC%88%98%EC%99%80-%EC%9D%BC%EA%B8%89-%EA%B0%9D%EC%B2%B4</link>
            <guid>https://velog.io/@lifefm_j/JavaScript-%EB%AA%A8%EB%8D%98-%EC%9E%90%EB%B0%94%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8-Deep-Dive-18%EC%9E%A5-%ED%95%A8%EC%88%98%EC%99%80-%EC%9D%BC%EA%B8%89-%EA%B0%9D%EC%B2%B4</guid>
            <pubDate>Wed, 13 Jul 2022 09:35:24 GMT</pubDate>
            <description><![CDATA[<h2 id="18장-함수와-일급-객체">18장 함수와 일급 객체</h2>
<h3 id="📌-일급-객체">📌 일급 객체</h3>
<ul>
<li>다음과 같은 조건을 만족하는 객체를 일급 객체라 한다.</li>
<li>자바스크립트의 함수는 일급 객체이다.<ul>
<li>무명의 리터럴로 생성 가능. 즉, 런타임에 생성 가능</li>
<li>변수나 자료구조(객체, 배열)에 저장 가능</li>
<li>함수의 매개변수에 전달 가능</li>
<li>함수의 반환값으로 사용 가능</li>
</ul>
</li>
<li>함수가 일급 객체라는 것은 함수를 객체와 동일하게 사용할 수 있다는 의미이다.</li>
<li>함수는 객체이지만 일반 객체와 달리 호출할 수 있다. </li>
<li>그리고 함수 객체는 일반 객체에는 없는 함수 고유의 프로퍼티를 소유한다.<h3 id="📌-함수-객체의-프로퍼티">📌 함수 객체의 프로퍼티</h3>
</li>
<li><code>데이터 프로퍼티</code> : arguments, caller, length, name, prototype</li>
<li><code>접근자 프로퍼티</code> : __proto __<h4 id="✨-arguments-프로퍼티">✨ arguments 프로퍼티</h4>
</li>
<li>함수 호출 시 전달된 인수(argument)들의 정보를 담고 있는 순회 가능한 유사 배열 객체</li>
<li>함수 내부에서 지역 변수처럼 사용되며, 함수 외부에서는 참조할 수 없다.</li>
<li>매개변수의 개수보다 인수를 더 많이 전달한 경우 초과된 인수는 무시된다.</li>
<li>그러나 그냥 버려지는 것이 아니라 모든 인수는 암묵적으로 arguments 객체의 프로퍼티로 보관된다.<h4 id="✨-caller-프로퍼티">✨ caller 프로퍼티</h4>
</li>
<li>ECMAScript 사양에 포함되지 않은 비표준 프로퍼티. 사용하지 말고 참고로만 알아둘 것<h4 id="✨-length-프로퍼티">✨ length 프로퍼티</h4>
</li>
<li>함수를 저의할 때 선언한 매개변수의 개수</li>
<li>arguments 객체의 length 프로퍼티와 함수 객체의 length 프로퍼티의 값은 다를 수 있으므로 주의해야 한다.</li>
<li><code>인자(argument)</code>의 개수 : arguments 객체의 length 프로퍼티 </li>
<li><code>매개변수(parameter)</code>의 개수 : 함수 객체의 length 프로퍼티<pre><code class="language-js">function foo () {}
console.log(foo.length)l // 0
</code></pre>
</li>
</ul>
<p>function baz(x, y) {
  return x * y;
}</p>
<p>console.log(baz.length); // 2</p>
<pre><code>#### ✨ name 프로퍼티
- 함수 이름
- ES6 이전까지는 비표준이었다가 ES6에서 정식 표준이 되었다.
- ES5 : 빈 문자열을 값으로 갖는다.
- ES6 : 함수 객체를 가리키는 식별자를 값으로 갖는다.
#### ✨ __proto__접근자 프로퍼티
- 모든 객체는 [[Prototype]]이라는 내부 슬롯을 갖는데 이는 객체지향 프로그래밍의 상속을 구현하는 프로토타입 객체를 가리킨다.
- __proto __ 프로퍼티는 [[Prototpye]] 내부 슬롯이 가리키는 프로토타입 객체에 접근하기 위해 사용하는 접근자 프로퍼티다.
- 내부 슬롯에는 직접 접근할 수 없고 간접적으로 프로토타입 객체에 접근할 수 있다. 
#### ✨ prototype 프로퍼티
- 생성자 함수로 호출할 수 있는 함수 객체.
- 즉, constructor만이 소유하는 프로퍼티다.
- 일반 객체와 생성자 함수로 호출할 수 없는 non-constructor에는 prototype 프로퍼티가 없다. 
- prototype 프로퍼티는 함수가 객체를 생성하는 생성자 함수로 호출될 때 생성자 함수가 생성할 인스턴스의 프로토타입 객체를 가리킨다. 
```js
// 함수 객체는 prototype 프로퍼티를 소유한다.
(function () {}).hasOwnProperty(&#39;prototype&#39;); // true

// 일반 객체는 prototype 프로퍼티를 소유하지 않는다.
({}).hasOwnProperty(&#39;prototype&#39;); // false</code></pre>]]></description>
        </item>
    </channel>
</rss>