<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ Jung Hoon Lee - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/korean/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ Jung Hoon Lee - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/korean/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Fri, 08 May 2026 14:10:07 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/korean/news/author/jung/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ 자바스크립트 데이터 타입들: Typeof 설명 ]]>
                </title>
                <description>
                    <![CDATA[  typeof는 호출했을 때 변수의 타입을 반환하는 자바스크립트 키워드입니다. 이를 사용하여 함수 매개변수의 유효성을 검사하거나 변수가 정의되어 있는지 확인할 수 있습니다. 그 외에 다른 용도들도 있습니다. typeof 연산자는 코드에서 변수의 타입을 쉽게 확인할 수 있는 방법이기 때문에 유용합니다. 이것은 자바스크립트가 동적 타입 언어 [https://stackoverflow.com/questions/2690544/what-is-the-difference-between-a-strongly-typed-language-and-a-statically-typed] 이기 때문에 중요합니다. 이는 변수를 생성할 ]]>
                </description>
                <link>https://www.freecodecamp.org/korean/news/javascript-data-types-typeof-explained/</link>
                <guid isPermaLink="false">6436fe64c44e4506867281a0</guid>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Jung Hoon Lee ]]>
                </dc:creator>
                <pubDate>Wed, 12 Apr 2023 21:46:34 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/korean/news/content/images/2023/04/5f9c9e80740569d1a4ca3d75.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p data-test-label="translation-intro">
        <strong>기사 원문:</strong> <a href="https://www.freecodecamp.org/news/javascript-data-types-typeof-explained/" target="_blank" rel="noopener noreferrer" data-test-label="original-article-link">JavaScript Data Types: Typeof Explained</a>
      </p><h4></h4><h3 id="typeof-"><code>typeof</code>는 호출했을 때 변수의 타입을 반환하는 자바스크립트 키워드입니다. 이를 사용하여 함수 매개변수의 유효성을 검사하거나 변수가 정의되어 있는지 확인할 수 있습니다. 그 외에 다른 용도들도 있습니다.</h3><p><code>typeof</code> 연산자는 코드에서 변수의 타입을 쉽게 확인할 수 있는 방법이기 때문에 유용합니다. 이것은 자바스크립트가 <a href="https://stackoverflow.com/questions/2690544/what-is-the-difference-between-a-strongly-typed-language-and-a-statically-typed">동적 타입 언어</a>이기 때문에 중요합니다. 이는 변수를 생성할 때 타입을 할당하지 않아도 된다는 뜻입니다. 변수는 이런 식으로 제한이 되지 않으므로 프로그램의 실행 중에 타입이 바뀔 수 있습니다.</p><p>예제:</p><pre><code class="language-javascript">var x = 12345; // number
x = 'string'; // string
x = { key: 'value' }; // object
</code></pre><p>위의 예제에서 볼 수 있듯이, 자바스크립트의 변수는 프로그램이 실행되는 동안 타입이 바뀔 수 있습니다. 프로그래머로서 이를 추적하기는 어려울 수 있고, 여기서 <code>typeof</code> 연산자가 유용합니다.</p><p><code>typeof</code> 연산자는 변수의 현재 타입을 나타내는 문자열을 반환합니다. <code>typeof(변수)</code> 또는 <code>typeof 변수</code>로 입력하여 사용합니다. 이전 예제로 돌아가서 각 단계의 변수 <code>x</code>의 타입을 확인하는데 이를 사용할 수 있습니다.</p><pre><code class="language-javascript">var x = 12345;
console.log(typeof x) // number
x = 'string';
console.log(typeof x) // string
x = { key: 'value' };
console.log(typeof x) // object
</code></pre><p>이는 함수 안에서 변수의 타입을 확인하고 적절히 계속해 나가는 데 유용할 수 있습니다.</p><p>문자열이나 숫자 변수를 가져올 수 있게 하는 함수의 예제입니다.<br>예제:</p><pre><code class="language-javascript">function doSomething(x) {
  if(typeof(x) === 'string') {
    alert('x is a string')
  } else if(typeof(x) === 'number') {
    alert('x is a number')
  }
}
</code></pre><p><code>typeof</code> 연산자가 유용할 수 있는 또 다른 방법은 코드 안에서 액세스하려고 시도하기 전에 변수가 정의되어 있는지 확인하는 것입니다. 이는 만약에 정의되어 있지 않은 변수에 액세스를 시도하려고 할 때 발생할 수 있는 프로그램 오류를 막을 수 있습니다.</p><pre><code class="language-javascript">function(x){
  if (typeof(x) === 'undefined') {
    console.log('variable x is not defined');
    return;
  }
  // continue with function here...
}
</code></pre><p><code>typeof</code> 연산자의 결과는 숫자를 확인할 때 항상 기대했던 결과를 주지는 않을 것입니다.<br>숫자는 여러 가지 이유로 <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN">Nan(Not A Number : 숫자가 아님)</a> 값으로 바뀔 수 있습니다.</p><pre><code class="language-javascript">console.log(typeof NaN); //"number"
</code></pre><p>아마도 오브젝트 안의 숫자에 액세스하는 것을 잊어서 오브젝트 자체에 숫자를 곱하려고 시도했을 수도 있습니다.</p><pre><code class="language-javascript">var x = 1;
var y = { number: 2 };
console.log(x * y); // NaN
console.log(typeof (x * y)); // number
</code></pre><p>이것이 유용한 유효성 검사 방법임에도 불구하고 자바스크립트는 좀 이상한 부분이 있고 그중의 하나는 특정 명령어에 대한 <code>typeof</code>의 결과이기 때문에 주의해야 합니다. 예를 들어 자바스크립트에서는 많은 것들이 단지 <code>objects</code>로 취급됩니다.</p><pre><code class="language-javascript">var x = [1,2,3,4];
console.log(typeof x)  // object

console.log(typeof null)  // object
</code></pre><p><br></p><hr><p><br></p><p>만약 이글이 도움이 되었다면, <a href="https://twitter.com/intent/tweet?text=JavaScript%20Data%20Types%3A%20Typeof%20Explained%0A%0A">트윗해 주세요</a>.</p><p>무료로 코딩하는 법을 배우세요. freeCodeCamp의 오픈 소스 과정은 4만 명이 넘는 사람들이 개발자로 직업을 얻도록 도왔습니다. <a href="https://www.freecodecamp.org/learn/">시작하기</a>.</p> ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
