<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: 김영민</title>
    <description>The latest articles on Forem by 김영민 (@adrahi).</description>
    <link>https://forem.com/adrahi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3411543%2F224b78eb-1849-4eb7-9c64-cbd62acbf1ac.png</url>
      <title>Forem: 김영민</title>
      <link>https://forem.com/adrahi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/adrahi"/>
    <language>en</language>
    <item>
      <title>Building a Unique Developer Portfolio</title>
      <dc:creator>김영민</dc:creator>
      <pubDate>Sun, 09 Nov 2025 08:46:20 +0000</pubDate>
      <link>https://forem.com/adrahi/building-a-unique-developer-portfolio-2b9a</link>
      <guid>https://forem.com/adrahi/building-a-unique-developer-portfolio-2b9a</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzrrpdgm0bi2uilsg0mdo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzrrpdgm0bi2uilsg0mdo.png" alt=" " width="800" height="380"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Creating a Portfolio Page
&lt;/h1&gt;

&lt;p&gt;As a developer, I wanted to create a portfolio page that showcases my skills and experience in a unique way. I decided to go with a magazine-style concept, as it looks clean and easy to read.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Three Different Views?
&lt;/h2&gt;

&lt;p&gt;I divided my portfolio into three views: resume, timeline, and gallery. Each view displays the same career data but in a different format.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Resume Page&lt;/strong&gt;: A clean and traditional resume-style page.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Timeline&lt;/strong&gt;: A timeline view that organizes my experience in chronological order.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gallery&lt;/strong&gt;: A gallery view that showcases my projects in detail.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each page has a distinct feel and purpose, allowing me to highlight different aspects of my portfolio.&lt;/p&gt;

&lt;h2&gt;
  
  
  Notable Features
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Color Pencil Hover Effect
&lt;/h3&gt;

&lt;p&gt;I experimented with various hover effects and settled on a color pencil underline effect. The implementation turned out better than expected.&lt;/p&gt;

&lt;h3&gt;
  
  
  Gallery Emphasis
&lt;/h3&gt;

&lt;p&gt;When creating the project details page, I worried that lengthy content would deter readers. To address this, I highlighted key points with underlines, making it easy to scan and understand the project's essence.&lt;/p&gt;

&lt;h3&gt;
  
  
  Responsive Timeline
&lt;/h3&gt;

&lt;p&gt;The timeline's responsive design was the most challenging aspect. Initially, the columns would overflow, and &lt;code&gt;overflow-x: auto&lt;/code&gt; would break the &lt;code&gt;position: sticky&lt;/code&gt; property. After a day of troubleshooting, I resolved the issue using &lt;code&gt;transform: scale()&lt;/code&gt;, which scales the entire timeline to fit within the viewport on smaller screens.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sidebar Project Summary
&lt;/h3&gt;

&lt;p&gt;On the resume and timeline pages, clicking on a project displays a brief summary in the sidebar. This design choice prevents the project overview from disrupting the page's flow, allowing readers to expand or collapse the summary as needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Through this project, I learned that the way data is presented significantly impacts the user experience. I will continue to experiment with different formats and designs to create engaging and effective portfolios.&lt;/p&gt;

&lt;p&gt;You can visit my portfolio page at: &lt;a href="https://readmekym.vercel.app/" rel="noopener noreferrer"&gt;https://readmekym.vercel.app/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>portfolio</category>
      <category>resume</category>
      <category>timeline</category>
    </item>
    <item>
      <title>Browser Rendering Process and Optimization</title>
      <dc:creator>김영민</dc:creator>
      <pubDate>Mon, 03 Nov 2025 05:36:53 +0000</pubDate>
      <link>https://forem.com/adrahi/browser-rendering-process-and-optimization-3a18</link>
      <guid>https://forem.com/adrahi/browser-rendering-process-and-optimization-3a18</guid>
      <description>&lt;h1&gt;
  
  
  Browser Rendering Process and Optimization
&lt;/h1&gt;

&lt;p&gt;The process of a browser rendering a web page on the screen involves several steps. Understanding these steps is crucial for optimizing the performance of web applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Entire Rendering Process
&lt;/h2&gt;

&lt;p&gt;The sequence of events in the browser rendering process is as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;HTML parsing → DOM creation → CSS parsing → CSSOM creation 
→ render tree creation → layout → paint → compositing
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  1. HTML Parsing and DOM Tree Creation
&lt;/h3&gt;

&lt;p&gt;The browser reads the HTML document and creates a DOM (Document Object Model) tree. The DOM tree represents the hierarchical structure of the HTML document as a tree of objects.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Characteristics of the DOM Tree:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Represents the HTML document's structure as an object model&lt;/li&gt;
&lt;li&gt;Each element, attribute, and text is represented as a node&lt;/li&gt;
&lt;li&gt;Parent-child and sibling node relationships can be determined&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Role:&lt;/strong&gt; Provides an interface for JavaScript to navigate and manipulate HTML elements.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. CSS Parsing and CSSOM Tree Creation
&lt;/h3&gt;

&lt;p&gt;The browser parses CSS files and &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; tags to create a CSSOM (CSS Object Model) tree.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Characteristics of CSSOM:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Represents each HTML element's applied CSS rules as objects&lt;/li&gt;
&lt;li&gt;Combines with the DOM to prepare visual styles&lt;/li&gt;
&lt;li&gt;Considered a render-blocking resource&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Render Tree Formation
&lt;/h3&gt;

&lt;p&gt;The browser combines the DOM and CSSOM to create a render tree.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Characteristics of the Render Tree:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Only includes elements that will be displayed on the screen (&lt;code&gt;display: none&lt;/code&gt; elements are excluded)&lt;/li&gt;
&lt;li&gt;Includes the styles and visual information for each element&lt;/li&gt;
&lt;li&gt;The core data structure for rendering the screen&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. Layout (Layout/Reflow)
&lt;/h3&gt;

&lt;p&gt;The browser calculates the exact position and size of each element based on the render tree.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Main Tasks:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Determines the position of elements within the viewport&lt;/li&gt;
&lt;li&gt;Calculates the size, margin, and padding of each element&lt;/li&gt;
&lt;li&gt;Layout calculations can cause reflow&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  5. Paint
&lt;/h3&gt;

&lt;p&gt;The browser draws the elements on the screen in pixel units, using the positions and sizes calculated during the layout stage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Applied Style Properties:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Color, text, shadow, border&lt;/li&gt;
&lt;li&gt;Background image, transparency&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Paint Layers:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;z-index&lt;/code&gt;, &lt;code&gt;position&lt;/code&gt;, &lt;code&gt;opacity&lt;/code&gt; properties can create independent layers&lt;/li&gt;
&lt;li&gt;Each element can have its own paint layer&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  6. Compositing
&lt;/h3&gt;

&lt;p&gt;The browser combines the layers created during the paint process onto the screen.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Compositing Process:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Considers the layering order (&lt;code&gt;z-index&lt;/code&gt;, &lt;code&gt;position&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Uses the GPU to composite the final screen&lt;/li&gt;
&lt;li&gt;Completes the rendering of the browser screen&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Summary of the Rendering Process
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Stage&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;th&gt;Key Points&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;HTML Parsing&lt;/td&gt;
&lt;td&gt;HTML → DOM Tree&lt;/td&gt;
&lt;td&gt;Incremental rendering possible&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CSS Parsing&lt;/td&gt;
&lt;td&gt;CSS → CSSOM Tree&lt;/td&gt;
&lt;td&gt;Render-blocking resource&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Render Tree Creation&lt;/td&gt;
&lt;td&gt;DOM + CSSOM → Render Tree&lt;/td&gt;
&lt;td&gt;Excludes &lt;code&gt;display:none&lt;/code&gt; elements&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Layout&lt;/td&gt;
&lt;td&gt;Calculates element position/size&lt;/td&gt;
&lt;td&gt;Can cause reflow (high cost)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Paint&lt;/td&gt;
&lt;td&gt;Draws pixels&lt;/td&gt;
&lt;td&gt;Can cause repaint&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Compositing&lt;/td&gt;
&lt;td&gt;Combines layers onto the screen&lt;/td&gt;
&lt;td&gt;Utilizes GPU acceleration&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Critical Rendering Path and Optimization
&lt;/h2&gt;

&lt;p&gt;The Critical Rendering Path (CRP) refers to the sequence of events from the time the browser receives HTML, CSS, and JavaScript resources to the time it renders the first pixel on the screen.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. DOM construction (HTML parsing)
        ↓
2. CSSOM construction (CSS parsing)  
        ↓
3. Render tree creation (DOM + CSSOM)
        ↓
4. Layout (position/size calculation)
        ↓
5. Paint (actual pixel drawing)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;While it may seem similar to the browser rendering process, the CRP is specifically focused on optimizing the time it takes for the browser to receive resources and render the first pixel.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Checkpoints
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. CSS Blocks Rendering
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- Rendering is blocked until this CSS is loaded --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"styles.css"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If CSS is not loaded, the browser will block rendering, causing a Flash of Unstyled Content (FOUC), where the HTML is rendered without CSS, and then the CSS is applied, causing a sudden change in the layout.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. JavaScript Blocks Parsing
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- HTML parsing is blocked until this script is executed --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"app.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;JavaScript can update the DOM structure, so the browser blocks HTML parsing until the script is downloaded and executed.&lt;/p&gt;

&lt;h3&gt;
  
  
  CRP Optimization Strategies
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1️⃣ JavaScript Loading Strategy
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- ❌ Blocks parsing --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"app.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

&lt;span class="c"&gt;&amp;lt;!-- ✅ Executes after HTML parsing is complete --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"app.js"&lt;/span&gt; &lt;span class="na"&gt;defer&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

&lt;span class="c"&gt;&amp;lt;!-- ✅ Downloads in parallel, executes as soon as downloaded --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"analytics.js"&lt;/span&gt; &lt;span class="na"&gt;async&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

&lt;span class="c"&gt;&amp;lt;!-- ✅ Module syntax (automatic defer) --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"module"&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"app.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Differences between each approach:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Regular &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt;: Blocks HTML parsing and executes immediately&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;defer&lt;/code&gt;: Downloads in parallel with HTML parsing, executes after parsing is complete (order is guaranteed)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;async&lt;/code&gt;: Downloads in parallel with HTML parsing, executes as soon as downloaded (order is not guaranteed)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;type="module"&lt;/code&gt;: Automatically defers execution&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  2️⃣ Using Resource Hints
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- Preloads font --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"preload"&lt;/span&gt; &lt;span class="na"&gt;as=&lt;/span&gt;&lt;span class="s"&gt;"font"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"/myfont.woff2"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"font/woff2"&lt;/span&gt; &lt;span class="na"&gt;crossorigin&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="c"&gt;&amp;lt;!-- Preloads LCP image --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"preload"&lt;/span&gt; &lt;span class="na"&gt;as=&lt;/span&gt;&lt;span class="s"&gt;"image"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"/hero.jpg"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="c"&gt;&amp;lt;!-- Prefetches resources for the next page --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"prefetch"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"/next-page.bundle.js"&lt;/span&gt; &lt;span class="na"&gt;as=&lt;/span&gt;&lt;span class="s"&gt;"script"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Types of resource hints:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;preload&lt;/code&gt;: Prioritizes the download of resources needed for the current page&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;prefetch&lt;/code&gt;: Downloads resources for the next page during idle time&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;preconnect&lt;/code&gt;: Establishes a connection to a specific domain in advance&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  3️⃣ Font Optimization
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@font-face&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;'MyFont'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;src&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sx"&gt;url('myfont.woff2')&lt;/span&gt; &lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;'woff2'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="py"&gt;font-display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;swap&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Need for font optimization:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Web fonts require a network request&lt;/li&gt;
&lt;li&gt;Large font files can delay initial rendering&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;font-display: swap&lt;/code&gt; allows the browser to display the system font first and then swap to the web font once it's loaded&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;font-display&lt;/code&gt; options:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;auto&lt;/code&gt;: Browser default behavior&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;block&lt;/code&gt;: Hides text until the font is loaded (up to 3 seconds)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;swap&lt;/code&gt;: Displays system font first, then swaps to web font once loaded&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;fallback&lt;/code&gt;: Uses a fallback font for a short period&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;optional&lt;/code&gt;: Decides whether to use the web font based on network conditions&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  4️⃣ Image Optimization
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"thumb.webp"&lt;/span&gt; &lt;span class="na"&gt;loading=&lt;/span&gt;&lt;span class="s"&gt;"lazy"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"Thumbnail"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Image optimization methods:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use WebP, AVIF, or other formats optimized for the web&lt;/li&gt;
&lt;li&gt;Use lazy loading to delay loading images until they're visible in the viewport&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;srcset&lt;/code&gt; and &lt;code&gt;sizes&lt;/code&gt; attributes to provide responsive images&lt;/li&gt;
&lt;li&gt;Optimize image file size and compression&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Reflow and Repaint
&lt;/h2&gt;

&lt;p&gt;Let's dive deeper into the process of updating elements in the browser.&lt;/p&gt;

&lt;h3&gt;
  
  
  Definitions
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Reflow&lt;/strong&gt;: The process of recalculating the layout of an element, including its position and size.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Repaint&lt;/strong&gt;: The process of redrawing an element's visual styles, such as color, background, or border.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  DOM Update → Reflow/Repaint Flow
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. DOM Update
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;JavaScript updates the DOM, marking the affected node as dirty.&lt;/li&gt;
&lt;li&gt;The render tree remains unchanged at this point.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  2. Render Tree (Render Tree) Check
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The browser checks the dirty node and determines which areas of the render tree need to be updated.&lt;/li&gt;
&lt;li&gt;If the size or position of an element changes, a reflow is marked as necessary.&lt;/li&gt;
&lt;li&gt;If only visual styles change, a repaint is marked as necessary.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  3. Reflow (Layout) Stage
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The browser recalculates the box model (box model) of the dirty node and its affected ancestors, descendants, and siblings.&lt;/li&gt;
&lt;li&gt;The render tree is updated with the new layout information.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  4. Repaint (Paint) Stage
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The browser redraws the element with the updated visual styles.&lt;/li&gt;
&lt;li&gt;The repaint stage occurs after the reflow stage, if necessary.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  5. Composite Stage
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The browser composites the painted layers onto the screen using the GPU.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DOM update → dirty mark → reflow (if necessary) → repaint → composite → screen update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Reflow Details
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Definition
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The process of calculating the layout of an element, including its position and size.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Relationship with Browser Rendering
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DOM + CSSOM → Render Tree → Layout (Reflow) → Paint → Composite
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reflow is a necessary step in the rendering process to ensure that elements are correctly positioned and sized.&lt;/p&gt;

&lt;h4&gt;
  
  
  Occurrence Conditions
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;When an element's size, position, or DOM structure changes.&lt;/li&gt;
&lt;li&gt;When CSS properties that affect layout are changed, such as &lt;code&gt;width&lt;/code&gt;, &lt;code&gt;height&lt;/code&gt;, &lt;code&gt;margin&lt;/code&gt;, &lt;code&gt;padding&lt;/code&gt;, or &lt;code&gt;border&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;When the browser window is resized or scrolled.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Characteristics
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Reflow can be an expensive operation, especially when it affects many elements.&lt;/li&gt;
&lt;li&gt;Reflow can cause a cascade of reflows in affected elements.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Repaint Details
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Definition
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The process of redrawing an element's visual styles, such as color, background, or border.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Relationship with Browser Rendering
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Layout (Reflow) → Paint (Repaint) → Composite
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Repaint occurs after the reflow stage, if necessary, to update the visual styles of an element.&lt;/p&gt;

&lt;h4&gt;
  
  
  Occurrence Conditions
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;When an element's visual styles change, such as &lt;code&gt;color&lt;/code&gt;, &lt;code&gt;background-color&lt;/code&gt;, or &lt;code&gt;border-color&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;When an element's opacity or transparency changes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Characteristics
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Repaint is generally less expensive than reflow.&lt;/li&gt;
&lt;li&gt;Repaint only affects the element being updated, whereas reflow can affect multiple elements.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Reflow vs Repaint Comparison
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Category&lt;/th&gt;
&lt;th&gt;Reflow (Layout)&lt;/th&gt;
&lt;th&gt;Repaint (Paint)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Definition&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Calculates element position and size&lt;/td&gt;
&lt;td&gt;Redraws element visual styles&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Occurrence Conditions&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Size, position, or DOM structure changes&lt;/td&gt;
&lt;td&gt;Visual style changes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Calculation Cost&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Cascade Effect&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Can affect multiple elements&lt;/td&gt;
&lt;td&gt;Only affects the updated element&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Examples&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;width&lt;/code&gt;, &lt;code&gt;height&lt;/code&gt;, &lt;code&gt;display&lt;/code&gt;, &lt;code&gt;font-size&lt;/code&gt; changes&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;color&lt;/code&gt;, &lt;code&gt;background-color&lt;/code&gt;, &lt;code&gt;border-color&lt;/code&gt; changes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;In conclusion, understanding the browser rendering process and the critical rendering path is crucial for optimizing the performance of web applications. By minimizing reflow and repaint operations, using efficient JavaScript loading strategies, and optimizing fonts and images, developers can improve the user experience and reduce the time it takes for the browser to render the first pixel on the screen.&lt;/p&gt;

</description>
      <category>performance</category>
      <category>html</category>
      <category>frontend</category>
      <category>css</category>
    </item>
    <item>
      <title>Ace Your Next Interview: Frontend Developer Questions in Korea</title>
      <dc:creator>김영민</dc:creator>
      <pubDate>Tue, 23 Sep 2025 10:30:39 +0000</pubDate>
      <link>https://forem.com/adrahi/ace-your-next-interview-frontend-developer-questions-in-korea-2lni</link>
      <guid>https://forem.com/adrahi/ace-your-next-interview-frontend-developer-questions-in-korea-2lni</guid>
      <description>&lt;h1&gt;
  
  
  Frontend Developer Interview Questions in the Korean IT Industry
&lt;/h1&gt;

&lt;p&gt;As a frontend developer, preparing for technical interviews can be a daunting task. In this article, we'll explore common interview questions that frontend developers may encounter in the Korean IT industry. These questions are designed to test not only your technical skills but also your understanding of web development principles and your ability to solve real-world problems.&lt;/p&gt;

&lt;h2&gt;
  
  
  Browser-Related Questions
&lt;/h2&gt;

&lt;p&gt;When it comes to browser-related questions, interviewers often want to assess your understanding of how browsers work and how to optimize web applications for better performance. Here are some examples:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Explain the browser rendering process step by step&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What is the Critical Rendering Path, and how can you optimize it?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What is the difference between Reflow and Repaint, and under what conditions do they occur?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Explain browser caching strategies and their characteristics&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What is CORS, and how can you resolve CORS issues?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What are the differences between LocalStorage, SessionStorage, and Cookies?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Explain the Event Loop, Call Stack, and Task Queue&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;How do you handle browser compatibility issues, and what methods do you use to resolve them?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What are the key metrics for web performance optimization, and how can you improve them?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What is the role of Service Workers, and how can you utilize them?&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  HTML-Related Questions
&lt;/h2&gt;

&lt;p&gt;HTML is the foundation of web development, and interviewers may ask questions to test your understanding of HTML concepts and best practices. Here are some examples:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Explain the importance of semantic HTML and its major tags&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What is the role of the DOCTYPE declaration, and what are the characteristics of the HTML5 DOCTYPE?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What are the different types of meta tags, and how do they impact SEO and performance?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;How do you ensure web accessibility (a11y) in your HTML code?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What are the key attributes and validation methods for the Form tag?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What is the purpose of the &lt;code&gt;data-*&lt;/code&gt; attribute, and how can you use it?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What HTML tags and attributes can you use to optimize images?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What new elements were introduced in HTML5, and how can you use them?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What is the difference between the &lt;code&gt;async&lt;/code&gt; and &lt;code&gt;defer&lt;/code&gt; attributes in the script tag?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What HTML settings are required for Progressive Web Apps?&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  CSS-Related Questions
&lt;/h2&gt;

&lt;p&gt;CSS is a crucial aspect of web development, and interviewers may ask questions to test your understanding of CSS concepts, best practices, and optimization techniques. Here are some examples:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Explain the CSS Box Model and the &lt;code&gt;box-sizing&lt;/code&gt; property&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What is the difference between Flexbox and Grid, and when should you use each?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;How do you calculate CSS specificity, and what are the rules for overriding styles?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What CSS techniques can you use for responsive web design?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What are the benefits and drawbacks of using CSS preprocessors like Sass or LESS?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What is the difference between CSS-in-JS and traditional CSS, and what are the pros and cons of each approach?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;How can you optimize CSS animations and the &lt;code&gt;transform&lt;/code&gt; property?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What are the benefits and drawbacks of using CSS methodologies like BEM or SMACSS?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What is the difference between a mobile-first and desktop-first approach, and when should you use each?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What CSS optimization techniques can you use to improve web performance?&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  JavaScript-Related Questions
&lt;/h2&gt;

&lt;p&gt;JavaScript is a fundamental programming language for web development, and interviewers may ask questions to test your understanding of JavaScript concepts, syntax, and best practices. Here are some examples:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Explain the concept of hoisting and the Temporal Dead Zone (TDZ)&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What is a closure, and how can you use it in your code?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What are the rules for &lt;code&gt;this&lt;/code&gt; binding, and how does it work in different contexts?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;How do you implement prototypal inheritance in JavaScript?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What are the differences between Promises, async/await, and callbacks?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What is event delegation, and how can you use it to improve performance?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What is the difference between scope and execution context, and how do they relate to each other?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What are the key features and use cases for ES6+ syntax?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;How can you prevent memory leaks in your JavaScript code?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What is functional programming, and how can you apply it in JavaScript?&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  React-Related Questions
&lt;/h2&gt;

&lt;p&gt;React is a popular JavaScript library for building user interfaces, and interviewers may ask questions to test your understanding of React concepts, best practices, and optimization techniques. Here are some examples:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Explain the concept of the Virtual DOM and its performance benefits&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What is the React lifecycle, and how do Hooks relate to it?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;How can you optimize the use of &lt;code&gt;useState&lt;/code&gt; and &lt;code&gt;useEffect&lt;/code&gt;?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What is the problem of Props Drilling, and how can you solve it?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What are the benefits and drawbacks of using state management libraries like Redux or Zustand?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What is the difference between &lt;code&gt;React.memo&lt;/code&gt;, &lt;code&gt;useMemo&lt;/code&gt;, and &lt;code&gt;useCallback&lt;/code&gt;, and when should you use each?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;How can you write custom Hooks, and what are the benefits of doing so?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What are the principles of component design, and how can you write reusable components?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What are the key features and changes in React 18?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What React optimization techniques can you use to improve web performance?&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Network-Related Questions
&lt;/h2&gt;

&lt;p&gt;Understanding how the web works is crucial for frontend developers, and interviewers may ask questions to test your knowledge of network protocols, security, and optimization techniques. Here are some examples:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;What is the difference between HTTP and HTTPS, and how does the SSL/TLS handshake work?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What are the main HTTP status codes, and what do they mean?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What are the principles of RESTful API design, and what are some best practices?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What is the difference between GraphQL and REST API, and what are the pros and cons of each?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What are some common web security threats (XSS, CSRF), and how can you prevent them?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;How do you implement HTTP caching, and what are the benefits of doing so?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What is the difference between WebSockets and traditional HTTP communication?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;How do CDNs work, and what are the performance benefits of using them?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What are some common API authentication methods (JWT, OAuth), and what are the security considerations?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What network optimization techniques can you use to improve web performance?&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Computer Science-Related Questions
&lt;/h2&gt;

&lt;p&gt;Finally, interviewers may ask questions to test your understanding of computer science concepts, data structures, and algorithms. Here are some examples:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;What are the characteristics of common data structures (arrays, stacks, queues, trees), and what are their time complexities?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What are the different types of sorting algorithms, and what are their performance characteristics?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;How do hash tables work, and what are some strategies for resolving collisions?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What are the concepts of time and space complexity, and how do you analyze them?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What is the difference between recursion and iteration, and when should you use each?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What is dynamic programming, and how can you apply it to solve problems?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;How do database indexes work, and what are the performance implications?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What is the difference between processes and threads, and how do they relate to web development?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What are some strategies for memory management, and how do you prevent memory leaks?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What are some common design patterns (Singleton, Observer, Factory), and how can you apply them in your code?&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;I'll organize and post these questions one by one going forward.&lt;br&gt;
Actually, the questions above might be a bit outdated by 1-2 years, so they might be somewhat different from what's used in the current industry. These days, there's also a growing trend of giving pre-assignments and conducting technical interviews based on the actual code that candidates have written. What kinds of questions do you ask when hiring junior or entry-level developers in your workplace?&lt;br&gt;
It would be interesting for all of us to check together how much we know about these questions and whether there are any parts we might have forgotten.&lt;/p&gt;

</description>
      <category>frontend</category>
      <category>korea</category>
      <category>interview</category>
    </item>
    <item>
      <title>Exploring Programming Language Paradigms</title>
      <dc:creator>김영민</dc:creator>
      <pubDate>Sun, 21 Sep 2025 08:08:45 +0000</pubDate>
      <link>https://forem.com/adrahi/exploring-programming-language-paradigms-403a</link>
      <guid>https://forem.com/adrahi/exploring-programming-language-paradigms-403a</guid>
      <description>&lt;h1&gt;
  
  
  Programming Language Paradigms
&lt;/h1&gt;

&lt;p&gt;Programming language paradigms are fundamental styles or approaches to writing software. Each paradigm provides a unique perspective on how to design, structure, and implement code. Understanding these paradigms is essential for developers to choose the best approach for their projects.&lt;/p&gt;

&lt;h2&gt;
  
  
  Overview of Programming Languages and Paradigms
&lt;/h2&gt;

&lt;p&gt;The following table summarizes some popular programming languages and the paradigms they support:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Language&lt;/th&gt;
&lt;th&gt;Supported Paradigms&lt;/th&gt;
&lt;th&gt;Characteristics&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;C&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Procedural&lt;/td&gt;
&lt;td&gt;System programming, performance-oriented&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Java&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Object-Oriented, Functional&lt;/td&gt;
&lt;td&gt;Large-scale enterprise applications, popular&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Python&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Procedural, Object-Oriented, Functional&lt;/td&gt;
&lt;td&gt;Multi-paradigm, easy syntax, extensive libraries&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;JavaScript&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Procedural, Object-Oriented, Functional, Event-Driven&lt;/td&gt;
&lt;td&gt;Core language for web development, flexible multi-paradigm support&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Ruby&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Object-Oriented, Functional&lt;/td&gt;
&lt;td&gt;Concise syntax, famous for Rails&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Haskell&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Functional&lt;/td&gt;
&lt;td&gt;Pure functional programming, academic research, and finance&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;C++&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Procedural, Object-Oriented&lt;/td&gt;
&lt;td&gt;Performance-centric, games, and high-performance systems&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Object-Oriented, Functional&lt;/td&gt;
&lt;td&gt;Strongly supported in Microsoft environments&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Scala&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Object-Oriented, Functional&lt;/td&gt;
&lt;td&gt;Introduces functional programming to the Java ecosystem&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Kotlin&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Object-Oriented, Functional&lt;/td&gt;
&lt;td&gt;Popular for Android development, modern alternative to Java&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Prolog&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Logic&lt;/td&gt;
&lt;td&gt;AI, data inference systems&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;SQL&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Declarative&lt;/td&gt;
&lt;td&gt;Database query language&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Key Programming Paradigms
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Procedural Programming&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Characteristics&lt;/strong&gt;: Programs are written in a sequence of commands, executed in order.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Usage&lt;/strong&gt;: Simple problem-solving, logical flow implementation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Advantages&lt;/strong&gt;: Simple structure, suitable for small projects.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Disadvantages&lt;/strong&gt;: Difficult code reuse, challenging for large projects.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Main Languages&lt;/strong&gt;: C, Pascal, BASIC&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Object-Oriented Programming (OOP)&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Characteristics&lt;/strong&gt;: Data is encapsulated into objects, which interact with each other.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Usage&lt;/strong&gt;: Complex system design, maximizing code reuse.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Advantages&lt;/strong&gt;: &lt;strong&gt;Inheritance, polymorphism, and encapsulation enhance maintainability and extensibility&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Disadvantages&lt;/strong&gt;: Initial design and structuring can be challenging.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Main Languages&lt;/strong&gt;: Java, C++, Python, C#, Ruby&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Functional Programming&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Characteristics&lt;/strong&gt;: Minimizes state and side effects, focusing on functions as primary components.

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Pure Functions&lt;/strong&gt;: Emphasizes functions with no side effects, calculating output based solely on input.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Immutability&lt;/strong&gt;: Treats data as immutable to prevent unexpected changes and facilitate parallel processing.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Usage&lt;/strong&gt;: Parallel processing, data analysis, complex mathematical computations.&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Advantages&lt;/strong&gt;: &lt;strong&gt;High code readability, easy testing, and debugging&lt;/strong&gt;.&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Disadvantages&lt;/strong&gt;: May have a learning curve compared to object-oriented programming.&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Main Languages&lt;/strong&gt;: Haskell, Scala, Lisp, F#, parts of JavaScript, Python&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Declarative Programming&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Characteristics&lt;/strong&gt;: Focuses on what the program should accomplish, abstracting how it's done.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Usage&lt;/strong&gt;: Database queries, user interface design.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Advantages&lt;/strong&gt;: Concise code, easy maintenance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Disadvantages&lt;/strong&gt;: Can be challenging for complex logic implementation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Main Languages&lt;/strong&gt;: SQL, HTML, CSS, parts of React (JSX)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Event-Driven Programming&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Characteristics&lt;/strong&gt;: Programs react to specific events (clicks, inputs, network requests).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Usage&lt;/strong&gt;: User interfaces, real-time data processing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Advantages&lt;/strong&gt;: Efficiently handles asynchronous tasks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Disadvantages&lt;/strong&gt;: Event flow can become complex.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Main Languages&lt;/strong&gt;: JavaScript, Node.js&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Logic Programming&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Characteristics&lt;/strong&gt;: Solves problems based on logical rules.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Usage&lt;/strong&gt;: AI, data inference, complex problem-solving.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Advantages&lt;/strong&gt;: Allows logical modeling of problems.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Disadvantages&lt;/strong&gt;: Can be slow in execution.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Main Languages&lt;/strong&gt;: Prolog, Datalog&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Multi-Paradigm Programming&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Characteristics&lt;/strong&gt;: A single language supports multiple paradigms.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Usage&lt;/strong&gt;: Choosing the best paradigm for the problem at hand.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Advantages&lt;/strong&gt;: Offers flexibility for different requirements.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Disadvantages&lt;/strong&gt;: Requires choosing the appropriate paradigm.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Main Languages&lt;/strong&gt;: Python, JavaScript, C#, Kotlin, Swift&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Other Paradigms
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Data-Oriented Programming&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Focuses on data storage and manipulation.&lt;/li&gt;
&lt;li&gt;Languages: R, MATLAB, Julia&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Distributed Programming&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Designs programs to operate in distributed environments.&lt;/li&gt;
&lt;li&gt;Languages: Erlang, Elixir&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Understanding programming language paradigms is crucial for software development. Each paradigm has its strengths and weaknesses, and the choice of paradigm can significantly impact the success of a project. By grasping the fundamentals of these paradigms, developers can make informed decisions about which approach to use for their specific needs, leading to more efficient, maintainable, and scalable software solutions.&lt;/p&gt;

</description>
      <category>paradigms</category>
      <category>languages</category>
      <category>coding</category>
    </item>
    <item>
      <title>Understanding Type Systems in Programming</title>
      <dc:creator>김영민</dc:creator>
      <pubDate>Fri, 19 Sep 2025 11:00:25 +0000</pubDate>
      <link>https://forem.com/adrahi/understanding-type-systems-in-programming-25pf</link>
      <guid>https://forem.com/adrahi/understanding-type-systems-in-programming-25pf</guid>
      <description>&lt;h1&gt;
  
  
  Introduction to Type Systems in Programming Languages
&lt;/h1&gt;

&lt;p&gt;Type systems are a fundamental concept in programming languages, determining how a language handles variables, data types, and operations. In this article, we'll delve into the world of type systems, exploring the different categories, their characteristics, and examples of languages that implement them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Type Classifications
&lt;/h2&gt;

&lt;p&gt;The following table summarizes the main type classifications:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Type Classification&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Description&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Examples&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Dynamically Typed&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Type determined at runtime&lt;/td&gt;
&lt;td&gt;JavaScript, Python, Ruby&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Statically Typed&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Type determined at compile time&lt;/td&gt;
&lt;td&gt;Java, C, C++, TypeScript&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Strongly Typed&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Strict type conversion&lt;/td&gt;
&lt;td&gt;Python, Java, Kotlin&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Weakly Typed&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Automatic type conversion&lt;/td&gt;
&lt;td&gt;JavaScript, PHP, Perl&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Dynamically Typed Languages
&lt;/h2&gt;

&lt;p&gt;Dynamically typed languages determine the type of a variable at runtime. This means that a variable can hold any type of data, and its type is only known when the code is executed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Characteristics
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Variables can hold any type of data&lt;/li&gt;
&lt;li&gt;Type is determined at runtime&lt;/li&gt;
&lt;li&gt;Advantages: flexible and concise code&lt;/li&gt;
&lt;li&gt;Disadvantages: type-related errors are only discovered at runtime&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Examples
&lt;/h3&gt;

&lt;h4&gt;
  
  
  JavaScript
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;    &lt;span class="c1"&gt;// number&lt;/span&gt;
&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// string&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Python
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;          &lt;span class="c1"&gt;# int
&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Python&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;    &lt;span class="c1"&gt;# str
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Statically Typed Languages
&lt;/h2&gt;

&lt;p&gt;Statically typed languages determine the type of a variable at compile time. This means that the type of a variable is known before the code is executed, and any type-related errors are caught during compilation.&lt;/p&gt;

&lt;h3&gt;
  
  
  Characteristics
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Variables must be declared with a specific type&lt;/li&gt;
&lt;li&gt;Type is determined at compile time&lt;/li&gt;
&lt;li&gt;Advantages: type-related errors are caught at compile time&lt;/li&gt;
&lt;li&gt;Disadvantages: more code is required for initial declarations&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Examples
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Java
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;         &lt;span class="c1"&gt;// only numbers are allowed&lt;/span&gt;
&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Hello"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;        &lt;span class="c1"&gt;// compile-time error&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  C
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Alice"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// only strings are allowed&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Strongly Typed Languages
&lt;/h2&gt;

&lt;p&gt;Strongly typed languages have a strict type system, where type conversions are explicit and any implicit conversions are not allowed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Characteristics
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Explicit type conversions are required&lt;/li&gt;
&lt;li&gt;Implicit type conversions are not allowed&lt;/li&gt;
&lt;li&gt;Advantages: prevents type-related errors&lt;/li&gt;
&lt;li&gt;Disadvantages: more verbose code&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Examples
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Python
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;2&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# TypeError
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Java
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"20"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nc"&gt;Integer&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;parseInt&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// explicit conversion required&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Weakly Typed Languages
&lt;/h2&gt;

&lt;p&gt;Weakly typed languages have a lenient type system, where type conversions are automatic and implicit.&lt;/p&gt;

&lt;h3&gt;
  
  
  Characteristics
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Implicit type conversions are allowed&lt;/li&gt;
&lt;li&gt;Explicit type conversions are not required&lt;/li&gt;
&lt;li&gt;Advantages: more flexible code&lt;/li&gt;
&lt;li&gt;Disadvantages: can lead to unexpected behavior&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Examples
&lt;/h3&gt;

&lt;h4&gt;
  
  
  JavaScript
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;    &lt;span class="c1"&gt;// "12" (number is converted to string)&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;5&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;    &lt;span class="c1"&gt;// 3 (string is converted to number)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Mixed Typed Languages
&lt;/h2&gt;

&lt;p&gt;Mixed typed languages combine elements of both dynamically and statically typed languages. They can enforce type checks at compile time but also allow for dynamic typing in certain situations.&lt;/p&gt;

&lt;h3&gt;
  
  
  Characteristics
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Combination of dynamic and static typing&lt;/li&gt;
&lt;li&gt;Type checks can be enforced at compile time&lt;/li&gt;
&lt;li&gt;Advantages: flexibility and type safety&lt;/li&gt;
&lt;li&gt;Disadvantages: can be complex to implement&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Examples
&lt;/h3&gt;

&lt;h4&gt;
  
  
  TypeScript (JavaScript with static typing)
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// static typing&lt;/span&gt;
&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;        &lt;span class="c1"&gt;// compile-time error&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Kotlin
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Alice"&lt;/span&gt;  &lt;span class="c1"&gt;// static typing&lt;/span&gt;
&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;                   &lt;span class="c1"&gt;// compile-time error&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In conclusion, type systems are a crucial aspect of programming languages, and understanding their differences is essential for effective programming. By recognizing the strengths and weaknesses of each type system, developers can choose the best language for their project and write more robust, maintainable code. Whether you prefer the flexibility of dynamically typed languages or the type safety of statically typed languages, knowing the characteristics of each type system will help you become a better programmer.&lt;/p&gt;

</description>
      <category>types</category>
      <category>programming</category>
      <category>languages</category>
    </item>
    <item>
      <title>Mastering JavaScript Inheritance with Prototypes</title>
      <dc:creator>김영민</dc:creator>
      <pubDate>Mon, 15 Sep 2025 11:01:36 +0000</pubDate>
      <link>https://forem.com/adrahi/mastering-javascript-inheritance-with-prototypes-1ph6</link>
      <guid>https://forem.com/adrahi/mastering-javascript-inheritance-with-prototypes-1ph6</guid>
      <description>&lt;h1&gt;
  
  
  Understanding JavaScript Prototypes
&lt;/h1&gt;

&lt;p&gt;JavaScript prototypes are a fundamental concept in object-oriented programming, providing a mechanism for inheritance. Unlike class-based languages, JavaScript uses prototype-based inheritance, allowing objects to inherit properties and methods from other objects.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are Prototypes?
&lt;/h2&gt;

&lt;p&gt;In JavaScript, every object has an internal &lt;code&gt;[[Prototype]]&lt;/code&gt; property that references its parent object. When accessing a property on an object, if it doesn't exist, the prototype chain is searched for that property.&lt;/p&gt;

&lt;h3&gt;
  
  
  Prototype Chain
&lt;/h3&gt;

&lt;p&gt;The prototype chain is a series of objects referencing each other, allowing for continuous searching of properties. If the chain is traversed and the property is still not found, &lt;code&gt;undefined&lt;/code&gt; is returned. &lt;code&gt;Object.prototype&lt;/code&gt; is the top-most prototype that all objects reference.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Prototypes
&lt;/h2&gt;

&lt;p&gt;Objects can set their prototypes using the &lt;code&gt;prototype&lt;/code&gt; property.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Person&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Set the greet method on the Person prototype&lt;/span&gt;
&lt;span class="nx"&gt;Person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;greet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Hello, my name is &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;person1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Person&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;person1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// "Hello, my name is Alice"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Utilizing Prototypes
&lt;/h2&gt;

&lt;p&gt;Prototypes are useful for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Inheritance&lt;/strong&gt;: Sharing common functionality among multiple objects.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Method sharing&lt;/strong&gt;: Saving memory by sharing methods among objects.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Class-based inheritance&lt;/strong&gt;: Defining classes and methods using prototypes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Prototype Chain Example
&lt;/h2&gt;

&lt;p&gt;Here's an example of a prototype chain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Animal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;Animal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sayHello&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Hello, I'm a(n) &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Dog&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;Animal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// Call the parent class constructor&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;Dog&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Animal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// Set Dog's prototype to Animal's&lt;/span&gt;
&lt;span class="nx"&gt;Dog&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;constructor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Dog&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// Update the constructor&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;dog&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Dog&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Dog&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;dog&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sayHello&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  &lt;span class="c1"&gt;// "Hello, I'm a(n) Dog"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Implicit Prototype Chain
&lt;/h2&gt;

&lt;p&gt;If you don't explicitly set a prototype chain, JavaScript will default to &lt;code&gt;Object.prototype&lt;/code&gt;. However, to share new methods, you need to explicitly set the prototype or use inheritance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Best Practices
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Avoid creating overly deep prototype chains, as they can impact performance.&lt;/li&gt;
&lt;li&gt;Only add necessary methods and properties to prototypes, and avoid unnecessary inheritance.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In conclusion, understanding JavaScript prototypes is crucial for effective object-oriented programming. By leveraging prototypes, you can create more efficient, scalable, and maintainable code. Remember to use prototypes judiciously and follow best practices to avoid potential performance issues.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>prototypes</category>
      <category>oop</category>
    </item>
    <item>
      <title>Mastering Map and Set in JavaScript</title>
      <dc:creator>김영민</dc:creator>
      <pubDate>Fri, 12 Sep 2025 11:43:23 +0000</pubDate>
      <link>https://forem.com/adrahi/mastering-map-and-set-in-javascript-40j1</link>
      <guid>https://forem.com/adrahi/mastering-map-and-set-in-javascript-40j1</guid>
      <description>&lt;h1&gt;
  
  
  Introduction to Map and Set in JavaScript
&lt;/h1&gt;

&lt;p&gt;Map and Set are new data structures introduced in ES6 to complement the existing objects and arrays, providing more powerful features and flexibility in specific situations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Map: A More Powerful Key-Value Store
&lt;/h2&gt;

&lt;p&gt;Map is a data structure that stores key-value pairs, offering more robust features and flexibility compared to traditional objects.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Features of Map
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No key restrictions&lt;/strong&gt;: Unlike objects, where keys are limited to strings and symbols, Map allows any type to be used as a key.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Preserves insertion order&lt;/strong&gt;: Map remembers the order in which elements were inserted, making it an iterable object.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Easy size checking&lt;/strong&gt;: Map has a &lt;code&gt;size&lt;/code&gt; property, making it simple to check the number of elements.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Performance optimization&lt;/strong&gt;: Map provides more efficient addition, deletion, and lookup of key-value pairs compared to objects.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Using Map
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;map&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Map&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// Add elements&lt;/span&gt;
&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;key1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;value1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;value2&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Using a number as a key&lt;/span&gt;
&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;value3&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Using an object as a key&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;key1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// 'value1'&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// 'value2'&lt;/span&gt;

&lt;span class="c1"&gt;// Check size&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;size&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 3&lt;/span&gt;

&lt;span class="c1"&gt;// Delete an element&lt;/span&gt;
&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Check if a key exists&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;has&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// false&lt;/span&gt;

&lt;span class="c1"&gt;// Iterate over all elements&lt;/span&gt;
&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Set: A Collection of Unique Values
&lt;/h2&gt;

&lt;p&gt;Set is a data structure that stores a collection of unique values, similar to an array but without duplicates.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Features of Set
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No duplicates&lt;/strong&gt;: Set automatically removes duplicates, ensuring all values are unique.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stores unique values&lt;/strong&gt;: Set can store numbers, strings, objects, and other values, with each value being unique.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Preserves insertion order&lt;/strong&gt;: Set remembers the order in which elements were inserted.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Using Set
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="kd"&gt;set&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// Add elements&lt;/span&gt;
&lt;span class="kd"&gt;set&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;set&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;set&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Duplicate value is ignored&lt;/span&gt;
&lt;span class="kd"&gt;set&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;set&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Set { 1, 2, 'Hello' }&lt;/span&gt;

&lt;span class="c1"&gt;// Check size&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;set&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;size&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 3&lt;/span&gt;

&lt;span class="c1"&gt;// Delete an element&lt;/span&gt;
&lt;span class="kd"&gt;set&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Check if a value exists&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;set&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;has&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// false&lt;/span&gt;

&lt;span class="c1"&gt;// Iterate over all elements&lt;/span&gt;
&lt;span class="kd"&gt;set&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Practical Use Case: Removing Duplicates from an Array
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;uniqueNumbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;)];&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;uniqueNumbers&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// [1, 2, 3, 4, 5]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In conclusion, Map and Set are powerful data structures in JavaScript that provide more flexibility and features compared to traditional objects and arrays. By understanding how to use Map and Set, you can write more efficient and effective code, and take advantage of their unique features to solve complex problems.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>es6</category>
      <category>mapset</category>
    </item>
    <item>
      <title>Unwrapping JavaScript Primitive Values and Methods</title>
      <dc:creator>김영민</dc:creator>
      <pubDate>Thu, 11 Sep 2025 08:15:37 +0000</pubDate>
      <link>https://forem.com/adrahi/unwrapping-javascript-primitive-values-and-methods-322b</link>
      <guid>https://forem.com/adrahi/unwrapping-javascript-primitive-values-and-methods-322b</guid>
      <description>&lt;h1&gt;
  
  
  JavaScript Primitive Values and Methods
&lt;/h1&gt;

&lt;p&gt;JavaScript primitive values are treated as simple values, so they can't have methods or properties directly. However, when you call a method on a primitive value, it seems to work. Let's dive into how this is possible.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction to Primitive Values
&lt;/h2&gt;

&lt;p&gt;In JavaScript, primitive values include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;String&lt;/strong&gt; (strings)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Number&lt;/strong&gt; (numbers)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;BigInt&lt;/strong&gt; (big integers)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Boolean&lt;/strong&gt; (booleans)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;undefined&lt;/strong&gt; (undefined)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;null&lt;/strong&gt; (null)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Symbol&lt;/strong&gt; (symbols)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Auto-Boxing of Primitive Values
&lt;/h2&gt;

&lt;p&gt;JavaScript automatically wraps primitive values in objects when a method is called on them. This process is called auto-boxing. For example, when you call a string method on a primitive string value, JavaScript converts it to a &lt;strong&gt;String&lt;/strong&gt; object, calls the method, and then converts it back to the original primitive value.&lt;/p&gt;

&lt;p&gt;In other words, when you call a method on a primitive value, JavaScript temporarily boxes it in an object, executes the method, and then unboxes it, returning the original primitive value.&lt;/p&gt;

&lt;p&gt;Here's an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;str&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toUpperCase&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// "HELLO"&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// "HELLO"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, &lt;code&gt;str&lt;/code&gt; is a primitive string value, but you can still call methods like &lt;code&gt;toUpperCase()&lt;/code&gt;, &lt;code&gt;charAt()&lt;/code&gt;, &lt;code&gt;slice()&lt;/code&gt;, and &lt;code&gt;split()&lt;/code&gt; on it. This is because JavaScript automatically converts &lt;code&gt;str&lt;/code&gt; to a &lt;strong&gt;String&lt;/strong&gt; object, calls the method, and then converts it back to the original primitive string value.&lt;/p&gt;

&lt;h2&gt;
  
  
  Practical Tips
&lt;/h2&gt;

&lt;p&gt;When working with primitive values in JavaScript, keep in mind that auto-boxing occurs when you call methods on them. This means you can use methods like &lt;code&gt;toUpperCase()&lt;/code&gt; on string primitives, but it's essential to remember that the original value remains a primitive.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In conclusion, JavaScript's auto-boxing feature allows you to call methods on primitive values by temporarily converting them to objects. This behavior is essential to understand when working with primitive values in JavaScript, and it can help you write more efficient and effective code. By recognizing how auto-boxing works, you can take advantage of methods like &lt;code&gt;toUpperCase()&lt;/code&gt; on string primitives and write more robust JavaScript applications.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>primitives</category>
      <category>methods</category>
    </item>
    <item>
      <title>Mastering JavaScript Iterables</title>
      <dc:creator>김영민</dc:creator>
      <pubDate>Thu, 11 Sep 2025 05:24:59 +0000</pubDate>
      <link>https://forem.com/adrahi/mastering-javascript-iterables-3e17</link>
      <guid>https://forem.com/adrahi/mastering-javascript-iterables-3e17</guid>
      <description>&lt;h1&gt;
  
  
  Introduction to JavaScript Iterable Objects
&lt;/h1&gt;

&lt;p&gt;Iterable objects in JavaScript represent a sequence of values that can be iterated over, such as arrays or strings. Understanding iterable objects is essential for effective data processing and manipulation in JavaScript.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are Iterable Objects?
&lt;/h2&gt;

&lt;p&gt;An iterable object is an object that implements the &lt;code&gt;Symbol.iterator&lt;/code&gt; property, which returns an iterator. This iterator is responsible for yielding values one at a time, allowing us to iterate over the object's values using a &lt;code&gt;for...of&lt;/code&gt; loop.&lt;/p&gt;

&lt;h3&gt;
  
  
  Structure of Iterable Objects
&lt;/h3&gt;

&lt;p&gt;An iterable object consists of two main components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Iterable&lt;/strong&gt;: An object that defines the &lt;code&gt;Symbol.iterator&lt;/code&gt; method, which returns an iterator.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Iterator&lt;/strong&gt;: An object that has a &lt;code&gt;next()&lt;/code&gt; method, which returns an object with &lt;code&gt;value&lt;/code&gt; and &lt;code&gt;done&lt;/code&gt; properties.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// 1, 2, 3, 4, 5&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Examples of Iterable Objects
&lt;/h2&gt;

&lt;p&gt;Some of the most commonly used iterable objects include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Arrays&lt;/strong&gt;: Can be iterated over using &lt;code&gt;for...of&lt;/code&gt; to access each element.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Strings&lt;/strong&gt;: Can be iterated over character by character.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;char&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;char&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// 'H', 'e', 'l', 'l', 'o'&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Implementing Custom Iterable Objects
&lt;/h2&gt;

&lt;p&gt;We can create our own iterable objects by defining the &lt;code&gt;Symbol.iterator&lt;/code&gt; method and implementing the iterator logic.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;myIterable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;Symbol&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;iterator&lt;/span&gt;&lt;span class="p"&gt;]()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;next&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="na"&gt;done&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;done&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;myIterable&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// 1, 2, 3, 4, 5&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Differences Between &lt;code&gt;for...of&lt;/code&gt; and &lt;code&gt;for...in&lt;/code&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;for...of&lt;/code&gt;&lt;/strong&gt;: Iterates over the values of an iterable object.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;for...in&lt;/code&gt;&lt;/strong&gt;: Iterates over the keys of an object.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="c1"&gt;// for...of iterates over values&lt;/span&gt;
&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// 10, 20, 30&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// for...in iterates over indices&lt;/span&gt;
&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// 0, 1, 2&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Using the Spread Operator with Iterable Objects
&lt;/h2&gt;

&lt;p&gt;The spread operator (&lt;code&gt;...&lt;/code&gt;) can be used to expand an iterable object into an array or another iterable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;newArr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;  &lt;span class="c1"&gt;// expands the array and creates a new one&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newArr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// [1, 2, 3, 4, 5]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Examples of Other Iterable Objects
&lt;/h2&gt;

&lt;p&gt;Other examples of iterable objects include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Maps&lt;/strong&gt;: Can be iterated over using &lt;code&gt;for...of&lt;/code&gt; to access key-value pairs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sets&lt;/strong&gt;: Can be iterated over using &lt;code&gt;for...of&lt;/code&gt; to access unique values.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;map&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Map&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;a&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;b&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// 'a' 1, 'b' 2&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="kd"&gt;set&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;

&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="kd"&gt;set&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// 1, 2, 3, 4&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Generators and Iterables
&lt;/h2&gt;

&lt;p&gt;Generators are a special type of function that can be used to create iterable objects. They are defined using the &lt;code&gt;function*&lt;/code&gt; syntax and use the &lt;code&gt;yield&lt;/code&gt; keyword to produce values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nf"&gt;myGenerator&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;gen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;myGenerator&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;gen&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// 1, 2, 3&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In conclusion, iterable objects are a fundamental concept in JavaScript that enables us to work with sequences of values in a flexible and efficient way. By understanding how to create and use iterable objects, we can write more effective and scalable code. Whether you're working with arrays, strings, maps, or sets, iterable objects provide a powerful tool for data processing and manipulation.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>iterables</category>
      <category>es6</category>
    </item>
    <item>
      <title>Mastering the 'this' Keyword in JavaScript</title>
      <dc:creator>김영민</dc:creator>
      <pubDate>Tue, 09 Sep 2025 12:06:44 +0000</pubDate>
      <link>https://forem.com/adrahi/mastering-the-this-keyword-in-javascript-3f7m</link>
      <guid>https://forem.com/adrahi/mastering-the-this-keyword-in-javascript-3f7m</guid>
      <description>&lt;h1&gt;
  
  
  Understanding the &lt;code&gt;this&lt;/code&gt; Keyword in JavaScript
&lt;/h1&gt;

&lt;p&gt;The &lt;code&gt;this&lt;/code&gt; keyword in JavaScript is a special keyword that refers to the context of the currently executing code. It can be confusing, especially for beginners, but understanding how &lt;code&gt;this&lt;/code&gt; works is crucial for effective JavaScript development.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction to &lt;code&gt;this&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;this&lt;/code&gt; keyword behaves differently depending on where it is used. Let's explore the various contexts in which &lt;code&gt;this&lt;/code&gt; can be used.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Global Context
&lt;/h3&gt;

&lt;p&gt;In the global context, &lt;code&gt;this&lt;/code&gt; refers to the global object. In a browser environment, &lt;code&gt;this&lt;/code&gt; points to the &lt;code&gt;window&lt;/code&gt; object, while in a Node.js environment, it points to the &lt;code&gt;global&lt;/code&gt; object.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// browser: window object&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Regular Functions
&lt;/h3&gt;

&lt;p&gt;Inside a regular function, &lt;code&gt;this&lt;/code&gt; refers to the global object. However, in strict mode, &lt;code&gt;this&lt;/code&gt; is set to &lt;code&gt;undefined&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;example&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// browser: window object, strict mode: undefined&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nf"&gt;example&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Object Methods
&lt;/h3&gt;

&lt;p&gt;When used inside an object method, &lt;code&gt;this&lt;/code&gt; refers to the object itself.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// "John" output, this refers to person object&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Arrow Functions
&lt;/h3&gt;

&lt;p&gt;Arrow functions behave differently than regular functions. They statically bind &lt;code&gt;this&lt;/code&gt;, meaning that the &lt;code&gt;this&lt;/code&gt; inside an arrow function refers to the &lt;code&gt;this&lt;/code&gt; of the outer function. This is known as lexical scoping.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;innerGreet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// "John" output, this refers to greet method's this&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="nf"&gt;innerGreet&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5. Class Methods
&lt;/h3&gt;

&lt;p&gt;In JavaScript classes, &lt;code&gt;this&lt;/code&gt; refers to the instance of the class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Person&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Hello, &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;john&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Person&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;john&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  &lt;span class="c1"&gt;// "Hello, John"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6. Event Handlers
&lt;/h3&gt;

&lt;p&gt;Inside a DOM event handler, &lt;code&gt;this&lt;/code&gt; refers to the DOM element that triggered the event.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;button&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;button&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// outputs the clicked button element&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Dynamic Binding of &lt;code&gt;this&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;this&lt;/code&gt; keyword is dynamically bound, meaning its value depends on how the function is called.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In global execution, &lt;code&gt;this&lt;/code&gt; refers to the global object.&lt;/li&gt;
&lt;li&gt;In method calls, &lt;code&gt;this&lt;/code&gt; refers to the object the method belongs to.&lt;/li&gt;
&lt;li&gt;Using &lt;code&gt;call&lt;/code&gt;, &lt;code&gt;apply&lt;/code&gt;, or &lt;code&gt;bind&lt;/code&gt; methods allows you to explicitly set &lt;code&gt;this&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Strict Mode and &lt;code&gt;this&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;In strict mode, the behavior of &lt;code&gt;this&lt;/code&gt; is more strictly defined. Inside regular functions, &lt;code&gt;this&lt;/code&gt; is set to &lt;code&gt;undefined&lt;/code&gt; instead of the global object, preventing accidental modifications to the global object.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;use strict&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;example&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// undefined&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nf"&gt;example&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Understanding the &lt;code&gt;this&lt;/code&gt; keyword is essential for effective JavaScript development. By recognizing how &lt;code&gt;this&lt;/code&gt; behaves in different contexts, you can write more robust and maintainable code. Remember that &lt;code&gt;this&lt;/code&gt; is dynamically bound, and its value depends on the execution context. With practice and experience, you'll become more comfortable using &lt;code&gt;this&lt;/code&gt; in your JavaScript projects.&lt;/p&gt;

</description>
      <category>jsbasics</category>
      <category>javascript</category>
      <category>coding</category>
    </item>
    <item>
      <title>Understanding JavaScript Copy by Reference</title>
      <dc:creator>김영민</dc:creator>
      <pubDate>Tue, 09 Sep 2025 10:54:23 +0000</pubDate>
      <link>https://forem.com/adrahi/understanding-javascript-copy-by-reference-3pl4</link>
      <guid>https://forem.com/adrahi/understanding-javascript-copy-by-reference-3pl4</guid>
      <description>&lt;h1&gt;
  
  
  JavaScript Copy by Reference
&lt;/h1&gt;

&lt;p&gt;JavaScript is a versatile language with various data types, including primitive and reference types. Understanding how these types are copied is crucial for effective programming. In this article, we'll delve into the world of JavaScript copy by reference, exploring the differences between primitive and reference types, shallow and deep copying, and providing practical tips for working with these concepts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Primitive Types
&lt;/h2&gt;

&lt;p&gt;Primitive types in JavaScript are &lt;strong&gt;values stored directly in variables&lt;/strong&gt;. When you copy a primitive value, it creates a new copy of the value in a new memory space.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Examples: &lt;code&gt;string&lt;/code&gt;, &lt;code&gt;number&lt;/code&gt;, &lt;code&gt;boolean&lt;/code&gt;, &lt;code&gt;undefined&lt;/code&gt;, &lt;code&gt;null&lt;/code&gt;, &lt;code&gt;symbol&lt;/code&gt;, &lt;code&gt;bigint&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// a's value is copied to b&lt;/span&gt;

&lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// only b is changed&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// 10&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// 20&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Here, &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt; have &lt;strong&gt;independent values&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Although &lt;code&gt;a&lt;/code&gt;'s value is copied to &lt;code&gt;b&lt;/code&gt;, they occupy &lt;strong&gt;different memory spaces&lt;/strong&gt;. Therefore, changing &lt;code&gt;b&lt;/code&gt; doesn't affect &lt;code&gt;a&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Reference Types
&lt;/h2&gt;

&lt;p&gt;Reference types in JavaScript &lt;strong&gt;store the reference address of an object&lt;/strong&gt; in variables. When you copy an object or array, you're copying the &lt;strong&gt;reference address&lt;/strong&gt;, not the value. This means both variables will point to the same object.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Examples: &lt;code&gt;object&lt;/code&gt;, &lt;code&gt;array&lt;/code&gt;, &lt;code&gt;function&lt;/code&gt;, &lt;code&gt;date&lt;/code&gt;, &lt;code&gt;regExp&lt;/code&gt;, &lt;code&gt;map&lt;/code&gt;, &lt;code&gt;set&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;person1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;person2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;person1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// person1's reference address is copied to person2&lt;/span&gt;

&lt;span class="nx"&gt;person2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;35&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// person2's age value is changed&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;person1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// 35 (person1 is also changed)&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;person2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// 35&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;person1&lt;/code&gt; and &lt;code&gt;person2&lt;/code&gt; &lt;strong&gt;point to the same object&lt;/strong&gt;. Changing &lt;code&gt;person2&lt;/code&gt; affects &lt;code&gt;person1&lt;/code&gt; because they reference the same memory space.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Characteristics of Copy by Reference
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Both variables point to the same object&lt;/strong&gt;, so changing one affects the other.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No new object is created&lt;/strong&gt; when copying arrays or objects; only the reference address is copied.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Shallow Copy
&lt;/h3&gt;

&lt;p&gt;When copying reference types, we use the concept of &lt;strong&gt;shallow copying&lt;/strong&gt;. Shallow copying only copies the top-level properties of an object and &lt;strong&gt;copies the reference&lt;/strong&gt; to inner objects or arrays.&lt;/p&gt;

&lt;h3&gt;
  
  
  Shallow Copy Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;original&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;hobbies&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;reading&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;biking&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;copy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;original&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;  &lt;span class="c1"&gt;// shallow copy using spread operator&lt;/span&gt;

&lt;span class="nx"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Bob&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// only the copy is changed&lt;/span&gt;
&lt;span class="nx"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hobbies&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;swimming&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// both the original and copy are changed&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;original&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;    &lt;span class="c1"&gt;// Alice (unchanged)&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;original&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hobbies&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// ['reading', 'biking', 'swimming']&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hobbies&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;     &lt;span class="c1"&gt;// ['reading', 'biking', 'swimming']&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Changing &lt;code&gt;name&lt;/code&gt; only affects the copy, but &lt;strong&gt;both the original and copy share the same &lt;code&gt;hobbies&lt;/code&gt; array&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Deep Copy
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Deep copying&lt;/strong&gt; creates a &lt;strong&gt;completely independent object&lt;/strong&gt; by copying all nested objects and arrays. This solves the reference problem that can occur with shallow copying.&lt;/p&gt;

&lt;h3&gt;
  
  
  Deep Copy Example
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Using &lt;code&gt;JSON.parse()&lt;/code&gt; and &lt;code&gt;JSON.stringify()&lt;/code&gt; for deep copying
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;original&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;hobbies&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;reading&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;biking&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;copy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;original&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;  &lt;span class="c1"&gt;// deep copy&lt;/span&gt;

&lt;span class="nx"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Bob&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// only the copy is changed&lt;/span&gt;
&lt;span class="nx"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hobbies&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;swimming&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// only the copy is changed&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;original&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;    &lt;span class="c1"&gt;// Alice (unchanged)&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;original&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hobbies&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// ['reading', 'biking']&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hobbies&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;     &lt;span class="c1"&gt;// ['reading', 'biking', 'swimming']&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;JSON.parse(JSON.stringify())&lt;/code&gt; creates a new copy of the object, including all nested objects and arrays, solving the reference issue.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Alternative Methods
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Using the &lt;code&gt;cloneDeep()&lt;/code&gt; function from the &lt;code&gt;lodash&lt;/code&gt; library for deep copying
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;lodash&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;copy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cloneDeep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;original&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This method is particularly useful when dealing with complex, nested objects.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In conclusion, understanding how JavaScript copies values, whether by reference or by value, is essential for writing effective and bug-free code. By recognizing the differences between primitive and reference types and knowing when to use shallow or deep copying, you can better manage your data and avoid common pitfalls. Remember, the key to mastering JavaScript is practice and a deep understanding of its fundamental concepts.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>copybyref</category>
      <category>datatypes</category>
      <category>programming</category>
    </item>
    <item>
      <title>Unlocking JavaScript's Built-in Object Power</title>
      <dc:creator>김영민</dc:creator>
      <pubDate>Mon, 08 Sep 2025 10:10:37 +0000</pubDate>
      <link>https://forem.com/adrahi/unlocking-javascripts-built-in-object-power-65c</link>
      <guid>https://forem.com/adrahi/unlocking-javascripts-built-in-object-power-65c</guid>
      <description>&lt;h1&gt;
  
  
  Mastering JavaScript's Built-in Object Methods
&lt;/h1&gt;

&lt;p&gt;JavaScript provides a plethora of built-in object methods that can be used to create, manipulate, and interact with objects. In this article, we'll delve into the most commonly used object methods, exploring their use cases, examples, and practical tips for implementing them in your daily coding routine.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. &lt;code&gt;Object.keys(obj)&lt;/code&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Retrieving an Object's Keys
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;Object.keys(obj)&lt;/code&gt; is a method used to retrieve an array of a given object's own enumerable property names. This method is particularly useful when you need to iterate over an object's properties or check if a specific key exists.&lt;/p&gt;

&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// ["name", "age"]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. &lt;code&gt;Object.values(obj)&lt;/code&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Retrieving an Object's Values
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;Object.values(obj)&lt;/code&gt; returns an array of a given object's own enumerable property values. This method is useful when you need to perform value-based operations, such as filtering or summing.&lt;/p&gt;

&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;values&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// ["Alice", 25]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. &lt;code&gt;Object.entries(obj)&lt;/code&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Retrieving an Object's Key-Value Pairs
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;Object.entries(obj)&lt;/code&gt; returns an array of a given object's own enumerable string-keyed property pairs. This method is useful when you need to iterate over an object's properties and access both the key and value simultaneously.&lt;/p&gt;

&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;entries&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;// name: Alice&lt;/span&gt;
&lt;span class="c1"&gt;// age: 25&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. &lt;code&gt;Object.assign(target, ...sources)&lt;/code&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Merging Objects
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;Object.assign(target, ...sources)&lt;/code&gt; is a method used to copy the values of all enumerable own properties from one or more source objects to a target object. This method is useful when you need to merge objects or create a new object with the properties of an existing object.&lt;/p&gt;

&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;updates&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;city&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Seoul&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;merged&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;({},&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;updates&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;merged&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// { name: "Alice", age: 25, city: "Seoul" }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. &lt;code&gt;Object.fromEntries(array)&lt;/code&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Creating an Object from an Array
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;Object.fromEntries(array)&lt;/code&gt; is a method used to create a new object from an array of key-value pairs. This method is useful when you need to convert an array of data into an object.&lt;/p&gt;

&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;entries&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;age&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;]];&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromEntries&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;entries&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// { name: "Alice", age: 25 }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  6. &lt;code&gt;Object.freeze(obj)&lt;/code&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Freezing an Object
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;Object.freeze(obj)&lt;/code&gt; is a method used to freeze an object, making it immutable. This method is useful when you need to ensure that an object's properties cannot be modified.&lt;/p&gt;

&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;config&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;freeze&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;dark&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;theme&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;light&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// ignored&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// "dark"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  7. &lt;code&gt;Object.hasOwn(obj, key)&lt;/code&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Checking if an Object has a Property
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;Object.hasOwn(obj, key)&lt;/code&gt; is a method used to check if an object has a specific property. This method is useful when you need to ensure that an object has a certain property before attempting to access it.&lt;/p&gt;

&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;hasOwn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// true&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;hasOwn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;toString&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  8. &lt;code&gt;Object.getPrototypeOf(obj)&lt;/code&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Retrieving an Object's Prototype
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;Object.getPrototypeOf(obj)&lt;/code&gt; is a method used to retrieve an object's prototype. This method is useful when you need to inspect an object's inheritance chain.&lt;/p&gt;

&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getPrototypeOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  9. &lt;code&gt;Object.defineProperty(obj, key, descriptor)&lt;/code&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Defining a Property
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;Object.defineProperty(obj, key, descriptor)&lt;/code&gt; is a method used to define a property on an object. This method is useful when you need to create a property with specific attributes, such as making it read-only or hidden.&lt;/p&gt;

&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;
&lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;defineProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;writable&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// non-configurable&lt;/span&gt;
  &lt;span class="na"&gt;enumerable&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// enumerable&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// "Alice"&lt;/span&gt;
&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Bob&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// ignored&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  10. &lt;code&gt;Object.seal(obj)&lt;/code&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Sealing an Object
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;Object.seal(obj)&lt;/code&gt; is a method used to seal an object, making it impossible to add or remove properties. This method is useful when you need to ensure that an object's structure remains intact.&lt;/p&gt;

&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;seal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// ignored (cannot add new properties)&lt;/span&gt;
&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Bob&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// allowed (can modify existing properties)&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// { name: "Bob" }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Practical Applications
&lt;/h2&gt;

&lt;p&gt;These built-in object methods are essential in various real-world scenarios:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Object.keys/values/entries&lt;/code&gt;: frequently used for iterating over objects or converting them to arrays.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Object.assign&lt;/code&gt;: commonly used for merging objects or creating new objects with existing properties.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Object.freeze&lt;/code&gt;: used to ensure immutability in state management and other applications.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Object.hasOwn&lt;/code&gt;: useful for safely checking if an object has a specific property.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Object.fromEntries&lt;/code&gt;: handy for converting array data into objects.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By mastering these built-in object methods, you'll become more proficient in handling objects and writing more efficient, readable code. Remember to explore and practice each method to get the most out of JavaScript's built-in functionality.&lt;/p&gt;

</description>
      <category>jsobjects</category>
      <category>javascript</category>
      <category>objectmethods</category>
    </item>
  </channel>
</rss>
