<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Igor Thkorik on Medium]]></title>
        <description><![CDATA[Stories by Igor Thkorik on Medium]]></description>
        <link>https://medium.com/@habcerga1?source=rss-7fe97c4903b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*TmIT5Hi3knVJ5O8q6pCXkQ.png</url>
            <title>Stories by Igor Thkorik on Medium</title>
            <link>https://medium.com/@habcerga1?source=rss-7fe97c4903b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 19 May 2026 13:10:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@habcerga1/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Solving the Mystery: Why typeof null Returns ‘object’ in JavaScript]]></title>
            <link>https://medium.com/@habcerga1/understanding-typeof-null-and-null-instanceof-object-in-javascript-b167e34aa21c?source=rss-7fe97c4903b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b167e34aa21c</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Igor Thkorik]]></dc:creator>
            <pubDate>Sun, 22 Dec 2024 11:14:04 GMT</pubDate>
            <atom:updated>2024-12-22T20:10:38.589Z</atom:updated>
            <content:encoded><![CDATA[<p>Learn why null in JavaScript is classified as an object and how this affects your code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*2WOKPO-99MVmY1ZEVTPq1Q.png" /></figure><p>JavaScript is a powerful yet quirky language that often surprises developers with its behavior. One such curiosity lies in how null behaves with typeof and instanceof operators. Let’s break it down and understand this in detail.</p><p><strong>The Quirk of typeof null</strong></p><p>If you’ve ever written this simple line of JavaScript:</p><pre>console.log(typeof null); // &quot;object&quot;</pre><p>You might be puzzled by the result. Why does typeof null return “object” when null is clearly not an object?</p><p>The answer lies in JavaScript’s early implementation. In the first versions of the language, null was represented as a null pointer — a reference to an object value. This historical design decision led typeof to classify it as an “object”. Over time, this behavior became part of the language specification and was left unchanged for backward compatibility.</p><p>However, in reality, null is a <strong>primitive type</strong>, not an object. While this behavior is considered a bug, it has become a feature we must understand and work with.</p><p><strong>Why null instanceof Object is false</strong></p><p>Now let’s look at another seemingly confusing piece of code:</p><pre>console.log(null instanceof Object); // false</pre><p>Here’s what’s happening:</p><p>1. The instanceof operator checks whether the prototype chain of an object includes a specific constructor.</p><p>2. In this case, null is a <strong>primitive value</strong>, not an object, and it doesn’t have a prototype chain.</p><p>3. Therefore, instanceof returns false, confirming that null is not an instance of Object.</p><p>This behavior aligns with the fact that null is fundamentally different from objects.</p><p><strong>Practical Tips for Developers</strong></p><ul><li>When checking for null, avoid relying on typeof. Instead, use a direct equality check:</li></ul><pre>if (value === null) {<br>  console.log(&quot;Value is null&quot;);<br>}</pre><ul><li>To differentiate between null and objects more reliably, use:</li></ul><pre>if (value === null || typeof value !== &quot;object&quot;) {<br>  console.log(&quot;Not an object&quot;);<br>}</pre><p>Understanding these quirks is crucial for mastering JavaScript and avoiding potential bugs in your code. While these behaviors might feel counterintuitive at first, embracing them as part of the language’s personality can help you write more robust and predictable programs.</p><p>Happy coding! 😊</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b167e34aa21c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Context in JavaScript: Global vs Function Context]]></title>
            <link>https://medium.com/@habcerga1/global-context-or-function-context-in-java-script-4195eab1c6e8?source=rss-7fe97c4903b------2</link>
            <guid isPermaLink="false">https://medium.com/p/4195eab1c6e8</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Igor Thkorik]]></dc:creator>
            <pubDate>Wed, 16 Oct 2024 19:29:37 GMT</pubDate>
            <atom:updated>2024-12-22T20:09:26.259Z</atom:updated>
            <content:encoded><![CDATA[<p>Understand the differences between global and function context in JavaScript for writing more efficient code</p><p>In the <strong>global context</strong> (outside any function) or inside a regular function (not a method of an object), this refers to the global object, which is window in browsers or global in Node.js.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2mep7KKQ_nQvAN5OqbTV0g.png" /></figure><p><strong>Object Methods:</strong><br>When a function is called as a method of an object, this refers to the object that was used to call the method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aMoNDI_HOEL64hoyx0_AgQ.png" /></figure><p><strong>Constructors and Classes:</strong><br>this refers to the newly created object.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gltHxB5kRo4RIY9ufJbq6g.png" /></figure><p><strong>Explicitly Setting </strong><strong>this with call, apply, and bind:</strong><br>The call and apply methods allow you to invoke a function with an explicitly defined value for this. The bind method creates a new function that, when called, has a specific value for this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ao2tXQieaLV_fdqGLTaNGw.png" /></figure><p><strong>The Value of this Depends on the Call Context:</strong></p><ul><li>In the global context and regular functions, this refers to the global object (window or global).</li><li>In object methods, this refers to the object itself.</li><li>In constructors and classes, this refers to the newly created object.</li><li>You can explicitly set the value of this using call, apply, and bind.</li><li>Arrow functions capture this from their surrounding lexical context.</li><li>Nested functions can have different values for this, which can be resolved using arrow functions or by saving the context of the outer function. Feel free to ask if you need further assistance!</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4195eab1c6e8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What will be displayed in the console? #3]]></title>
            <link>https://medium.com/@habcerga1/what-will-be-displayed-in-the-console-3-a7f5c211c0a3?source=rss-7fe97c4903b------2</link>
            <guid isPermaLink="false">https://medium.com/p/a7f5c211c0a3</guid>
            <dc:creator><![CDATA[Igor Thkorik]]></dc:creator>
            <pubDate>Wed, 09 Oct 2024 18:34:53 GMT</pubDate>
            <atom:updated>2024-10-09T18:34:53.678Z</atom:updated>
            <content:encoded><![CDATA[<p>We have the code and the answers to it, what will it output to the console?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ETAockwVj53ZrQHnD1XO8Q.png" /></figure><h3>Explanation</h3><ol><li>Loop Initialization: The loop starts with i initialized to 1 and continues as long as i &lt; 5.</li><li>Iteration Details:</li></ol><p>When i = 1: The condition is true, so it logs 1.</p><p>When i = 2: The condition is true, so it logs 2.</p><p>When i = 3: The condition is true, but the if (i == 3) continue;statement causes the loop to skip the logging for this iteration.</p><p>When i = 4: The condition is true, so it logs 4.</p><ol><li>Termination: When i becomes 5, the loop terminates since the condition i &lt; 5 is no longer satisfied.</li></ol><h3>Thus, the output of the code will be</h3><pre>1 2 4</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a7f5c211c0a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What will be displayed in the console? #2]]></title>
            <link>https://medium.com/@habcerga1/what-will-be-displayed-in-the-console-2-90667b0a959f?source=rss-7fe97c4903b------2</link>
            <guid isPermaLink="false">https://medium.com/p/90667b0a959f</guid>
            <dc:creator><![CDATA[Igor Thkorik]]></dc:creator>
            <pubDate>Wed, 09 Oct 2024 18:33:41 GMT</pubDate>
            <atom:updated>2024-10-09T18:33:41.202Z</atom:updated>
            <content:encoded><![CDATA[<p>We have the code and the answers to it, what will it output to the console?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BPmT_hp6D_cp34et4u83lw.png" /></figure><h3>Output Explanation</h3><p>When you execute arr.flat(1), the flat() method flattens the array to a depth of 1. This means it will flatten only the first level of nested arrays.Original Array Structure:</p><ul><li>The array arr contains:</li><li>1 (a number)</li><li>2 (a number)</li><li>[3, 4] (a sub-array)</li><li>[[5], [6]] (a sub-array containing two more sub-arrays)</li></ul><h3>Flattening Process</h3><ol><li>The first two elements (1 and 2) are kept as they are.</li><li>The sub-array [3, 4] is flattened into the main array.</li><li>The last element [[5], [6]] remains unchanged because it is nested deeper than the specified depth of 1.</li></ol><h3>Thus, the output of the code will be</h3><pre>[1, 2, 3, 4, [5], [6]]</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90667b0a959f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What will be displayed in the console? #2]]></title>
            <link>https://medium.com/@habcerga1/what-will-be-displayed-in-the-console-2-b53843e7b66b?source=rss-7fe97c4903b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b53843e7b66b</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[questions]]></category>
            <dc:creator><![CDATA[Igor Thkorik]]></dc:creator>
            <pubDate>Tue, 08 Oct 2024 19:41:32 GMT</pubDate>
            <atom:updated>2024-10-08T19:41:32.300Z</atom:updated>
            <content:encoded><![CDATA[<p>We have the code and the answers to it, what will it output to the console?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BPmT_hp6D_cp34et4u83lw.png" /></figure><h3>Output Explanation</h3><p>When you execute arr.flat(1), the flat() method flattens the array to a depth of 1. This means it will flatten only the first level of nested arrays.Original Array Structure:</p><ul><li>The array arr contains:</li><li>1 (a number)</li><li>2 (a number)</li><li>[3, 4] (a sub-array)</li><li>[[5], [6]] (a sub-array containing two more sub-arrays)</li></ul><h3>Flattening Process</h3><ol><li>The first two elements (1 and 2) are kept as they are.</li><li>The sub-array [3, 4] is flattened into the main array.</li><li>The last element [[5], [6]] remains unchanged because it is nested deeper than the specified depth of 1.</li></ol><h3>Thus, the output of the code will be:</h3><pre>[1, 2, 3, 4, [5], [6]]</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b53843e7b66b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What will the console display]]></title>
            <link>https://medium.com/@habcerga1/what-will-the-console-display-3dcb334bc976?source=rss-7fe97c4903b------2</link>
            <guid isPermaLink="false">https://medium.com/p/3dcb334bc976</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Igor Thkorik]]></dc:creator>
            <pubDate>Mon, 07 Oct 2024 06:36:31 GMT</pubDate>
            <atom:updated>2024-10-07T06:36:31.146Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iWrMRvuPr0R5nr3TriJ3tw.png" /></figure><p><strong>Spoiler, the console will display:</strong></p><pre>Hi there, undefined</pre><h3>Why is like that.</h3><ol><li>The sayHi function is defined to take a parameter name.</li><li>When the function is called with sayHi(), no argument is passed for the nameparameter.</li><li>In JavaScript, when a function parameter is not provided, it defaults to undefined.</li><li>The function then returns the string &quot;Hi there, undefined&quot;, where ${name} is replaced with the value of name, which is undefined.</li><li>This returned string is then logged to the console.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3dcb334bc976" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Operator new in .Net]]></title>
            <link>https://medium.com/@habcerga1/operator-new-in-net-564482499d9d?source=rss-7fe97c4903b------2</link>
            <guid isPermaLink="false">https://medium.com/p/564482499d9d</guid>
            <dc:creator><![CDATA[Igor Thkorik]]></dc:creator>
            <pubDate>Wed, 25 Jan 2023 18:22:24 GMT</pubDate>
            <atom:updated>2024-12-22T20:11:40.630Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gmQhbzegDBJpRqWOBYpjJg.png" /></figure><h3>Understanding the new Operator in .NET: Creating Object Instances</h3><p>Learn how the new operator is used to create objects in .NET and the nuances to consider.</p><p>Everyone who starts their way in programming gets acquainted with the operator New and learns how it can be used to create <strong>instances of a type</strong>. However, few people think about how it does it, and what it is capable of. The work of this operator can be divided into several stages:</p><ol><li><em>Calculation (how much </em><strong><em>our object weighs)</em></strong></li><li><em>Allocation (memory for our object)</em></li><li><em>Initialization (creating our object)</em></li></ol><p>Let’s take a closer look at what happens when an object is created by using this operator.</p><p><strong>Calculation</strong></p><p>First, the number of bytes required to store <strong>all instance fields of the type </strong>is calculated, which means that it is considered how much all the elements of our instance <strong>weigh</strong> + 8/16 bytes for the SyncBlock Index &amp; Type Object Pointer.</p><p>Example:</p><pre>class MyExampleClass <br> {<br>    private string _myString = &quot;String&quot;; <br> }</pre><p>Our class contains one field of the String type that takes 4 bytes + we add 4 bytes of <strong>synchronization block</strong> to it and add a pointer to the object type plus 2 bytes for each character that contains our string type field</p><p>StringValue = SyncBlock (4) + TypeHandle (4) + m_stringLength (4) + m_firstChar (2) + “String” (12) = 26 bytes.</p><p>The extra 2 bytes need for the alignment done by the CLR memory manager.</p><p>The main difference is the size of the DWORD, the <strong>memory pointer.</strong> On 32-bit systems it is 4 bytes, on 64-bit systems it is 8 bytes.</p><p>So, if an empty class is equal to only 12 bytes in x86, then in x64 it is already 24 bytes.</p><p><strong>Selection</strong></p><p><strong>The memory for the object is now allocated, reserving the required number of bytes for the type in the managed heap.</strong> The allocated bytes are initialized to zero (0).</p><p>As long as there is address space available on the managed heap, the CLR continues to allocate space for new objects, but when it runs out, garbage collection is performed using an optimization mechanism, releasing objects and fragmenting them.</p><p><strong>Initialization</strong></p><p>Now we need to initialize the pointer to<strong> the type object</strong> and the synchronization block index and call the type instance constructor with the parameters specified when calling new.</p><p>Most compilers automatically include code for calling the base class constructor in the constructor. Each constructor initializes the fields defined in the corresponding type. In particular, the System.Object constructor is called, but it does nothing and <strong>simply returns</strong>.</p><p><strong>Limitation</strong></p><p>The new constraint specifies that the type argument in a generic class declaration must have a public parameterless constructor. You can use the new constraint only if the type is not abstract. When using the new() constraint with other constraints, it must be specified last.</p><p>Apply the <strong>new constraint</strong> to a type parameter when the generic class creates new instances of that type. This is shown in the following example:</p><pre>public class ItemFactory2&lt;T&gt; where T : IComparable, new() <br>{  <br>   // Your code here;<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=564482499d9d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>