<?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 Yug on Medium]]></title>
        <description><![CDATA[Stories by Yug on Medium]]></description>
        <link>https://medium.com/@yugSaini?source=rss-e64d6e0b7139------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*0ROE6IGXOsT4D3OtvaeTdQ.jpeg</url>
            <title>Stories by Yug on Medium</title>
            <link>https://medium.com/@yugSaini?source=rss-e64d6e0b7139------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 00:42:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yugSaini/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[Array Methods You Must Know in JavaScript]]></title>
            <link>https://medium.com/@yugSaini/array-methods-you-must-know-in-javascript-ae78df077503?source=rss-e64d6e0b7139------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae78df077503</guid>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Yug]]></dc:creator>
            <pubDate>Fri, 08 May 2026 14:39:43 GMT</pubDate>
            <atom:updated>2026-05-08T14:39:43.469Z</atom:updated>
            <content:encoded><![CDATA[<p>As you’re here, I’m hoping you already know basic things about the arrays, what is array, how to access and change its elements. If not, I would highly recommend you to <a href="https://medium.com/@yugSaini/javascript-arrays-101-faf9a7085c1e">read here</a>.</p><p>In this blog you’ll learn about array methods that you can use instead of manually doing that work. Let’s discuss them in details —</p><h3>push()</h3><p>This is use to add the elements at the end of an array and it returns new length of the array</p><pre>const asianCountry = [&quot;India&quot;, &quot;Japan&quot;, &quot;China&quot;]<br><br>const whatItReturn = asianCountry.push(&quot;UAE&quot;, &quot;Sri Lanka&quot;)<br><br>console.log(asianCountry)<br>// output: [&quot;India&quot;, &quot;Japan&quot;, &quot;China&quot;, &quot;UAE&quot;, &quot;Sri Lanka&quot;]<br><br>console.log(whatItReturn)<br>// output: 5</pre><h4>How to do it without push</h4><p>To understand behind the scene let’s say you want to add a new country(“Nepal”) at the end of asianCountry array.</p><p>First you need to know array’s length, then add the element at that position and then return the updated length of the array.</p><pre>console.log(asianCountry)<br>// output: [&quot;India&quot;, &quot;Japan&quot;, &quot;China&quot;, &quot;UAE&quot;, &quot;Sri Lanka&quot;]<br>// index :     0        1        2       3       4<br><br>const arrayLength = asianCountry.length<br><br>console.log(arrayLength)<br>// output: 5<br><br>asianCountry[arrayLength] = &quot;Nepal&quot;<br><br>console.log(asianCountry.length)<br>// output: 6</pre><p>How it works? What is the relation between array_length and position of last index?</p><p>If array_length is 3 then index of last element will always be array_length -1</p><h3>pop()</h3><p>This is method is use to remove the last element of the array, and it returns the removed element.</p><pre>console.log(asianCountry)<br>// output: [&quot;India&quot;, &quot;Japan&quot;, &quot;China&quot;, &quot;UAE&quot;, &quot;Sri Lanka&quot;, &quot;Nepal&quot;]<br><br>const whatItRemove = asianCountry.pop()<br><br>console.log(whatItRemove)<br>// output : &quot;Nepal&quot;<br><br>console.log(asianCountry)<br>// output: [&quot;India&quot;, &quot;Japan&quot;, &quot;China&quot;, &quot;UAE&quot;, &quot;Sri Lanka&quot;]</pre><h4>How to do it without pop</h4><p>As usual, First you need to know array’s length, then get the last element and update the length of the array with length-1.</p><pre>console.log(asianCountry)<br>// output: [&quot;India&quot;, &quot;Japan&quot;, &quot;China&quot;, &quot;UAE&quot;, &quot;Sri Lanka&quot;, &quot;Nepal&quot;]<br>// index :     0        1        2       3         4          5<br><br>const arrayLength = asianCountry.length<br>console.log(arrayLength)<br>// output: 6<br><br>// Getting the last element<br>const removedElement = asianCountry[arrayLength - 1 ] <br><br>console.log(removedElement)<br>// output: &quot;Nepal&quot;<br><br>asianCountry.length = arrayLength - 1<br><br>console.log(asianCountry.length)<br>// output: 5<br><br>console.log(asianCountry)<br>// output: [&quot;India&quot;, &quot;Japan&quot;, &quot;China&quot;, &quot;UAE&quot;, &quot;Sri Lanka&quot;]</pre><h3>shift()</h3><p>This is use to add the elements at the beginning of an array and it also returns new length of the array.</p><pre>const topSitcom = [&quot;Friends&quot;, &quot;Brooklyn 99&quot;]<br><br>const whatItReturns = topSitcom.shift(&quot;The Office&quot;, &quot;Modern Family&quot;)<br><br>console.log(whatItReturns)<br>// output: 4<br><br>console.log(topSitcom)<br>// output: [&quot;The Office&quot;, &quot;Modern Family&quot;, &quot;Friends&quot;, &quot;Brooklyn 99&quot;]</pre><h4>How to do it without shift()</h4><ol><li>First calculate the length of the array</li><li>Count how many elements you want to add?</li><li>Update the array_length with the count you just did, i.e., array_length + countedElements</li><li>Now shift all elements towards right side, so that you have space to add the elements in the beginning.</li><li>Add the elements one by one</li></ol><pre>// Add -&gt; &quot;The Office&quot;, &quot;Modern Family&quot;<br>// Total 2 elements<br><br>const topSitcom = [&quot;Friends&quot;, &quot;Brooklyn 99&quot;] // length-&gt; 2<br><br>topSitcom.length = topSitcom.length + 2<br><br>console.log(topSitcom)<br>// [&quot;Friends&quot;, &quot;Brooklyn 99&quot;,&lt;2 empty slots&gt;]<br><br>console.log(topSitcom.length, topSitcom[3])<br>// output: length -&gt; 4 , topSitcom[3] -&gt; undefined<br><br>topSitcom[3] = topSitcom[1]<br>topSitcom[2] = topSitcom[0]<br>topSitcom[1] = &quot;Modern Family&quot;<br>topSitcom[0] = &quot;The Office&quot;<br><br>console.log(topSitcom)<br>// output: [&quot;The Office&quot;, &quot;Modern Family&quot;, &quot;Friends&quot;, &quot;Brooklyn 99&quot;]<br><br></pre><h3>unshift()</h3><p>This is method is use to remove the first element of the array, and it returns the removed element.</p><pre>console.log(topSitcom)<br>// output: [&quot;The Office&quot;, &quot;Modern Family&quot;, &quot;Friends&quot;, &quot;Brooklyn 99&quot;]<br><br>console.log(topSitcom.unshift())<br>// output: &quot;The Office&quot;<br><br>console.log(topSitcom)<br>// output: [&quot;Modern Family&quot;, &quot;Friends&quot;, &quot;Brooklyn 99&quot;]</pre><h4>How to do it without unshift()</h4><ol><li>First, get the element at zeroth index from the array.</li><li>Shift all elements one by one to the left.</li><li>Update the array length by array_length -1</li></ol><pre>console.log(topSitcom)<br>// output: [&quot;The Office&quot;, &quot;Modern Family&quot;, &quot;Friends&quot;, &quot;Brooklyn 99&quot;]<br><br>const removedELement = topSitcom[0]<br><br>topSitcom[0] = topSitcom[1]<br>topSitcom[1] = topSitcom[2]<br>topSitcom[2] = topSitcom[3]<br><br>topSitcom.length = topSitcom.length - 1<br><br>console.log(topSitcom)<br>// output: [&quot;Modern Family&quot;, &quot;Friends&quot;, &quot;Brooklyn 99&quot;]<br><br>console.log(removedElement)<br>// output: &quot;The Office&quot;</pre><h3>map()</h3><p>A map() method is used to transform the array by performing some operations on elements of that array but this does not modify the original array instead it returns a new array.</p><p>The syntax to use map is very simple array.map((element,index,array)=&gt; () and () =&gt; () this syntax is known as <strong>a callback.</strong></p><p>map() method has three parameters: element, index, array. 90% of the time you’ll only deal with element.</p><p>Let’s understand map with an example, Suppose you have to 10x every element of the array. As of now you only one easy way, i.e., using <strong>for loop. </strong>So, let’s try to do it using for loop.</p><pre>const stuMarks = [20,40,35,33,12]<br>const updatedMarks = []<br><br>for(let i=0; i &lt; stuMarks.length ; i++ ){<br>  updatedMarks[i] = stuMarks[i] * 10;<br>}<br><br>console.log(updatedMarks)<br>// output: [200, 400, 350, 330, 120]<br><br>console.log(stuMarks)<br>// output: [20,40,35,33,12]</pre><p>Now lets do it in more simpler and easy way using map().</p><pre>const stuMarks = [20,40,35,33,12]<br><br>const updatedMarks = stuMarks.map(element=&gt; element * 10)<br><br>console.log(updatedMarks)<br>// output: [200, 400, 350, 330, 120]<br><br>console.log(stuMarks)<br>// output: [20,40,35,33,12]</pre><p>Instead of writing so much code, you can do few operation is just one line of code.</p><h3>filter()</h3><p>It also returns a new array of elements which satisfies the given condition, if nothing satisfy the condition, it returns an empty array.</p><pre>const stuMarks = [20,40,35,33,12]<br><br>const marksHigherThan30 = stuMarks.filter((element) =&gt; element &gt;= 30)<br><br>console.log(marksHigherThan30)<br><br>// output: [40, 35, 33]<br><br>const marksHigherThan50 = stuMarks.filter((ele) =&gt; ele &gt;= 50)<br><br>console.log(marksHigherThan50)<br>// output: []</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bdnFtIGokx2e53CCXxDgQA.png" /></figure><h3>reduce()</h3><p>This is how reduce method looks like; arrayName.reduce(callbackfn,initialValue)</p><p>It needs a callback but initial value is optional. A callback further have different fields such as accumulator, currentValue, currentIndex and array.</p><p>An accumulator is something which is used to hold the value of performed operations and then it automatically passed in the callback so that you can use it during next iteration, and at the end it returns the value of accumulator</p><p>A current value is value of array element which is present at current index.</p><p>Let’s understand this with an example; As you have the array of student marks, If you want to calculate the sum of all marks, it can be done using reduce.</p><pre>const stuMarks = [20,40,35,33,12]<br><br>const sumOfMarks = stuMarks.reduce((total,cValue) =&gt; {<br>  total = total + cValue<br>  return total<br>}, 0)<br><br>console.log(sumOfMarks)<br>// output: 140</pre><h4>Behind the scene working</h4><p>Here, total is acting as accumulator and cValue is current value, these are just variable names, but remember the order, first one will always act like accumulator and so on.</p><p>Initial Value is assigned as 0 and also to the accumulator i.e. total in our case. So it’s just basic operation, you are calculating the sum and that value passed to the next callback, until it reaches the last index and then it returns value of total which is 140 in this case.</p><p>But why reduce() is a big deal? You see we can assign the initial value in this method that means, you can also assigned empty array, or object as an initial value and you can do so much with that. It’s okay if you don’t get it as a beginner, maybe do some research or ask you favorite AI tool to describe it.</p><h3>forEach()</h3><p>This is similar to for loop but it doesn’t returns anything. This method can be used to perform some operations on the array, and that will mutate(change) the given array .</p><pre>const stuMarks = [20,40,35,33,12]<br><br>stuMarks.forEach((ele) =&gt; element * 10)<br><br>console.log(stuMarks)<br>// output: [200,400,350,330,120]</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae78df077503" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How React Virtual DOM works under the Hood]]></title>
            <link>https://medium.com/@yugSaini/how-react-virtual-dom-works-under-the-hood-de128d039d4a?source=rss-e64d6e0b7139------2</link>
            <guid isPermaLink="false">https://medium.com/p/de128d039d4a</guid>
            <category><![CDATA[react-virtual-dom]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Yug]]></dc:creator>
            <pubDate>Fri, 08 May 2026 14:21:59 GMT</pubDate>
            <atom:updated>2026-05-08T14:21:59.461Z</atom:updated>
            <content:encoded><![CDATA[<p>Remember when you were learning DOM manipulation? Did you ever wonder how powerful the DOM really is? You can literally write an entire application inside a script file, and it will run without issues because the DOM gives JavaScript the power to manipulate the document dynamically.</p><h3>How DOM Really Works</h3><p>Whatever code we write using HTML, CSS, and JavaScript, the browser first converts it into a tree-like structure of nodes called the DOM Tree. It starts from the root node, where the document contains child nodes like html, which further contains head and body.</p><p>Once this structure is created, the browser calculates the styles (CSS), performs layout calculations to determine the position and size of elements, and finally paints the pixels onto the screen.</p><p>But there’s a difference between just manipulating the DOM and manipulating it efficiently. For smaller projects, the DOM is great and works without any issues. But when your application starts re-rendering frequently or handling complex computations, directly updating the DOM can cost both time and performance because manipulating the real DOM is relatively expensive. To solve this problem React introduced the Virtual DOM.</p><h3>Virtual DOM</h3><p>It is a lightweight in-memory representation of actual DOM, which is created using JSX (JavaScript-XML).</p><p>When writing traditional DOM scripts developers need to manually manipulate the UI step by step; creating element, update, append or remove nodes etc.</p><p>Whereas JSX is more like describing what the UI should look like, structure is as similar as writing html and adding javascript wherever necessary.</p><p>Let’s understand the flow using an example of counter.</p><pre>function App() {<br> const [count, setCount] = useState(0)<br> return (<br>   &lt;&gt;<br>     &lt;h1&gt;Counter: {count} &lt;/h1&gt;<br>     &lt;button onClick={()=&gt;setCount(count+1)} &gt;Click me &lt;/button&gt;   <br>   &lt;/&gt; <br>  )<br>}<br>export default App</pre><h4>Initial Render Process in React</h4><p>The initial render happens when a user first visits the website or reloads the page. During this process, React executes the functional components and creates a tree-like structure called the Virtual DOM.</p><p>React then converts this Virtual DOM into the real DOM by updating the root element inside the index.html file. Once the real DOM is ready, the browser calculates styles, performs layout calculations, and finally paints the UI onto the screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pIBxUueFgieFvIcG9z3_Xw.png" /></figure><p>During the initial render, React executes the App component and creates a Virtual DOM representation of the UI. Since the initial value of count is 0, the browser displays:</p><ul><li>an h1 element showing Counter: 0</li><li>a button labeled Click me</li></ul><h4>How state or props change triggers re-render</h4><p>When the user clicks the button, an event listener triggers a callback function that updates the count state by increasing its value by 1.</p><p>As soon as setCount(count + 1) updates the state, React detects that something has changed inside the component that needs to be reflected in the UI.</p><h4>Creation of a new Virtual DOM tree</h4><p>To update the UI efficiently, React re-executes the component function, creates a new Virtual DOM tree based on the updated state or props.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*80RYW80pn6DE-apeROyFww.png" /></figure><h4>Diffing (reconciliation)</h4><p>Now that new Virtual DOM is created, React compares it with the previous Virtual DOM to identify what has actually changed. This comparison process is called Diffing or Reconciliation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0DafFbEQZUd5E6kZM_vMNA.png" /></figure><h4>Finds minimal required changes</h4><p>After comparing both tress, it finds the exact parts of the UI that needs to be changed instead of rebuilding the entire interface. In our case: Text inside the h1 changes from Counter: 0 to Counter: 1 , and button remains exactly same.</p><h4>Updating only changed nodes in the Real DOM</h4><p>Once React identifies where changes are needed in the UI, it updates only the necessary parts of the real DOM instead of re-rendering the entire page. This reduces unnecessary browser work and improves application performance, especially in large and frequently updating applications.</p><p><strong>High level summary of Virtual DOM</strong></p><pre>State changes<br>   ↓<br>Render phase<br>(Create new VDOM)<br>   ↓<br>Diffing phase<br>(Find changes)<br>   ↓<br>Commit phase<br>(Update real DOM)<br>   ↓<br>Browser paint</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de128d039d4a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript Arrays 101]]></title>
            <link>https://medium.com/@yugSaini/javascript-arrays-101-faf9a7085c1e?source=rss-e64d6e0b7139------2</link>
            <guid isPermaLink="false">https://medium.com/p/faf9a7085c1e</guid>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Yug]]></dc:creator>
            <pubDate>Thu, 09 Apr 2026 08:35:14 GMT</pubDate>
            <atom:updated>2026-04-09T08:35:14.683Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eRGRHmb0Et9GYvSWsj-H4A.png" /></figure><p>As a beginner in JavaScript; we all have learned to assign a value in a variable such as let, var or const. But the problem with this kind of assignment is, you can only store one value in a variable, But just like any other programming languages, JavaScript also have arrays.</p><h3>What is Array</h3><p>An Array is a way to store more data in a single variable and each value can be accessible using index. Consider a train as a variable name and the coaches attach to the train are like the index and we can access that coach by using its index.</p><h3>How to create an array</h3><p>Creating an array is very simple, It is same as declaring the other variables with let, var or const and assign the value in square bracket, i.e., [ ]</p><p>const arrayName = [&quot;value1&quot;,&quot;value2&quot;,&quot;value3&quot;]</p><p>example : const countryName = [&quot;India&quot;,&quot;Japan&quot;,&quot;Singapore&quot;,&quot;Australia&quot;]</p><p>Like this we can add as many values as we need, and these values can be of any type; number, string, boolean, undefined, object, another_array, function etc.</p><h3>How to access the array values</h3><p>Each value in array has an index, which start from 0, i.e. , first value is at zeroth index as shown below.</p><pre>const countryName = [&quot;India&quot;,&quot;Japan&quot;,&quot;Singapore&quot;,&quot;Australia&quot;]<br>   index -&gt;             0       1         2            3</pre><p>So to access any value we just need to know it’s index.</p><p>console.log(countryName[2]) =&gt; It’ll give us “Singapore”</p><p>Great, but what will happen if we give an index which is not assigned to any value? for example: there is no value for index 4?</p><p>console.log(countryName[4]) =&gt; undefined</p><p>It’ll not give any outOfBound error instead it gives just <strong>undefined</strong> , and here is a task for you to check what it will give for negative index such as -1 or -2.</p><h3>Finding length of an array</h3><p>One way to finding the length of an array is by console log for every index from 0 up to the index which returns the <strong>undefined</strong> right? But it may be possible that someone assigned the value as undefined for that index. for example array can be look like this —</p><p>const student_marks = [32, 42, undefined, 87, 60]</p><p>So to make programming little easier we have a built in property names as length which will give the length of an array</p><p>console.log(student_marks.length) =&gt; 5</p><p>Notice, Last index of an array will always be at length — 1.</p><h3>Playing with array</h3><p>Okay! so for you have learned how to assigned elements in an array, how to access them and most importantly length property.</p><p>Let’s see how to modify the values inside an array</p><pre>console.log(student_marks[2]) <br>// output: undefiend<br><br>student_marks[2] = 72<br><br>console.log(student_marks)<br>// output =&gt; [32, 42, 72, 87, 60]</pre><p>Most of the beginner thinks that we can assigned only one type of value in an array, such as array of string (ex. country_name) or array of numbers (ex. student_marks), but in JavaScript you can have array which contains string, number, boolean or an object.</p><p>const random_array = [&quot;Hello&quot; , 67, true, {id: 23}, [&quot;Mango&quot;]]</p><p>Cool! right.</p><h3>What are loops</h3><p>Loops means iterating(or repeating) something over an over and using loop you’ll see how to access the elements in an array.</p><p>In this blog, let’s only see basic <strong>for</strong> loop. The <strong>for </strong>loop takes three arguments; initialization, condition, afterthought. The afterthought could be incrementing that value or maybe doing some other operations.</p><pre>for (let index = 0; index &lt; random_array.length ; index ++){<br>    console.log(random_array[index])<br>}<br><br>// output:<br>&quot;Hello&quot;<br>67<br>true<br>{id: 23}<br>[&quot;Mango&quot;]</pre><p>Instead of just printing the values you can actually do some other operation such as updating all values</p><pre>for (let index = 0; index &lt; random_array.length ; index ++){<br>    random_array[index] = 2 * [index + 1]<br>}<br><br>console.log(random_array)<br>// [2,4,6,8,10]</pre><p>That’s it for this blog, Hope you enjoyed reading the blog. In the next blog you’ll learn more array methods such as push, pop, shift, unshift etc.</p><p>If you have any feedback just let me know. Thanks for your time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=faf9a7085c1e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Control Flow in JavaScript: If, Else, and Switch Explained]]></title>
            <link>https://medium.com/@yugSaini/control-flow-in-javascript-if-else-and-switch-explained-4eff2d164884?source=rss-e64d6e0b7139------2</link>
            <guid isPermaLink="false">https://medium.com/p/4eff2d164884</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[js-beginner]]></category>
            <category><![CDATA[chaicode]]></category>
            <dc:creator><![CDATA[Yug]]></dc:creator>
            <pubDate>Thu, 12 Mar 2026 09:55:42 GMT</pubDate>
            <atom:updated>2026-03-12T17:10:58.640Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SBSD6A73ksPJIWCZVrldCA.png" /></figure><p>Control Flow literally means controlling the flow of a program. It’s similar to what we do in our day-to-day life. Suppose you’re at a traffic light, you know you have to stop when the light is red, yellow to alert that it’s going to change, and green means you can go. You’re checking some conditions and making the decision, correct? Similarly, when you write code, and you have to make a decision based on certain conditions, this is called control flow.</p><p>Suppose a user created a new account on Netflix. Does that mean they can watch the content? Nope! First, a user needs to verify their email, and then they have to subscribe to any of their plan then they can access the content. So here they need to check some conditions, such as whether their email is verified and whether they have a subscription plan or not.</p><p>There are many ways to control the flow, let’s see them in detail —</p><h3>The if Statement</h3><p>The if statement is used to check a condition and then allows a part of the code we want to execute. If the condition is not satisfied, it will skip that part of the code.</p><pre>let isUserLoggedIn = true<br>let age = 12<br>if(isUserLoggedIn){ <br>  console.log(&quot;You&#39;re logged in&quot;)<br>}<br>if(age &gt;= 18){ <br>  console.log(&quot;Welcome to adulthood&quot;)   //Can&#39;t print it because age is 12<br>}<br>//output:<br>//You&#39;re logged in</pre><h3>The if-else Statement</h3><p>In this statement, if the given condition is satisfied flow enters inside if block otherwise it’ll enter the else block.</p><pre>let age = 12;<br>if(age &gt;= 18){<br>  console.log(&quot;You&#39;re 18+&quot;)<br>}else{<br>	console.log(&quot;You&#39;re not an adult&quot;)<br>}<br>//output: You&#39;re not an adult</pre><h3>The else if ladder</h3><p>This ladder is used when we have more than two independent conditions to check, such as the traffic light situation</p><pre>//Traffic light --&gt; &quot;red&quot;, &quot;yellow&quot;, &quot;green&quot;<br>let trafficLightColor = &quot;green&quot;<br>if(trafficLightColor === &quot;red&quot;){<br>		console.log(&quot;Stop&quot;);<br>}else if(trafficLightColor === &quot;yellow&quot;){<br>		console.log(&quot;Alert! Light is going to change&quot;)<br>}else{<br>	console.log(&quot;Light is Green, GO GO GO!&quot;)<br>}</pre><p>Wait? How’s this work? Basically, a traffic light can have only three colors. So first we checked for the <strong>red</strong> color, then we checked for the <strong>yellow</strong> color, and lastly we checked for the <strong>green</strong> color. So we could’ve used it else if for that, but it’s the only color left, so we used the else statement.</p><p>Can we do it using three if statements? Yes</p><pre>//Traffic light --&gt; &quot;red&quot;, &quot;yellow&quot;, &quot;green&quot;<br>let trafficLightColor = &quot;green&quot;<br>if(trafficLightColor === &quot;red&quot;){<br>		console.log(&quot;Stop&quot;);<br>}<br>if(trafficLightColor === &quot;yellow&quot;){<br>		console.log(&quot;Alert! Light is going to change&quot;)<br>}<br>if(trafficLightColor === &quot;green&quot;){<br>	console.log(&quot;Light is Green, GO GO GO!&quot;)<br>}</pre><h3>The switch ladder</h3><p>You’re going to use switch-case when you have to compare one expression against multiple possible expressions. Suppose you need to find out what day it is today! It could be any of seven different days, so you can easily use switch It just gives clearer and more readable code.</p><pre>const day = &quot;Tuesday&quot;<br>switch(day){<br>	case &quot;Monday&quot; : <br>	          console.log(&quot;Day is Monday&quot;);<br>		  break;<br>	case &quot;Tuesday&quot; : <br>		  console.log(&quot;Day is Tuesday&quot;);<br>		  break;<br>	case &quot;Wednesday&quot; : <br>		  console.log(&quot;Day is Wednesday&quot;);<br>		  break;<br>	case &quot;Thursday&quot; : <br>		  console.log(&quot;Day is Thursday&quot;);<br>		  break;<br>	case &quot;Friday&quot; : <br>		  console.log(&quot;Day is Friday&quot;);<br>		  break;<br>	case &quot;Saturday&quot; : <br>		  console.log(&quot;Day is Saturday&quot;);<br>		  break;<br>	case &quot;Sunday&quot; : <br>		  console.log(&quot;Day is Sunday&quot;);<br>		  break;<br>               default:<br>		  console.log(&quot;This is not a valid day&quot;);<br>}<br>//output: Day is Tuesday</pre><h4>break Statement</h4><p>break statement inside switch case breaks the flow of further comparison and gets the programming flow out of the swtich block.</p><p>But is it necessary? Yes, in a switch we need some statement such as break or return to get out of that block, if we don’t use any of them, it will execute the rest of the code inside that block without comparing the any case until it executes the default statement code or finds any return or break</p><h3>When to use switch vs if-else</h3><p>The if-else can be used to check multiple values using the logical operators, such as || (logical <strong>OR</strong>), &amp;&amp;(logical <strong>AND</strong>), but the switch case can only be used for a single value comparison.</p><pre>let userLoggedIn = true<br>let age = 20<br>let isSubscribe = false<br><br>if(userLoggedIn &amp;&amp; age &gt;= 18 &amp;&amp; isSubscribe){<br>    console.log(&quot;You are allowed to watch this content&quot;)<br>}else{<br>    console.log(&quot;You&#39;re not allowed&quot;)<br>}<br>//output: You&#39;re not allowed</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4eff2d164884" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Variables and Data Types in JavaScript]]></title>
            <link>https://medium.com/@yugSaini/understanding-variables-and-data-types-in-javascript-72e4eef3d1fe?source=rss-e64d6e0b7139------2</link>
            <guid isPermaLink="false">https://medium.com/p/72e4eef3d1fe</guid>
            <category><![CDATA[chaicode]]></category>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[js-data-type]]></category>
            <category><![CDATA[variables-in-javascript]]></category>
            <dc:creator><![CDATA[Yug]]></dc:creator>
            <pubDate>Wed, 11 Mar 2026 16:49:31 GMT</pubDate>
            <atom:updated>2026-03-11T16:49:31.605Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1zQVToq1ZfReLyGltf9nSQ.png" /></figure><p>Variables are like a container in the kitchen. When you first take a jar, it’s empty, and later you can store different things in it, such as snacks, spices, lentils, pickles, rice, flour, and so on. The labels on the container help you easily find what’s inside.</p><p>Variables work the same way: they store data — numbers, strings, objects, arrays, and just like a jar can hold sugar today and cookies tomorrow, a variable can also store different types of values.</p><h3>What is Scope</h3><p>Scope is the area of the program where a variable can be accessed.</p><p>Let’s understand this with an analogy :</p><p>Suppose you’re in the living room, which has some furniture like a sofa, table, and chairs, along with some other decorative items. All these items are accessible when you’re inside that room, but if you leave the room, you can’t access those items anymore; this is what we call <strong>scope</strong> in programming.</p><h4>Types of Scope</h4><ol><li><strong>Global Scope</strong>: A scope that is accessible from anywhere in that program.</li><li><strong>Function Scope</strong>: A scope that is created by a function, and we can access that code within the function</li><li><strong>Block Scope:</strong> A scope created by a pair of curly braces “{ }”. Variables declared with let and const inside a block can only be accessed within that block</li></ol><h3>Declaring variables in JS</h3><p>Declaring means taking some memory, giving it a name for reference, and then storing some data in it. JavaScript gives us three different ways to declare a variable: var, let, and const.</p><h4>var</h4><p>A variable declared using var has a global-scoped variable that means we can access/modify this variable anywhere in that file.</p><pre>var name = &quot;Yuki&quot;<br>{<br>//name is declared in outer-scope, and inner block can read outer variable<br><br>console.log(name)                        //output: Yuki<br>name = &quot;Kaori&quot;<br>var age = 5<br>}<br>console.log(&quot;name: &quot;,name,&quot;, age: &quot;,age)   //output: name: Kaori, age: 5</pre><h4>let</h4><p>Variable declared using let is block-scoped, which means we can only access it within that scope or in its nested scope, but we can not access it outside its scope.</p><pre>let name = &quot;Yuki&quot;<br>{<br>//name is declared in outer-scope, and inner block can read outer variable<br>console.log(name)                        //output: Yuki                <br>let age = 5<br>}<br>//variable age is not accessible here <br>console.log(&quot;name: &quot;,name,&quot;, age: &quot;,age)   <br>//ReferenceError: age is not defined</pre><h4>const</h4><p>const is also block-scoped, but if we declare a variable using const and assign some value to it. We can still access that variable, but we can’t change its value.</p><pre>const name = &quot;Yuki&quot;<br>{<br>// variables from outer scope are accessible<br>console.log(name)                      //output: Yuki<br>name = &quot;Kaori&quot;                        <br>//TypeError: Assignment to constant variable <br>}</pre><h3>Datatypes in JS</h3><p>DataTypes represent the type of data we are storing in a variable; it could be string, number, boolean, null, undefined, Symbol, BigInt, or objects.</p><p>JavaScript has two types of datatypes: Primitive and Non-Primitive.</p><h4>Primitive Datatypes</h4><pre>let name = &quot;Yuki&quot;       //value is string<br>let age = 5             //value is number<br>let isSheOld = false    //value is boolean<br>let myIncome = 200n     //value is BigInt (n represent BigInt)<br>let loveLife = undefined   //value is undefined<br>let lover = null          // value is null</pre><p>null and undefined might feel almost similar to beginners, but remember, null is an intentional value, whereas undefined is a missing value.</p><h4>Non-Primitive Datatypes</h4><p>In JS, we have only one non-primitive datatype, which isobject, you might think, what about arrays and functions? Actually, both of them are objects in JavaScript.</p><pre>let obj = {<br>name : &quot;Yuki&quot;,<br>age : 5<br>}<br><br>console.log(typeof obj)                    //output: object</pre><h3>How to check the type of any variable</h3><p>We can easily find out the type of value a variable is storing by using typeof</p><pre>console.log(typeof isSheOld)                 //output: boolean<br>console.log(typeof age)                      //output: number<br>console.log(typeof name)                     //output: string</pre><p><strong>Important</strong>: When you do typeof null It will return objectYes, it is unexpected, but it is what it is.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72e4eef3d1fe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript Operators: The Basics You Need to Know]]></title>
            <link>https://medium.com/@yugSaini/javascript-operators-the-basics-you-need-to-know-87e234422fc4?source=rss-e64d6e0b7139------2</link>
            <guid isPermaLink="false">https://medium.com/p/87e234422fc4</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[beginner-javascript]]></category>
            <category><![CDATA[javascript-for-beginners]]></category>
            <dc:creator><![CDATA[Yug]]></dc:creator>
            <pubDate>Fri, 06 Mar 2026 17:42:06 GMT</pubDate>
            <atom:updated>2026-03-06T17:42:06.415Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kdk6yQFB1xoLCEOjWifP_w.png" /></figure><p>An operator is something that we use with operands to perform some operation, just like we do in mathematics. JavaScript offers us so many operators. Let’s discuss them one by one -</p><h3>Arithmetic Operators</h3><p>An operator that allows us to perform simple mathematical operations such as: Addition (+), Subtraction (-), Multiplication (*), Division (/), and Modulo (%).</p><pre>//------ Addition ------<br>console.log(23 + 42) <br>//output: 65<br><br>//------ Subtraction ------<br>console.log(42 - 23)<br>//output: 19<br><br>//------ Multiplication ------<br>console.log(12 * 4)<br>//output: 48<br><br>//------ Division ------<br>console.log(12 / 4)<br>//output: 3<br><br>//------ Modulus ------<br>// Modulus is just another name of remainder<br>console.log(12 % 5)<br>//output: 2</pre><h3>Assignment Operators</h3><p>As the name suggest this operator is used to assign some values to a variable. A variable can hold a number, string, array, object, or function.</p><h4>=</h4><pre>let numberOne<br>numberOne = 12<br>// 12 is assigned into variable named numberOne</pre><h4>+=</h4><p>This operator is basically a shorthand, which adds the new value to the original value and then assigns the result to the same variable.</p><pre>let numberTwo = 12<br><br>// Method-1<br>numberTwo = numberTwo + 10         // numberTwo = 12 + 10<br>console.log(numberTwo)             //output: 22<br><br>//Method-2 ShortHand<br>numberTwo += 12<br>console.log(numberTwo)             //output: 22</pre><h4>-=</h4><p>This operator is basically a shorthand, which subtracts the new value from the original value and then assigns the result to the same variable.</p><pre>let numberTwo = 12<br>// Method-1<br>numberTwo = numberTwo - 10         // numberTwo = 12 - 10<br>console.log(numberTwo)             //output: 2<br><br>//Method-2 ShortHand<br>numberTwo -= 12<br>console.log(numberTwo)            //output: 2</pre><h3>Comparison Operators</h3><p>An operator that allows us to compare two operands.</p><h4>== (double equal-to)</h4><p>This is used to check whether two <strong>values</strong> are equal. If they are, it returns true; otherwise, it returns false.</p><pre>console.log(12 == 23)          //output: false<br>console.log(&quot;Air&quot; == &quot;air&quot;)    //output: false<br>//JavaScript string comparision is caseSenstive.</pre><p>Okay, you got the idea of what this operator actually does, but there are some cases where “==” will surpass your prediction.</p><pre>//Number and String comparision<br>console.log(12 == &quot;12&quot;)     //output: true<br>console.log(0 == false)     //output: true</pre><p>true? How on earth does it return true? Actually, JS is a little smart language. In the first example, it converts “12” into a number and then compares it, so it returns trueas 12 == 12 A similar conversion is done in the second example, in which the boolean value true is considered as <strong>1,</strong> and false is considered as 0.</p><p>Just remember: == perform loose equality comparison. It attempts to convert the second operand to the matching datatype of the first operand, and this process is called <strong>type coercion.</strong></p><h4>=== (triple equal to)</h4><p>This is used to check whether two <strong>values and their types</strong> are equal. If they are, it returns true; otherwise, it returns false.</p><pre>console.log(2 == &quot;2&quot;)     //output: false<br>console.log(false == 0)   //output: false</pre><p>In the above examples, although they look almost the same, their type are different, that’s why it returns false. It doesn’t do type coercion like ==</p><h4>!= (not equal to)</h4><p>This is used to check whether two <strong>values</strong> are not equal. If they are, it returns true; otherwise, it returns false.</p><pre>console.log(2 != 3)           //output: true<br>console.log(&quot;Air&quot; != &quot;air&quot;)   //output: true<br><br>//Type coercion<br>console.log(2 != &quot;2&quot;)         //output: false</pre><p>To avoid type coercion, we can use !== It adds an extra type check along with the value.</p><h4>&gt; (greater than)</h4><p>This is used to check whether the left side value is greater than the right side value. If they are, it returns true; otherwise, it returns false.</p><pre>console.log(43 &gt; 21)         //output: true<br>console.log(21 &gt; 43)         //output: false</pre><p>Let’s see something interesting:</p><pre>console.log(&quot;Abc&quot; &gt; &quot;abc&quot;)   //output: false<br><br>/*<br>false? It&#39;s because every char has its ASCII value, &quot;A&quot; has 65 and <br>&quot;a&quot; has 97 which means &quot;a&quot; has higher value than &quot;A&quot; <br>jathat&#39;s why it returs false<br>*/</pre><p>Similary we have &lt; (less than) which gives true if the left side value is less than the right side value</p><h3>Logical Operators</h3><p>An operator that allows us to combine two or more conditions and then perform some actions based on the result. You can relate them to Gates, such as OR, AND, NOT, etc.</p><h4>&amp;&amp; (Logical AND)</h4><p>This returns true only if and only if both conditions are true; if any of the conditions is false, it returns false.</p><pre>let isUserLoggedIn = true<br>let hasSubscription = false<br><br>console.log(&quot;Can I access this premium course? :: &quot;,<br>isUserLoggedIn &amp;&amp; hasSubscription )<br>//output: Can I access this premium course? :: false</pre><h4>|| (Logical OR)</h4><p>This returns true if any of the conditions are true; otherwise, it returns false.</p><pre>let isUserLoggedIn = true<br>let hasSubscription = false<br><br>console.log(&quot;Can I access this free course? :: &quot;,<br>isUserLoggedIn || hasSubscription )<br>//output: Can I access this premium course? :: true</pre><h4>! (Logical NOT)</h4><p>This operator returns the reverse of the Boolean expression of that condition. In simple terms, if the condition is true, it returns false, and if it is false, then it returns true.</p><pre>let isUserLoggedIn = true<br>console.log(!isUserLoggedIn)     //output: false</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=87e234422fc4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How a Browser Works: A Beginner-Friendly Guide to Browser Internals]]></title>
            <link>https://medium.com/@yugSaini/how-a-browser-works-a-beginner-friendly-guide-to-browser-internals-911dc95436f7?source=rss-e64d6e0b7139------2</link>
            <guid isPermaLink="false">https://medium.com/p/911dc95436f7</guid>
            <dc:creator><![CDATA[Yug]]></dc:creator>
            <pubDate>Sun, 01 Feb 2026 13:39:20 GMT</pubDate>
            <atom:updated>2026-02-01T13:39:20.239Z</atom:updated>
            <content:encoded><![CDATA[<p>Most people think browser as another software used to do some googling and visiting few websites. Have you ever wondered what happens when you type the url and press enter?</p><p>Yes, of course, you’re from a computer science background, and you know that the browser sends a request to the DNS server to ask for the IP address, and then connects with that IP address and fetches the website, right?</p><p>Yes, but the next question is how it renders a web page? How can a common software be capable of converting the HTML, CSS, and JavaScript code into a beautiful website? If this sparks any curiosity inside you, let’s try to explore a Browser today.</p><h3>What is a browser</h3><p>A browser is a collection of components working together. A browser is not just software; I would say it is a complete OS.</p><h3>Browser components</h3><ul><li>User Interface</li><li>Browser Engine</li><li>Rendering Engine</li><li>Networking, JS Interpreter, UI Backend</li><li>Disk API and storage</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2R3lsDlVtOXghZcDhgO-6Q.png" /><figcaption>Browser Internal</figcaption></figure><p>Let’s explore all components one by one.</p><h4>User Interface</h4><p>The user interface is the only component most people can see. This is where they interact with the browser. It has tabs, buttons, and an address bar.</p><h4>Browser Engine</h4><p>It is like a middleware between the User Interface and the Rendering Engine, which manages interaction between them, acting as an overall controller for the browser.</p><h4>Rendering Engine</h4><p>This engine helps the browser in parsing the HTML, CSS, and images, etc., and uses them to render/paint the web page. Examples of some popular rendering engines: Blink (Chrome, Edge, Opera), WebKit (Safari), Gecko (Firefox).</p><h4>Networking</h4><p>Networking is also a key component of the browser, allowing it to communicate with servers and retrieve/fetch HTML, CSS, and JavaScript.</p><h4>JS Interpreter</h4><p>The JS Interpreter is the one who helps to execute the JavaScript code inside the browser. A few popular JS engines are V8(Chrome, Edge), SpiderMonkey(Mozilla Firefox), and JavaScriptCore(Apple Safari).</p><h4>UI Backend</h4><p>UI Backend is a part of the rendering engine responsible for painting the UI on the screen to make the user visualize the fetched data.</p><h4>Disk API</h4><p>Disk API is an API designed to communicate with the local storage of the browser, such as cache, cookies, sessions, etc. It is also responsible for requesting the system to allow GPU processing to load the heavy websites.</p><p>Okay, you’ve understood the browser components and basic overview of their functionality, but what does the browser do to the raw data? How does it parse it and paint it on the screen?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4USur2B1Fjic6jIfztOJNg.png" /><figcaption>Process of painting a webpage</figcaption></figure><p>After fetching the data, browser’s first priority is to look for html file, once it found the HTML file it starts to begin parsing it, if it found any external CSS file link to this html file it halt the process and start looking for that file. Once it gets the CSS file, it continue to parse this file along with HTML file. It creates the CSSOM and then combine all these parsing files in <strong>Content Sink</strong>.</p><h4>DOM Construction</h4><p>Document Object Model is where browser starts arranging the content in a document model, convert tags and values into nodes. These nodes have HTML as well as CSS data.</p><h4>Frame Construction</h4><p>It is where browser with the help of document model starts to make a kind of layout. Think of it as creating wireframes or boxes.</p><h4>Frame Tree/Reflow</h4><p>This is the part where browser do a lot of calculation that how much width, height etc should be given to that container. These things can actually make any websites slow or fast, all depends upon the values that are given in the file.</p><h4>Painting</h4><p>Painting is like the creative brain for the browser, it apply all the provided colors to the container and make the website beautiful for users. This actually paint every pixel on the screens. Wow!</p><h4>Display</h4><p>Display is the final result what a user can see on the screen. For user point of view they just provided the url and that url contains all these things, but they don’t know what actually is happening inside the browser.</p><h3>Conclusion</h3><p>As a beginner you don’t have to remember all this, just understand the flow, what browser actually do when you hit <strong>enter</strong> to get the website.</p><p>By the way do you know HTML is a language of Tabs, you would be surprised if I tell you HTML parser is actually written in C++.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=911dc95436f7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Emmet for HTML: A Beginner’s Guide to Writing Faster Markup]]></title>
            <link>https://medium.com/@yugSaini/emmet-for-html-a-beginners-guide-to-writing-faster-markup-a91fbf2c536f?source=rss-e64d6e0b7139------2</link>
            <guid isPermaLink="false">https://medium.com/p/a91fbf2c536f</guid>
            <category><![CDATA[toolkit]]></category>
            <category><![CDATA[chaicode]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[emmet]]></category>
            <dc:creator><![CDATA[Yug]]></dc:creator>
            <pubDate>Sun, 01 Feb 2026 07:22:09 GMT</pubDate>
            <atom:updated>2026-02-01T07:22:09.221Z</atom:updated>
            <content:encoded><![CDATA[<p>HTML is not that much fun after a certain time; writing tags, nested tags again and again for different sections, is a boring and time-consuming task. Imagine writing the opening tag and then writing the closing tag. Why can’t it close automatically?. To make our lives easier, developers introduced a tool called <strong>Emmet.</strong></p><h3>What is Emmet</h3><p>Emmet is a toolkit that uses <strong>abbreviations</strong> to speed up the process of writing code. Emmet is a shortcut language for HTML. We can simply write an abbreviation, then hit tab, and it automatically converts it into a tag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LKwxvRDqfhhiWOpk15k0ZQ.png" /><figcaption>Emmet is fun!</figcaption></figure><p>Here, we can use any HTML element, such as body head h1 br etc., and this tool is intelligent enough to differentiate whether it is a self-closing tag or needs to be closed.</p><h3>Basic Syntax and Abbreviations</h3><p>Emmet is a really fun tool to use. Let me show you how you can play with Emmet and save your time.</p><h4>Generate the HTML document</h4><p>We have written HTML documents (boilerplate code) hundreds of times before actually making a web page.</p><pre>&lt;html&gt;<br>&lt;head&gt;<br>&lt;title&gt;&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;&lt;/body&gt;<br>&lt;/html&gt;</pre><p>Do we have to type all this every time? Answer is NO! We can use an Emmet shortcut ! to generate a boilerplate code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vtGzQ_o90w45nr--qN1Jpw.png" /><figcaption>A “!” can transform into HTML document</figcaption></figure><h4>Generate the Lorem Ipsum</h4><p>Writing lorem ipsum is the best way if we want a few random words to act as a content copy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nvZo-6Ie8ioLrfA9VKEeUw.png" /><figcaption>Tadaaa! 10 words of lorem ipsum</figcaption></figure><h4>Nesting abbreviation using “&gt;”</h4><p>Nesting is useful when we know what we need inside that element, for example: Need 10 lorem-ipsum words inside a p tag. For this, we use &gt; opearator which tells Emmet that it needs to be nested.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bFrUyIDQyoSrjxltH5G_lw.png" /><figcaption>Lorem ipsum inside p tag</figcaption></figure><h4>Using “*” to multiply the elements</h4><p>The best example for this would be list items inside an ordered/unordered list. If we need more than one list items we can use this as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BH-TMFch8xVxPaVgNI4zaw.png" /><figcaption>mutliplied list-item</figcaption></figure><h4>Adding Class or IDs</h4><p>Adding classes or ID’s to any element is really easy. There are two symbols that we use to differentiate between them.</p><ul><li>For class, we use . followed by classname</li><li>For id, we use # followed by id-name</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M8ngyK7zyOweQbbRpx_-SQ.png" /><figcaption>Adding classname inside div</figcaption></figure><p>Similarly, we can use # to add id-name.</p><h4>Adding Attributes to an element</h4><p>Adding attributes using Emmet is also very easy; for this, we need to write attributes inside [] and then hit tab. Use it when there is more than one attribute for an element, such as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S6zYL0SDzWGuqOKs8ejAUQ.png" /><figcaption>Multiple attributes for an element</figcaption></figure><h3>Conclusion</h3><p>Writing code without any tools is also fine, but after a few days or months, these elements don’t feel that interesting to write. We are developers, we’re here to write logic to solve a problem; we are not here to write div element 1000 times in a webpage. To make development easier and enjoyable, these tools really save a lot of time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a91fbf2c536f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started with cURL]]></title>
            <link>https://medium.com/@yugSaini/getting-started-with-curl-edcadd7aaf3b?source=rss-e64d6e0b7139------2</link>
            <guid isPermaLink="false">https://medium.com/p/edcadd7aaf3b</guid>
            <category><![CDATA[dev]]></category>
            <category><![CDATA[api-testing]]></category>
            <category><![CDATA[chaicode]]></category>
            <category><![CDATA[curl]]></category>
            <dc:creator><![CDATA[Yug]]></dc:creator>
            <pubDate>Sat, 31 Jan 2026 07:47:52 GMT</pubDate>
            <atom:updated>2026-01-31T07:47:52.287Z</atom:updated>
            <content:encoded><![CDATA[<p>Whenever we talk about accessing the internet, the client and server are always part of the conversation. While the client is considered close to the user, having some interface to let them interact with the machine, the client is also considered untrusted, i.e., Zero Trusted Architecture.</p><p>On the other hand, a server is a machine that runs continuously and serves user requests. A server is considered a Single Source of Truth and a single central authority that receives all the clients’ requests. A server should only allow authorized users to make changes because the server is very responsible for business logic, authentication, data storage, and security.</p><p>In most cases, a client accesses the websites via a browser, the browser sends the request to the server, and the server sends the response, but for a developer who wants send some messages to the server using a terminal, we have a Linux command that comes in handy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*10p_ZNFeMlb0baN99AaIrA.jpeg" /></figure><h3>cURL Command</h3><p>A cURL is a Linux command that stands for “Client URL” and is used to transfer data to and from a server using network protocols, including HTTP, HTTPS, and FTP, using a terminal. This command is mostly used in testing API, fetching web content, and sending and receiving data over a network.</p><h4>First request using curl</h4><pre>curl https://www.example.com<br><br>&lt;!doctype html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>&lt;title&gt;Example Domain&lt;/title&gt;<br>&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt;<br>&lt;style&gt;<br>body{background:#eee;width:60vw;margin:15vh auto;font-family:system-ui,<br>sans-serif}h1{font-size:1.5em}div{opacity:0.8}a:link,a:visited{color:#348}<br>&lt;/style&gt;<br>&lt;body&gt;<br>&lt;div&gt;<br>&lt;h1&gt;Example Domain&lt;/h1&gt;<br>&lt;p&gt;This domain is for use in documentation examples without needing <br>permission. Avoid use in operations.<br>&lt;p&gt;&lt;a href=&quot;https://iana.org/domains/example&quot;&gt;Learn more&lt;/a&gt;<br>&lt;/div&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><h4>Understanding the curl response</h4><p>We sent a request to the domain www.example.com and the server responded with HTTP</p><p>Using the curl command with the URL as shown above only gives us a raw HTML response in the terminal; by default, it sends a get request, and the response can be raw Text, HTML, or JSON.</p><h3>cURL Requests</h3><p>There are a few HTTP methods used for cURL requests, such as GET, POST, DELETE, PUT, and HEAD. Among all these, GET is the default method if not specified.</p><p><strong>GET</strong>: This method is used to retrieve the data from a server. This request typically does not contain a request body.</p><p><strong>POST:</strong> This method is used to create new resources, such as adding a new product into database.</p><p><strong>PUT:</strong> This method is used to replace an existing resource with an updated version</p><p><strong>DELETE:</strong> This method is used to remove data from a database</p><h3>cURL Response</h3><p>Whenever we sent a request, the response we get mainly contains two things; Status code and Data.</p><h4>Status Code</h4><p>An HTTP status code is a code that returns the status of our request, for example:</p><ul><li>1xx → More response is coming</li><li>2xx → Success</li><li>3xx → Redirect</li><li>4xx → Not Found (Client asked for something that could not be delivered)</li><li>5xx → Server Error</li></ul><h4>DATA</h4><p>Response can include requested data, such as HTML, JSON, or an image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tVczhfPCg0schqaZ-e5SiA.png" /></figure><h3>Using cURL to talk to the API</h3><p>Let&#39;s explore a public api of GitHub to build a little confidence and see what an API actually looks like:</p><pre>$ curl https://api.github.com<br>{<br>  &quot;current_user_url&quot;: &quot;https://api.github.com/user&quot;,<br>  &quot;current_user_authorizations_html_url&quot;: &quot;https://github.com/settings/connections/applications{/client_id}&quot;,<br>  &quot;authorizations_url&quot;: &quot;https://api.github.com/authorizations&quot;,<br>  &quot;code_search_url&quot;: &quot;https://api.github.com/search/code?q={query}{&amp;page,per_page,sort,order}&quot;,<br>  &quot;commit_search_url&quot;: &quot;https://api.github.com/search/commits?q={query}{&amp;page,per_page,sort,order}&quot;,<br>  &quot;emails_url&quot;: &quot;https://api.github.com/user/emails&quot;,<br>  &quot;emojis_url&quot;: &quot;https://api.github.com/emojis&quot;,<br>  &quot;events_url&quot;: &quot;https://api.github.com/events&quot;,<br>  &quot;feeds_url&quot;: &quot;https://api.github.com/feeds&quot;,<br>  &quot;followers_url&quot;: &quot;https://api.github.com/user/followers&quot;,<br>  &quot;following_url&quot;: &quot;https://api.github.com/user/following{/target}&quot;,<br>  &quot;gists_url&quot;: &quot;https://api.github.com/gists{/gist_id}&quot;,<br>  &quot;hub_url&quot;: &quot;https://api.github.com/hub&quot;,<br>  &quot;issue_search_url&quot;: &quot;https://api.github.com/search/issues?q={query}{&amp;page,per_page,sort,order}&quot;,<br>  &quot;issues_url&quot;: &quot;https://api.github.com/issues&quot;,<br>  &quot;keys_url&quot;: &quot;https://api.github.com/user/keys&quot;,<br>  &quot;label_search_url&quot;: &quot;https://api.github.com/search/labels?q={query}&amp;repository_id={repository_id}{&amp;page,per_page}&quot;,<br>  &quot;notifications_url&quot;: &quot;https://api.github.com/notifications&quot;,<br>  &quot;organization_url&quot;: &quot;https://api.github.com/orgs/{org}&quot;,<br>  &quot;organization_repositories_url&quot;: &quot;https://api.github.com/orgs/{org}/repos{?type,page,per_page,sort}&quot;,<br>  &quot;organization_teams_url&quot;: &quot;https://api.github.com/orgs/{org}/teams&quot;,<br>  &quot;public_gists_url&quot;: &quot;https://api.github.com/gists/public&quot;,<br>  &quot;rate_limit_url&quot;: &quot;https://api.github.com/rate_limit&quot;,<br>  &quot;repository_url&quot;: &quot;https://api.github.com/repos/{owner}/{repo}&quot;,<br>  &quot;repository_search_url&quot;: &quot;https://api.github.com/search/repositories?q={query}{&amp;page,per_page,sort,order}&quot;,<br>  &quot;current_user_repositories_url&quot;: &quot;https://api.github.com/user/repos{?type,page,per_page,sort}&quot;,<br>  &quot;starred_url&quot;: &quot;https://api.github.com/user/starred{/owner}{/repo}&quot;,<br>  &quot;starred_gists_url&quot;: &quot;https://api.github.com/gists/starred&quot;,<br>  &quot;topic_search_url&quot;: &quot;https://api.github.com/search/topics?q={query}{&amp;page,per_page}&quot;,<br>  &quot;user_url&quot;: &quot;https://api.github.com/users/{user}&quot;,<br>  &quot;user_organizations_url&quot;: &quot;https://api.github.com/user/orgs&quot;,<br>  &quot;user_repositories_url&quot;: &quot;https://api.github.com/users/{user}/repos{?type,page,per_page,sort}&quot;,<br>  &quot;user_search_url&quot;: &quot;https://api.github.com/search/users?q={query}{&amp;page,per_page,sort,order}&quot;<br>}</pre><p>This request gives us the api response in JSON format, and that’s how developers talk to the api.</p><h3>Conclusion</h3><p>Understanding the cURL command will definitely help a developer during api testing and debugging, to test endpoints and send various HTTP requests. curl provides a powerful and flexible way to interact with a web service using a terminal.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=edcadd7aaf3b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TCP Working: 3-Way Handshake & Reliable Communication]]></title>
            <link>https://medium.com/@yugSaini/tcp-working-3-way-handshake-reliable-communication-a88fda7cf6e7?source=rss-e64d6e0b7139------2</link>
            <guid isPermaLink="false">https://medium.com/p/a88fda7cf6e7</guid>
            <category><![CDATA[chaicode]]></category>
            <category><![CDATA[tcp]]></category>
            <category><![CDATA[3-way-handshake]]></category>
            <dc:creator><![CDATA[Yug]]></dc:creator>
            <pubDate>Sat, 31 Jan 2026 06:03:54 GMT</pubDate>
            <atom:updated>2026-01-31T06:03:54.056Z</atom:updated>
            <content:encoded><![CDATA[<p>Sending the data over the network is a challenging task. Imagine you sent the data, and the data got corrupted, or it got lost somewhere, and didn’t reach its destination.</p><p>There are a lot of thing needs to be considered while sending data, such as:</p><p>Sending a big file is a risky and time-consuming process. How to make sure transmission is efficient, and data reaches its destination without any loss or corruption. That means we need some rules(Protocol) and reliability over the networks, and here TCP comes into the picture.</p><h3>Transmission Control Protocol (TCP)</h3><p>TCP helps in establishing the connection between the sender and the receiver and helps them exchange data over the network. TCP makes transmission faster by breaking the data into chunks, which are called Packets. Then number each data packet and arrange them in order, so that if the receiver misses any packet, then the sender knows which packet to resend. This makes TCP efficient and reliable.</p><h3>TCP 3-Way Handshake</h3><p>A simple way to understand 3-way handshaking is: When we join a meeting as a speaker, first we ask, “Am I audible?” and then the panelist responds with “Yes”, then we’re like “Perfect.” Connection is established, and now we can continue our conversation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xjGh0XCRoOHZLz_zSPjDWQ.png" /><figcaption>TCP: 3-way handshaking</figcaption></figure><p>TCP uses a process to establish the connection between the client and the server. In which</p><ul><li>The client first sends a connection request to the server, which is called a SYN.</li><li>The server first acknowledges the request and then agrees to the connection, so it sends ACK+SYN to the client.</li><li>The client receives the response and sends the acknowledgement (ACK) to the server, letting them know that a connection has been established.</li></ul><h4>Synchronization Sequence Number(SYN)</h4><p>A SYN packet is sent to the receiver that contains the SYN flags set to 1, a random 32-bit sequence number, and the ACK flag set to 0. It tells the server what the maximum segment size and window size are. In simple terms, what is the total capacity, and within that limit, how much packet client is going to send? and asking the server if there are any open connections.</p><h4>Synchronization and Acknowledgement(SYN + ACK)</h4><p>This request is sent by the receiver(server) if there is any open port available to establish the connection. SYN sent by the server also contains a sequence number, and ACK is actually the client’s SYN+1. Basically server is saying I received your request, and we can establish the connection.</p><h4>Acknowledgement (ACK)</h4><p>This request is again sent by the client to let the server know that the connection is established, and we are ready to transmit the data.</p><h3>Data Transfer in TCP</h3><p>As we know, before establishing the connection, two things need to be decided: one is the window size, and the other is the segment size.</p><p><strong>Window Size:</strong> Window size is the amount of data a receiver can accept before needing an acknowledgement. It is used to control the flow and avoid receiver from overflowing with data.</p><p><strong>Segment Size:</strong> Segment size is the maximum amount of data in a single packet.</p><p>So, the first thing breaks the data into data packets and transmits them according to the window size limit. Suppose we have 30 data packets, and the window size is 25, then</p><ol><li>TCP sent the 25 packets to the server and waits for the ACK. Once the server receives all 25 packets, it sends the ACK to the client.</li><li>TCP received the ACK and sent the 5 packets from the remaining packets, and again waits from ACK from the server.</li><li>Here, if the server doesn’t send the response within the time limit, the client will consider that something happened, and it will resend all those packets and wait for the ACK.</li><li>If the server responded with ACK, that means all the data packets were transmitted successfully.</li></ol><h3>4-way Handshaking in TCP</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MQkVas6U3D4H762gTECybQ.png" /><figcaption>4-way Handshaking: Closing the connection</figcaption></figure><p>This is basically closing the established connection between client and server. It should be done when the client has sent all the data packets and the server has received all the packets. Let’s see how it’s done</p><ol><li>Client sends the FIN to the server that I’ve sent all the packets, i.e., I’m finished.</li><li>The server receives the requests and sends the ACK first, telling the client that the request has been received.</li><li>After receiving all the data packets, it sends FIN. It means yes, I’ve received all the data packets, and I’m ready to close the connection.</li><li>Once the client gets both ACK and then FIN, it closes the connection and sends an ACK to the server that the connection has been closed.</li></ol><h3>Conclusion</h3><p>3-way handshaking is very important if we want reliability and correctness in sending data. TCP actually helps in ordering the data packets in such a way that if there is any loss of data packets at the server’s end, the server can respond with that sequence number, and TCP will retransmit that packet instead of sending them all again. We must have seen it during downloading a file or a software that if we pause the process for a bit, downloading starts from that point instead of downloading from the beginning.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a88fda7cf6e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>