<?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"><channel><title><![CDATA[Chaicode Web Dev Cohort 2026]]></title><description><![CDATA[This is my journey of coding begins .]]></description><link>https://blogs.dipeshchaudhary.name.np</link><generator>RSS for Node</generator><lastBuildDate>Thu, 16 Apr 2026 03:40:05 GMT</lastBuildDate><atom:link href="https://blogs.dipeshchaudhary.name.np/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Template Literals in JavaScript]]></title><description><![CDATA[In this article we discussed about the template literal in javascript
Before Template literal
In programming we used string data type with alot of time. to print something we need string format . to s]]></description><link>https://blogs.dipeshchaudhary.name.np/template-literals-in-javascript</link><guid isPermaLink="true">https://blogs.dipeshchaudhary.name.np/template-literals-in-javascript</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Cohort2026]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Dipesh Chaudhary]]></dc:creator><pubDate>Sun, 12 Apr 2026 18:58:40 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6950c18c622afddd90b193eb/686fbcae-53a3-4a5b-9fe7-22e32c1b2cf0.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In this article we discussed about the template literal in javascript</p>
<h2>Before Template literal</h2>
<p>In programming we used string data type with alot of time. to print something we need string format . to show output in formatted way we need string . so before template literal we have to combine the string with plus (+) sign which is called string concatenation in programming .</p>
<p>lets see some examples :</p>
<img src="https://cdn.hashnode.com/uploads/covers/6950c18c622afddd90b193eb/e5eb9bbf-87c4-4249-a0f5-dc8b39cf38d7.png" alt="" style="display:block;margin:0 auto" />

<p>we need to concatenate the variable with using plus operator to add two to more strings before template literal .</p>
<h2>Benefits of Template Literals</h2>
<p>The template literal solve mainly two problems:</p>
<ol>
<li><p><strong>string concatenation /string interpolation</strong> : we can do string interpolation just by using placeholders with like this ${}.</p>
</li>
<li><p><strong>multi-line stings</strong> : this is huge benefits to use template literals to format the string in any format . It print same to same however you write inside the back ticks.</p>
</li>
<li><p>we can embed any variable and calculation inside the template literals</p>
</li>
</ol>
<img src="https://cdn.hashnode.com/uploads/covers/6950c18c622afddd90b193eb/394d202f-cab3-4441-9fb0-49bb84162832.png" alt="" style="display:block;margin:0 auto" />

<h2>Reasons of bringing it</h2>
<ul>
<li><p><strong>Simplifying Concatenation</strong>: Previously, developers had to rely on the <code>+</code> operator to join strings and variables, which led to "cluttered" code that was difficult to read and maintain. Template literals allow direct variable embedding via <code>${}</code>.</p>
</li>
<li><p><strong>Enabling Native Multi-line Support</strong>: In older versions of JS, you had to manually insert <code>\n</code> or use awkward concatenation to break a string into multiple lines. Template literals preserve line breaks and whitespace exactly as they are written.</p>
</li>
<li><p><strong>Reducing "Quote Clash"</strong>: Using single and double quotes inside a string often required tricky backslash escaping (e.g., <code>\'</code> or <code>\"</code>). Since template literals use backticks (<code>`</code>), they can contain both types of quotes naturally.</p>
</li>
<li><p><strong>Advanced Processing (Tagged Templates)</strong>: They introduced <strong>tagged templates</strong>, which allowed developers to process strings with a function before they were rendered. This innovation paved the way for powerful tools like <strong>Styled Conponents</strong> and GraphQL queries.</p>
</li>
<li><p><strong>Modernizing Functionality</strong>: JavaScript's string capabilities were lagging behind languages like Python or Ruby; template literals brought the language's string manipulation up to a competitive modern standard.</p>
</li>
</ul>
<h2>Summary</h2>
<p>The template literal is introduced to remove the the messy and error prone while writing the string concatenation burden from developer. before it the developer nedd to think double times how to format it where to keep plus sign and space more frustration seems in developer. so template literal make easy that task . It helps to develop the dynamic content and multi line formatting easier.</p>
]]></content:encoded></item><item><title><![CDATA[Flatten Array in JavaScript]]></title><description><![CDATA[This blog is all about flatten the array in JavaScript. The concept of flatten the array and explained various ways for flatten the array with some common interview questions .
What is Flatten means ?]]></description><link>https://blogs.dipeshchaudhary.name.np/flatten-array</link><guid isPermaLink="true">https://blogs.dipeshchaudhary.name.np/flatten-array</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Cohort2026]]></category><category><![CDATA[webdevelopment]]></category><category><![CDATA[array]]></category><category><![CDATA[Beginner Developers]]></category><dc:creator><![CDATA[Dipesh Chaudhary]]></dc:creator><pubDate>Wed, 25 Mar 2026 06:02:55 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6950c18c622afddd90b193eb/f6964ec6-c6cf-4c82-8419-11452a92376b.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>This blog is all about flatten the array in JavaScript. The concept of flatten the array and explained various ways for flatten the array with some common interview questions .</p>
<h1>What is Flatten means ?</h1>
<p>Flatten array means converting nested arrays of many dept to single level array</p>
<h2>Why we need to do that ?</h2>
<p>Generally The developer who works in frontend need to show data which is coming from api to UI so . They prefer to come response in easy data structure as much as possible. when there is single level array then there are more easy to process data</p>
<ul>
<li><p>Looping through data becomes easy</p>
</li>
<li><p>Easier to apply array methods like map, filter</p>
</li>
<li><p>Easier to get required data from array and show on UI</p>
</li>
<li><p>performance wise also single level array is good</p>
</li>
</ul>
<h2>Examples</h2>
<pre><code class="language-javascript">const arr = [1, 2, [34, 10], [7, 9, [100]]];
console.log(arr); //[ 1, 2, [ 34, 10 ], [ 7, 9, [ 100 ] ] ]
console.log(arr.flat(Infinity)); // to flatten to more depth
// [ 1, 2, 34, 10, 7, 9, 100 ]
</code></pre>
<h2>Different ways to flatten array</h2>
<p><strong>1 . using built in flat method</strong></p>
<p>we can directly use flat array methods. It accepts depth of nested to give flatten output.</p>
<pre><code class="language-javascript">const alphas = ["a", "b", ["c"], ["d", ["e", ["f", ["g"]]]]];
console.log(alphas.flat(1)); // one level
console.log(alphas.flat(2)); // 2 level depth
console.log(alphas.flat(4)); // 4 level depth

/**
 *  [ "a", "b", "c", "d", [ "e", [ "f", [ "g" ] ] ] ]
[ "a", "b", "c", "d", "e", [ "f", [ "g" ] ] ]
[ "a", "b", "c", "d", "e", "f", "g" ]
 */
</code></pre>
<p><strong>2 . using recursion</strong></p>
<p>This is asked in interview . Just use recursion function to flatten array</p>
<pre><code class="language-javascript">//  using recursion
const flatten = (arr) =&gt; {
  return arr.reduce((acc, arr) =&gt; {
    return acc.concat(Array.isArray(arr) ? flatten(arr) : arr);
  }, []);
};

console.log(flatten(alphas));
// [ "a", "b", "c", "d", "e", "f", "g" ]
</code></pre>
<p><strong>3 . using flatMap</strong></p>
<p>it does two works flat + map . it only flatten array to one level</p>
<pre><code class="language-javascript">const result = [1, 2, [3, 4], [5, 6]].flatMap((i) =&gt; i);
console.log(result);
// [ 1, 2, 3, 4, 5, 6 ]
</code></pre>
<p><strong>4 . using loop and spread</strong></p>
<pre><code class="language-javascript">const flatResult = [];
for (let el of nums) {
  if (Array.isArray(el)) {
    flatResult.push(...el);
  } else {
    flatResult.push(el);
  }
}
console.log(flatResult);
</code></pre>
<h3>Common Interview Questions</h3>
<p><strong>1 . Flat deeply nested array without flat()</strong></p>
<p>using recursion</p>
<p><strong>2 . Flatten array with unknown depth</strong></p>
<p>use Infinity depth</p>
<pre><code class="language-javascript">array.flat(Infinity)
</code></pre>
<p><strong>3 . Flatten and remove falsy values</strong></p>
<pre><code class="language-javascript">arr.flat(Infinity).filter(Boolean)
</code></pre>
<h2>Diagram showing recursion of flatten array</h2>
<img src="https://cdn.hashnode.com/uploads/covers/6950c18c622afddd90b193eb/810420da-f412-4a94-8325-8881d2a9eeaa.png" alt="" style="display:block;margin:0 auto" />

<h1>Summary</h1>
<p>Flatten is process of converting the nested array of many depth into the one level or any required depth. There are different ways of doing flattening the array in JavaScript.</p>
<p>There is built in array method flat method which do shallow or deep flatten according to depth provide to it.</p>
<p>without using built in methods we can flatten the array by using recursive function call .</p>
]]></content:encoded></item><item><title><![CDATA[Introduction of Import and Export in JavaScript]]></title><description><![CDATA[In early days, JavaScript was light-weight very simple script file which is load faster and do some tasks on website . But when It evolve in modern JavaScript , large projects are build by it. many fr]]></description><link>https://blogs.dipeshchaudhary.name.np/js-module</link><guid isPermaLink="true">https://blogs.dipeshchaudhary.name.np/js-module</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Cohort2026]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[software development]]></category><category><![CDATA[backend]]></category><dc:creator><![CDATA[Dipesh Chaudhary]]></dc:creator><pubDate>Sun, 22 Mar 2026 05:25:45 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6950c18c622afddd90b193eb/17ec8928-c5bf-496f-af3d-c519684c5495.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In early days, JavaScript was light-weight very simple script file which is load faster and do some tasks on website . But when It evolve in modern JavaScript , large projects are build by it. many frameworks are build by using JavaScript. In large Projects , code base are large and many codes lines thousand of lines are written .</p>
<p>Just think when that huge lines of codes when written in only one file then how it possible to maintain the code . and also there will be very difficult to understand the code. and also when the files push into production , the one file is huge size which effect in performance.</p>
<p>In this article I discussed about the concept of modules and how it done in JavaScript.</p>
<h2>Introduction about modules system</h2>
<p>module means simple file it will be any file with any extension but we are in JavaScript. so Lets say the different JavaScript files which are created and handle properly and all files are interconnected on system so they can share and used code into one another file is modules system.</p>
<h2>Problems without modules</h2>
<p>problems are simple . The file size increase which becomes more complex o handle and we donot have idea about the what this code files is about.</p>
<p>This makes harder to refactor code and also maintain it when some bug arise we have to look on deeper inside file and it takes more time on just finding the code .</p>
<p>so module sytem introduces in JavaScript .</p>
<h2>How to use modules system</h2>
<p>we can used simple by using two keywords : Import and export . By word we can guess the what is it used for . Import is used to import another file code and export is use to export the code so that other file can import it for use it .</p>
<h3>Types of modules in JavaScript</h3>
<ul>
<li><p>Asynchronous Module Definition (AMD)</p>
</li>
<li><p>Common JS</p>
</li>
<li><p>Universal Module Definition (UMD)</p>
</li>
<li><p>ES Modules</p>
</li>
</ul>
<p>The official JavaScript module is ES Modules System in which we used import and export keyword .</p>
<h3>Problems on not using module system</h3>
<p>The problems are listed below :</p>
<ul>
<li><p>Global Scope pollution : The variables, function declaration all are global scope means easily access in different script file which can cause name collision and also some variable may get override.</p>
</li>
<li><p>No dependency management : we have to load all the scripts manually in index.html file and also remember the order of maintaining to load the script files like one after another . If order does not maintain the code files cannot be used in another file.</p>
</li>
<li><p>Hard to maintain and reuse the code</p>
</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6950c18c622afddd90b193eb/aa70689f-cda1-495f-a6a2-f6b598b70394.png" alt="" style="display:block;margin:0 auto" />

<h3>Appling the module system</h3>
<p>It is easy to apply module system just by add the attribute type module in script tag . The entry script file means the file which call all other modules like main.js</p>
<p>like shown on below image</p>
<img src="https://cdn.hashnode.com/uploads/covers/6950c18c622afddd90b193eb/c638e9a8-c23b-406a-8d6e-4051f846ff26.png" alt="" style="display:block;margin:0 auto" />

<h3>Types of Export and Import</h3>
<p>There are two types of export and import the files.</p>
<ol>
<li><p>Default export : The default export is done by simple <code>export default &lt;code&gt;</code>. Here code placeholder is for any variables, function, object any code which you want to export from file.</p>
</li>
<li><p>Named export : The named export is done by simple using export keyword before any code like <code>export let score =0;</code> or there is another way of doing by simply write many codes like function, variable and at last used export {add,score} . like this this is also one way .</p>
</li>
</ol>
<p>Note : The default export should be only one in one code files and there is as many named export .</p>
<p>while importing</p>
<ul>
<li><p>Default import is simple by just <code>import &lt;name_of_code&gt; from "&lt;filename.js&gt;"</code>. We can give any name while importing default export in place of <code>&lt;name_of_code&gt;</code> .</p>
</li>
<li><p>Named Import : while importing named export , The curly braces is used like <code>import {add,score} from './calculation.js"</code> . the name must be same in named export</p>
</li>
</ul>
<h2>Exporting the code</h2>
<img src="https://cdn.hashnode.com/uploads/covers/6950c18c622afddd90b193eb/1a3ea56a-8ee7-476d-be5d-554407d39419.png" alt="" style="display:block;margin:0 auto" />

<h2>Importing the code</h2>
<img src="https://cdn.hashnode.com/uploads/covers/6950c18c622afddd90b193eb/0383e44e-7c1e-480d-9368-96a319265def.png" alt="" style="display:block;margin:0 auto" />

<h2>Conclusion</h2>
<p>The module system enables to write modular code means the different pattern where one code files share the code and we can use in another files making the code files isoated from one another .</p>
<p>It encapsulate our variables and functions which makes it private in that file so there is no chance of conflicting the name of variable and function. and It makes our projects scalable and maintainable.</p>
]]></content:encoded></item><item><title><![CDATA[Understanding the NodeJS and Its architecture]]></title><description><![CDATA[NodeJS is the run time environment to execute javascript outside of the browser. In this article , we discussed about the introduction of nodejs, meaning of non-blocking event driven model, and event ]]></description><link>https://blogs.dipeshchaudhary.name.np/nodejs-intro</link><guid isPermaLink="true">https://blogs.dipeshchaudhary.name.np/nodejs-intro</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Node.js]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[Cohort2026]]></category><category><![CDATA[Beginner Developers]]></category><dc:creator><![CDATA[Dipesh Chaudhary]]></dc:creator><pubDate>Mon, 16 Mar 2026 08:23:36 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6950c18c622afddd90b193eb/66b81e2e-762a-4cb0-a6b5-890be9f476db.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>NodeJS is the run time environment to execute javascript outside of the browser. In this article , we discussed about the introduction of nodejs, meaning of non-blocking event driven model, and event loop.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6950c18c622afddd90b193eb/4e63b502-989b-433a-aa50-821a3222301d.png" alt="" style="display:block;margin:0 auto" />

<h1>Introduction of NodeJS</h1>
<p>Nodejs is created on 2009 by using the chrome Javascript engine which is V8. The main motive of bringing nodejs is that obviously to run javascript outside of browser. It enables the door for building server side application. It is used to build highly scalable, efficient networking applications by using its powerful non-blocking event driven model.</p>
<h2>Dive into some reasons of arrival of nodejs</h2>
<ul>
<li><p>Server-Side JavaScript: Initially JavaScript is used in client side on the browser. It is just used for making website interactive, so nobody take it seriously but when nodejs arrives it is fully capable to build highly performant server side application , for making scalable full stack data intrensic application.</p>
</li>
<li><p>Non-blocking I/O model : In past time, the server was multi-threaded means the each operation takes dedicated thread to execute and finished which is inefficent for high concurrent operations so nodejs is single threaded, non-blocking event driven I/O model which is more suitable to handle multiple thousands of concurrent tasks easily like reading file system , database query etc.</p>
</li>
<li><p>unified language: it is simple both client and server side can be now built by using single language JavaScript.</p>
</li>
<li><p>performance: nodejs is buit bu using high perfomant chrome v8 engine which compiles the JavaScript code into machine code and fast executes it.</p>
</li>
<li><p>Rich eco system : nodejs comes with npm package manager which enables access of world largest ecosystem of libraries , frameworks and tools which are used to build application really fast in sort period of time.</p>
</li>
<li><p>Real Time Applications: It is non-blocking event driven I/O model so It is more suitable to build I/O bound applications and data-intrensic applications like web-server, chat application, collaborative tool, online games etc.</p>
</li>
</ul>
<h2>what is meant by non-blocking and event driven model</h2>
<p>Non-blocking event driven I/O model means it initiate input/output operation, without waiting them to finish. It delegates or offloads the tasks to the underlying sytem (kernel) or threadpool by libuv. so when the operation finish, It executed the associated callback which makes its more fast, efficient, responsiveness making ideal for high concurrency environments like web-servers.</p>
<p>Non-blocking I/O means when your code request data like reading files or some network request. It does not wait for the result. The system return the control immediately allowing to execute the other code.</p>
<p>Event-Driven Architecture: The program operates by listening the events when I/O tasks finished, the underlying system kernel signal that event occurred .</p>
<p>Event Loop : It is main core coordinator. It keeps monitoring the new tasks or finished I/O tasks. when a task completed, the loop picks up the associated callback and execute to it.</p>
<h2>Why this model ?</h2>
<p>The reasons behind it are:</p>
<ul>
<li><p>Scalability : It can handle high concurrency connections without blocking the main thread, you can handle significantly more traffic than thread per request model.</p>
</li>
<li><p>Efficiency: It eliminated the idle time . The CPU doesnot have to wait for the slow response from hard dirve or network request.</p>
</li>
<li><p>Suitability: It is highly suited to build I/O bound applications like web severs, chat applications, streaming applications etc.</p>
</li>
</ul>
<h2>What is meant by I/O tasks</h2>
<p>It is simple the program interaction with external environment like reading and writing file system, database query, network request or logging some files data.</p>
<h2>Summary</h2>
<p>Nodejs is JavaScript run time environment which is based on non-blocking event driven I/O model that means It doesnot wait for tasks to finished, rather it offloads the I/O task to underlying sytem kernel or threadpool by libuv.</p>
<p>It is most suitable for handling high concurrency tasks meaning different tasks at same time which increase the efficiency , responsiveness , resources utilization especially on I/O bound operations .</p>
]]></content:encoded></item><item><title><![CDATA[In Depth OOP In JavaScript]]></title><description><![CDATA[Let's learn how to do Object Oriented Programming JavaScript. It is not concept of JavaScript. It is paradigm of writing code . It is based on the concept of object. We used objects to model real worl]]></description><link>https://blogs.dipeshchaudhary.name.np/oop-js</link><guid isPermaLink="true">https://blogs.dipeshchaudhary.name.np/oop-js</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[oop]]></category><category><![CDATA[Cohort2026]]></category><category><![CDATA[Beginner Developers]]></category><category><![CDATA[Chaiaurcode]]></category><dc:creator><![CDATA[Dipesh Chaudhary]]></dc:creator><pubDate>Sat, 07 Mar 2026 11:11:01 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6950c18c622afddd90b193eb/238234bb-1bc9-4fa6-a8fd-05951e011362.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Let's learn how to do Object Oriented Programming JavaScript. It is not concept of JavaScript. It is paradigm of writing code . It is based on the concept of object. We used objects to model real worlds so Inside objects . There are two things . data and behaviors. The data is called properties and behaviors called methods of object.</p>
<p>The OOP is introduced to organize the code to make it more flexible and easier to maintain the codebase. If you do not maintain and organize the code then It will be totally mess in large codebase. so there are few structure or practice of organizing code. One of the is OOP.</p>
<pre><code class="language-plaintext">User {
user
password
email
login(password) {
// login logic
}
upoadPhoto() {
// logic
}
</code></pre>
<h2>Four Pillars of OOP</h2>
<p>There are main 4 pillar or concept of oop :</p>
<ol>
<li><p>Abstraction : In simple word abstraction means hiding the implementation of logic. example like in DOM there are many selectors given in document object like querySelector, addEventListner, which we can used it instead of knowing its actual implementation . we only need to just used it .It is great way of abstract the some methods from user.</p>
</li>
<li><p>Encapsulation : It is just making some properties and methods private so that They cannot be accessed outside of class.</p>
</li>
<li><p>Inheritance : It is known from itself meaning to make some property and method inherit from parent class. In JavaScript It is done by prototype so that it is called prototypal inherotance.</p>
</li>
<li><p>Polymorphism : It is taken from greek word . Its meaning is many form so The implementation of same methods in different way in different objects</p>
</li>
</ol>
<h2>Ways of OOP in JavaScript</h2>
<p>In JavaScript there are 3 ways of creating blueprint of object. The blueprint means designing the model of objects, It is not real objects. It is just like map from which any number of real objects can create. so</p>
<p>1 . Constructor function : It is most used way of creating blueprints for object. It is just regular function but it is called by using new operator. The new operator does 4 things .</p>
<ul>
<li><p>It create empty object .</p>
</li>
<li><p>It links the empty object with this keyword so that we can create property on object by using this keyword .</p>
</li>
<li><p>It assign the prototype of Object to newly created instance of objects with new keyword.</p>
</li>
<li><p>It implicitly return the objects.</p>
</li>
</ul>
<p>2 . Es6 class : It is just Syntactic sugar of constructor function . In JavaScript The class is not behave as other programming language like Java, C++ . Under the hood it is just wrapper which do the same thing of constructor function . It is just easy to write and cleaner way because we do not have to manually set the prototype in it .</p>
<p>3 . Object.create : It is the way of creating object. It doesnot use any new operator, any prototype object. It is simple way and also easy to understand the way of JavaScript handle the inheritance by prototype. It shows clear picture. we have to set manually which object you want to set as prototype.</p>
<h2>Constructor Function</h2>
<pre><code class="language-plaintext">// constructor function 
function TataCar(chassisNumber, modelName) {
  this.chassisNumber = chassisNumber;
  this.modelName = modelName;
  this.fuelLevel = 100;
  
// adding method inside function
// this is bad practice
  this.start= function (){
    console.log("Engine start")
  }
  
}

const car1 = new TataCar("MH-101", "Nexon");
const car2 = new TataCar("DL-202", "Harrier");
console.log(car1) ;
car1.start() ;
</code></pre>
<p>We can add the methods inside the constructor function but it is bad practice because when you create any objects then the method created and copied that much times for object. so It is not good for memory and performance. suppose we have create 1000 objects then there are 1000 copies of that methods . Its make our website slow. so we used prototype for adding methods and also common properties.</p>
<p>Prototype is the object which JavaScript add to all objects which is constructed by constructor function . So any methods or properties which is not own property of object then it search to the prototype and used it .</p>
<pre><code class="language-javascript">function TataCar(chassisNumber, modelName) {
  
  this.chassisNumber = chassisNumber;
  this.modelName = modelName;
  this.fuelLevel = 100;
}

TataCar.prototype.status = function () {
  return `Tata \({this.modelName} #\){this.chassisNumber} | Fuel: ${this.fuelLevel}`;
};

const car1 = new TataCar("MH-101", "Nexon");
const car2 = new TataCar("DL-202", "Harrier");
console.log(car1.modelName);
console.log(car2.modelName);
console.log(car1.status());
console.log(car2.status());
</code></pre>
<h2>Es6 Class</h2>
<pre><code class="language-javascript">// Es6 class
class Person {
  constructor(firstName, email, birthYear) {
    this.firstName = firstName;
    this.email = email ;
    this.birthYear = birthYear ;
  }
  calcAge() {
    return new Date().getFullYear() - this.birthYear ;
  }
  introduce() {
    console.log(`Hi, Myself \({this.firstName} and I am \){this.calcAge()} years old `)
  }
  
}
const shekhar = new Person("Shekhar", "shekhar12@mail.com", 1995) ;
const prahlad = new Person("Prahlad", "prahlad@mail.com", 2004) ;
console.log(shekhar);
// Person {firstName: 'Shekhar', email: 'shekhar12@mail.com'}
console.log(shekhar.email) ;
// shekhar12@mail.com
prahlad.introduce() 
// Hi, Myself Prahlad and I am 22 years old 
</code></pre>
<p>we have to keep following things into mind :</p>
<ul>
<li><p>The class is not hoisted even it is wrapper of constructor function.</p>
</li>
<li><p>The code inside class is always executed in strict mode.</p>
</li>
</ul>
<h2>Object.create</h2>
<p>It is very easy methods to do prototype chain and prototypal inheritance. It helps to set the object as the prototype.</p>
<pre><code class="language-javascript">const PersonProto = {
  calcAge() {
    return new Date().getFullYear() - this.birthYear ;
  },
  init(firstName, email, birthYear) {
    this.firstName = firstName ;
    this.email = email ; 
    this.birthYear = birthYear ;
  }
  
}
const sunita = Object.create(PersonProto) ;
sunita.init("Sunita", "sunita@mail.com", 2000) ;
console.log(sunita) ;
// {firstName: 'Sunita', email: 'sunita@mail.com', birthYear: 2000}
</code></pre>
<h2>Inheritance by Constructor function</h2>
<p>We do inheritance in constructor by setting the prototype by using Object.create. This is shown in below code :</p>
<pre><code class="language-javascript">// Inheritance of constructor function 

function  Person(name,age) {
  this.name = name ;
  this.age = age ;
}

Person.prototype.introduce = function(){
  return `Hello, I am \({this.name} of \){this.age} years old` ;
}

function Student (name,age,course) {
  Person.call(this,name,age) ;
  this.cource = course;
}
// set Person prototype to Student prototype
Student.prototype = Object.create(Person.prototype) ;



Student.prototype.enrolled = function () {
  return `\({this.name} is enrolled in \){this.cource}` ;
}
// to set constructor function to Student
Student.prototype.constructor = Student ;

const dipesh = new Student("Dipesh Tharu", 23,"Cohort2026") ;
console.log(dipesh) ;
// Student {name: 'Dipesh Tharu', age: 23, cource: 'Cohort2026'}
console.log(dipesh.enrolled())
// Dipesh Tharu is enrolled in Cohort2026
console.log(dipesh.introduce())
// Hello, I am Dipesh Tharu of 23 years old

// lets see chain 
// dipesh.__proto__ === Student.prototype 
console.log(dipesh.__proto__);
// it is Student prototype
// {enrolled: ƒ}

console.log(dipesh.__proto__.__proto__);
// it is Person prototype
// {introduce: ƒ}
console.log(dipesh.__proto__.__proto__.__proto__);
// It is global Object prototype
// {__defineGetter__: ƒ, __defineSetter__: ƒ, hasOwnProperty: ƒ, __lookupGetter__: ƒ, __lookupSetter__: ƒ, …}
console.log(dipesh.__proto__.__proto__.__proto__.__proto__);
// it is null 
// null
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6950c18c622afddd90b193eb/c178def6-339a-4e0d-aa7f-e431619ca215.png" alt="" style="display:block;margin:0 auto" />

<h2>Inheritance by Es6 class</h2>
<p>It is most easier to implement inheritance by class just by using extends keyword and used super keyword to set prototype of parent class.</p>
<pre><code class="language-javascript">// inheritance in class syntax

class Person {
  constructor(name,age) {
    this.name = name ;
    this.age = age;
  }
  introduce(){
    return `Hey,\({this.name} is of \){this.age} years old` ;
  }
}
class Student extends Person {
  constructor(name,age,course){
    super(name,age) 
    this.course = course ;
  }
  enrolled(){
    return `\({this.name} has enrolled in \){this.course}`
  }
}
const mohan = new Student("Mohan" , 20, "Cohort 2026") ;
console.log(mohan.introduce()) ;
console.log(mohan.enrolled()) ;
</code></pre>
<h2>Summary</h2>
<p>This is the way of doing OOP in JavaScript. Class is easier to use but we must know the inheritance done by using prototypal chain and it is called prototypal inheritance.</p>
]]></content:encoded></item><item><title><![CDATA[Understanding Objects in JavaScript]]></title><description><![CDATA[In programming , We deal with real world entities. So there must be the way of storing the properties and its behaviors together . This facility is provide by the objects data structure.
It is defined]]></description><link>https://blogs.dipeshchaudhary.name.np/object-js</link><guid isPermaLink="true">https://blogs.dipeshchaudhary.name.np/object-js</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[Beginner Developers]]></category><category><![CDATA[Objects]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[Cohort2026]]></category><dc:creator><![CDATA[Dipesh Chaudhary]]></dc:creator><pubDate>Fri, 06 Mar 2026 07:58:01 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6950c18c622afddd90b193eb/992f8d5f-db3c-46c1-a05c-1a9c656eef00.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In programming , We deal with real world entities. So there must be the way of storing the properties and its behaviors together . This facility is provide by the objects data structure.</p>
<p>It is defined as the collection of data by name- value pairs. It stores data in key-value pairs. The functionality is called the methods in objects.</p>
<h2>Ways of creating Objects</h2>
<p>There are various ways of creating objects in JavaScript. The mot used is Object literal . The ways are shown below .</p>
<pre><code class="language-javascript">// ways of creating objects 
// 1. Object Literal {}
cost car = {
    brand : "Toyota",
    model : "Corolla"
}

// 2.new Object()
const carObj = new Object();
carObj.brand = "Toyota";
carObj.model = "Corolla";

//3.constructor function 
function Car (brand, model) {
    this.brand = brnd;
    this.model = model;
}
const myCar = new Car("Toyota", "Corolla") ;

// 4.Es6+ class
class MyCar {
    constructor(brand,model){
        this.brand = brand ;
        this.model = model ;
    }
    
}
const anotherCar = MyCar("Tata", "Nexon")
</code></pre>
<h2>Accessing Property</h2>
<p>There are two ways to access property in object . by dot notation and square bracket . so What is difference between them know by following examples :</p>
<pre><code class="language-javascript">// Accessing property 

const hero = {
  name: "Luna the Brave",
  class: "Mage",
  level: 12,
  health: 85,
  mana: 120,
  isAlive: true,
};
// get any property 
console.log(hero.name) ;
console.log(hero.level) ;

// suppose you want to add property which has some space, symbol 
// then we used bracket notation
hero["game-win"] = true ;
console.log(hero["game-win"]) ;
</code></pre>
<h2>Adding and Deleting Property</h2>
<p>It is easy to add property just by giving name and assign value and if any property need to delete do by using delete keyword.</p>
<pre><code class="language-javascript">hero.weapon = "fire";
console.log(hero.weapon) ;

// delete the property with delete keyword
delete hero.class
</code></pre>
<h2>Checking property present in object</h2>
<p>There are various ways to check the property is present or not in object .</p>
<pre><code class="language-javascript">// checking property is present or not 

console.log(hero.mana !==undefined) // true means it is present 
// if you access any property if not present it gives undefined
console.log(hero.power) // undefined

// There is good way to check by using in 
console.log("power" in hero) // false
// one thing to keep in mind it also check in  prototype like
console.log("toString" in hero) // true

// The best way to check only own property is hasOwnProperty
console.log(hero.hasOwnProperty("toString")) //false
</code></pre>
<h2>Methods in Objects</h2>
<p>Like Objects has methods in JavaScript. If anything has methods that are object in nature . So In JavaScript It is called everything is object under the hood .</p>
<p>There are Object.keys, Object.values and Object.entries . These are methods . It used for getting keys, values or entries of objects like</p>
<pre><code class="language-javascript">// methods in objects

const artifact = {
  name: "Obsidian Crown",
  era: "Ancient",
  value: 50000,
  material: "volcanic glass",
};
// What are the data type comes in using these methods 
const keys = Object.keys(artifact)
console.log(keys)
// ['name', 'era', 'value', 'material']
// all keys in arrays 
console.log(Array.isArray(keys)) // true


const values = Object.values(artifact) ;
console.log(values) ;
//  ['Obsidian Crown', 'Ancient', 50000, 'volcanic glass']
// arrays of values

// getting entries
const entries = Object.entries(artifact) ;
console.log(entries) ;
//  [Array(2), Array(2), Array(2), Array(2)]
// nested array with [[key1,value1], [key2,value2]]
</code></pre>
<h2>Looping Through objects</h2>
<p>We know Object is non iterable. It means we cannot directly use for of loop in objects . so we have to take help of these methods like Object.entries to get array and then loop through it .</p>
<pre><code class="language-javascript">// loop through it 
for(let [key,value] of Object.entries(artifact)){
    console.log(`\({key} : \){value}`)
}
// name : Obsidian Crown
// era : Ancient
// value : 50000
// material : volcanic glass
// there is one loop we can used in object which is 

// for in loop
for(let key in artifact){
console.log(key)
console.log(artifact[key])
}
</code></pre>
<p>Suppose we need to convert nested array into object then we have methods that is <strong>Object.fromEntries()</strong> . It converts the output of entries back to object.</p>
<pre><code class="language-javascript">// there is array of nested array 
const priceList = [
  ["Obsidian Crown", 50000],
  ["Ruby Pendant", 30000],
  ["Iron Shield", 5000],
];
const priceObj = Object.fromEntries(priceList) ;
console.log(priceObj) ;
// {Obsidian Crown: 50000, Ruby Pendant: 30000, Iron Shield: 5000}
</code></pre>
<h2>Object.freeze and Object.seal</h2>
<p>We know object are created and stored as reference in JavaScript . so It is mutable . We can add, delete and update the property of objects so We can Control it . We can freeze the entire object so It cannot get update, delete and add any new property in it .</p>
<p>The main difference between them is After the Object.freeze The Object becomes immutable means we can not change, add, delete the property but after Object.seal We can only change the existing property . The delete and addition is not allowed .</p>
<pre><code class="language-javascript">// concept of Object.freeze and Object.seal
const displayCase = {
  artifact: "Obsidian",
  location: "Hall A, Case 3",
  locked: true,
};

// displayCase.locked = false
// console.log(displayCase) ;
// it get changed so 
Object.freeze(displayCase) ;
displayCase.locked = false
console.log(displayCase) ;
// no change now
displayCase.version = "1.2.3" ;
console.log(displayCase)
// means after Object.freeze we cannot mutate the objects

// Object.seal 
// it is the method which enable us to change only the existing property 


const catalogEntry = {
  id: "ART-001",
  description: "Ancient Crows",
  verified: true,
};

Object.seal(catalogEntry);
catalogEntry.verified = false ;
console.log(catalogEntry)
// it only change the existing property
catalogEntry.price = 200;
console.log(catalogEntry) ;
// no new property add

delete catalogEntry.id
console.log(catalogEntry)
// no delete property
</code></pre>
<h2>Configuring the property</h2>
<p>Sometimes we need to configure the property in object so that they can be loopable, writable or can delete .</p>
<pre><code class="language-javascript">// configuring the property 
const secureArtificats = { name: "Ruby Pendant" };
Object.defineProperty(secureArtificats, "catalogId" , {
    value:"SEC-999",
    writable:true,
    enumerable:false,
    configurable:true ,
})
console.log(secureArtificats) ;
// {name: 'Ruby Pendant', catalogId: 'SEC-999'}
</code></pre>
<ul>
<li><p>writable : It means the value of property can be change. if true then we can change the value otherwise not.</p>
</li>
<li><p>enumerable : it is for looping by using for of loop</p>
</li>
<li><p>configurable : If it is true then we can delete property and also redefine the attributes of like writable, enumerable if it is true .</p>
</li>
</ul>
<pre><code class="language-javascript">// configuring the property 
const secureArtificats = { name: "Ruby Pendant" };
Object.defineProperty(secureArtificats, "catelogId" , {
    value:"SEC-999",
    writable:false,
    enumerable:false,
    configurable:false ,
})
// console.log(secureArtificats) ;
// {name: 'Ruby Pendant', catalogId: 'SEC-999'}
console.log(secureArtificats.catelogId);
secureArtificats.catelogId = "HACKED";
console.log(secureArtificats.catelogId);

for (const [key, value] of Object.entries(secureArtificats)) {
    // only print the property which is emunerable
  console.log(`\({key} : \){value}`);
}

// SEC-999
// SEC-999
// name : Ruby Pendant

// to check property is dexcription 
// we have getOwnPropertyDescriptor
console.log(Object.getOwnPropertyDescriptor(secureArtificats, "name"))
// {value: 'Ruby Pendant', writable: true, enumerable: true, configurable: true
</code></pre>
<h2>Difference between object and array</h2>
<p>The main difference is the way of storing data . In objects we store in key value pair. but in array we just give name . In array there we get indexing starting from 0 . we have length property but i n object there is no such property and all keys are either string or Symbol.</p>
<p>There is one thing when we give numbers as key in object then JavaScript sorted it in run time.</p>
<pre><code class="language-javascript">const obj = {
    5:"chocolate",
    20:"noodles",
    10:"Chips",
    2:"Nothing"
    
}
console.log(obj)
//{2: 'Nothing', 5: 'chocolate', 10: 'Chips', 20: 'noodles'}
</code></pre>
<h2>Summary</h2>
<p>This is all about object in JavaScript. It store data in name value pair. It is very easy to create and used in our program .</p>
]]></content:encoded></item><item><title><![CDATA[Conditional Flow In JavaScript]]></title><description><![CDATA[In JavaScript the code runs line by line. but in certain condition we have to make decision into our program to run certain portion of code. Then There comes the use of conditionals which helps us to ]]></description><link>https://blogs.dipeshchaudhary.name.np/conditionals-js</link><guid isPermaLink="true">https://blogs.dipeshchaudhary.name.np/conditionals-js</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[Cohort2026]]></category><category><![CDATA[Beginner Developers]]></category><category><![CDATA[Conditional statement]]></category><category><![CDATA[if-else]]></category><dc:creator><![CDATA[Dipesh Chaudhary]]></dc:creator><pubDate>Wed, 04 Mar 2026 05:46:55 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6950c18c622afddd90b193eb/a5306026-edbf-4c8e-b345-6cd151a88c1c.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In JavaScript the code runs line by line. but in certain condition we have to make decision into our program to run certain portion of code. Then There comes the use of conditionals which helps us to choose between one or multiple conditions. In this way, we can control the flow of our program so it is called control flow.</p>
<p>In JavaScript , There is If , else if and else and switch statement used for making decision and control the clow of program .</p>
<h2>Statement Vs Expression</h2>
<p>statement is the block of code that we do not store in variable. It is individually block and It do not return value. It may contain expressions. for examples like <code>if-else, for loop</code> etc.</p>
<p>expressions means the unit of code that resolved to result . <code>like 2+3, name + " " + location</code></p>
<h2>If , Else If , Else</h2>
<img src="https://cdn.hashnode.com/uploads/covers/6950c18c622afddd90b193eb/dd5d94dc-a82c-40f6-9f11-c4cff6640898.png" alt="Flowchart of if else statement " style="display:block;margin:0 auto" />

<p>This is classical syntax which is used for conditional in programming that is also in JavaScript. When the result of expression is true then if block execute and other than that else block execute .</p>
<p>if true then if block run and if we want to check more condition then else if run otherwise else run .</p>
<pre><code class="language-javascript">// if

let num = 7
if (num ===7){
    console.log("7 for a reson")
}
console.log("here is end") ;

// if-else 
// check positive and negative

num = -3; 
if(num &gt; 0) {
    console.log("Number is positive") ;
} else {
    console.log("Number is negative") ;
}


// to check zero consitiin also 
// else if used 
num =0 ;
if(num &gt; 0) {
    console.log("Number is positive") ;
}else if(num &lt; 0) {
    console.log("Number is negative") ;
}else {
    console.log("Number is exactly zero") ;
}
</code></pre>
<h2>If else and Switch Case</h2>
<p>Both are used for conditional branching but they have different use cases and performance characteristics.</p>
<p>if-else :</p>
<p>it executes the code blocks on the basis of boolean conditionals. They are versatile and can handle complex conditions with operators .</p>
<pre><code class="language-javascript">let score = 78 ; 
// score is sequentially check \
if(score &gt;=90) {
    console.log("Grade A") ;
}else if (score &gt;=80) {
    console.log("Grade B") ;
}else if(score &gt;=70) {
    console.log("Grade C") ;
}else if(score &gt;=60) {
    console.log("Grade D")
}else {
    console.log("Fail")
}
    
</code></pre>
<p>Advantages :</p>
<ul>
<li><p>It is versatile and can be used to handle complex logic conditions including operators.</p>
</li>
<li><p>It is easier to use with simple and small set of conditions.</p>
</li>
</ul>
<p>Disadvantages :</p>
<ul>
<li><p>It can be slower for large conditionals as it execute sequentially.</p>
</li>
<li><p>It will be hard to read and maintain for nested conditions.</p>
</li>
</ul>
<p>Switch Case :</p>
<p>It is used to execute the blocks of code for multiple options based on the value for single expressions. like</p>
<pre><code class="language-javascript">let days = 6;
switch(days) {
    case 1 :
        console.log("Sunday") ;
        break;
    case 2 :
      console.log("Monday") ;
      break;  
    case 3 :
        console.log("Tuesday") ;
        brak ;
    case 4:
        console.log("Wednesday") ;
        break;
    case 5 :
        console.log("Thursday") ;
        break;
    case 6 :
        console.log("Friday") ;
        break;
    case 7 :
        console.log("Saturday") ;
        break;
    default :
        console.log("Invalid day") ;
        
}

///////////////////////////////////////////////////
let day ="friday"
switch (day) {
        // can handle multiple case if you want to execute same code 
        // for multiple cases
        // if you do not break 
        // if faLL to the next case until found break
        
    case "saturday":
    case "sunday" :
        console.log("Cohort class");
        console.log("Weekend") ;
        console.log("Learning and Coding Day") ;
        break;

    case "monday":
    case "tuesday":
     console.log("Assignment day") ;
        break;
    case "wednesday" :
        console.log("Blog Day") ;
        break;
    case "thursday":
        console.log("T-Class Day") ;
        console.log("Bonus session and How to use brain to remember anything") ;
        console.log("By Akash Sir @yntp") ;
        break;
    case "friday" :
        console.log("Peer Class Day") ;
        break;

    default :
        console.log("Enjoy day");
  
}
</code></pre>
<p>Advantages:</p>
<ul>
<li><p>It is fast for larger conditions as it use jump table.</p>
</li>
<li><p>It is easier to read and maintain multiple conditions.</p>
</li>
</ul>
<p>Disadvantages :</p>
<ul>
<li><p>It can only used for equality. It does not used for complex logical expressions.</p>
</li>
<li><p>We have to use break statement carefully to prevent unintended fall-through.</p>
</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6950c18c622afddd90b193eb/bc946f59-a3dc-4f55-8169-738fdabc1fd9.png" alt="" style="display:block;margin:0 auto" />

<h2>When to use which :</h2>
<p>It is simple. If you need to handle complex logic building which includes large number of logical expressions then you can go with if else .</p>
<p>but if you need to choose one among the multiple options and it is to check equality then this is proper place to use switch case.</p>
<p>Most of time 99 .5% of time we go through if else if statement.</p>
<h2>Truthy and Falsy Values</h2>
<p>In JavaScript there is concept of truthy and falsy because we can give any thing as value in conditional . Truthy means the boolean value comes true on conversion of values . same for falsy it gives false . The falsy values are :</p>
<ul>
<li><p>false</p>
</li>
<li><p>0 , -0, 0n</p>
</li>
<li><p>"", '', ``</p>
</li>
<li><p>null</p>
</li>
<li><p>undefined</p>
</li>
<li><p>NaN</p>
</li>
<li><p>document.all</p>
</li>
</ul>
<p>These are falsy values which return false on conditionals . Besides these all are truthy in JavaScript like <code>[], {}, "0", true etc.</code></p>
<h2>Summary</h2>
<p>This is all about conditional control flow in JavaScript. It is used to handle logical expressions and used to execute code on the basics of decisions in programming, It is used to build complex logic and easy to handle block of code on the basis of our logic.</p>
]]></content:encoded></item><item><title><![CDATA[Handling Date and Time in JavaScript]]></title><description><![CDATA[Handling date and time in JavaScript is notoriously tricky because of several design quirks and real-world complexities. Lets learn about the Date object from its construction, ways of formatting and ]]></description><link>https://blogs.dipeshchaudhary.name.np/date-time-js</link><guid isPermaLink="true">https://blogs.dipeshchaudhary.name.np/date-time-js</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[coding]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[datetime]]></category><category><![CDATA[Beginner Developers]]></category><dc:creator><![CDATA[Dipesh Chaudhary]]></dc:creator><pubDate>Tue, 03 Mar 2026 07:52:22 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6950c18c622afddd90b193eb/a6e542c2-9a4e-4101-bd3f-0d47bd87e588.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Handling date and time in JavaScript is notoriously tricky because of several design quirks and real-world complexities. Lets learn about the Date object from its construction, ways of formatting and calculations days , problems and its solution in this blog .</p>
<h2>Ways of creating date in JavaScript</h2>
<p>There are 4 ways of creating date.</p>
<ol>
<li><p>simple using new Date() . It gives current date and time based on your system timezone.</p>
</li>
<li><p>using string like new Date("Mar3, 2026")</p>
</li>
<li><p>using numbers arguments like new Date(2026, 2,3,10,20)</p>
</li>
<li><p>using timestamps new Date(Date.now())</p>
</li>
</ol>
<pre><code class="language-javascript">// 4 ways of creating date 

const now = new Date() ;
 console.log(now) ;  // Tue Mar 03 2026 11:03:05 GMT+0545 (Nepal Time)

// by string format 
 console.log(new Date("Mar 03, 2026")) ;
 console.log(new Date("2026-3-3")) ;
 console.log(new Date("feb 28, 2026")) ; // Sat Feb 28 2026 00:00:00 GMT+0545 (Nepal Time)
 console.log(new Date("feb 30, 2026")) ;  
// JS does auto correct the date 2 days in march
 // Mon Mar 02 2026 00:00:00 GMT+0545 (Nepal Time)
// console.log(new Date("3/3/2026")) ; // avoid using may behave differently in different browsers

// 3.by numbers arguments

console.log(new Date(0)) 
// this gives from where JS start to calculate timestamp 
// Thu Jan 01 1970 05:30:00 GMT+0530 (Nepal Time) 
// any invalid arguments give same data Jan 01, 1970

console.log(new Date(2026, 10, 29, 1, 10)) 
// year , month, day, hours, minutes, seconds
// month is 0 based 

// 4. by timestamps
// to get current timestamps calculate from Jan 01 , 1970
console.log(Date.now()) // 1772515848019
console.log(new Date(1772515848019))
</code></pre>
<h2>Date Objects</h2>
<p>There are many methods to get year, month, day, hours, minutes , seconds and many date related info .</p>
<pre><code class="language-javascript">// methods in Date

const now = new Date() ;
// gives current date and time 

// to get year use getFullYear
console.log(now.getFullYear()) // 2026
console.log(now.getMonth())  // 0 based 0 = Jan 
console.log(now.getDate())  // day of months
console.log(now.getDay())  // day of weeks 0 = sun
console.log(now.getHours())  // get hours
console.log(now.getMinutes())  // get minutes
console.log(now.getSeconds())  // get seconds
console.log(now.getTime())   // give timestamps
console.log(Date.now()) // fast way to get current timeStamps
</code></pre>
<h2>Different Date Formatting Style</h2>
<p>There are so many ways to show date format .</p>
<pre><code class="language-javascript">// formatting date
console.log(now) ; 
console.log(now.toString()) ;  
// it is defult way of showing date
// same as new Date()
// it gives long string with date and time 
// not ideal for UI 

console.log(now.toDateString()) ; 
// it gives only date
// Tue Mar 03 2026
// weekday month day year

console.log(now.toTimeString()) ; 
// it gives time  with time zone
// 12:11:58 GMT+0545 (Nepal Time)

console.log(now.toLocaleString());
// it is most useful 
// it gives date and time based on your locale like "en-us"
// 3/3/2026, 12:14:05 PM

console.log(now.toLocaleDateString());
// locale date 
// 3/3/2026

// similarlt to get locale time
console.log(now.toLocaleTimeString());
// 12:16:22 PM

console.log(now.toISOString())
// 2026-03-03T06:31:57.682Z

console.log(now.toUTCString())
// Tue, 03 Mar 2026 06:33:02 GMT

// custom ways of showing date

const month = String(now.getMonth()).padStart(2, "0");
const day = String(now.getDate()).padStart(2,"0") ;
const year = now.getFullYear()
// dd-mm-yyy
const formatted = `\({day}/\){month}/${year}`;
console.log(formatted) // 03/02/2026

// custom date 
console.log(now.toLocaleDateString()) 
// depends upon on your locale it gives date
// 3/3/2026

// now format it 
const formatDate = now.toLocaleDateString("en-US", {
    year:"numeric",
    month:"short",
    day:"2-digit"
})
console.log(formatDate)
// March 3, 2026
// month : "short" || "long" || "narrow"
// year, day : "numeric" , "2-digit"

// Date and Time Together 
console.log(now.toLocaleString())
// 3/3/2026, 12:32:48 PM

const formatDateAndTime = now.toLocaleString("en-US", {
    year:"numeric",
    month:"long",
    day:"2-digit",
    hour:"2-digit",
    minute:"2-digit",
    second:"2-digit"
})

console.log(formatDateAndTime)
// March 03, 2026 at 12:35 PM

// in YYYY-MM-DD API friendly 
console.log(now.toISOString())
// 2026-03-03T06:52:33.070Z
// now split on basis of T
console.log(now.toISOString().split("T")[0]) // 2026-03-03

// Time format 
const formatTime = now.toLocaleTimeString("en-US", {
    hour:"2-digit",
    minute:"2-digit",
    hour12 : false
})
console.log(formatTime)
// 12:40

// Locale is in format lie language-country
console.log(navigator.language) // to check locale on your system
// every locale has different style

console.log(now.toLocaleDateString("en-US")) // 3/3/2026
console.log(now.toLocaleDateString("en-GB")) // 03/03/2026
console.log(now.toLocaleDateString("de-DE")) // 3.3.2026

//Locale tells JavaScript how people in a specific country display dates, numbers, and text.

// JavaScript Date internally stores time in UTC.
// it is standard global time doesnot depend on yor country timezone
// your system clock offset

// MongoDB stores time in toISOString format 
// it ends with Z
</code></pre>
<h2>Operation with Date</h2>
<p>we can add and subtract date . The Date converts into timestamps when you convert date into numbers so It can be add and subtract.</p>
<pre><code class="language-javascript">// operations in date
const date1 = new Date();
const date2 = new Date("2026-03-04")
const diff = date2 - date1
console.log(diff) 
console.log(Math.round(diff/(1000 * 60*60*24))) // 1
console.log(date2 &gt; date1) // true
console.log(date2 &lt; date1) // false
// 60609462 
// it is in milliseconds
// convert into days by dividing with (1000 * 60*60*24)
</code></pre>
<h2>Problems with Date handling in JavaScript</h2>
<p><code>Date</code> combines date, time , timezone, timestamp all in one object when you call new Date().</p>
<ul>
<li><p>TimeZoe confusion</p>
</li>
<li><p>Month are 0 indexed</p>
</li>
<li><p>It is mutable when date is add or subtract it nutates original date variable.</p>
</li>
<li><p>Inconsistent in string parsing like new Date("03/04/2026") . what is this march 4 or April 3 ? Different browsers interpret this differently . only ISO format is safe .</p>
</li>
<li><p>DST (Daylight Saving Time) problems</p>
</li>
</ul>
<h2>Solutions</h2>
<p>There are many packages to help us to deal with date and time if projects use complex date then some are</p>
<ul>
<li><p>date-fns</p>
</li>
<li><p>dayjs</p>
</li>
<li><p>moment</p>
</li>
<li><p>for future date handling in JS Temporal objects used instead of date.</p>
</li>
</ul>
<h2>Conclusion</h2>
<p>This is all about date and time in JavaScript. Developer need to go through a lot of works to handle through by date object in JavaScript. so we need to either handle manually or used third party npm packages .</p>
<p>Thanks for reading this article. I hope It will help you to understand Date object in JavaScript.</p>
]]></content:encoded></item><item><title><![CDATA[Understanding Variables and Data Types in JavaScript]]></title><description><![CDATA[There are a lot of saying that variable is container and box to store different type of value in memory . It is just label to the value so whenever It needed we can directly used by variable name and ]]></description><link>https://blogs.dipeshchaudhary.name.np/js-variable</link><guid isPermaLink="true">https://blogs.dipeshchaudhary.name.np/js-variable</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Programming Blogs]]></category><category><![CDATA[coding]]></category><category><![CDATA[variables]]></category><category><![CDATA[Beginner Developers]]></category><dc:creator><![CDATA[Dipesh Chaudhary]]></dc:creator><pubDate>Mon, 02 Mar 2026 16:50:25 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6950c18c622afddd90b193eb/8ab6fc89-8087-404f-b18e-fcf896dc4c0e.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>There are a lot of saying that variable is container and box to store different type of value in memory . It is just label to the value so whenever It needed we can directly used by variable name and the value is placed in place of variable name. let say in glass we can drink water, milk , juice any liquid type data so glass is variable . same way In programming, It is used to hold value.</p>
<p>In this article , we discussed about variable and data type in JavaScript.</p>
<h2>What is Variable and why it is needed ?</h2>
<p>It is the name given to the value which is stored in the memory and It is used to access and manipulate the value by variable throughout the program. It is holding the information which can access or change during execution of program.</p>
<p>It is used because of following reasons :It provide name to the value that gonna be stored in memory so It can easily accessed and manipulated during the execution of program</p>
<p><strong>Characteristics of Variables :</strong></p>
<ol>
<li><p><strong>Named Storage :</strong> It is name which is also called identifier that is given to the memory location where data can be stored. <code>let x = 5 ;</code></p>
</li>
<li><p><strong>Dynamic Values :</strong> The value of variable can change during execution of program . <code>x = x+10;</code></p>
</li>
<li><p><strong>Data types :</strong> It can hold different types of data like number, string, boolean etc.</p>
</li>
<li><p><strong>Scope :</strong> The variable has scope . It means where the variable are accessible in the program. If it is bloc scope then it is not accessible outside of that block . global scope variable is accessible overall the program . It depends upon use case in which scope you want to define the variable.</p>
</li>
</ol>
<pre><code class="language-javascript">
// declaring and initializing the variable 
var yourName = "Lollipop" ;
var price ; // declaring
price = 5 ; // initializing

// used in expressions
const info = "Hi I am " + yourName + " and my price is Rs." + price ;
console.log(info) ; // Hi I am Lollipop and my price is Rs.5

// updating the values
price = 10 ;
console.log("Price : ", price) ;  // Price :  10

// const variable cannot change
const gender = male ;
gender = female ; // Error : Assignment to const variable
</code></pre>
<h2>Naming convention for variable</h2>
<p>There are certain rules for declaring the name of variable in JavaScript . They are :</p>
<ol>
<li><p>It only starts with letters or $ or _ .</p>
</li>
<li><p>It doesnot start with numbers like <code>let 1num = 10 ;</code></p>
</li>
<li><p>No reserved words are allowed to used as variable . There are some reserved words of language like let , const , function , for, some, every , this, while, do, if, else, class, extends, and many which is keywords which is used in programming in JavaScript.</p>
</li>
<li><p>There is convention to write the variable name in camelCase and it must be descriptive and meaningful because It is name and name must be descriptive which is very useful to understand about the code what it is used for .</p>
</li>
<li><p>No space is allowed and others special characters in the name of variable .</p>
</li>
</ol>
<h2>Way of declaring variables</h2>
<p>There are 3 ways of declaring variables in JavaScript . by using var, let and const . But In Today modern JavaScript we used let and const only .</p>
<p>var is traditional way before es6 . It has few issues .</p>
<ol>
<li><p>It is function scoped .</p>
</li>
<li><p>It creates variable in global window object .</p>
</li>
<li><p>It get hoisted means we can access it before declare in code .</p>
</li>
</ol>
<p>but let and const are introduced in es6 and it is block scoped and solve the problems which is in var .</p>
<p>let is same as var by varying nature . It value can be changed during the program but const is constant . it value cannot be changed throughout the program and we need to initialize in one line . like <code>const myName = "Dipesh" ;</code></p>
<h2>Primitive Data Type in JavaScript</h2>
<p>Primitive means It is single value and stored and copied by value . There are 7 different primitive types . They are</p>
<pre><code class="language-javascript">// primitive data types

// 1. number
let a = 10 ; 
let total = 200.78 ;
let balance = 25_00_000 ;
let age = 23 ; 

// 2. string
let userName = "Dipesh Chaudhary" ;
let getIn = "Chaicode Cohort 2026" ;
 
// 3. Boolean
let isCohortStd = true ;
let isRude = false ;

// 4. null
let gf = null ;

// 5.undefined 
let job ;

// 6. bigint
let aura = 999999999999999999n; // we can say Infinity

// 7. Symbol
const nationalId = Symbol("Dipesh") ;
</code></pre>
<h2>Simple Scoping Understanding</h2>
<p>Scope is the place where we can access the value of variable.</p>
<p>There are Block and Global scope in JavaScript.</p>
<pre><code class="language-javascript">// scoping discussion

console.log(userName) ; // global scope
// not inside any function means global 

function goToGym(gymName) {
    console.log("Gym name is ", gymName)
}
goToGym("BodyBuilder")
// console.log(gymName); // gymName is not accessible
// ReferenceError: gymName is not defined

// we can give block scope by curly braces
{
    let myCount = 98 ; 
    const myBirthPlace = "Lahan" ;
    const myMotherTongue = "Tharu , Maithili " ;
}
// console.log(myCount) ; 
// if variable name is not found suppose inside function , or any block like if 
// then it look up outside of it which is also called variable lookup 
// it is called scope chain 
    
</code></pre>
<h3>Comparison Table</h3>
<table style="min-width:100px"><colgroup><col style="min-width:25px"></col><col style="min-width:25px"></col><col style="min-width:25px"></col><col style="min-width:25px"></col></colgroup><tbody><tr><td><p><strong>Feature</strong></p></td><td><p><strong>var</strong></p></td><td><p><strong>let</strong></p></td><td><p><strong>const</strong></p></td></tr><tr><td><p><strong>Scope</strong></p></td><td><p>Functional Scope</p></td><td><p>Block Scope <code>{ }</code></p></td><td><p>Block Scope <code>{ }</code></p></td></tr><tr><td><p><strong>Redeclaring</strong></p></td><td><p>Allowed</p></td><td><p>Not Allowed</p></td><td><p>Not Allowed</p></td></tr><tr><td><p><strong>Reassigning</strong></p></td><td><p>Allowed</p></td><td><p>Allowed</p></td><td><p><strong>Not Allowed</strong></p></td></tr><tr><td><p><strong>Hoisting</strong></p></td><td><p>Hoisted (initialized as <code>undefined</code>)</p></td><td><p>Hoisted (but uninitialized)</p></td><td><p>Hoisted (but uninitialized)</p></td></tr><tr><td><p><strong>Temporal Dead Zone</strong></p></td><td><p>No</p></td><td><p>Yes</p></td><td><p>Yes</p></td></tr></tbody></table>

<p>Temporal Dead Zone (TDZ) is the area before declaration and initialization of let and const variable where we cannot access the value before assign the value.</p>
<h2>Scoping Diagram</h2>
<img src="https://cdn.hashnode.com/uploads/covers/6950c18c622afddd90b193eb/d8990c29-d9a5-4a85-bfa2-2d0449f675e2.png" alt="" style="display:block;margin:0 auto" />

<h2>Conclusion</h2>
<p>The variable is container like a box which holds the reference of memory location where value is stored. I hope It is worth for reading and understanding the variable and scoping of variable.</p>
]]></content:encoded></item><item><title><![CDATA[Mastering Arrays: Everything You Need to Know to Get Started]]></title><description><![CDATA[In programming we need variable to store data . so we can access easily in another place just by variable name. suppose when you need to store five friend name then you have to create five separate va]]></description><link>https://blogs.dipeshchaudhary.name.np/array-js-101</link><guid isPermaLink="true">https://blogs.dipeshchaudhary.name.np/array-js-101</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[array]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Cohort2026]]></category><category><![CDATA[array101]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[coding]]></category><category><![CDATA[Beginner Developers]]></category><dc:creator><![CDATA[Dipesh Chaudhary]]></dc:creator><pubDate>Mon, 02 Mar 2026 08:07:10 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6950c18c622afddd90b193eb/84448c27-ccef-4010-b2e1-28dc23e37a29.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In programming we need variable to store data . so we can access easily in another place just by variable name. suppose when you need to store five friend name then you have to create five separate variable . This is unnecessary because all belongs to same, your friend group .</p>
<p>To solve this problem , we used array . It is just storing values which are same in nature in one variable name. It has many benefits .</p>
<ol>
<li><p>It provides collection in one variable name.</p>
</li>
<li><p>The items are easily accessible and update by using index.</p>
</li>
<li><p>Fast retrieval of data from memory .</p>
</li>
<li><p>There are a lot of methods to work with data.</p>
</li>
<li><p>Array stored data on order manner. so for ordered collection array is used</p>
</li>
</ol>
<p>In JavaScript both array and object are of object type. The main difference is array stored data in ordered way so whenever ordered matter we use array.</p>
<pre><code class="language-javascript">// suppose i need to make super hero array 
const superman = "Superman" ;
const ironMan = "Ironman" ;
const thor = "Thor" ;
const hulk = "HULK" ;
// this should be one collection 
// when someone say 10 heroes , we have to make 10 variables 
// so what is best array is best to store these type of data 

const superHeroes = [superman, ironMan, thor, hulk];
console.log(superHeroes) ; // ['Superman', 'Ironman', 'Thor', 'HULK']
</code></pre>
<h2>Ways of creating array</h2>
<p>There are many ways of creating arrays in JavaScript .</p>
<p>first is Array Constructor and second is Array literal which is just [].</p>
<pre><code class="language-javascript">// ways of creating arrays
// 1. Array constructor

const friends = new Array("Sudip", "Akash", "Rakesh");
console.log(friends)

// by just Array
const fruits = Array("Mango", "Grapes", "Watermelon", "Litchi") ;
console.log(fruits)
// when one items add
const numbers = new Array(7)
console.log(numbers) // it create empty slot   [empty × 7]

// 2. Array literal
const ourSirs = ["Hitesh", "Piyush", "Anirudh", "Akash"] ;
console.log(ourSirs) // ['Hitesh', 'Piyush', 'Anirudh', 'Akash']
</code></pre>
<h2>Accessing and Updating Elements</h2>
<p>Elements is members of array. It is ordered so It is 0 indexed. we can access by using index which is assign to each elements of array.</p>
<pre><code class="language-javascript">// Accesssing elements in array
const colors = ["red", "pink", "orange", "blue"] ; 
// accessing first 
colors[0] // red
// accessing last 
colors[3] // blue
// every array has length property so we can used to find length 
console.log(colors.length) // 4
colors[colors.length - 1] // last element accessing
</code></pre>
<p>for updating also same just access and update with new item .</p>
<pre><code class="language-javascript">// updating items in array
// change blue to green
colors[3] = "green"
console.log(colors) // (4) ['red', 'pink', 'orange', 'green']
</code></pre>
<h2>Looping in Array</h2>
<p>We need array to store group of data so that we can perform some operations on overall data easily . This is easily done by looping in array elements .</p>
<p>There are many looping methods available in JavaScript. They are :</p>
<pre><code class="language-javascript">// Looping in arrays 

// baiscs for loop 
for(let i = 0; i&lt;colors.length; i++){
   const upper = colors[i].toUpperCase() ;
    // console.log(upper) ;   // RED PINK ORANGE GREEN
}
// for of loop 
// it is same as for loop but it doesnot need counter variable like for loop
for(let color of colors){
    console.log(color) ;
}

// forEach 
colors.forEach(function (color){
    console.log(color) ;
})
</code></pre>
<h3>How Array stored in JavaScript</h3>
<p>We know that creating and storing of array is by reference in JavaScript. There are two memory callstack and heap memory . All primitives data are stored in callstack and Object type stored in hep memory . It is because Object are growing in nature. They can grow and shrink dynamically so It is stored in Heap memory and the variable are stored in callstack and it is pointing to the reference in heap memory .</p>
<img src="https://cdn.hashnode.com/uploads/covers/6950c18c622afddd90b193eb/c0421c1d-5054-4b4e-83be-39844c47496a.png" alt="" style="display:block;margin:0 auto" />

<p>when we give like about[5] = "Developer" it create empty slot in 4 index . The undefined is value in JavaScript which is default value of JavaScript if variable is not assign any value .</p>
<h2>Summary</h2>
<p>This is all about array and It is very much used and basics data structure in JavaScript . It is dynamic in nature. We can store different type of data in arrays and there is no issue. we can access many built in methods which make easy to work with array . The typeof array is object and when you create and store it in variable it is just reference stored in variable . so when we copy the reference only copy which point to same array or objects in JavaScript . so It is not actual copy of array.</p>
]]></content:encoded></item><item><title><![CDATA[JavaScript Operators: The Basics You Need to Know]]></title><description><![CDATA[In programming , we need to do some operation with data, calculation and store the result. example : for mathematical calculation we use arithmetic operators like +, -, *, /, %. It is used for logic b]]></description><link>https://blogs.dipeshchaudhary.name.np/understanding-javascript-operators</link><guid isPermaLink="true">https://blogs.dipeshchaudhary.name.np/understanding-javascript-operators</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Operators]]></category><category><![CDATA[Cohort2026]]></category><dc:creator><![CDATA[Dipesh Chaudhary]]></dc:creator><pubDate>Sun, 01 Mar 2026 21:02:40 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6950c18c622afddd90b193eb/8fdc46a7-67c5-4d3b-aa36-9dddf9b3b0b6.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In programming , we need to do some operation with data, calculation and store the result. example : for mathematical calculation we use arithmetic operators like +, -, *, /, %. It is used for logic building and calculation. In JavaScript, The operators is just function that takes parameters which called operand, there are types of operators like Binary, Unary or Tertiary.</p>
<p>Every operators return different type of data.</p>
<ol>
<li><p>Arithmetic operator : It is just mathematic operator. It is used for basics math operations like addition, subtraction, multiplication, division and remainder.</p>
</li>
<li><p>Comparison operator : It is used for comparing data. It is used for making decision and it return Boolean. like &gt; , &lt; , &gt;=, &lt;=,!==</p>
</li>
<li><p>Assignment operator : It is used for assigning data like =, +=, -=, *=,++, --</p>
</li>
<li><p>Logical Operator : This is used for combining logics in conditionals using || , &amp;&amp;, !</p>
</li>
</ol>
<h2>Truth Table</h2>
<img src="https://cdn.hashnode.com/uploads/covers/6950c18c622afddd90b193eb/6759fe9f-2fb0-46ab-8a90-3c49e71b955a.png" alt="" style="display:block;margin:0 auto" />

<img src="https://cdn.hashnode.com/uploads/covers/6950c18c622afddd90b193eb/3425e482-addd-41cd-8b87-ed8b59ce2b7c.png" alt="" style="display:block;margin:0 auto" />

<img src="https://cdn.hashnode.com/uploads/covers/6950c18c622afddd90b193eb/f476ad31-64ba-49ea-baab-b4c47f684791.png" alt="" style="display:block;margin:0 auto" />

<h2>Examples for all operators</h2>
<h3>Arithmetic operators</h3>
<pre><code class="language-javascript">// addition
let a =2, b = 3;
console.log(a+b) // 5

console.log(a-b)// -1
console.log(a*b)// 6
console.log(a / b)   // 0.666
console.log(a % b) // 2
</code></pre>
<h2>Comparison operator</h2>
<pre><code class="language-javascript">// comparison like &gt;, &gt;=, &lt;, &lt;=, ==, ===, !==, !=
let a=1, b=2;
// greater than
console.log(a &gt; b) // false
// less than
console.log(a &lt; b) // true
// greater than equal
console.log(a &gt;= b) // false
// less than equal
console.log(a &lt;= b) // true
//  double equal
console.log(a == b) // false
// triple equal
console.log(a === b) // false
// not equal to  
console.log(a !== b) // true
</code></pre>
<h3>Logical operator</h3>
<pre><code class="language-javascript">// logical operator
// want to make decison like after 4 baje wakeup 
// between 12 and  4 sleeping
let age = 20

if(age &gt;=18)
    console.log("You can give vote")
else
    console.log("You are not allowed to give vote")
</code></pre>
<h3>Assignment operator</h3>
<pre><code class="language-javascript">// assignment 
let a = 10;
console.log(a +=20) // 30
console.log(a -=20) //10
console.log(a *=20) //200
console.log(a++) //200
console.log(++a)//202
console.log(a--) // 202
console.log(--a) //200
</code></pre>
<h3>Complex Operator Precedence</h3>
<p>Operator precedence determines the order in which operators in an expression are calculated. This is similar as PEMDAS / BODMAs.</p>
<p>It also depends upon associativity of operator . It is of two ways : left to right and right to left.</p>
<pre><code class="language-javascript">// operator

let a=b=10 ; 
// here value of a =10 and b=10;
// first b =10 and 
// then a = b which is 10
// this is associativity which is right to left

let result = 2 + 4 ** 3 // 
// first exponential done which is  ** 3
// addition done
// this is operator precedence ** has high precedence than + 

// Note simple for no confusion just used parens () for grouping 
let sum =  2 + 5 + (3 * 2)
</code></pre>
<h3>Difference between double and triple equal</h3>
<p>double equality is loosely equality so it doesnot check type it only check value like <code>2 =="2" JS do coherce on data due to this many bug arise so we try to use === instead of == . === is strict equality so it check both type and value so it is reliable and most used instead of ==.</code></p>
<h2>Summary</h2>
<p>operator is used for logic building and solving calculations and return the results. There are many operators for the different purpose and it return different type of data which make easier to process and used the data for logic building.</p>
]]></content:encoded></item><item><title><![CDATA[Understanding Promise by Singer Analogy]]></title><description><![CDATA[one singer who went viral for his songs. He got lakho followers , his fan demand for new song. his fan always excited and wait for his concert, new release so, he promised his fan to release song in h]]></description><link>https://blogs.dipeshchaudhary.name.np/understanding-promise-by-singer-analogy</link><guid isPermaLink="true">https://blogs.dipeshchaudhary.name.np/understanding-promise-by-singer-analogy</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[promises]]></category><dc:creator><![CDATA[Dipesh Chaudhary]]></dc:creator><pubDate>Sun, 01 Mar 2026 11:26:27 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6950c18c622afddd90b193eb/2c4ef4eb-ea5c-433d-9738-e501d6913a92.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>one singer who went viral for his songs. He got lakho followers , his fan demand for new song. his fan always excited and wait for his concert, new release so, he promised his fan to release song in his channel. He gave channel name and his fan subscribed it. Now whenever The singer released it will show in the channel so this is the promise. It is object which is placeholder for future value. It has two things: state and results.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6950c18c622afddd90b193eb/f2f3fe32-ab17-49ec-9be8-0fe7e12b0037.png" alt="" style="display:block;margin:0 auto" />

<p>Initially It is pending state. first singer write the song then after record in studio and plan to release date. This is the process time so In this state the results is undefined . There is no new song in the channel.</p>
<p>After record and planned the date , the song is ready to released and the song released . This is the fulfilled state. and the results value is new song which fans or viewers can see and listen in his channel.</p>
<p>but when there comes some technical issues and some disputes between the director and the singer then the song could not get to release on time then this is rejected state . In this case the singer may post sorry message on channel post or may come live to say sorry to his fans.</p>
<p>Now lets learn about some methods in promise by the excitement of fans.</p>
<pre><code class="language-javascript">const singerPromise = new Promise((resolve, reject) =&gt; {
  const songReady = true;
  const conflictWithDirector = false;

  if (songReady &amp;&amp; !conflictWithDirector) {
    resolve("Song released on channel 🎶");
  } else {
    reject("Song release failed due to issues 😢");
  }
});

singerPromise
  .then((message) =&gt; console.log("Fulfilled:", message))
  .catch((error) =&gt; console.log("Rejected:", error));
</code></pre>
<h2>Some Methods</h2>
<p>i. Promise.all</p>
<p>All fans are excited for new album release. if all songs come at once in the channel then it is fulfilled state. if any song may not release the it ruins the experience of fans to listen the album so it is rejected state.</p>
<pre><code class="language-javascript">const song1 = Promise.resolve("Track 1 released");
const song2 = Promise.resolve("Track 2 released");
const song3 = Promise.reject("Track 3 failed");

Promise.all([song1, song2, song3])
  .then((messages) =&gt; console.log("Album released:", messages))
  .catch((error) =&gt; console.log("Album failed:", error));
</code></pre>
<p>ii. Promise.any</p>
<p>The fans become happy on the first drop of a song of the album. it is fulfilled state . it does not matter for other songs released or fail to release.</p>
<pre><code class="language-javascript">const song1 = Promise.reject("Track 1 failed");
const song2 = Promise.resolve("Track 2 released");
const song3 = Promise.reject("Track 3 failed");

Promise.any([song1, song2, song3])
  .then((message) =&gt; console.log("Fans are happy with:", message))
  .catch((error) =&gt; console.log("No song released:", error));
</code></pre>
<p>iii. Promise.allSettled</p>
<p>This is the total records of the song . the fans or audience get to know which song is released or fail .</p>
<pre><code class="language-javascript">const song1 = Promise.resolve("Track 1 released");
const song2 = Promise.reject("Track 2 failed");
const song3 = Promise.resolve("Track 3 released");

Promise.allSettled([song1, song2, song3])
  .then((results) =&gt; {
    results.forEach((result, index) =&gt; {
      console.log(`Track ${index + 1}:`, result.status, result.reason || result.value);
    });
  });
</code></pre>
<p>iv. Promise.race</p>
<p>It is like race . which song released first got millions of views so The first released determines the outcomes .</p>
<pre><code class="language-javascript">const song1 = new Promise((resolve) =&gt; setTimeout(resolve, 3000, "Track 1 released"));
const song2 = new Promise((resolve) =&gt; setTimeout(resolve, 1000, "Track 2 released"));

Promise.race([song1, song2])
  .then((message) =&gt; console.log("First song out:", message));
</code></pre>
<h2>Summary</h2>
<p>So this is the singer analogy to understand the promise in JavaScript in easy way.</p>
]]></content:encoded></item><item><title><![CDATA[Understanding Object Type of JavaScript]]></title><description><![CDATA[JavaScript has 8 data types . 7 are primitive and 1 is complex object type. This is summary of T- class of cohort on 26 feb, 2026
// Objects 
//terminal 
mkdir t-5
code . // current directory me vscod]]></description><link>https://blogs.dipeshchaudhary.name.np/understanding-object-type-of-javascript</link><guid isPermaLink="true">https://blogs.dipeshchaudhary.name.np/understanding-object-type-of-javascript</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Object Oriented Programming]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Dipesh Chaudhary]]></dc:creator><pubDate>Sun, 01 Mar 2026 05:09:26 GMT</pubDate><content:encoded><![CDATA[<p>JavaScript has 8 data types . 7 are primitive and 1 is complex object type. This is summary of T- class of cohort on 26 feb, 2026</p>
<pre><code class="language-javascript">// Objects 
//terminal 
mkdir t-5
code . // current directory me vscode snip up

1-object.js
8 data types 7 + 1
// properties : 
name-value pairs
// 2 ways of creeting objects
let claude = new Object() // object constructor syntax
let gemini = {}  // object literal

let gpt = {
company : 'openai',
version:5.3,
releaseYear:2025
}
// accessing properties
// gpt.company

// new properties
// property can be any type
gpt.type = 'Large Language Model' ;
gpt.isMultiModel = true // multiModel means can do many things

// remove properties 
delete gpt.type

// sonnet 
let sonnet = {
company :"anthrophic",
version : 4.6,
"released on": 2026, // trailing comma
}
// multi word property must be quotated

// square bracket notation
sonnet["released on"]
// valid identifier 
1. starting not from number
2. only $and _.

// property are string in objects
// expression as values as property name
const input = "company"
sonnet[input]

// property value shorthand
                            //params
function getLaptop(name, price) {
return {
brand : 'apple',
//property shorthand if key and value are same
name,
price 
}
}
let myMac = getLaptop("M4 Air", 99_000) // args
// myMac 

// check property exists or not
// ram propert or not
myMac.ram === undefined  // conditional always return boolean

// in method
"ram" in myMac // is there or not // key in object

// hasOwnProperty


// looping the objects 
// for in 

for(let key in myMac) {
console.log(`\({key} : \){myMac[key]}`)
}

// objects are ordered in different fashion
const codes = {
// Asia
7 : 'Russia',
32:'Belgium',
91:'India',

// North America
1:'Canada',
52:'Mexico'
}

// codes  { 1,4,32,52,91}

// integer properties got sorted in objects , other appear in creation order
for (let code in codes ) {
console.log(key)
}
// fixing it 
{
'+7': 'Russia',
'+32' : 'Belgium',
'+91':'India'
}

//Non Numeric properties
// Array, Date, Promise, Error


//Ref and copying
// primitives are always copied as "value"
let like = "Radhika Das" ;
le love = like ;

console.log(like, love)

// like : Taylor Swift
like = 'Taylor Swift' ;
console.log(love)

// Object are stored and copied by reference 
let artist  = {
name : "Radhika Das ",
country : "UK"
}

let Kirtaniya = artist ;
artist.country = "England" ;
// artist === Kirtaniya ;

// store by reference 
let a = {};
let b = {} ;
console.log(a === b )

// Const can't be modified  then how we modified objects

const ev = {
name : "Mahindra be6",
}
ev.name = "BYD Seal"  // new word : contracdictin

// ev

// we cannot do 
ev = {name : "Thar"}

// cloning and merging
const org = {
k1 : 'V1',
k2 : 'V2',
}
// why to clone becz cannot copy by value it taken ref 
const clone = {}
for (let key in org ) {
clone[key] = org[key] ;
}
// Object.assign(dest, soyrces .. )
let clone2 = Object.assign ({}, org) ;

// nested objects 
const nestedObj = {
model,
version ,
capabilities : {
reasoning}
}

// capabilities are ref 

// deep clone needed
structuredClone(nestedObj)
// nestedObj.capabilities.reasoning  = false
// it not change in nestedClone

// 02- Garbage Collection
// Reachability

let temp = {
emial : "gibbesis@xyz.com",
valid : 5
}
// yes it is reachable
// temp
// after 5 minutes it becomes invalid
temp = null
// temp // it is not point to the temp obj
// Garbage collector will junk the data and free the memory

const movie = {
title : 'Ghosted',
release : 2023,
production : 'Apple TV',
}
function coStars (actor, actress) {
actor.coStar = actress;
actress.coStar = actor
 return {
leading : actor,
supporter:actress
}
}
movie.cast = coStars({
name : 'Chris Evan' , salary : 10_000_000},
{name: 'Anna de Armas', salary: 2_000_000}
})
movie.cast = null
// garbage collector do clean it 

// 03- methods

function viralDance() {
//Ichu Ichu Song 
}

const dogesh  = {
name:'husky',
dance: viralDance
}

// activities by methods
dogesh.dance = function (){
// Ichu Ichu song
}


const dogesh  = {
name:'husky',
dance:function () {
//Ichu Ichu Song 
}
}

// shorthand method prop

const dogesh  = {
name:'husky',
dance() {
//Ichu Ichu Song 
}
}

// 
let user = {
name,
age,
college,
passedOut,
gf,
intro() {
// user.name
// user.age
// user.college
// user.gf
}
}

let piyush = user
user=null

piyush.intro()

// jessa sang use rang
// arrow is transparency glass
// this is just like chamelom
// contemplate

// 4 new operator 

// It is mostly used in constructor function
// used to construct object
// capital Name // first letter Capital
// should be executed by new operator

function User (name) {
this.name = name ;
this.isPaid = false ;
}

const anirudh = new User('Ani') ;  // User {}

// new does these things
this = {} ;
property assign
// return this


// optional chaining
const user = {
name, email,
address :{
full,
zip
}
}
// user.address.city
// agar address ho toh city me jana
// user.address ?.city
if(user.address){
if(user.address.city) {
// user.address.city
}
else {
// full address

}
else return ""
}

// logica or  returnn// first truthy and last truthy

// &amp;&amp; first falsy and last truthy value

// Symbol 
// Object keys should be string and Symbol
// primitive unique value with description
let baby = Symbol("Ladla") ;

// Symbols are always unique even after its descriptions are same

// use case 
// hidden property , for in loop skip by 


// globalSymbol
// they exist in global symbol registry
let org = Symbol.for("Chaicode") ;

let company = Symbol.for("Chaicode") ;

Symbol.keyfor(org)

// System Symbol
Symbol.Iterator
Symbol.toPrimtive

// Date object add and subtract

[Symbol.toPrimitive](hint) {}

hint=&gt; string,number,default
// default is concatenation
// toString

const galgota = {
status :"wasted",
aura:-1000,

[Symbol.toPrimitive](hint) {
if(hint === "string") return this.status
if(hint === "number") return this.aura
return this.aura
}
}

// number bigint string boolean null undefined Sybol
// null and undefined are pure primitive
// Boxing

// let str = ""
// Wrapper object create which gives access of methods

let million = 1_000_000 ;
million = 1e6 ;

// e is used to zero
let cr = 4e7 ;
// 4e1 40
// 4e9 
// 1e5
// 0xff // 0x hex
// 0b111 // binary
// 0o13  //


//Math.floor(Math.random() * (max-min+1)) + max-min ;

// min + Math.random() * (max-min)

// Json no trailing comma
</code></pre>
<h2>Summary</h2>
<p>This is all about basic object foundation in JavaScript. This is foundation and learn nee thing about the use of e for adding zero and also number system like hex, octal, binary etc.</p>
]]></content:encoded></item><item><title><![CDATA[Understanding Array In JavaScript and some most used methods.]]></title><description><![CDATA[In programming we do two things first know data type and second is process data. JavaScript is dynamic and flexible programming language . It means that the variable is not typed static at declare sta]]></description><link>https://blogs.dipeshchaudhary.name.np/array-and-its-methods-in-javascript</link><guid isPermaLink="true">https://blogs.dipeshchaudhary.name.np/array-and-its-methods-in-javascript</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[array]]></category><category><![CDATA[array methods]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Cohort2026]]></category><dc:creator><![CDATA[Dipesh Chaudhary]]></dc:creator><pubDate>Thu, 26 Feb 2026 11:21:48 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6950c18c622afddd90b193eb/cdac5baf-e21c-48c0-912d-e7674d99b3b3.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In programming we do two things first know data type and second is process data. JavaScript is dynamic and flexible programming language . It means that the variable is not typed static at declare state like other programming language. JS engines figure out the type of variable by looking the value store during runtime. it means you can store and change any type of data at any time. You can assign number initially and later change to store string . JS gives no error so it is dynamic typed language.</p>
<h2>Data Types In JavaScript</h2>
<p>The types of data that we have to deal while working with JS. There are very few data types in JS. They are classified as :</p>
<p>a. Primitive Type : It is defined as single type of data which is immutable ( does not change ) and when you copy it it actually create another variable and store copy data. so when you change one variable , it does not change original variable. There are 7 types of primitive type they are:</p>
<ol>
<li><p>number : simple any type of number is number type data, positive, negative, decimal, zero , Infinity all comes under number type</p>
</li>
<li><p>string : string is sequence of characters. so in JS , string is written as three ways : by single quotes ('apple') , double quotes ("apple") or by back tick which is under Esc key `apple`</p>
</li>
<li><p>boolean : It is very simple type. it has only two values either true or false.</p>
</li>
<li><p>null : null is data type in JS. It represents as no value for variable. if you want to give no value then assign variable with null like let temperature = null ;</p>
</li>
<li><p>undefined : it is also another data type. It is defined as the variable is not set with any value. like you declare a variable but does not assign with any value then JS engines set it undefined.</p>
</li>
<li><p>bigint : It is also another type which is used to represent large integer value . it is simple and easy to create by giving n at end of number like let bigNum = 1028389226822n ;</p>
</li>
<li><p>symbol : It is the type which is used to create unique label . It is used for creating unique label .</p>
</li>
</ol>
<p>b. Non-Primitive data type : The data which is not primitive means it is mutable in nature which means when you try to copy by simply assigning variable with another variable then it does not copy the value rather it is another name for that variable and when you change it , it also change to original variable. examples like array, objects , Map, Set etc.</p>
<p>In this article lets discuss and learn about array in JS and its some methods . It is awesome to work with array in JS.</p>
<h2>Array and Its Introduction</h2>
<p>n JavaScript , array is object type data structure which is used to store collection or group of data. In array single name is given and store data , In JS , we can store different type of data in single array .</p>
<img src="https://cdn.hashnode.com/uploads/covers/6950c18c622afddd90b193eb/50633482-f994-422b-b021-39b1fce15d58.jpg" alt="" style="display:block;margin:0 auto" />

<pre><code class="language-javascript">const buyMushroom = [
  'I',
  'mushroom',
  50,
  true,
  function () {
    return buyMushroom[0] + ' can cook ' + buyMushroom[1];
  },
  ['tomato', 'chilly', 'dhaniya'],
];
console.log(buyMushroom[4]()); // I can cook mushroom
</code></pre>
<p>it is flexible in JavaScript. We can store any type of data and do our needed work .</p>
<img src="https://cdn.hashnode.com/uploads/covers/6950c18c622afddd90b193eb/d58f4f20-dd7f-4aea-a2ce-355085bfb57b.webp" alt="" style="display:block;margin:0 auto" />

<h2>Methods of creating Array</h2>
<p>There are so many ways to creating array. some are</p>
<pre><code class="language-javascript">// methods of creating Array
// 1. Array constructor
const citiesOfNepal = Array('Janakpur', 'Lumbini','Chitwan', 'Kathmandu', 'Pokhara')
console.log(citiesOfNepal)

// 2. Array.of()
const sameCities = Array.of(
  'Janakpur',
  'Lumbini',
  'Chitwan',
  'Kathmandu',
  'Pokhara'
);
console.log(sameCities);

//3 . Array.from()
const againSameCities = Array.from(sameCities)
console.log(againSameCities);

// 4. literal method (Most used and simple way)
const beautifulCities = ["Kathmandu", "Lumbini", "Pokhara", "Chitwan","Janakpur", "Solukhumbu"]
console.log(beautifulCities);

// output 
// [ "Janakpur", "Lumbini", "Chitwan", "Kathmandu", "Pokhara" ]
// [ "Janakpur", "Lumbini", "Chitwan", "Kathmandu", "Pokhara" ]
// [ "Janakpur", "Lumbini", "Chitwan", "Kathmandu", "Pokhara" ]
// [ "Kathmandu", "Lumbini", "Pokhara", "Chitwan", "Janakpur", "Solukhumbu" ]
</code></pre>
<p>There are difference between the way they create array.</p>
<ol>
<li><p>Array() and Array.of() : while giving single arguments to them . Array() create empty-slots of that much of arguments given and Array.of() create array with single element</p>
</li>
<li><p>Array.from() : It is mostly used to create array from array like structure like In DOM There comes nodelist while querySelectorAll() and also it is used to create array programatically like of particular length.</p>
</li>
</ol>
<pre><code class="language-javascript">const oneEl = Array(10)
const oneElOf = Array.of(10)
const nums1To10 = Array.from(({length:10}));
console.log(oneEl, oneElOf, nums1To10)

// output
// [ 10 x empty items ] [ 10 ] [ undefined, undefined, undefined, undefined, undefined,
//   undefined, undefined, undefined, undefined, undefined
// ]

const arrNums1To10 = Array.from(({length:10}), (_, i)=&gt;i+1);
console.log(arrNums1To10) //  [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
</code></pre>
<p>We use array because there are so many methods which make us easy to work with data. so let's know about some most used methods in arrays.</p>
<p>As it is non primitive type so There are methods which effect original array and other methods return new array without affecting original array .</p>
<h3>Methods that mutate array</h3>
<p>i. push : It is just method which is used to push data in array at end . It return new length of array.</p>
<p>ii. pop : It is method which is used to remove one element from array from end. it return removed element of array.</p>
<p>iii. unshift : It is another method which is used to again add item in array at start . it again return new length of array.</p>
<p>iv. shift : It is used to remove element from start. It again return remove element .</p>
<p>v. splice : It is the method which is used to remove to more than one elements. It is used to replace , modify , delete items of array. It return removed items . If no items removed it simply give empty array []. It includes array.splice(start, deleteCount, [item1, item2,...])</p>
<pre><code class="language-javascript">// mutating method

let vegetables = ['potato'];

// push method to add brinjal
vegetables.push('brinjal');
console.log(vegetables) // ['potato','brinjal' ]
vegetables.push('pumpkin', 'reddish', 'Cauli', 'Jackfruit')
console.log(vegetables); 
// [ "potato", "brinjal", "pumpkin", "reddish", "Cauli", "Jackfruit" ]

// pop  method to remove
const removedItem = vegetables.pop() // remove last Jackfruit 
console.log(removedItem, vegetables)
// Jackfruit [ "potato", "brinjal", "pumpkin", "reddish", "Cauli" ]

// unshift 
vegetables.unshift("Ladyfinger")  // ['Ladyfinger', ...]
// [ "Ladyfinger", "potato", "brinjal", "pumpkin", "reddish", "Cauli" ]
console.log( vegetables);
// shift 
vegetables.shift() // remove first item at start

// splice method 
console.log(vegetables) // [ "potato", "brinjal", "pumpkin", "reddish", "Cauli" ]

// remove more than 1 itens from anywhere in array

vegetables.splice(1,2) // remove 2 items start from 1 Index
//[ "potato", "reddish", "Cauli" ]
console.log(vegetables)

// add items in array at any position
vegetables.splice(1, 0 , "Naaf Saag", "Rhai Saag") // add items from 1 Index 
// [ "potato", "Naaf Saag", "Rhai Saag", "reddish", "Cauli" ]

console.log(vegetables);

// replace items of array
vegetables.splice(0,1,"Potatoes") // delete and add is like replace
console.log(vegetables);

// splice also remove from end by taking negative Index
vegetables.splice(-2,1) // remove item at second position from end
console.log(vegetables)
</code></pre>
<h3>Methods That return new Array</h3>
<p>These are methods which do not mutate original array rather it return new array which we can store in variable and used it .</p>
<p>i. slice : It is the methods which is used as taking part of array means slice the portion which you want and also used to copy entire array. It take start and end index , end index is exclusive. for eg : arr.slice(1,5) , start index is 1 and end is 5 but 5 index does not include . We can easily find out how many items we get in new array by difference the end-start so 5-1 is 4 .</p>
<p>ii. flat : it is method which is used to flatten the array . It accepts depth to which part you want to flat it.</p>
<p>iii. concat : it is simple method which is used to concat two or more than two array and return new array.</p>
<p>iv. Other methods are map, filter, reduce</p>
<pre><code class="language-javascript">// methods that return new array

let houseAnimals = ['cow', 'goat', 'ox', 'buffalo', 'horse', 'donkey',  'dog', 'cat','peacock', 'parrot', 'pigeon', 'hen', 'duck', 'bee']

// let make birds group
// slice 
const birds =  houseAnimals.slice(8)
const myHouseAnimals = houseAnimals.slice(0,4) //['cow', 'goat', 'ox', 'buffalo']

console.log(birds) // [ "peacock", "parrot", "pigeon", "hen", "duck", "bee" ]
// original array still same 
// console.log(houseAnimals)

//concat
const myTotalAnimals = myHouseAnimals.concat(["pigeon", "bee"])
console.log(myTotalAnimals)

// flat the nested array
const nestedAnimals = ["rabbit", birds, [["ostrich", "sparrow", "fox"]]]
console.log(nestedAnimals)
/*[ "rabbit", [ "peacock", "parrot", "pigeon", "hen", "duck", "bee" ], 
  [
    [ "ostrich", "sparrow", "fox" ]
  ] 
]
*/
console.log(nestedAnimals.flat()) // by default depth is 1
// [ "rabbit", "peacock", "parrot", "pigeon", "hen", "duck", "bee", [ "ostrich", "sparrow", "fox" ] ]

console.log(birds.concat(["sparrow"], ["ostrich"]))
console.log(Array.from({length:4}).fill(1,1,3)) // [ undefined, 1, 1, undefined ]

// map , filter, reduce , flatMap these are mostly used to do some tasks in array 
//map is used to perform any operations which you want to do with all items in array
// it is used to take some property and create array from array of objects

const tasks = [
  {
    id: 1,
    name: 'wake up at 4am',
    isDone: true,
  },
  {
    id: 2,
    name: 'do exercise and meditation',
    isDone: false,
  },
  {
    id: 3,
    name: 'finish assignments',
    isDone: false,
  },
  {
    id: 4,
    name: 'play football',
    isDone: true,

  },
];
// get name of all task
const allTasksByName = tasks.map(task=&gt;task.name)
console.log(allTasksByName) 
//[ "wake up at 4am", "do exercise and meditation", "finish assignments", "play football" ]

// get all done tasks
// console.log(tasks.filter(task=&gt;task.isDone))
/**
 * [
  {
    id: 1,
    name: "wake up at 4am",
    isDone: true,
  }, {
    id: 4,
    name: "play football",
    isDone: true,
  }
]
 */

// reduce is so versatile and powerful methods
// mainly it is used to sum of all values and find total 
const movements = [100, 2000, 20000, -500, 1000, 12000]
const total = movements.reduce((total,mov)=&gt;{
  console.log(`current is \({total} : item is \){mov}`)
  return total + mov
},0)
/**
 * current is 0 : item is 100
current is 100 : item is 2000
current is 2100 : item is 20000
current is 22100 : item is -500
current is 21600 : item is 1000
current is 22600 : item is 12000
34600
 */
// console.log(movements.reduce((total, mov)=&gt;total+mov,0))
// console.log(total)
</code></pre>
<h2>Looping in Arrays</h2>
<p>There are lots of methods to iterate through arrays. like map, filter, reduce , forEach and traditional loops like for, in JS for of loop also.</p>
<p>i. forEach : it is methods which accepts function as parameters that run for each element at once.</p>
<p>Things to consider in it :</p>
<ol>
<li><p>It does not has break statement means there is no use of break and continue keyword.</p>
</li>
<li><p>It accepts synchronous function . means It does not wait for promises . There is no effect of async and await .</p>
</li>
</ol>
<h2>Searching methods in array</h2>
<p>There need to search items in array so there are also so many methods to do that few of them are : indexOf, includes, find, findIndex, findLastIndex, lasyIndexOf , filter, some, every etc</p>
<p>i. indexOf : it gives index of element if not found return -1 . arr.indexOf(3)</p>
<p>ii. lastIndexOf : it is same as indexOf , only it start to search from last. arr.lastIndexOf(5)</p>
<p>iii. includes : It is most used method. It is used to search elements is present or not in array. it return boolean . arr.includes("apple")</p>
<p>iv. find : It accepts callback function and return the first match of conditional . if not found return undefined. arr.find(item=&gt;item.price &lt;10)</p>
<p>v. findIndex : It return index of matched conditional. if not found return -1. arr.findIndex(item=&gt;item.name="Mango")</p>
<p>vi. findLastIndex : same as findIndex only it start to serach from last.</p>
<p>vii. filter : It is methods which create new array of elements that match the conditional passed in it.</p>
<p>viii. some : it is method which is used to return true when any one element satisfy the condition. otherwise false.</p>
<p>ix. every : it is used to check is every element satisfy the condition. It return true if all match the condition otherwise false.</p>
<pre><code class="language-javascript">// forEach is used to call the function for all items in array and perform what the function apply to all items . simple so It is called Higher Order Function in JavaScript
vegetables.forEach(vege=&gt;console.log(vege))
</code></pre>
<h2>Summary</h2>
<p>So Array is most used in JavaScript to store different type of value at one variable name. It provides inbuilt methods to perform operations. so it is easy to work with array elements.</p>
<p>It is very easy to construct and used array in JavaScript.</p>
<p>I hope you liked all this info if you want to read more you can visit MDN Docs :</p>
<p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">MDN ARRAYS</a></p>
]]></content:encoded></item><item><title><![CDATA[Exploring JavaScript: From Its Origins to Modern Developments]]></title><description><![CDATA[Programming is the way of giving instructions to computer to perform some tasks. but Computer does not understand our natural language like English, Hindi, Nepali, Spanish etc. so We used tools to write our instructions which converted into machine c...]]></description><link>https://blogs.dipeshchaudhary.name.np/exploring-javascript-from-its-origins-to-modern-developments</link><guid isPermaLink="true">https://blogs.dipeshchaudhary.name.np/exploring-javascript-from-its-origins-to-modern-developments</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[Cohort2026]]></category><dc:creator><![CDATA[Dipesh Chaudhary]]></dc:creator><pubDate>Sun, 15 Feb 2026 09:37:55 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1771147923097/eae3f85c-57c7-4811-aef3-f4e58927ddf1.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Programming is the way of giving instructions to computer to perform some tasks. but Computer does not understand our natural language like English, Hindi, Nepali, Spanish etc. so We used tools to write our instructions which converted into machine code and that understand by computer. These tools are called programming language. Every programming languages has own used . some are low level or some are high level.</p>
<p>Popular programming languages are Javascript, Python, Java, C++, and many more. Each on of them are used on the basis of what we need to develop and build like software development, machine learning, gaming , data analysis etc.</p>
<p>In this article we discussed about the JavaScript one of most popular language which is widely used from browser to server, web app to mobile app, desktop app, machine code and more .</p>
<h2 id="heading-beginning-of-world">Beginning of world</h2>
<p><img src="https://th.bing.com/th/id/OIP.xpOlrWt0F4FTZ3zuSaqJzQHaDa?w=314&amp;h=161&amp;c=7&amp;r=0&amp;o=7&amp;dpr=1.5&amp;pid=1.7&amp;rm=3" alt class="image--center mx-auto" /></p>
<p><strong>In 1995, Brendan Eich</strong> was hired to develop one lightweight scripting language to add interactivity in Netscape navigator browser. it was initially developed in just 10 days and since evolved to become one of the widely used programming language.</p>
<p>Initially it was named <strong>Mocha</strong>. then changed to <strong>LiveScript</strong> . In that days Java was widely famous and everyone talking about that so to bring on the eyes of people . It was named <strong>JavaScript.</strong> However Both are different paradigm language There are no any similarity and Both have different take and purpose.</p>
<p>The microsoft developed its own <strong>JScript</strong>. and many other browser implement their own Javascript so to bring consistency on the use of JavaScript. Netscape submitted for standardization to <strong>ECMA International</strong> and The standard specification built and written for Javascript is known as <strong>ECMAScript(ECMA-262)</strong> and the first edition was released in <strong>June 1997.</strong></p>
<h3 id="heading-es3">ES3</h3>
<p>It was released in <strong>December 1999</strong>, It added the features of <strong>Regex, try/catch block and new string methods</strong>. which makes it more serious programming language.</p>
<p><strong>In 2005, AJAX and Web 2.0</strong> enables the dynamic contents updates without full page loads. It helps in making applications like Gmail and Google maps much more interaction and dynamic apps.</p>
<h3 id="heading-v8-engine-and-nodejs">V8 Engine and NodeJs</h3>
<p><strong>In 2008, Google</strong> released chrome browser with high performance <strong>V8 Javascript engine.</strong> which complied Javascript code directly to machine code. We can run Javascript directly on browser due to this engine in chrome. It was open source so <strong>Ryan Dahl</strong> takeout the V8 engine and wraps with C++ bindings and create the Javascript run time environment to run Javascript outside the browser for the first time. That is <strong>NodeJs</strong> . There are large package directories with millions of packages called NPM.</p>
<p>and by this It opens the gate so we can used Javascript to build server side apps which makes Javascript more powerful.</p>
<h3 id="heading-modern-javascript-2010-present">Modern Javascript (2010- present)</h3>
<p>The major updates comes in <strong>ES6 in 2015</strong>. It brought many changes in language. There are addition of many features which enables today way of writing Javascript in much more cleaner and modular way. Features like <strong>(let/const, Classes, Modules,arrow function, promises)</strong> making it more robust for large applications. <strong>The standard committee (TC39)</strong> then shifted to release update or some new addition of smaller features on every year.</p>
<h3 id="heading-the-frameworks-and-libraries">The Frameworks and Libraries</h3>
<p>The Javascript capture all over the Software development field. so In 2010s saw the rise of powerful libraries and frameworks like <strong>Angular JS,</strong> then on 2013 the most favorite among many developers <strong>The React</strong> introduces by facebook, and on <strong>2014 Vue.js</strong>. These are JavaScript frameworks and libraries that simplified the development of single page applications easy . The frontend engineers do their job on these tools.</p>
<h3 id="heading-typescript">TypeScript:</h3>
<p><strong>In 2012 Microsoft i</strong>ntroduced the strict type of Javascript which is superset of Javascript . it is Typescript. It add type safety and make it more less error and bug free on writing Javascript in large codebase.</p>
<h2 id="heading-summary">Summary</h2>
<p>This is the journey of Javascript to become the most used programming language. It is High level Programming Language so it is most human friendly to learn and write the code and It helps to develop the <strong>software, server side backend , mobile apps, games, CLI tools</strong> , whatever you can think all the things can be done with JS .</p>
<p>The ecosystem of JavaScript is really very vast . you can find any tools, packages to do specific tasks on NPM which makes it more easy to build software in JavaScript.</p>
]]></content:encoded></item><item><title><![CDATA[Mastering Emmet Syntax For Speed Up in Writing HTML]]></title><description><![CDATA[Emmet is a toolkit that is built in many code editors (vs code, sublime, Atom) that helps us to writeabbreviation code which instantly expand to full html and css code.
Without the use of Emmet the workflow is very slow . you have to manually write a...]]></description><link>https://blogs.dipeshchaudhary.name.np/emmet-for-speedup-html-writing</link><guid isPermaLink="true">https://blogs.dipeshchaudhary.name.np/emmet-for-speedup-html-writing</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[HTML5]]></category><category><![CDATA[Emmet]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Dipesh Chaudhary]]></dc:creator><pubDate>Thu, 29 Jan 2026 11:27:49 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769685940850/c8bbbc97-547b-45b7-a127-7e40913fcfc0.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Emmet is a toolkit that is built in many code editors (vs code, sublime, Atom) that helps us to write<br />abbreviation code which instantly expand to full html and css code.</p>
<p>Without the use of Emmet the workflow is very slow . you have to manually write all those HTML boilerplate code and manually write the completely full tag starting from angular brackets to close the angular brackets. The benefits of Emmet are :</p>
<ul>
<li><p>it helps to complete the boilerplate code.</p>
</li>
<li><p>it completes the code with abbr. tag name like p for paragraph , img for image</p>
</li>
<li><p>it really speed our code writing and increase our speed and makes easier to write boring html with most fun way.</p>
</li>
</ul>
<h2 id="heading-some-emmet-shortcut-for-html">Some Emmet Shortcut for HTML</h2>
<p><strong>1 . for creating HTML documents (boilerplates)</strong></p>
<p>Use <code>!</code> exclamation mark for boilerplate.</p>
<p>2 . Create any Tag just by name</p>
<p>When you want any Element just type the name of tag like p= paragraph, img = image, inp = input It means just by some starting letter you get suggestions on code editors and when you press Tab or Enter key you get complete Element . In this way You can increase your speed on writing markup.</p>
<p>There are some relation We ca generate by using Emmet abbreviation :</p>
<pre><code class="lang-xml">- emmet shortcut:
  - create div : `div` 
  - create parent &amp; child relation :
    div &gt; P
  - create siblings : + 
    div+p+img
  - multiplication : *
    ul&gt;Li*5{hello}
  - attribute operator : []
    a[href=<span class="hljs-symbol">&amp;quot;</span>]
  - text operator: {}
    h2{hello}
  - Numbering operator: $
    ul&gt;li.item$*5
  - grouping operator: ()
    (header&gt;ul&gt;li*3)+footer&gt;p{copyright &amp;copy 2025}
</code></pre>
<h2 id="heading-summary">Summary</h2>
<p>Hence Emmet is very powerful toolkit that increase speed up the markup structure . we just have to learn the abbreviate format and apply daily basics for practice and muscle memory. It helps to write boring tag in immediate way and increase and increase our speed . so It is very useful for beginner because when they Knew it they work as professionals in the HTML and CSS syntax.</p>
<p><strong>More Resources :</strong></p>
<p><a target="_blank" href="https://www.freecodecamp.org/news/write-html-css-faster-with-emmet-cheat-codes/">Emmet CheetSheet for HTML and CSS</a></p>
]]></content:encoded></item><item><title><![CDATA[Master CSS Selectors and Emmet for Faster Web Styling]]></title><description><![CDATA[For learning CSS , HTML is prerequestic . On the basis of human anatomy, HTML is skeleton , CSS is Skin layer and Javasvript is brain of body . browser only understand three things HTML, CSS and Javacript.
We need to define the stylesheet because Use...]]></description><link>https://blogs.dipeshchaudhary.name.np/understanding-selectors-and-emmet-use</link><guid isPermaLink="true">https://blogs.dipeshchaudhary.name.np/understanding-selectors-and-emmet-use</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[CSS]]></category><category><![CDATA[Emmet]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Dipesh Chaudhary]]></dc:creator><pubDate>Wed, 28 Jan 2026 06:09:19 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769581418448/e8aabeb1-e56f-467d-8081-dc611a9d8362.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>For learning CSS , HTML is prerequestic . On the basis of human anatomy, HTML is skeleton , CSS is Skin layer and Javasvript is brain of body . browser only understand three things HTML, CSS and Javacript.</p>
<p>We need to define the stylesheet because User Agent stylesheet are different according to the browser so to make our styles work same in all browser we need to write our CSS.</p>
<h2 id="heading-what-is-css">What Is CSS</h2>
<p>CSS stands for Cascading Stylesheet . lets break down the terms :</p>
<p><strong>Stylesheet :</strong> Stylesheet is simply the styles files that can apply to element of webpage. It is some set of rules for applying CSS.</p>
<p><strong>Cascading :</strong> How CSS applied in elements , HTML is defined by Cascading. In basics term Cascading is overwriting the default browser stylesheet which is also called User-Agent Stylesheet. It is overwriting the CSS with our own CSS rules . when you search meaning of Cascading , It is action of something that is falling or flowing downwards like waterfall. it is fit in CSS . the bottom styles got apply when same property change to same element.</p>
<p>But There are difference between overwriting and Cascading .</p>
<p><strong>Overwriting :</strong> When there Will be overwriting in some property then beside all property will erase . and for applying previous styles. we need to write the property again .</p>
<p><strong>Cascading :</strong> In Cascading There is no need to write previous styles . It is like combining the previous styles and new property or change property to the element.</p>
<pre><code class="lang-css">// <span class="hljs-selector-tag">there</span> <span class="hljs-selector-tag">is</span> <span class="hljs-selector-tag">button</span>
<span class="hljs-selector-tag">button</span> {
<span class="hljs-attribute">background-color </span>: tomato;
<span class="hljs-attribute">color</span>: <span class="hljs-number">#000</span>;
<span class="hljs-attribute">padding</span>: <span class="hljs-number">10px</span> <span class="hljs-number">20px</span>;
}
<span class="hljs-selector-tag">button</span> {
<span class="hljs-attribute">border </span>: none;
}
// <span class="hljs-selector-tag">in</span> <span class="hljs-selector-tag">this</span> <span class="hljs-selector-tag">both</span> <span class="hljs-selector-tag">button</span> <span class="hljs-selector-tag">styles</span> <span class="hljs-selector-tag">got</span> <span class="hljs-selector-tag">combine</span> <span class="hljs-selector-tag">and</span> <span class="hljs-selector-tag">apply</span> <span class="hljs-selector-tag">in</span> <span class="hljs-selector-tag">button</span> <span class="hljs-selector-tag">element</span> .
// <span class="hljs-selector-tag">upper</span> <span class="hljs-selector-tag">property</span> + <span class="hljs-selector-tag">bottom</span> <span class="hljs-selector-tag">proprty</span> <span class="hljs-selector-tag">combine</span> <span class="hljs-selector-tag">together</span>.
</code></pre>
<h2 id="heading-ways-of-applying-css">Ways of Applying CSS :</h2>
<p>There are 3 ways of applying CSS . They are :</p>
<ul>
<li><p><strong>Inline CSS :</strong> It is apply in HTML on the tag with the style attribute .it is like <code>&lt;p style=”color:red; font-size:20px”&gt;Consistency and Community&lt;/p</code>. Its pros are we can style the element on the same line, it is easy to write . but its cons are it makes our html files more messy . we cannot reused our style again in different element .</p>
</li>
<li><p><strong>Internal CSS :</strong> it is used inside html file in head tag under style tag . it makes the separation of our html and CSS and helps to solve the problem that is in inline CSS . we can write reusable css , there is separate place for html and CSS but when we want to apply same stylesheet in another file then we have to copy all the styles to another file which is not good that makes our work double</p>
</li>
<li><p><strong>External CSS :</strong> this is way of writing CSS in separate file and apply in html by Linking the CSS files with <code>link</code> tag under head. just write css into separate file and no need to worry about html and whenever that is need to apply . no matter how much files just link the <code>style.css</code> into all those files your style applied.</p>
</li>
</ul>
<h2 id="heading-ways-of-writing-css-in-internal-or-external-styles">Ways of Writing CSS in Internal or External Styles</h2>
<p>We need to apply CSS in Some format to write css in Internal or External Stylesheet. we have to decide about selector .</p>
<p><strong>Selector :</strong> it is just the selecting of element of HTML where you want to apply css . like h1, p, button, img, body, ul, li , input etc.</p>
<p>There are different types of ways of selecting Element :</p>
<p><strong>i. By direct Tag-name :</strong> It is most forward and direct way of styling any element of HTML just by writing the name of tag . It selects all the same tag and apply styles.</p>
<p><strong>ii. Combining elements with Comma :</strong> <code>h1 , h2 , h3 {color : magenta}</code> this apply the styles to the all element which includes with comma separarted . it is useful to combine the elements to apply some common styles to multiple elements.</p>
<p>The Cascading is good but to be more specific about our styling we can used class and id selector.</p>
<p><strong>iii. Class Selector :</strong> class is used for grouping the elements on the basis of class attribute .it use <code>.</code> for selector.</p>
<ul>
<li><p>one element may have multiple classname .</p>
</li>
<li><p>one class may apply to multiple element.</p>
</li>
</ul>
<p>It has more specific than above two selecting methods.</p>
<p><strong>iv. Id Selector :</strong> It is unique and for only one element . It is like id card , email . It has more specificity so styles under ID selector applied . it use dot <code>#</code> for selector.</p>
<pre><code class="lang-css">// <span class="hljs-selector-tag">class</span> <span class="hljs-selector-tag">slector</span> 
<span class="hljs-selector-class">.btn</span> {
<span class="hljs-attribute">padding</span>: <span class="hljs-number">10px</span> <span class="hljs-number">20px</span>;
<span class="hljs-attribute">border </span>: <span class="hljs-number">0px</span>;
<span class="hljs-attribute">background-color</span>: <span class="hljs-number">#000</span>;
<span class="hljs-attribute">color </span>: <span class="hljs-number">#fff</span>;
}
//<span class="hljs-selector-tag">id</span> <span class="hljs-selector-tag">seletor</span>
<span class="hljs-selector-id">#red-btn</span> {
<span class="hljs-attribute">color </span>: red;
}
</code></pre>
<p><strong>v. Descendent Selector :</strong> The <strong>descendant selector</strong> in CSS is used to select elements that are descendants of a specified element. This means that the selected elements can be nested at any level within the specified ancestor element in the DOM tree. The descendant selector is represented by a space between two selectors . like</p>
<pre><code class="lang-css">// <span class="hljs-selector-tag">nav</span> &gt; <span class="hljs-selector-tag">ul</span> &gt; <span class="hljs-selector-tag">li</span> <span class="hljs-selector-tag">in</span> <span class="hljs-selector-tag">this</span> <span class="hljs-selector-tag">we</span> <span class="hljs-selector-tag">can</span> <span class="hljs-selector-tag">select</span> <span class="hljs-selector-tag">li</span> <span class="hljs-selector-tag">directly</span> <span class="hljs-selector-tag">by</span> <span class="hljs-selector-tag">descendent</span> <span class="hljs-selector-tag">selector</span>
// <span class="hljs-selector-tag">there</span> <span class="hljs-selector-tag">might</span> <span class="hljs-selector-tag">me</span> <span class="hljs-selector-tag">many</span> <span class="hljs-selector-tag">li</span> <span class="hljs-selector-tag">in</span> <span class="hljs-selector-tag">our</span> <span class="hljs-selector-tag">html</span> <span class="hljs-selector-tag">so</span> <span class="hljs-selector-tag">we</span> <span class="hljs-selector-tag">tell</span> <span class="hljs-selector-tag">that</span> <span class="hljs-selector-tag">only</span> <span class="hljs-selector-tag">li</span> <span class="hljs-selector-tag">which</span> <span class="hljs-selector-tag">is</span> <span class="hljs-selector-tag">descendent</span> <span class="hljs-selector-tag">of</span> <span class="hljs-selector-tag">nav</span>
<span class="hljs-selector-tag">nav</span> <span class="hljs-selector-tag">li</span> {
<span class="hljs-attribute">color </span>: blue;
<span class="hljs-attribute">font-size </span>: <span class="hljs-number">24px</span>;
<span class="hljs-attribute">margin-bottom </span>:<span class="hljs-number">5px</span>;
}
</code></pre>
<p><strong>v. !important :</strong> it has more specificity than all. The <em>!important</em> rule is used to give a CSS declaration higher priority than other declarations. When a property is marked as <em>!important</em>, it overrides all previous styling rules for that specific property on that element, regardless of specificity. However, overusing <em>!important</em> can make the CSS code difficult to maintain and debug. It should be used sparingly and only when necessary.</p>
<p><strong>Note</strong>: <strong>Specificity and Cascading determine how styles need to get apply on element.</strong></p>
<h3 id="heading-analogy">Analogy</h3>
<p>Specificity flow top to bottom in below image :</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769572346364/97d48c4d-5ec9-43b2-977e-b91e61dd3fec.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-some-common-emmet-used-in-css">Some Common Emmet used In CSS</h2>
<pre><code class="lang-css"><span class="hljs-selector-tag">w</span> <span class="hljs-selector-tag">-</span>&gt; <span class="hljs-selector-tag">for</span> <span class="hljs-selector-tag">width</span>
<span class="hljs-selector-tag">w10</span> <span class="hljs-selector-tag">-</span>&gt; <span class="hljs-selector-tag">width</span> 10<span class="hljs-selector-tag">px</span>
<span class="hljs-selector-tag">w100</span>% <span class="hljs-selector-tag">-</span>&gt; <span class="hljs-selector-tag">width</span> 100%

<span class="hljs-comment">/* similar for height*/</span>
<span class="hljs-selector-tag">h</span> <span class="hljs-selector-tag">---</span>&gt; <span class="hljs-selector-tag">height</span>
<span class="hljs-selector-tag">h10</span> <span class="hljs-selector-tag">----</span>&gt; <span class="hljs-selector-tag">height</span> 10<span class="hljs-selector-tag">px</span>
<span class="hljs-selector-tag">h100</span>% <span class="hljs-selector-tag">----</span>&gt; <span class="hljs-selector-tag">height</span> 100%

<span class="hljs-comment">/* background*/</span>
<span class="hljs-selector-tag">bg</span> <span class="hljs-selector-tag">---</span>&gt; <span class="hljs-selector-tag">background</span> <span class="hljs-selector-id">#000</span>
<span class="hljs-selector-tag">bgc</span><span class="hljs-selector-id">#000</span> <span class="hljs-selector-tag">---</span>&gt; <span class="hljs-selector-tag">background-colr</span>: <span class="hljs-selector-id">#000</span>
<span class="hljs-selector-tag">bg----</span>&gt; <span class="hljs-selector-tag">background</span>
<span class="hljs-selector-tag">bgi---</span>&gt; <span class="hljs-selector-tag">background-image</span>
<span class="hljs-selector-tag">bgr</span> <span class="hljs-selector-tag">-</span>&gt; <span class="hljs-selector-tag">background-repeat</span> 

<span class="hljs-comment">/* we can give value by colon */</span>
<span class="hljs-selector-tag">bgr</span><span class="hljs-selector-pseudo">:n</span> <span class="hljs-selector-tag">--</span>&gt; <span class="hljs-selector-tag">background-reeat</span><span class="hljs-selector-pseudo">:no-repeat</span>
<span class="hljs-selector-tag">bgs</span><span class="hljs-selector-pseudo">:cover--</span>&gt; <span class="hljs-selector-tag">background-size</span> : <span class="hljs-selector-tag">cover</span>
<span class="hljs-selector-tag">bgp</span> <span class="hljs-selector-tag">-</span>&gt; <span class="hljs-selector-tag">background-position</span>

<span class="hljs-comment">/*for color*/</span>
<span class="hljs-selector-tag">c</span> = <span class="hljs-selector-tag">color</span> <span class="hljs-selector-id">#000</span>
<span class="hljs-selector-tag">c</span><span class="hljs-selector-pseudo">:red</span> = <span class="hljs-selector-tag">color</span> : <span class="hljs-selector-tag">red</span>
<span class="hljs-selector-tag">c</span><span class="hljs-selector-id">#fff</span> = <span class="hljs-selector-tag">color</span> : <span class="hljs-selector-id">#fff</span>

<span class="hljs-comment">/* font*/</span>
<span class="hljs-selector-tag">fs</span> = <span class="hljs-selector-tag">font-style</span> <span class="hljs-selector-tag">italic</span>
<span class="hljs-selector-tag">fz</span> = <span class="hljs-selector-tag">font-size</span> 
<span class="hljs-selector-tag">fz22px</span> = <span class="hljs-selector-tag">font-size</span> : 22<span class="hljs-selector-tag">px</span>
<span class="hljs-selector-tag">fw</span> = <span class="hljs-selector-tag">font</span> <span class="hljs-selector-tag">-weight</span>
<span class="hljs-selector-tag">fw900</span> = <span class="hljs-selector-tag">font-weight</span><span class="hljs-selector-pseudo">:900</span>
<span class="hljs-selector-tag">lh</span> = <span class="hljs-selector-tag">line-height</span>
<span class="hljs-selector-tag">lh1</span><span class="hljs-selector-class">.5</span> = <span class="hljs-selector-tag">line-height</span> : 1<span class="hljs-selector-class">.5</span>

<span class="hljs-comment">/*Text */</span>
<span class="hljs-selector-tag">ta</span> = <span class="hljs-selector-tag">text-align</span>
<span class="hljs-selector-tag">tac</span> = <span class="hljs-selector-tag">text-align</span>: <span class="hljs-selector-tag">center</span>
<span class="hljs-selector-tag">td</span> = <span class="hljs-selector-tag">text-decoration</span> <span class="hljs-selector-pseudo">:none</span>
<span class="hljs-selector-tag">tt</span> = <span class="hljs-selector-tag">text-transform</span>

<span class="hljs-comment">/* Border */</span>
<span class="hljs-selector-tag">bd</span> = <span class="hljs-selector-tag">border</span>
<span class="hljs-selector-tag">bdrs</span> = <span class="hljs-selector-tag">border-radius</span>
<span class="hljs-selector-tag">bdrs50</span>% = <span class="hljs-selector-tag">border-radius</span>: 50%
<span class="hljs-comment">/*Some More */</span>
<span class="hljs-selector-tag">m</span> = <span class="hljs-selector-tag">margin</span>
<span class="hljs-selector-tag">t</span>= <span class="hljs-selector-tag">top</span>
<span class="hljs-selector-tag">d</span> = <span class="hljs-selector-tag">display</span>
<span class="hljs-selector-tag">pos</span> = <span class="hljs-selector-tag">position</span>
<span class="hljs-selector-tag">z</span>= <span class="hljs-selector-tag">z-index</span>
<span class="hljs-selector-tag">l</span>= <span class="hljs-selector-tag">left</span>
<span class="hljs-selector-tag">b</span> = <span class="hljs-selector-tag">bottom</span>
<span class="hljs-selector-tag">ov</span> = <span class="hljs-selector-tag">overflow</span>
<span class="hljs-selector-tag">d</span><span class="hljs-selector-pseudo">:f</span> = <span class="hljs-selector-tag">dislay</span><span class="hljs-selector-pseudo">:flex</span>
<span class="hljs-selector-tag">jc</span><span class="hljs-selector-pseudo">:c</span> = <span class="hljs-selector-tag">justify-content</span><span class="hljs-selector-pseudo">:center</span>
<span class="hljs-selector-tag">ai</span><span class="hljs-selector-pseudo">:c</span> = <span class="hljs-selector-tag">align</span>=<span class="hljs-selector-tag">-items</span>: <span class="hljs-selector-tag">center</span>

// <span class="hljs-selector-tag">we</span> <span class="hljs-selector-tag">can</span> <span class="hljs-selector-tag">give</span> <span class="hljs-selector-tag">value</span> <span class="hljs-selector-tag">by</span> : <span class="hljs-selector-tag">or</span> <span class="hljs-selector-tag">just</span> <span class="hljs-selector-tag">by</span> <span class="hljs-selector-tag">starting</span> <span class="hljs-selector-tag">letter</span> <span class="hljs-selector-tag">like</span>
<span class="hljs-selector-tag">df</span> = <span class="hljs-selector-tag">display</span><span class="hljs-selector-pseudo">:flex</span>; || <span class="hljs-selector-tag">d</span><span class="hljs-selector-pseudo">:f</span> = <span class="hljs-selector-tag">display</span> <span class="hljs-selector-pseudo">:flex</span>;
</code></pre>
<h2 id="heading-summary">Summary</h2>
<p>CSS provides beauty to the elements by using Cascading and specificity technique. It is used for styling the webpage. There are many libraries and CSS frameworks in the market which helps to write CSS or used the inbuilt components in our project which increase our productivity .</p>
<p><strong>Some CSS Libraries are : Bootstap, Bulma, Tailwind etc.</strong></p>
<p><strong>Some component-Library are : Shadcn, Daisy, Ant Design, Material Ui, Chakra Ui , Mantine etc.</strong></p>
<p>More Resources :</p>
<p><a target="_blank" href="https://www.tutorialspoint.com/css/css_cheat_sheet.htm">CSS Cheat Sheet</a></p>
]]></content:encoded></item><item><title><![CDATA[Mastering HTML: Discovering the Fundamental Tags]]></title><description><![CDATA[We used HTML to create webpage for our website. It use markup for formatting text and provide meaning behind the text.
What Is HTML
HTML is created under WWW. it is created to provide proper structure to the document so the browser understand how to ...]]></description><link>https://blogs.dipeshchaudhary.name.np/mastering-html-the-fundamental-tags</link><guid isPermaLink="true">https://blogs.dipeshchaudhary.name.np/mastering-html-the-fundamental-tags</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[HTML5]]></category><category><![CDATA[Hashnode]]></category><category><![CDATA[tags]]></category><category><![CDATA[Browsers]]></category><dc:creator><![CDATA[Dipesh Chaudhary]]></dc:creator><pubDate>Tue, 27 Jan 2026 06:32:17 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769494483462/40ac6253-0d3b-4095-896e-1a8b73d8f998.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>We used HTML to create webpage for our website. It use markup for formatting text and provide meaning behind the text.</p>
<h1 id="heading-what-is-html">What Is HTML</h1>
<p>HTML is created under WWW. it is created to provide proper structure to the document so the browser understand how to render the text on screen . Every things are text but HTML helps to give meaning of the different text like for image , there is <strong>img tag</strong>, for paragraph there is <strong>p tag</strong> , for bold and big heading/ main title of webpage , There is <strong>h1 tag</strong> , for link which is most important on the basis of which it is also called <strong>HyperText</strong> , There is <strong>a tag</strong> for it.</p>
<p>For every thing there are markup which is called Tag in HTML. Tags are used to define proper content that need to show on the screen . In HTML5 There are something called Semantic Tag. Semantic means provide meaning and structure which is easier to understand for both Browser and Developer. <strong>It is very important for SEO, screen readers and other tools to access and interpret with the content of webpage.</strong></p>
<p>Some Semantic Tags are :</p>
<p><strong>a . header</strong> : to show heading of website. &lt;header&gt;&lt;/header&gt;</p>
<p><strong>b . nav</strong> : to show navigation links on website . &lt;nav&gt;&lt;/nav&gt;</p>
<p><strong>c . main</strong> : it is used for main content of webpage . &lt;main&gt;&lt;/main&gt;</p>
<p><strong>d . aside</strong> : it is used for secondary info or additional information for webpage or mainly for sidebar . &lt;aside&gt;&lt;/side&gt;</p>
<p><strong>e . section ,article</strong> : section is used for section of page like About section, C.T.A. section, Testimonial section and article is used for mainly define one product , like on ecommerce website . the detail page for single product there article Tag is used for one product. &lt;section&gt;&lt;/section&gt; and &lt;article&gt;&lt;/article&gt;</p>
<p><strong>f. footer</strong> : footer is used for defining footer of website which is mainly at the bottom of page . it includes info about copyright . links of some extra resources . &lt;footer&gt;&lt;/footer&gt;</p>
<h2 id="heading-about-tag-content-element">About Tag , Content, Element</h2>
<p>from above section , We say Tag is used for markup the text. <strong>Tag</strong> has opening and closing part. The starting of Tag begins by <strong>&lt;Tagname&gt;</strong> and the ending part is <strong>&lt;/TagName&gt;.</strong></p>
<p>Content itself got meaning that the text which is written inside the between Opening Tag and Closing Tag is known as <strong>Content</strong> of Tag. on relation It is Child of Tag.</p>
<p><strong>Element</strong> is Overall structure of Tag with content. When Tag is used in webpage then it is called element . like paragraph we use p tag and when we used in code and it display on browser then we called it paragraph element or p tag.</p>
<p>By above scenario we can say There are few Tags which do not contain content between them so that is called <strong>void tag or self closing tag .</strong></p>
<p><strong>1 . Paired Tag</strong> : It always comes with opening and closing tag so it is called paired tags like &lt;p&gt;&lt;/p&gt;, &lt;strong&gt;&lt;/strong&gt;, &lt;date&gt;&lt;/date&gt;, &lt;code&gt;&lt;/code&gt;, &lt;div&gt;&lt;/div&gt;.</p>
<p><strong>2 . unpaired /empty/ void</strong> : it has only starting tag like &lt;img /&gt;, &lt;br /&gt;, &lt;hr /&gt;, &lt;input /&gt;. the slash at end gives developer about the the tag is self closed which makes developer easier to understand code. so always used slash at the end of empty tag . it is good for understanding purpose.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769494982200/cee9a3f2-c6d7-43ce-ad62-c99f03cd45aa.webp" alt /></p>
<h2 id="heading-some-most-used-tags">Some Most Used Tags</h2>
<p>Below is image showing HTML Code with most used Tag and Its output on browser.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769490835526/bb3cb38a-ec79-4cca-8a9f-de99b7096ffc.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-block-and-inline-elements">Block and Inline Elements</h2>
<p>Everything , every tag is displayed like <strong>rectangular box</strong> on browser screen. by default some elements are taking <strong>full width</strong> or some elements are taking <strong>content-size width</strong>. on the basis of that Elements are classified into <strong>two</strong> types :</p>
<p><strong>a. Block Level Element</strong> : These are the elements display as full width on the screen .The new Element comes after these type of elements into new line. examples like <code>div , p, h1-h6, nav, ul, li, ol, br, hr</code> …</p>
<p><strong>b. Inline Level Element</strong> : These are the elements who took only content-size width. and the another inline element comes side by side . examples : <code>img, a, button,span,input, label,strong,em,i</code>…</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769494519305/6fe2db9c-5fdc-4283-a754-6665ebcd10fc.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-behind-the-scenes">Behind the Scenes</h2>
<p>We know that browser can understand HTML so the browser engine got <strong>C++</strong> written code who understand the HTML and convert into proper structure that can be rendered on screen the Parsed HTML is called <strong>DOM</strong> which can be selected , modified and updated by using <strong>Javascript.</strong></p>
<h2 id="heading-summary">Summary</h2>
<p>HTML is <strong>HyperText Markup Programming Language</strong> that is used for creating structure of webpage . It is used for defining the content that can be shown on the screen by using tags</p>
]]></content:encoded></item><item><title><![CDATA[Behind The Scene Of How Browser Render Website]]></title><description><![CDATA[A Web browser a.k.a browser (Chrome, Edge, Firefox, Safari) used by people daily to visit websites, read news , watch videos on Youtube, reading documents, resources on Wikipedia and many more. s, it is used to show the resources what user want to to...]]></description><link>https://blogs.dipeshchaudhary.name.np/browser-internals-and-rendering-html</link><guid isPermaLink="true">https://blogs.dipeshchaudhary.name.np/browser-internals-and-rendering-html</guid><dc:creator><![CDATA[Dipesh Chaudhary]]></dc:creator><pubDate>Mon, 26 Jan 2026 21:48:30 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769461309178/96998684-cf7d-41da-8371-b8e9bc15b6d4.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>A Web browser a.k.a browser (Chrome, Edge, Firefox, Safari) used by people daily to visit <strong>websites, read news , watch videos on Youtube, reading documents, resources on Wikipedia and many more.</strong> s, it is used to show the resources what user want to to see/choose . It is like window, you can see through window just like that browser render the requested resources on screen (Browser Window).</p>
<h1 id="heading-overview">Overview</h1>
<p>Browser load files , convert into raw bytes (0,1), character encoding (utf-8), tokenization(h1,p,html,body), relation between element (parent,child), formed nodelist , create DOM . on parallel CSS also parsed , CSSOM created , merged DOM and CSSOM formed Render Tree, browser calculate size and position of element on render tree, painted into pixels and finally render on screen. JS →DOM when JS comes before DOM then first JS load and execute so it takes more priority but when CSSOM ←JS .JS executes halted until the CSS get ready.</p>
<h2 id="heading-how-browser-render-website-behind-the-scene">How Browser Render Website Behind The Scene</h2>
<p>All the browsers have some common UI like</p>
<ul>
<li><p>Address Bar for inserting URL</p>
</li>
<li><p>back and forward button</p>
</li>
<li><p>Bookmark button</p>
</li>
<li><p>Reloading and Stopping button to reload and stop the current documents</p>
</li>
<li><p>Home button that brings to Home page</p>
</li>
</ul>
<h3 id="heading-high-level-overview-of-browser">High Level Overview of Browser</h3>
<p>The main components of browser are :</p>
<p><strong>1 . The User Interface</strong> : it includes the UI part of browser. address bar , bookmark button , back/forward button, reload and stop button, homepage redirect button .</p>
<p><strong>2 . Browser Engine</strong> : it is middleman of browser. It is like traffic controller. every instruction is pass through Browser engine. it gives the required instruction to required part of browser (dispatcher). like when user type URL then it tells networking layer for make network request to fetch the requested resources and then it gives to rendering engine. some are :</p>
<ul>
<li><p>**Blink (**Chrome, Edge, Brave , new version of Opera)</p>
</li>
<li><p><strong>Webkit</strong> (Safari)</p>
</li>
<li><p><strong>Gecko</strong> (Mozilla FireFox)</p>
</li>
</ul>
<p><strong>3 . Rendering Engine</strong> : it is responsible for displaying requested data on screen. suppose the request is show webpage then first it parse HTML, CSS and then display the parsed content on screen.</p>
<p><strong>4 . Networking</strong> : it is responsible for network calls. like HTTP request .</p>
<p><strong>5 . Javascript Interpreter</strong> : It parse and execute scripts, Javascript code .</p>
<p><strong>6 . UI backend</strong> : It manages the UI of browser like where to show menus , back and forward button , Bookmark button , extensions and also it captures the events like mouse click, scrolls. It uses operating system Interface. for eg : when user click back button then it capture the click event and pass to browser engine and browser engine pass this to rendering engine and then rendering engine shows previous content.</p>
<p><strong>7 . Disk Api</strong> : it is data persistence layer . it includes local storage, session storage. It is used to store some pieces of information in the form of cookies or session.</p>
<p><img src="https://static.webplatform.org/f/f3/layers.png.pagespeed.ce.mFE5F8CtAV.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-html">HTML</h2>
<p>User use browser to request the resources they want. browser request server for response. server can send text, file, json, image, video, audio etc. server send response on the basis of request. but how user can request for resources . for this WWW is created.</p>
<p><strong>WWW (World Wide Web )</strong> is standards that is proposed to define the way to share and get data from server. It did three things</p>
<ul>
<li><p><strong>HTTP</strong> : http is created . it is used to get the data from server without accessing server. it is used to transfer resources from client to server and vice-versa . it works on application layer. it is used to make request of data from server.</p>
</li>
<li><p><strong>HTML</strong> : HTML is Markup language that is used to structure the webpage. without html , there is no structure of documents and which makes user more difficult to read and understand the resources so HTML gives tags that gives some meaning and structure and some visual representation on screen.</p>
</li>
<li><p><strong>URL Format</strong> : It define the way in which request can be done . like https://chaicode.com, https://dipeshchaudhary.name.np . whatever the resources to fetch define the URL in proper format.</p>
</li>
</ul>
<p><strong>Tim Berner Lee</strong> want to make some type of formatting Language that is used to define the writing way of documents because all the documents are in text format and also server responds back text response and when it render into screen it looks messy , not user friendly. it is more difficult to understand what are the heading and more important message of documents. so He created HTML which includes many tags that are used to define proper structure for documents and when it store on the server and when browser requested the documents , the server responds back with text in format of HTML . after that It renders on the screen .</p>
<p>HTML does three things :</p>
<p>1 . It makes the documents looks good.</p>
<p>2 . It provides proper meaning and structure of webpage.</p>
<p>3 . It includes hyperlink to link other resources inside one resource.</p>
<h3 id="heading-structure-of-tag">Structure Of Tag</h3>
<p>Tag has following structure:</p>
<p><strong>1 . Opening Tag</strong> : it is opening of tag . it use angular brackets &lt;&gt;</p>
<p><strong>2 . Closing Tag</strong> : It use &lt;/&gt; to close tag .</p>
<p>There are two types of Tag :</p>
<p><strong>a. Paired Tag</strong> : it comes into pairs of opening and closing tag. like &lt;p&gt;&lt;/p&gt;, &lt;h1&gt;&lt;/h1&gt;,&lt;div&gt;&lt;/div&gt;</p>
<p><strong>b. Unpaired Tag</strong> : it only comes with opening tag . it is also known as empty tag. like &lt;br&gt;, &lt;hr&gt;</p>
<p><strong>c. Self closing tag</strong> : the unpaired tags which used slash (/) at the end of opening tag to self closed . like <strong>&lt;img /&gt; , &lt;input /&gt;</strong> which is most common in react or <strong>XHTML</strong></p>
<p><strong>The complete structure of tag is called element</strong> .it includes starting tag, optional content , and closing tag like &lt;p&gt;This is paragraph &lt;/&gt; . on complete way it is called paragraph element.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Hi I am Paragraph Tag <span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
</code></pre>
<p>The <strong>Hyperlink</strong> make another call to sever for resource in format of like <code>https://docs.chaicode.com.</code></p>
<p>Tags are predefined element which are used to structure webpage like</p>
<p>1. for big and bold heading use h1 . it has 6 variants from h1-h6</p>
<p>2 . for paragraph and text use p tag</p>
<p>3 . to display image use img</p>
<p>4 . to display audio and video use audio and video tag</p>
<p>5 . for hyperlink use anchor tag which is a</p>
<p><strong>There are attributes used in tag , it provides look and behavior of tag</strong> . it is define inside opening tag and typically looks as <mark>name = “value”</mark> format</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"https://chaicode.com"</span> <span class="hljs-attr">target</span>=<span class="hljs-string">"_blank"</span>&gt;</span>chaicode<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"logo.png"</span> <span class="hljs-attr">alt</span>=<span class="hljs-string">"Logo of company"</span> <span class="hljs-attr">width</span>=<span class="hljs-string">"200"</span> <span class="hljs-attr">height</span>=<span class="hljs-string">"100"</span>&gt;</span>
</code></pre>
<p>When browser request through http to get homepage of chaicode.com then it request through URL like <code>http://chaicode.com</code>. The server does not understand that it want html format of text so browser also send additional information to sever which is called headers .there is <code>Content-Type : text/html</code> so that server responds back the html to the browser and browser render the html into screen.</p>
<h2 id="heading-how-browser-render-html">How Browser Render HTML</h2>
<p>When browser receive HTML as response from server . The server respond back with <code>Content-Type : text/html</code> . then the browser start the following process behind the scene :</p>
<p><strong>1 . Parsing</strong> : implementation of rules to make the code understandable for browser. the raw HTML and CSS parsed and construct the tree which is understandable for browser to render on screen. It has one works to form DOM Tree . There are two types of parsing :</p>
<p><strong>a . Conventional Parsing</strong> : CSS and Javascript are parsed by Conventional Parsing</p>
<p><strong>b . Unconventional Parsing</strong> : HTML is Unconventional Parsing</p>
<p><img src="https://static.webplatform.org/6/63/400x155wimage009.png.pagespeed.ic.KNewBFnKFk.png" alt class="image--center mx-auto" /></p>
<p>The following steps involves in rendering webpage :</p>
<p><strong>1 . Building DOM</strong> : The browser start by fetching HTML by HTTP Request. it <strong>tokenizes</strong> the element and form <strong>DOM Tree</strong> which contains content of page and hierarchy of element . It can be modified by using Javascript.</p>
<p><strong>2 . Creating CSSOM</strong> : In parallel , Browser fetches the css files and start to create CSSOM . This tree maps styles the elements. <strong>The parsing of HTML stops until the CSSOM is ready. so optimizing CSS files by media or using preload can speed up the rendering process.</strong></p>
<p><strong>3 . Generating Render Tree</strong> : <strong>The DOM and CSSOM are merged to form render tree</strong> . It only includes visible elements with computed styles . The <code>&lt;meta&gt;</code> and <code>display:none</code> elements are excluded.</p>
<p><strong>4 . Constructing Frames</strong> : Frame are constructed on the basis of Render Tree . It is like rectangular object for each element/node.</p>
<p><strong>5 . Layout (Reflow)</strong> : the browser calculates the exact size and position on the basis of CSS Box model(flexbox, css grid). <strong>Any Dom or styles change trigger the Reflow which are costly on performance</strong>. It is more computational or calculation heavy task.</p>
<p>**6 . Painting :**The render tree painted into pixels. then the browser apply color, border, shadow , images . complex effects like gradients can slow this process. It is more related to visuals like creative side of determining color, border, image etc.</p>
<p><strong>7 . Rendering :</strong> This is displaying the render tree on screen.</p>
<p><img src="https://static.webplatform.org/9/99/4b.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-why-there-is-www-before-domain-name-in-url">Why There is www before domain name in URL</h3>
<p><strong>WWW</strong> is standard and it reflect that the response coming back from server is html format so It obvious the user that the requesting data comes about the webpage that will bring the webpage. so there is www used in URL when to make website call or when we need HTML response from server.</p>
<p>like <code>https://www.chaicode.com</code> it gives landing page of most useful and beautiful <strong>Chaicode website</strong>. and <strong>Server who return html response is called web server.</strong></p>
<h2 id="heading-summary">Summary</h2>
<p>Browser is so powerful and it is OS in itself. There are so many layers which work together to run the applications, software efficiently and smoothly .This was the the overview of the browser internal how browser make call the http request to the server and server responds back as the response on the basis of requested data and then the browser look to the header where there is Content-Type then the rendering process start . first parsed HTML and CSS to create render tree and then the browser create frame and do the process of reflow and painting means showing in pixels and then finally the webpage of website got render n he screen . Through Browser Most of people are connected to Internet.</p>
<p>More Resources :</p>
<ul>
<li><p><a target="_blank" href="https://developer.chrome.com/blog/round-up-of-web-browser-internals-resources">Blogs on Browser Inernals by developer.chrome</a></p>
</li>
<li><div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://youtu.be/5rLFYtXHo9s">https://youtu.be/5rLFYtXHo9s</a></div>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[TCP Working: 3-Way Handshake & Reliable Communication]]></title><description><![CDATA[Computers are connected on Internet to share information , communicates with other computer. For communication some rules required just like Grammer is needed for english speaking . These rules called Protocols in computer language. TCP is communicat...]]></description><link>https://blogs.dipeshchaudhary.name.np/detailing-on-3-way-handshake-process</link><guid isPermaLink="true">https://blogs.dipeshchaudhary.name.np/detailing-on-3-way-handshake-process</guid><dc:creator><![CDATA[Dipesh Chaudhary]]></dc:creator><pubDate>Sat, 24 Jan 2026 10:44:23 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769251934499/6929fc88-4c3f-407c-b9bf-44594e7e845d.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><img src="https://image1.slideserve.com/2396822/the-three-way-handshake-l.jpg" alt class="image--center mx-auto" /></p>
<p>Computers are connected on Internet to share information , communicates with other computer. For communication some rules required just like Grammer is needed for english speaking . These rules called Protocols in computer language. TCP is communication protocol of internet suite and it operates at Transport layer of OSI model which is short form of <strong>(Open System Interconnection).</strong></p>
<h2 id="heading-understanding-the-basics">Understanding the basics</h2>
<p>Before diving on the 3-way handshake process . let’s learn about to main players in any network communication :</p>
<ul>
<li><p>Client : This is the computer who request the information or service</p>
</li>
<li><p>Server : This is computer or system who provides the requested information or services</p>
</li>
</ul>
<p>Now Imagine you want to visit website how the browser and the server are connect with each other. That’s where the 3-way handshake enter the scene.</p>
<p><img src="https://wsrv.nl/?url=https://gallery.cyndia.in/32a22723-1153-4f1b-a172-0080e2dbf007.png&amp;output=webp&amp;q=70&amp;w=1920" alt class="image--center mx-auto" /></p>
<h2 id="heading-3-way-handshake-process">3-Way Handshake Process</h2>
<p><strong>Step 1: SYN (Synchronize)</strong></p>
<p>Imagine you computer which is client want to talk to server . To start conversation . client send special message like saying “Hello , can we chat ?”. This message called SYN Packet. It includes a secret code which is called sequence number to keep things organized for future talks. It is like client raising hand to get attention of server and say “Hey , I’d like to connect with you !”</p>
<h3 id="heading-what-is-sequence-number">What is Sequence Number</h3>
<p>It is like putting number on your message so that other side knows in which number message are sent. Each message got unique number so that it helps to check the message received in right order or not.</p>
<p><strong>Step 2 : SYN-ACK (Synchronize-Acknowledge)</strong></p>
<p>When server receive “Hello” Client message (SYN Packet). The server acknowledges the client's message and says, "Yes, I got your request to chat! Let's do it." The server also shares its own secret code (sequence number) with the client. This second step is like the server responding, "Hey, I heard you! I'm ready to connect too."</p>
<p><strong>Step 3: ACK (Acknowledge)</strong></p>
<p>Now, the client, having received the server's friendly wave (SYN-ACK packet), gives a virtual high-five back. It says, "Great! I'm ready to chat too." The client also includes its own secret code, increasing it by one. When the server gets this high-five (ACK packet), it also increases its secret code. This third step is like both sides saying, "We're good to go! Let's start our conversation."</p>
<p>So, after these three friendly steps, the client and server are now connected and ready to share information like good pals chatting away! This whole process is called the 3-Way Handshake because it involves three steps, kind of like a friendly greeting before diving into a conversation.</p>
<p><img src="https://wsrv.nl/?url=https://gallery.cyndia.in/b80d06df-cae4-4121-b768-085bc818f1a4.png&amp;output=webp&amp;q=70&amp;w=1920" alt class="image--center mx-auto" /></p>
<h2 id="heading-what-is-tcp">What is TCP</h2>
<p>TCP, or Transmission Control Protocol, is a crucial part of the Internet Protocol (IP) suite. It operates in the transport layer and is responsible for establishing, maintaining, and completing connections between devices. TCP ensures reliable and connection-oriented communication, making sure that data reaches its destination accurately and in the right order.</p>
<p>TCP is widely used in applications that require dependable and accurate data delivery, such as web browsing, email, file transfer (FTP), and remote terminal access like SSH.</p>
<p>TCP does 3 things:</p>
<ul>
<li><p>It breaks the message into small packets.</p>
</li>
<li><p>it numbers them so they arrive in right order</p>
</li>
<li><p>it checks the every packet received</p>
</li>
<li><p>if something missing , resends it</p>
</li>
</ul>
<h2 id="heading-tcp-flags">TCP Flags</h2>
<p>These are special flags that help control communication between the sender and receiver. These flags provide specific information about the communication.</p>
<p><strong>1 . SYN (Synchronize):</strong></p>
<p>Used to start a connection. When a client wants to establish a connection with a server, it sends a TCP packet with the SYN flag set. The server responds with a SYN-ACK packet.</p>
<p><strong>2 .ACK (Acknowledge):</strong></p>
<p>Indicates the acknowledgment field. It confirms that data has been received correctly.</p>
<p><strong>3 .FIN (Finish):</strong></p>
<p>Signals the sender to close the connection. Both the client and server use this flag to end the connection.</p>
<p><strong>4 .RST (Reset):</strong></p>
<p>Resets the connection. This flag is used when there's an error or an unknown condition, and the connection needs to be terminated immediately.</p>
<p>These flags exist as bits in the TCP header and are set or unset to convey specific information. They play a role in indicating the state of the connection. For example, in the TCP handshake, SYN and ACK flags are used, while in connection termination, the FIN flag is utilized. Together, these flags allow TCP to effectively manage and control communication between devices.</p>
<h2 id="heading-why-is-3-way-handshake-important"><strong>Why is 3-Way Handshake Important ?</strong></h2>
<ul>
<li><p><strong>Reliability:</strong> It ensures that both the client and server are ready to communicate before sharing data.</p>
</li>
<li><p><strong>Security:</strong> The handshake helps prevent unauthorized access and ensures a secure connection.</p>
</li>
<li><p><strong>Error Handling:</strong> If any step fails, the connection isn't established, preventing potential issues.  </p>
</li>
</ul>
<h2 id="heading-kio">**</h2>
<p>Conclusion**</p>
<p>The 3-Way Handshake might sound complex, but it's essentially a digital greeting that ensures a smooth and secure conversation between your device and the server. Just like introducing yourself before starting a chat with a friend, the handshake establishes a reliable connection, making the vast world of computer networking a little less mysterious for beginners. So, the next time while browse a website or send a message, remember the friendly 3-Way Handshake that makes it all possible!</p>
]]></content:encoded></item></channel></rss>