<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Abhinav Kale</title>
    <description>The latest articles on DEV Community by Abhinav Kale (@kale_abhinav).</description>
    <link>https://dev.to/kale_abhinav</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F338991%2F3bfb4116-eebd-4d2b-b529-5158dbe5fae4.jpg</url>
      <title>DEV Community: Abhinav Kale</title>
      <link>https://dev.to/kale_abhinav</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kale_abhinav"/>
    <language>en</language>
    <item>
      <title>Weird behavior of javaScript you should know!</title>
      <dc:creator>Abhinav Kale</dc:creator>
      <pubDate>Mon, 10 Jan 2022 15:53:26 +0000</pubDate>
      <link>https://dev.to/kale_abhinav/weird-behavior-of-javascript-you-should-know-4056</link>
      <guid>https://dev.to/kale_abhinav/weird-behavior-of-javascript-you-should-know-4056</guid>
      <description>&lt;p&gt;We know that javaScript sometimes behaves weird as compare to other programming languages, but initially it was design only to make web pages.&lt;/p&gt;

&lt;p&gt;But now in today's world, we can do so many things using javaScript with help of other libraries/framework like react, angular.&lt;/p&gt;

&lt;p&gt;This weird behaviour is not a fault of javaScript, this is how the language was design in the initial phase. So we should understand why this behaviour happens, so we can take primitive actions based on it.(If we are intending that this should not happen)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vtOxqWll--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/grjvghciy63brggmle93.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vtOxqWll--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/grjvghciy63brggmle93.png" alt="Image1 description" width="681" height="259"&gt;&lt;/a&gt;&lt;br&gt;
So here, we make one object calling its name &lt;strong&gt;weirdObject&lt;/strong&gt; which has property &lt;code&gt;obj_id&lt;/code&gt; and &lt;code&gt;obj_name&lt;/code&gt; which is further divided into an object which has property &lt;code&gt;obj_title&lt;/code&gt; and &lt;code&gt;type&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If we run our code with node we get the output as the object considering &lt;code&gt;obj_id&lt;/code&gt; and &lt;code&gt;obj_name&lt;/code&gt;.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nrPmZmrp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pdmbkaa2ucxn0o48nqni.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nrPmZmrp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pdmbkaa2ucxn0o48nqni.png" alt="Image2 description" width="880" height="455"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, if we want to change the &lt;code&gt;obj_id&lt;/code&gt; of the object we can do that in javaScript inspite of using &lt;strong&gt;const&lt;/strong&gt; keyword.(It is allowed to change inside property of javaScript whether we use const or not)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LKPl4xwx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yng6lxqi137q4626pbxu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LKPl4xwx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yng6lxqi137q4626pbxu.png" alt="Image3 description" width="880" height="441"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To change this behaviour, we can use &lt;strong&gt;Object.freeze()&lt;/strong&gt; method which freezes an object. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--e2LbOHI1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hjwoyuhbhw174htvufna.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--e2LbOHI1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hjwoyuhbhw174htvufna.png" alt="Image4 description" width="880" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here the value of &lt;code&gt;obj_id&lt;/code&gt; not changed. A frozen object can no longer be changed; freezing an object prevents new properties from being added to it, existing properties from being removed, prevents changing the enumerability, configurability, and writability of existing properties, and also prevents the values of existing properties from being changed.&lt;/p&gt;

&lt;p&gt;But, what if we want to change value of the &lt;code&gt;obj_title&lt;/code&gt; from &lt;strong&gt;"My Object"&lt;/strong&gt; to &lt;strong&gt;"This Object"&lt;/strong&gt; which is present inside &lt;code&gt;obj_name&lt;/code&gt; object of weirdObject after using &lt;code&gt;Object.freeze()&lt;/code&gt; method.&lt;/p&gt;

&lt;p&gt;Let's see..&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aflh74v7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/msjc06wjx85zpqollh42.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aflh74v7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/msjc06wjx85zpqollh42.png" alt="Image5 description" width="880" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Yes, we can do that..!! This is called &lt;strong&gt;Shallow freeze&lt;/strong&gt; which only applies to the immediate properties of the object itself and will prevent future property addition, removal or value re-assignment operations only on object. If the value of those properties are objects themselves, those objects are not frozen and may be the target of property addition, removal or value re-assignment operations.&lt;/p&gt;

&lt;p&gt;To make object immutable, we will have to add explicit function which will check is wheather the object has another object present inside it.&lt;/p&gt;

&lt;p&gt;Hope this odd behaviour of javaScript information helps you.&lt;br&gt;
Thanks for reading and happy coding!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Do you know Isomorphic JavaScript?</title>
      <dc:creator>Abhinav Kale</dc:creator>
      <pubDate>Thu, 12 Aug 2021 14:21:56 +0000</pubDate>
      <link>https://dev.to/kale_abhinav/what-is-isomorphic-javascript-8ce</link>
      <guid>https://dev.to/kale_abhinav/what-is-isomorphic-javascript-8ce</guid>
      <description>&lt;p&gt;In programming we tend to hear a lot of really strange words such as isomorphism, etc. &lt;/p&gt;

&lt;h2&gt;
  
  
  What is Isomorphic?
&lt;/h2&gt;

&lt;p&gt;In general term &lt;strong&gt;"iso"&lt;/strong&gt; means "same" and &lt;strong&gt;"morphic"&lt;/strong&gt; means "form" ie same form that we are studied from our childhood.&lt;/p&gt;

&lt;p&gt;In simplest terms isomorphic javaScript is the javaScript that can be run on both the server as well as on the client.&lt;/p&gt;

&lt;p&gt;Let's discuss with examples below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi1l0dvr5p3ehnl6p2fzx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi1l0dvr5p3ehnl6p2fzx.png" alt="IsoJs function"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This code snippet is isomorphic, the code will run in a&lt;br&gt;
node.js environment and it will also run in the web browser.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmmae9j3ygx24g3dpfojw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmmae9j3ygx24g3dpfojw.png" alt="IsoJs Browser"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This code doesn't uses any node-specific libraries or browse any web apis, it's just an arrow function in javaScript that will run in environment. &lt;/p&gt;

&lt;p&gt;Now let's have a look on another example which is not isomorphic.&lt;br&gt;
We will be using fetch api to get some data from external api(NewsAPI).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmibnxlgj0t2i6l80g83v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmibnxlgj0t2i6l80g83v.png" alt="Fetch API"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This code is not isomorphic because the &lt;code&gt;fetch&lt;/code&gt; function is provided by the web browser and results in ReferenceError.&lt;/p&gt;

&lt;p&gt;If we want to run on both the client and the server we have to import a third-party library such as &lt;code&gt;axios&lt;/code&gt;. The code something looks like this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwbuminz464j9giy1h8h2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwbuminz464j9giy1h8h2.png" alt="Axios"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This would be considered as isomorphic javaScript but it's important to note that we only need one successful path that will run on both the server and the client in order to be considered isomorphic. &lt;/p&gt;

&lt;p&gt;If we have a javaScript function that checks the environment to determine whether or not it's on the client or the server and then it has the path for both of those cases then that can be considered as isomorphic javaScript for example this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fof1i20hddcpd2e344b2s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fof1i20hddcpd2e344b2s.png" alt="Check Isomorphic"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This code checks for the window object and determines whether or not it is running on the client or the server and then logs the result.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsa02mi83qdnh744kkuri.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsa02mi83qdnh744kkuri.png" alt="Check Iso Browser"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is isomorphic because it will run on both the server and the client so it's important to note here that isomorphic javaScript is the way that we write the code and&lt;br&gt;
it's &lt;strong&gt;"not a particular technology"&lt;/strong&gt; it's just sort of like a design pattern. Writing code in this way allows you to be able to do certain unique things such as server side rendering. &lt;/p&gt;

&lt;p&gt;Hope this information helps you to understand isomorphic javaScript.&lt;br&gt;
Thanks for reading and happy coding!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>isomorphic</category>
      <category>developer</category>
    </item>
  </channel>
</rss>
