<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Hari Karthyk on Medium]]></title>
        <description><![CDATA[Stories by Hari Karthyk on Medium]]></description>
        <link>https://medium.com/@harikarthyk?source=rss-23a6d93c29a1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*A5P6LVIU0qf82wBgxpn8Gg.png</url>
            <title>Stories by Hari Karthyk on Medium</title>
            <link>https://medium.com/@harikarthyk?source=rss-23a6d93c29a1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 14:08:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@harikarthyk/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Life Cycle in React JS]]></title>
            <link>https://harikarthyk.medium.com/life-cycle-in-react-js-1f16e2a85e4c?source=rss-23a6d93c29a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f16e2a85e4c</guid>
            <category><![CDATA[life-cycle-of-react]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-class-component]]></category>
            <dc:creator><![CDATA[Hari Karthyk]]></dc:creator>
            <pubDate>Fri, 27 May 2022 10:31:30 GMT</pubDate>
            <atom:updated>2022-05-27T10:31:30.740Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*W4RpsevxbZZeXWMD" /><figcaption>Photo by <a href="https://unsplash.com/@flowforfrank?utm_source=medium&amp;utm_medium=referral">Ferenc Almasi</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In React Everything has a lifecycle that can be observed or controlled during three phases</p><ol><li><strong>Mounting</strong></li><li><strong>Updating</strong></li><li><strong>Unmounting</strong></li></ol><h3><strong>Mounting</strong></h3><ol><li>constructor</li><li>getDerivedStateFromStaticProps</li><li>render</li><li>componentDidMount</li></ol><h3><strong>Updating</strong></h3><ol><li>shouldComponentUpdate</li><li>componentDidUpdate</li><li>getSnapShotBeforeUpdate</li><li>render</li></ol><h3>Unmount</h3><ol><li>componentWillUnmount</li></ol><p>Apart from this, we have</p><ol><li>componentDidCatch(To Catch Error)</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f16e2a85e4c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Coding Splitting In React Apps]]></title>
            <link>https://harikarthyk.medium.com/why-coding-splitting-in-react-apps-72d275ce8111?source=rss-23a6d93c29a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/72d275ce8111</guid>
            <category><![CDATA[lazy-loading]]></category>
            <category><![CDATA[bundling]]></category>
            <category><![CDATA[react-core-concept]]></category>
            <category><![CDATA[code-splitting]]></category>
            <category><![CDATA[webpack]]></category>
            <dc:creator><![CDATA[Hari Karthyk]]></dc:creator>
            <pubDate>Sat, 07 Aug 2021 18:24:30 GMT</pubDate>
            <atom:updated>2021-08-07T18:24:30.588Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/471/1*qpbkIMTbzbMdWpvhZsDhZA.jpeg" /></figure><blockquote>Code splitting helps in Increasing the Efficiency of the App by reducing the loading time of the browers</blockquote><h4>First of all why code-splitting?</h4><p>In React Apps Everything is bundled. File budling is the process of merging and importing all files into one single file. For budling, files React using <a href="https://webpack.js.org/">Webpack</a>.</p><h4>Now comes the question of why bundling the files?</h4><p>Bundling your files helps in optimization and reduces the time it takes for your page to load because the browser doesn’t have to run separate files while loading the web app.</p><p>Okay, then Bundling helps the browsers to run the App fast then why code splitting.</p><blockquote>Bundling helps React App to load Pages fastly but lets make it even more faster.</blockquote><p>Coming to the point while starting the react app entire app bundle gets loaded for the first time this doesn’t affect the small application but a bigger application where some third-party libraries are also present in the same bundle loads which makes the App slow to avoid this code splitting can be done.</p><h4>React has a function call “React.lazy()” that makes it possible to render dynamic imports as regular components.</h4><ol><li>While using the Lazy() suspense component is a must.</li></ol><p>2. Suspense is nothing but the component that accepts a fallback prop that can be rendered while your component is still loading and this can easily be achieved by wrapping your lazy-loaded components</p><p>Refer to this video for a better understanding</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Ffakjx6VW-5k%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dfakjx6VW-5k&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Ffakjx6VW-5k%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e44914a45f22ece9a9d7e730c24a91cb/href">https://medium.com/media/e44914a45f22ece9a9d7e730c24a91cb/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72d275ce8111" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Video Calling feature in React-Native using Twilio]]></title>
            <link>https://harikarthyk.medium.com/a-video-calling-feature-in-react-native-using-twilio-53130d91fef7?source=rss-23a6d93c29a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/53130d91fef7</guid>
            <category><![CDATA[twilio]]></category>
            <category><![CDATA[twilio-integration]]></category>
            <category><![CDATA[video-calling-app]]></category>
            <category><![CDATA[react-native-app]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Hari Karthyk]]></dc:creator>
            <pubDate>Sat, 29 May 2021 08:44:40 GMT</pubDate>
            <atom:updated>2021-05-29T08:44:40.546Z</atom:updated>
            <content:encoded><![CDATA[<h3>Video Calling App with React-Native</h3><blockquote>A Video Calling feature in React-Native using Twilio</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*lP_BK7v2BN_yEdSNcMqg6g.jpeg" /></figure><p><strong>Step 1</strong></p><ol><li>Create an account on Twilio: <a href="https://www.twilio.com/console">https://www.twilio.com/console</a></li><li>Now you have to create an API KEY for your App</li><li>Go to settings → API keys → no create your API KEY</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yhbrrcdDw5Pl7vy9F3MgvQ.png" /></figure><ol><li>take a copy for your ACCOUNT_SID, APK_SID, and APK_KEY</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QJiyFtIWx6ZR-6C6Quzjvw.png" /><figcaption>Account SID present in the Dashboard Screen</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y7Qp1RkyHwjMBFso4F9lMg.png" /><figcaption>For API Key have some name (click on generate key)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yhbrrcdDw5Pl7vy9F3MgvQ.png" /><figcaption>Make a not of SID and Secret Key for later use</figcaption></figure><p><strong>Step 2</strong></p><p>→ Now create your server using Node.js</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528171%252C%2B184%252C%2B195%252C%2B1%2529%26t%3Dsolarized%2Bdark%26wt%3Dnone%26l%3Dauto%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Drequire%2528%252522dotenv%252522%2529.config%2528%2529%25253B%25250Aconst%252520express%252520%25253D%252520require%2528%252522express%252522%2529%25253B%25250Aconst%252520app%252520%25253D%252520express%2528%2529%25253B%25250A%25250Aapp.use%2528express.json%2528%2529%2529%25253B%25250Aapp.use%2528express.urlencoded%2528%25257Bextended%25253A%252520false%25257D%2529%2529%25253B%25250A%25250Avar%252520AccessToken%252520%25253D%252520require%2528%252522twilio%252522%2529.jwt.AccessToken%25253B%25250Avar%252520VideoGrant%252520%25253D%252520AccessToken.VideoGrant%25253B%25250A%25250A%25252F%25252F%252520Substitute%252520your%252520Twilio%252520AccountSid%252520and%252520ApiKey%252520details%25250Avar%252520ACCOUNT_SID%252520%25253D%252520process.env.ACCOUNT_SID%25253B%25250Avar%252520API_KEY_SID%252520%25253D%252520process.env.API_KEY_SID%25253B%25250Avar%252520API_KEY_SECRET%252520%25253D%252520process.env.API_KEY_SECRET%25253B%25250A%25250A%25252F%25252F%252520Create%252520an%252520Access%252520Token%25250Avar%252520accessToken%252520%25253D%252520new%252520AccessToken%2528ACCOUNT_SID%25252C%252520API_KEY_SID%25252C%252520API_KEY_SECRET%2529%25253B%25250A%25250Aapp.get%2528%252522%25252F%252522%25252C%252520%2528req%25252C%252520res%2529%252520%25253D%25253E%252520%25257B%25250A%252509res.send%2528%252522Server%252520is%252520running%252520successfully...%252522%2529%25253B%25250A%25257D%2529%25253B%25250A%25250Aapp.post%2528%252522%25252Fapi%25252Ftoken%25252F%25253AuserId%252522%25252C%252520%2528req%25252C%252520res%2529%252520%25253D%25253E%252520%25257B%25250A%252509%25252F%25252F%252520Set%252520the%252520Identity%252520of%252520this%252520token%25250A%252509accessToken.identity%252520%25253D%252520req.params.userId%25253B%25250A%25250A%252509%25252F%25252F%252520Grant%252520access%252520to%252520Video%25250A%252509var%252520grant%252520%25253D%252520new%252520VideoGrant%2528%2529%25253B%25250A%252509grant.room%252520%25253D%252520req.body.roomName%25250A%252509%252509%25253F%252520req.body.roomName%25250A%252509%252509%25253A%252520%252522%252520Twilio_Vedio_Calling_Room_Name%252522%25253B%25250A%252509accessToken.addGrant%2528grant%2529%25253B%25250A%252509%25252F%25252F%252520Serialize%252520the%252520token%252520as%252520a%252520JWT%25250A%252509var%252520jwt%252520%25253D%252520accessToken.toJwt%2528%2529%25253B%25250A%25250A%252509res.status%2528200%2529.json%2528%25257B%25250A%252509%252509token%25253A%252520jwt%25252C%25250A%252509%25257D%2529%25253B%25250A%25257D%2529%25253B%25250A%25250Aconst%252520PORT%252520%25253D%252520process.env.PORT%252520%25257C%25257C%2525205050%25253B%25250A%25250Aapp.listen%2528PORT%25252C%252520%2528%2529%252520%25253D%25253E%252520console.log%2528%252560Server%252520is%252520running%252520at%252520PORT%252520%252524%25257BPORT%25257D%252560%2529%2529%25253B%25250A&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528171%25252C%2B184%25252C%2B195%25252C%2B1%252529%26t%3Dsolarized%2Bdark%26wt%3Dnone%26l%3Dauto%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Drequire%252528%25252522dotenv%25252522%252529.config%252528%252529%2525253B%2525250Aconst%25252520express%25252520%2525253D%25252520require%252528%25252522express%25252522%252529%2525253B%2525250Aconst%25252520app%25252520%2525253D%25252520express%252528%252529%2525253B%2525250A%2525250Aapp.use%252528express.json%252528%252529%252529%2525253B%2525250Aapp.use%252528express.urlencoded%252528%2525257Bextended%2525253A%25252520false%2525257D%252529%252529%2525253B%2525250A%2525250Avar%25252520AccessToken%25252520%2525253D%25252520require%252528%25252522twilio%25252522%252529.jwt.AccessToken%2525253B%2525250Avar%25252520VideoGrant%25252520%2525253D%25252520AccessToken.VideoGrant%2525253B%2525250A%2525250A%2525252F%2525252F%25252520Substitute%25252520your%25252520Twilio%25252520AccountSid%25252520and%25252520ApiKey%25252520details%2525250Avar%25252520ACCOUNT_SID%25252520%2525253D%25252520process.env.ACCOUNT_SID%2525253B%2525250Avar%25252520API_KEY_SID%25252520%2525253D%25252520process.env.API_KEY_SID%2525253B%2525250Avar%25252520API_KEY_SECRET%25252520%2525253D%25252520process.env.API_KEY_SECRET%2525253B%2525250A%2525250A%2525252F%2525252F%25252520Create%25252520an%25252520Access%25252520Token%2525250Avar%25252520accessToken%25252520%2525253D%25252520new%25252520AccessToken%252528ACCOUNT_SID%2525252C%25252520API_KEY_SID%2525252C%25252520API_KEY_SECRET%252529%2525253B%2525250A%2525250Aapp.get%252528%25252522%2525252F%25252522%2525252C%25252520%252528req%2525252C%25252520res%252529%25252520%2525253D%2525253E%25252520%2525257B%2525250A%25252509res.send%252528%25252522Server%25252520is%25252520running%25252520successfully...%25252522%252529%2525253B%2525250A%2525257D%252529%2525253B%2525250A%2525250Aapp.post%252528%25252522%2525252Fapi%2525252Ftoken%2525252F%2525253AuserId%25252522%2525252C%25252520%252528req%2525252C%25252520res%252529%25252520%2525253D%2525253E%25252520%2525257B%2525250A%25252509%2525252F%2525252F%25252520Set%25252520the%25252520Identity%25252520of%25252520this%25252520token%2525250A%25252509accessToken.identity%25252520%2525253D%25252520req.params.userId%2525253B%2525250A%2525250A%25252509%2525252F%2525252F%25252520Grant%25252520access%25252520to%25252520Video%2525250A%25252509var%25252520grant%25252520%2525253D%25252520new%25252520VideoGrant%252528%252529%2525253B%2525250A%25252509grant.room%25252520%2525253D%25252520req.body.roomName%2525250A%25252509%25252509%2525253F%25252520req.body.roomName%2525250A%25252509%25252509%2525253A%25252520%25252522%25252520Twilio_Vedio_Calling_Room_Name%25252522%2525253B%2525250A%25252509accessToken.addGrant%252528grant%252529%2525253B%2525250A%25252509%2525252F%2525252F%25252520Serialize%25252520the%25252520token%25252520as%25252520a%25252520JWT%2525250A%25252509var%25252520jwt%25252520%2525253D%25252520accessToken.toJwt%252528%252529%2525253B%2525250A%2525250A%25252509res.status%252528200%252529.json%252528%2525257B%2525250A%25252509%25252509token%2525253A%25252520jwt%2525252C%2525250A%25252509%2525257D%252529%2525253B%2525250A%2525257D%252529%2525253B%2525250A%2525250Aconst%25252520PORT%25252520%2525253D%25252520process.env.PORT%25252520%2525257C%2525257C%252525205050%2525253B%2525250A%2525250Aapp.listen%252528PORT%2525252C%25252520%252528%252529%25252520%2525253D%2525253E%25252520console.log%252528%25252560Server%25252520is%25252520running%25252520at%25252520PORT%25252520%25252524%2525257BPORT%2525257D%25252560%252529%252529%2525253B%2525250A&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/1023b4d040ec5f71b1f2781872c02ab8/href">https://medium.com/media/1023b4d040ec5f71b1f2781872c02ab8/href</a></iframe><p>→ You can host it on Heroku or any other platform or even in localhost</p><p><strong>Step 3</strong></p><p>→ Coming to the Application</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/767e47214ced55fdc0c287aae6a84b25/href">https://medium.com/media/767e47214ced55fdc0c287aae6a84b25/href</a></iframe><p><strong>Step 4</strong></p><p>NOTE : <br>Dependencies required (Server) :</p><p>→ express, twilio, dotenv</p><p>App :</p><p>→ axios , react , react-native , react-native-normalize , react-native-responsive-screen , react-native-twilio-video-webrtc , react-native-vector-icons</p><p>NOTE : link all the dependencies properly special mention to react-native-vector -icons</p><p>LinkedIn : <a href="https://www.linkedin.com/in/harikarthyk/">https://www.linkedin.com/in/harikarthyk/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=53130d91fef7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Objects in JavaScript]]></title>
            <link>https://harikarthyk.medium.com/objects-in-javascript-7cd9aa220990?source=rss-23a6d93c29a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/7cd9aa220990</guid>
            <category><![CDATA[new-keyword]]></category>
            <category><![CDATA[objects]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <category><![CDATA[objects-in-javascript]]></category>
            <dc:creator><![CDATA[Hari Karthyk]]></dc:creator>
            <pubDate>Wed, 27 Jan 2021 18:02:48 GMT</pubDate>
            <atom:updated>2021-01-28T03:06:25.766Z</atom:updated>
            <content:encoded><![CDATA[<h3>“Objects” in JavaScript</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*O-Ur9p6VWAxpY2aNt4yJEg.png" /></figure><h3>What is an Object?</h3><p>→ Any value that’s not of a primitive type (a string, a number, a boolean, a symbol, null, or undefined) is an object.</p><p>→ For Instance: Array, functions are also treated as an object by JavaScript.</p><h3>Creating Object</h3><p>Objects in JavaScript can be created in multiple ways</p><ol><li>Here’s how we define an object:</li></ol><pre>const User = {</pre><pre>}</pre><p>This is the object literal syntax.</p><p>2. You can also initialize an object using the new keyword. here the function acts as a constructor for that object. In this, we can initialize the value.</p><p><a href="https://hari-jsmith494.medium.com/this-in-java-script-fb0d6af75437"><em>Read this blog to know more about this keyword in JavaScript</em></a></p><pre><br>const User = function(name , courseCount){<br>    this.name = name ; <br>    this.courseCount = courseCount ;<br>}</pre><pre>//without using new keyword<br>const newUser1 = User(&quot;newUser1&quot; , 2) ;</pre><pre>console.log(newUser1) ; </pre><pre>//OUTPUT </pre><pre>//undefined </pre><p>→ This is because this is a <strong>normal function</strong> that <strong>refers to global object/window object</strong>, hence “name” and “coureCount” are not defined globally undefined.</p><p>→ To overcome this we use the <strong>new </strong>keyword to create an object, here new is used because this tells the JS engine that now the User has a separate scope that is pointing to “newUser1”.</p><pre>const User = function(name , courseCount){<br>    this.name = name ; <br>    this.courseCount = courseCount ;<br>}</pre><pre>const newUser1 = new User(&quot;newUser1&quot; , 2) ;</pre><pre>console.log(newUser1) ;</pre><pre>//OUTPUT </pre><pre>//User{<br>//   name:&quot;newUser1&quot;,<br>//   courseCount:2<br>//}</pre><h3>Object Properties</h3><p>→ Objects have properties, which have a label associated with a value to it</p><p>→ The value of a property can be of any type, which means that it can be an array, a function, and it can even be an object, as objects can nest other objects</p><p>For Instance,</p><pre>const car = {<br>    name : &quot;carName&quot; ,<br>    model : &quot;DummyModel&quot; ,<br>    showModelName : function(){<br>        console.log(`Model Name : ${this.model}`);<br>    }<br>}</pre><p>here “name” is the label and “carName ”is the value, similarly, we can have the values as an object, function, array …</p><h3>We can retrieve the value of a property using 2 different syntaxes</h3><p>→ The first is dot notation:</p><pre>car.name //&quot;carName&quot;</pre><p>→ The Second is to use Square brackets</p><pre>car[&#39;name&#39;] //&quot;carName&quot;</pre><h3>Object Methods</h3><p>Functions can be assigned to function properties, and in this case, they are called methods.</p><pre>const car = {<br>    name : &quot;carName&quot; ,<br>    model : &quot;DummyModel&quot;,<br>    showModelName : function(){<br>        console.log(`Model Name : ${this.model}`);<br>    }<br>}</pre><pre>car.showModelName();</pre><p>In this, we can access name and model properties value by this keyword.</p><blockquote>Note: Arrow function <strong>can’t be used as a method inside an object</strong> this is because <strong>Arrow Function</strong> has its own scope</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7cd9aa220990" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Transmission Control Protocol (TCP)]]></title>
            <link>https://harikarthyk.medium.com/transmission-control-protocol-tcp-e1493fdf5635?source=rss-23a6d93c29a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/e1493fdf5635</guid>
            <category><![CDATA[client-server]]></category>
            <category><![CDATA[socketio]]></category>
            <category><![CDATA[tcp-ip]]></category>
            <category><![CDATA[tcp]]></category>
            <category><![CDATA[socket-programming]]></category>
            <dc:creator><![CDATA[Hari Karthyk]]></dc:creator>
            <pubDate>Tue, 22 Dec 2020 02:24:47 GMT</pubDate>
            <atom:updated>2020-12-22T04:00:34.469Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/659/1*euqefUpnrp9oy5KqOdO-Zg.jpeg" /></figure><p>It is a connection-oriented communication protocol that helps the exchange of message between the commuting device</p><p>The most common protocol in networks that use the Internet Protocol(IP); together they are sometimes referred to as TCP/IP.</p><p>TCP takes messages from an application/server and divides them into <a href="https://www.sdxcentral.com/resources/glossary/packet/">p</a>ackets, which can then be forwarded by the devices in the network — <a href="https://www.sdxcentral.com/resources/glossary/switch/">s</a>witches, <a href="https://www.sdxcentral.com/resources/glossary/routers/">r</a>outers, security gateways to the destination.</p><p>It ensures a connection is established and maintained until the exchange between the application/servers sending and receiving the message is complete.</p><p><strong>Internet Protocol (IP)</strong></p><p>Internet Protocol has some set of rules for how data should be transferred over the public network.</p><p>Often works in conjunction with TCP, which divides the traffic into packets for efficient transport through the Internet; together they are referred to as TCP/IP.</p><h3>TCP socket programming in Node.js</h3><p>Eager to know how sockets are programmed in Node? There are three variants of sockets in Node:</p><ol><li>TCP</li><li>UDP</li></ol><p>In this particular post, I will show you the basics of TCP socket programming in Node.js.</p><p>There are two categories of TCP socket programs you can write:</p><ol><li>Server — listens for connections to it from clients and send data to the client</li><li>Client — connects to a TCP server exchange data with it. The communication between client and server happens via sockets</li></ol><p>Programming TCP sockets in Node requires the net module, which is an asynchronous wrapper for network programming. The net module is capable of many things, but for today we&#39;ll just focus on creating a TCP server and a client.</p><p><strong>Writing TCP Server</strong></p><pre>var <em>net</em> = require(&quot;net&quot;);</pre><pre>var HOST = &quot;127.0.0.1&quot;;</pre><pre>var PORT = 6969;</pre><pre><em><br>net</em>.createServer(function (<em>sock</em>) {</pre><pre>        console.log(&quot;CONNECTED: &quot; + <em>sock</em>.remoteAddress + &quot;:&quot; +            <em>sock</em>.remotePort);</pre><pre><em>        sock</em>.on(&quot;data&quot;, function (<em>data</em>) {</pre><pre>        console.log(&quot;DATA &quot; + <em>sock</em>.remoteAddress + &quot;: &quot; + <em>data</em>);</pre><pre><em>        sock</em>.write(&#39;You said &quot;&#39; + <em>data</em> + &#39;&quot;&#39;);<br>    });</pre><pre><em>    sock</em>.on(&quot;close&quot;, function (<em>data</em>) {</pre><pre>        console.log(&quot;CLOSED: &quot; + <em>sock</em>.remoteAddress + &quot; &quot; + <em>sock</em>.remotePort);</pre><pre>   });</pre><pre>}).listen(PORT, HOST);</pre><pre>console.log(&quot;Server listening on &quot; + HOST + &quot;:&quot; + PORT);</pre><p><strong>Writing TCP Client</strong></p><pre>var <em>net</em> = require(&quot;net&quot;);</pre><pre>var HOST = &quot;127.0.0.1&quot;;</pre><pre>var PORT = 6969;</pre><pre>var client = <strong>new</strong> <em>net</em>.Socket();</pre><pre>client.connect(PORT, HOST, function () {</pre><pre>      console.log(&quot;CONNECTED TO: &quot; + HOST + &quot;:&quot; + PORT);</pre><pre>      client.write(&quot;I am Chuck Norris!&quot;);</pre><pre>});<br></pre><pre>client.on(&quot;data&quot;, function (<em>data</em>) {</pre><pre>     console.log(&quot;DATA: &quot; + <em>data</em>);</pre><pre>     client.destroy();</pre><pre>});<br></pre><pre>client.on(&quot;close&quot;, function () {</pre><pre>     console.log(&quot;Connection closed&quot;);</pre><pre>});</pre><p>So that’s the very basics of TCP socket programming in Node.js, hope it helped you understand socket programming in Node better.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e1493fdf5635" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DOM VS VIRTUAL DOM VS SHADOW DOM]]></title>
            <link>https://harikarthyk.medium.com/dom-vs-virtual-dom-vs-shadow-dom-a408badd6536?source=rss-23a6d93c29a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/a408badd6536</guid>
            <category><![CDATA[javascript-dom]]></category>
            <category><![CDATA[shadow-dom]]></category>
            <category><![CDATA[dom-vs-virtual-dom]]></category>
            <category><![CDATA[react-virtual-dom]]></category>
            <category><![CDATA[document-object-model]]></category>
            <dc:creator><![CDATA[Hari Karthyk]]></dc:creator>
            <pubDate>Wed, 02 Dec 2020 03:36:51 GMT</pubDate>
            <atom:updated>2020-12-02T03:36:51.806Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*g5CEOHeYAZIm9aYpo-Lncw.png" /></figure><h3>DOM</h3><blockquote>As most of you know <strong>DOM </strong>refers to<strong> DOCUMENT OBJECT MODEL</strong> which is nothing but the Nested Tree structure of the HTML / XML code.</blockquote><p>→ Each node in the tree is an Object representing HTML elements.</p><p>→ DOM allows HTML code to connect with JavaScript, DOM can be manipulated directly (i.e) <em>documet.getElementById().</em></p><h4>The workflow of Web Browers</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*Ms00nTd13OyvD6NsV1fv-A.png" /></figure><p>→ DOM tree itself is constructed by the rendering engines.</p><p>→ Now the CSS is applied to HTML creating the render tree.</p><p>→ Now the render tree is painted in the browser.</p><blockquote>Now Updating this tree becomes Expensive, to overcome this frameworks like React, Vue, Angular, etc uses <strong>Virtual DOM</strong>.</blockquote><h3>VIRTUAL DOM</h3><p>→ Instead of changing all the changes to the real DOM first, these are applied to the virtual DOM.</p><p>→ virtual DOM is not rendered directly, It is stored in the memory of the framework used.</p><p>→ virtual DOM is a lightweight representation of real DOM.</p><p>→ It is just a plain JavaScript object tree.</p><h4>How Virtual DOM Works</h4><p>→ The changes made first updates the virtual DOM where now the differences between both real DOM and virtual DOM are rendered in the real DOM.</p><p>→ It does render everything so virtual DOM is fast and efficient</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*NvqRzlNKTJ_KwlXQC60MSA.png" /></figure><h3>SHADOW DOM</h3><p>→ Shadow DOM allows creating the Custom Components.</p><p>→ It allows a component to have it&#39;s very own “shadow” DOM tree, that can’t be accidentally accessed from the main document, may have local style rules, and more.</p><p>→ To inspect the shadow dom code in Chrome</p><p><em>Settings → Elements → (check) Show user agent shadow DOM</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*r7yu9zigiGC4uOgFq1i_cg.png" /></figure><p>→ Have their own ids space,</p><p>→ Invisible to JavaScript selectors from the main document, such as querySelector,</p><p>→ Use styles only from the shadow tree, not from the main document.</p><h4>References :</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F7Tok22qxPzQ%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D7Tok22qxPzQ&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F7Tok22qxPzQ%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/9bffee28392633379b41238e9b7d0bfe/href">https://medium.com/media/9bffee28392633379b41238e9b7d0bfe/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fd7pyEDqBDeE%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dd7pyEDqBDeE&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fd7pyEDqBDeE%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/a78e83d52876ad045af0e57b7b62a8dd/href">https://medium.com/media/a78e83d52876ad045af0e57b7b62a8dd/href</a></iframe><p>Github: <a href="https://github.com/Harikarthyk">https://github.com/Harikarthyk</a>/</p><p>LinkedIn: <a href="https://www.linkedin.com/in/hari-karthikkeyyan-116aaa1b3/">https://www.linkedin.com/in/hari-karthikkeyyan-116aaa1b3/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a408badd6536" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Modules in JavaScript]]></title>
            <link>https://harikarthyk.medium.com/modules-in-javascript-df78d3b30c29?source=rss-23a6d93c29a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/df78d3b30c29</guid>
            <category><![CDATA[modules-in-javascript]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <category><![CDATA[modules]]></category>
            <dc:creator><![CDATA[Hari Karthyk]]></dc:creator>
            <pubDate>Tue, 15 Sep 2020 06:45:52 GMT</pubDate>
            <atom:updated>2020-09-15T06:45:52.191Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1nDLiqk6Gjjx2VXh" /><figcaption>Photo by <a href="https://unsplash.com/@moritz_photography?utm_source=medium&amp;utm_medium=referral">Moritz Kindler</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In JavaScript, we can use the single module and reuse it in different scripts for several times by Importing and Exporting it.</p><h3>Import JavaScript modules 01</h3><p>In Node JS we mostly use require keyword to import module from another place,</p><p>and ES 6 importing is done by import keyword</p><p>Let’s see some Examples,</p><pre>const importedModule = require(&#39;./Folder1/File2.js&#39;) ;</pre><pre>import importedModule from &#39;./Folder1/File2.js&#39; ;</pre><pre>console.log(importModule.performSomething()) ;</pre><pre>//Invoking performSomething() from ./Folder1/File2.js</pre><blockquote><em>In Node JS we mostly use require keyword from importing Modules</em></blockquote><h3>Export JavaScript Modules</h3><p>To make an Object in our file to be exportable, we assign that module to exports</p><p>which is the property module .</p><pre>const person = {} ;</pre><pre>module.exports = person ;</pre><h3>export default in JavaScript</h3><p>As a feature of ES 6, we can have default export one function or variable in a file that can be imported in a straight forward manner. instead of requiring we may use import to import the default exported object</p><pre>//file add.js<br>let sayName = function(){<br>	return &quot;Hellen&quot; ;<br>}</pre><pre>export default sayName ;</pre><pre>//file index.js<br>import sayName from &#39;./add.js&#39; ;</pre><pre>console.log(sayName()) ;<br>//Hellen</pre><blockquote><em>NOTE : use </em><em>type = module in JSON file to use ES functionality in Node JS</em></blockquote><h3>Import JavaScript modules 02</h3><p>ES 6 feature import keyword can be used in different ways like import * from &#39;./module.js&#39;</p><p>where all the functions and variables that are exported can be used</p><p>A single function can be imported with curly brackets as follows:</p><p>import {funcA} as name from &#39;module_name&#39;;</p><p>Or many functions by name:</p><p>import {funcA, funcB} as name from &#39;module_name&#39;;</p><pre>// add.js<br>export const add = (x, y) =&gt; {<br>    return x + y<br>}</pre><pre>// index.js<br>import { add } from &#39;./add&#39;;<br>console.log(add(2, 3)); // 5</pre><blockquote>NOTE: Many get confused with import funA , {funB, funC} from &#39;module_name&#39; ;</blockquote><blockquote>here funA is a default Export and the rest are not default Export, One file can have only one default Export.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df78d3b30c29" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Classes in JavaScript]]></title>
            <link>https://harikarthyk.medium.com/classes-in-javascript-eeb3ae9cada7?source=rss-23a6d93c29a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/eeb3ae9cada7</guid>
            <category><![CDATA[javascript-tips]]></category>
            <category><![CDATA[classes-in-javascript]]></category>
            <category><![CDATA[es6-classes]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Hari Karthyk]]></dc:creator>
            <pubDate>Tue, 15 Sep 2020 03:24:46 GMT</pubDate>
            <atom:updated>2020-09-15T03:25:19.523Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Kbd1jw7Uf27vszY5" /></figure><h3>Class and Objects</h3><p>Class is a template or a blueprint to create multiple objects, objects are the instance of the class,</p><p>A Class also describes the properties and behavior of Objects</p><p>When an object is created based on the class, the new object is referred to as an instance of the class. New instances are created using the new keyword.</p><h3>Classes in JavaScript before ES 6</h3><pre>function myClass(name, age) {<br>	this.name = name;<br>	this.age = age;<br>	this.friends = [];<br>}</pre><pre>myClass.prototype.addFriends = function(newFriend){<br>	this.friends.push(newFriend)<br>}</pre><pre>let myObject = new myClass(&#39;John&#39;, 18);</pre><pre>console.log(myObject); // myClass { name: &#39;John&#39;, age: 18, friends: [] }</pre><pre>myObject.addFriends(&quot;Helen&quot;) ;<br>myObject.addFriends(&quot;Harry&quot;) ;<br>myObject.addFriends(&quot;Qazi&quot;) ;</pre><pre>console.log(myObject);<br>/* myClass {<br>   name: &#39;John&#39;,<br>   age: 18,<br>   friends: [ &#39;Helen&#39;, &#39;Harry&#39;, &#39;Qazi&#39; ]<br> } */</pre><p>So here “myClass” acts as a constructor and the “addFriends” method is added to myClass using prototype,</p><h3>what is a prototype?</h3><p>JavaScript is a prototype-based language, where every method and object is default inherited by the property prototype, so with help of prototype we can inject a new method to an Object</p><h3>Constructor</h3><p>A class can have a special function constructor which is used to set the initial value to the object and also to invoke the constructor of the parent class</p><h3>Classes in JavaScript after ES 6</h3><p>Similar to class syntax in Java, Python, Ruby, and PHP.</p><pre>class myClass {<br>	constructor(name, age) {<br>		this.name = name;<br>		this.age = age;<br>		this.friends = [];<br>	}<br>	addFriends(newFriend) {<br>		this.friends.push(newFriend);<br>	}<br>}</pre><pre>let myObject = new myClass(&#39;John&#39;, 19);</pre><pre>console.log(myObject); // myClass { name: &#39;John&#39;, age: 19, friends: [] }</pre><pre>myObject.addFriends(&#39;Hellen&#39;);<br>myObject.addFriends(&#39;Harry&#39;);<br>myObject.addFriends(&#39;Peter&#39;);</pre><pre>console.log(myObject);<br>/*<br>myClass {<br>  name: &#39;John&#39;,<br>  age: 19,<br>  friends: [ &#39;Hellen&#39;, &#39;Harry&#39;, &#39;Peter&#39; ]<br>}<br>*/</pre><p>Notice closely JavaScript treats “myClass” even now it act has a function,</p><pre>console.log(typeof myClass); <br>//function</pre><h3>extends</h3><p>JavaScript classes support the concept of inheritance — a child class can extend a parent class. This is accomplished by using the keyword as part of the class definition.</p><pre>class classRoom {<br>	constructor(name,age){<br>		this.name = name ;<br>		this.age = age ;<br>	}<br>}</pre><pre>class Student extends classRoom {<br>	constructor(name,age,major){<br>		super(name,age) ;<br>		this.major = major ;<br>	}<br>}</pre><pre>let newStudent = new Student(&quot;John&quot;,18,&quot;Computer Sciencs&quot;)</pre><pre>console.log(newStudent) <br>// Student { name: &#39;John&#39;, age: 18, major: &#39;Computer Sciencs&#39; }</pre><p>Child classes have access to all of the instance properties and methods of the parent class. They can add their properties and methods in addition to those. A child class constructor calls the parent class constructor using the super() method.</p><p>If we method in both child and parent class with say name then the method in child class gets executed because it overrides the method in the parent class</p><h3>Static Methods</h3><pre>class classRoom {<br>	constructor(name, age) {<br>		this.name = name;<br>		this.age = age;<br>		classRoom.totalStudents++;<br>	}<br>	static getTotalStudent() {<br>		console.log(`${classRoom.totalStudents} students`);<br>	}<br>}</pre><pre>classRoom.totalStudents = 0;</pre><pre>class Student extends classRoom {<br>	constructor(name, age, major) {<br>		super(name, age);<br>		this.major = major;<br>	}<br>}</pre><pre>let John = new Student(&#39;John&#39;, 18, &#39;Computer Sciencs&#39;);<br>let Harry = new Student(&#39;Harry&#39;, 18, &#39;Computer Sciencs&#39;);<br>let Peter = new Student(&#39;Peter&#39;, 18, &#39;Computer Sciencs&#39;);<br>// console.log(newStudent);</pre><pre>classRoom.getTotalStudent(); // 3 students</pre><p>So here classRoom.variableName = 0 , where this remains the same for all instances created and the static method can only be accessed with class Name</p><h3>Classes in JavaScript</h3><h3>Class and Objects</h3><p>Class is a template or a blueprint to create multiple objects , objects are the instance of the class ,</p><p>A Class also describes the properties and behavior of an Objects</p><p>When an object is created based on the class, the new object is referred to as an instance of the class. New instances are created using the new keyword.</p><h3>Classes in JavaScript before ES 6</h3><pre>function myClass(name, age) {<br>	this.name = name;<br>	this.age = age;<br>	this.friends = [];<br>}</pre><pre>myClass.prototype.addFriends = function(newFriend){<br>	this.friends.push(newFriend)<br>}</pre><pre>let myObject = new myClass(&#39;John&#39;, 18);</pre><pre>console.log(myObject); // myClass { name: &#39;John&#39;, age: 18, friends: [] }</pre><pre>myObject.addFriends(&quot;Helen&quot;) ;<br>myObject.addFriends(&quot;Harry&quot;) ;<br>myObject.addFriends(&quot;Qazi&quot;) ;</pre><pre>console.log(myObject);<br>/* myClass {<br>   name: &#39;John&#39;,<br>   age: 18,<br>   friends: [ &#39;Helen&#39;, &#39;Harry&#39;, &#39;Qazi&#39; ]<br> } */</pre><p>So here “myClass” acts as a constructor and “addFriends” method is added to myClass using prototype ,</p><h3>what is prototype ?</h3><p>JavaScript is a prototype-based language, where every method and object is default inherited by the property prototype, so with help of prototype we can inject a new method to an Object</p><h3>Constructor</h3><p>Class can have special function constructor which is used to set initial value to the object and also to invoke the constructor of the parent class</p><h3>Classes in JavaScript after ES 6</h3><p>Similar to class syntax in Java, Python, Ruby and PHP.</p><pre>class myClass {<br>	constructor(name, age) {<br>		this.name = name;<br>		this.age = age;<br>		this.friends = [];<br>	}<br>	addFriends(newFriend) {<br>		this.friends.push(newFriend);<br>	}<br>}</pre><pre>let myObject = new myClass(&#39;John&#39;, 19);</pre><pre>console.log(myObject); // myClass { name: &#39;John&#39;, age: 19, friends: [] }</pre><pre>myObject.addFriends(&#39;Hellen&#39;);<br>myObject.addFriends(&#39;Harry&#39;);<br>myObject.addFriends(&#39;Peter&#39;);</pre><pre>console.log(myObject);<br>/*<br>myClass {<br>  name: &#39;John&#39;,<br>  age: 19,<br>  friends: [ &#39;Hellen&#39;, &#39;Harry&#39;, &#39;Peter&#39; ]<br>}<br>*/</pre><p>Notice closely JavaScript treats “myClass” even now it act has a function ,</p><pre>console.log(typeof myClass); <br>//function</pre><h3>extends</h3><p>JavaScript classes support the concept of inheritance — a child class can extend a parent class. This is accomplished by using the extends keyword as part of the class definition.</p><pre>class classRoom {<br>	constructor(name,age){<br>		this.name = name ;<br>		this.age = age ;<br>	}<br>}</pre><pre>class Student extends classRoom {<br>	constructor(name,age,major){<br>		super(name,age) ;<br>		this.major = major ;<br>	}<br>}</pre><pre>let newStudent = new Student(&quot;John&quot;,18,&quot;Computer Sciencs&quot;)</pre><pre>console.log(newStudent) <br>// Student { name: &#39;John&#39;, age: 18, major: &#39;Computer Sciencs&#39; }</pre><p>Child classes have access to all of the instance properties and methods of the parent class. They can add their own properties and methods in addition to those. A child class constructor calls the parent class constructor using the super() method.</p><p>If we method in both child and parent class with say name then method in child class gets executed because it override the method in parent class</p><h3>Static Methods</h3><pre>class classRoom {<br>	constructor(name, age) {<br>		this.name = name;<br>		this.age = age;<br>		classRoom.totalStudents++;<br>	}<br>	static getTotalStudent() {<br>		console.log(`${classRoom.totalStudents} students`);<br>	}<br>}</pre><pre>classRoom.totalStudents = 0;</pre><pre>class Student extends classRoom {<br>	constructor(name, age, major) {<br>		super(name, age);<br>		this.major = major;<br>	}<br>}</pre><pre>let John = new Student(&#39;John&#39;, 18, &#39;Computer Sciencs&#39;);<br>let Harry = new Student(&#39;Harry&#39;, 18, &#39;Computer Sciencs&#39;);<br>let Peter = new Student(&#39;Peter&#39;, 18, &#39;Computer Sciencs&#39;);<br>// console.log(newStudent);</pre><pre>classRoom.getTotalStudent(); // 3 students</pre><p>So here classRoom.variableName = 0 , where this remains same for all instances created and static method can only be accessed with class Name</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eeb3ae9cada7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Objects in JavaScript]]></title>
            <link>https://harikarthyk.medium.com/objects-in-javascript-a0073349a095?source=rss-23a6d93c29a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/a0073349a095</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[this-in-javascript]]></category>
            <category><![CDATA[objects-in-javascript]]></category>
            <category><![CDATA[begginer-tips]]></category>
            <dc:creator><![CDATA[Hari Karthyk]]></dc:creator>
            <pubDate>Mon, 14 Sep 2020 18:59:42 GMT</pubDate>
            <atom:updated>2020-09-14T18:59:42.306Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Q8xYhX-gFJazGzbI" /><figcaption>Photo by <a href="https://unsplash.com/@stefanbc?utm_source=medium&amp;utm_medium=referral">Stefan Cosma</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Objects</h3><p>An <em>object</em> is a built-in data type for storing key-value pairs. Data inside objects are unordered, and the values can be of any type.</p><h3>Properties of Objects</h3><p>Objects are enclosed with {} and for assigning value to the key we use, and also we can add methods/function as properties</p><p>For Instance,</p><pre>let newObject = {<br>  key1 : &quot;value&quot;, <br>  key2 : {<br>    myKey : 14 <br>  }<br>  myFuction : function(){<br>    console.log(`This is how we use function/Method in an Object`) ;<br>  }<br>}</pre><h3>Accessing Values</h3><p>we use the DOT operator to access the value in the objects</p><p>For Instance,</p><pre>console.log(newObject.key1) ; //[value](//value) <br>newObject.myFunction() // This is how we use function/Method in an Object</pre><h3>Delete Operator</h3><p>In JavaScript, it is possible to delete a property from an Object using the “delete” operator</p><p>For Instance,</p><pre>let person = {<br>  name : &quot;John&quot; ,<br>  age : 18 ,<br>  isAdmin : false ,<br>}</pre><pre>console.log(person) <br>//{name: &quot;John&quot;, age: 18, isAdmin: false}</pre><pre>delete person.isAdmin</pre><pre>console.log(person) <br>//{name: &quot;John&quot;, age: 18}</pre><h3>Accessing properties which are doesn’t exist in an Object</h3><p>In JavaScript, if we access a key/object property which does not exist it returns undefined and not an error</p><p>In JavaScript, there is a difference between error and undefined ( undefined is not an error )</p><h3>Objects are mutable in JavaScript</h3><p>In JavaScript, objects are mutable means we can also change the value of the properties at run time</p><p>For Instance,</p><pre>let student = {<br>   name : &quot;John&quot; <br>}<br>student.name = &quot;Harry&quot;</pre><pre>console.log(student) // {name: &quot;Harry&quot;}</pre><h3>JavaScript for…in loop</h3><p>In JavaScript, we can also iterate Objects through loops</p><p>For Instance,</p><pre>let mobile = {<br>  brand: &#39;Samsung&#39;,<br>  model: &#39;Galaxy Note 9&#39;<br>};</pre><pre>for (let key in mobile) {<br>  console.log(`${key}: ${mobile[key]}`);<br>}</pre><h3>this keyword</h3><p>this in JavaScript is a reserved keyword, In JavaScript, this is referred to the context</p><p>(Global Context / Execution Context ) , In objects, this refers to the object Itself</p><p>For Instance,</p><pre>let myObj = {<br>   name: &#39;John&#39;,<br>   sayName: function () {<br>      console.log(this);<br>   },<br>}; </pre><pre>myObj.sayName();<br>//{ name: &#39;John&#39;, sayName: [Function: sayName] }</pre><pre>let newObj = {<br>   name : &quot;newObj&quot; ,<br>   sayName : function(){<br>      console.log(this.name) ;<br>   }<br>}</pre><pre>newObj.sayName() //newObj</pre><p>So, here this refers to the object itself</p><blockquote><em>NOTE : this in JS is little bite tricky , lets go deeper into it .</em></blockquote><h3>JavaScript Arrow Function this Scope</h3><p>In JavaScript ES 6 Introduces the concept of Arrow Function, where this in Arrow function doesn’t refer to its context like accessing parent context property.</p><p>For Instance,</p><pre>const myObj = {<br>    data: &#39;abc&#39;,<br>    loggerA: () =&gt; { console.log(this.data); },<br>    loggerB() { console.log(this.data); },<br>};</pre><pre>myObj.loggerA();    // undefined<br>myObj.loggerB();    // &#39;abc&#39;</pre><h3>JavaScript factory functions</h3><p>the function which returns an Object is known as Factory function, Factory functions often accept parameters to customize the returned object.</p><p>For Instance,</p><pre>const dogFactory = (firstName, secondName) =&gt; {<br>  return {<br>    firstName: firstName,<br>    secondName: secondName,<br>    name : function() {<br>       console.log(`${this.firstName}${this.secondName}`) ;<br>    }<br>  };<br>};</pre><h3>JavaScript DE Structuring</h3><p>JavaScript DE structuring allows us to use the object with DOT operator and it also increases the readability line of code</p><pre>const Lists = {<br>    students : {<br>	...<br>    } ,<br>    staffs : {<br>	...<br>    } ,<br>    HOD : &#39;&#39; ,<br>    totalStudents : 100 ,	<br>}</pre><pre>console.log(Lists.totalStudents) // 100</pre><pre>//instead</pre><pre>const { students , staffs , HOD , totalStudents } = Lists</pre><pre>console.log(totalStudents) ;</pre><blockquote>Getting Basic Understanding about this Key word in Java Script :</blockquote><blockquote><a href="https://medium.com/@hari.jsmith494/this-in-java-script-fb0d6af75437">https://medium.com/@hari.jsmith494/this-in-java-script-fb0d6af75437</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0073349a095" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[this in Java Script]]></title>
            <link>https://harikarthyk.medium.com/this-in-java-script-fb0d6af75437?source=rss-23a6d93c29a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb0d6af75437</guid>
            <category><![CDATA[this-keyword]]></category>
            <category><![CDATA[regular-function]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Hari Karthyk]]></dc:creator>
            <pubDate>Fri, 28 Aug 2020 06:48:36 GMT</pubDate>
            <atom:updated>2020-10-13T07:07:16.116Z</atom:updated>
            <content:encoded><![CDATA[<h3>“this” keyword in JavaScript</h3><blockquote>Most of us will be confused with<strong> this </strong>keyword in javascript because this in JS is different compared to <strong>this </strong>in other Programming language (JAVA) .</blockquote><blockquote>NOTE :</blockquote><blockquote>For All Regular function, this points to the WINDOW Object ( Global Context ) .</blockquote><p>For Instance,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*M7YF_685sHN839nwm0a72w.png" /></figure><p>Output :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dn3UYweu-Xhe-U2jPE7pKg.png" /></figure><p>You can see that when it is a Regular functional call wherever it is present it refers to the Global Object ( Window in browsers ).</p><p>User.sayHello() =&gt; is a Object call so this refers to the User Object.</p><p>Let Us See Some other Examples</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*ZBK-hDF_4f7_SmXYMDcm-Q.png" /></figure><p>In this case, we need to iterate through the all the elements in array students and map it to the in-charge as I said earlier regular function “this” refers to Global Context and we have no in charge declared in the Global Context so it remains undefined</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/393/1*Zb1qTX_SPQGqTpP47zY2hw.png" /></figure><p>So this is something confusing in JavaScript to overcome we cand do 2 thing</p><ol><li>Bind this keyword</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*g-3xuzfk7lYVmENFFbn5nQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/1*K7LCbm693Gyb5X8UIGkPkQ.png" /></figure><p>2 . we can use ES 6 Arrow function , where “this” doesn’t refer to its own context ,but use the this of the surrounding lexical context</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2xFcJw0IxN6KGv7yqNeBQg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*8wL8nHioNmvcPVT61NecGw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb0d6af75437" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>