<?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: Tether</title>
    <description>The latest articles on DEV Community by Tether (@tarunsankhla).</description>
    <link>https://dev.to/tarunsankhla</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%2F820745%2F0bb14df0-607a-4c96-a019-f3babf436572.jpeg</url>
      <title>DEV Community: Tether</title>
      <link>https://dev.to/tarunsankhla</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tarunsankhla"/>
    <language>en</language>
    <item>
      <title>Need of package.lock.json ?and npm clean install</title>
      <dc:creator>Tether</dc:creator>
      <pubDate>Tue, 10 May 2022 19:14:15 +0000</pubDate>
      <link>https://dev.to/tarunsankhla/need-of-packagelockjson-and-npm-clean-install-3alk</link>
      <guid>https://dev.to/tarunsankhla/need-of-packagelockjson-and-npm-clean-install-3alk</guid>
      <description>&lt;p&gt;You might have come across package.json and package.lock.json while working with node package modules or in yarn as yarn.lock in your React or node application; but why do we need them ?&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;em&gt;&lt;strong&gt;Background&lt;/strong&gt;&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;Basically package.json acts as a manifest file for all the multiple packages to be installed, it keep version tree of the dependencies including child dependency.It consist of dependency with version semantics, scripts and browserlist.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--N2DUfEMg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q39nuc5a9b6uhg42mjii.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--N2DUfEMg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q39nuc5a9b6uhg42mjii.png" alt="Package json" width="736" height="356"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--081FiGme--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9j5ataz7nt6h7fqus370.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--081FiGme--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9j5ataz7nt6h7fqus370.png" alt="Package lock json" width="589" height="229"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;package.lock.json constains list of exact version of all packages used in your project, it is needed for locking the dependency of installed version.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;What does npm install does underhood&lt;/strong&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -s MODULE_NAME
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;It will first search the module by name.&lt;/li&gt;
&lt;li&gt;Install the package modules and dependency.&lt;/li&gt;
&lt;li&gt;update or create package.lock.json and added the corresponding package name and version in package.json&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So if someone now clones your project and runs npm install command, the node package manager will ensure that it downloads the same file as it did previously by referring the version in lock.json and package.json but it will be comparing both and if they do match it will follow lock file, but &lt;strong&gt;what if they don't ?&lt;/strong&gt; then npm will take manifest of package.json as authorized and update the package.lock.json&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;You might also need to know about package.json semantics versioning:&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Generally npm package version look like 1.0.1 wherein first number from right is the patch version, then second number is for minor version and last is major version.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Patch release consist of bugs resolved to a feature or backward compatibility bug fixes and the patch version semantic: ~1.0.x&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Minor release is when a new feature is added and it should have backward compatibility and the minor version semantic : ^1.x or ^1.1.3&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Major release is when feature that can break backward compatibility and major version semantic : * or x.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;So now lets come back to npm install updating lock.json, some developers have tendency to changing dependencies by hand or let assume a case in your project wherein you update a package dependency and only commit the package.json and not the lock.json and in mean while some deveoper clones your repository.....&lt;/p&gt;

&lt;h2&gt;
  
  
  Entry of npm clean install
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm clean-install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;npm ci bypasses the packages of package.json to install modules from refering lockfile. This ensures reproducible builds—you are getting exactly what you expect on every install.&lt;/p&gt;

&lt;p&gt;Previously, developers who wanted to ensure that node_modules/ and package.json stayed in sync would have to archive their node_modules folder. npm ci replaces this process with a single command.&lt;/p&gt;

&lt;p&gt;What steps does it take&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If node_modules fodler exist, it will delete and install a fresh one&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If lock.json doesn't exist or doesn't match the version with package.json, it will give an &lt;strong&gt;&lt;em&gt;error and stop&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Npm CI in some cases is faster and it improves readibility&lt;br&gt;
&lt;a href="https://github.com/zkat/node-package-manager-benchmark/tree/zkat/cipm"&gt;check this github&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Conclusion:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Next time you clone a repository use npm clean install to avoid any version compatibility issue.&lt;/li&gt;
&lt;li&gt;Never try to update package.json by hand.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>node</category>
      <category>npm</category>
    </item>
    <item>
      <title>Prototype and Prototypical Inheritance</title>
      <dc:creator>Tether</dc:creator>
      <pubDate>Tue, 10 May 2022 15:07:08 +0000</pubDate>
      <link>https://dev.to/tarunsankhla/prototype-and-prototypical-inheritance-2p3n</link>
      <guid>https://dev.to/tarunsankhla/prototype-and-prototypical-inheritance-2p3n</guid>
      <description>&lt;p&gt;Whenever we create an object the Javascript engine automatically attaches your object with hidden properties and functions, the object is accessed via proto within every object that points out (references) the prototype that has been set for that object.&lt;/p&gt;

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

&lt;p&gt;We can access the properties of the object through the dot operator and can use this property or even update the existing properties&lt;/p&gt;

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

&lt;p&gt;, and with function when we create a function in JavaScript, the JS engine adds an extra property called prototype to the created function. This prototype property is an object (called a prototype object) that has a constructor property referenced to it by default and inside the prototype property, you will get access to proto object.&lt;/p&gt;

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

&lt;p&gt;In JavaScript, any function can be attached to an object in the form of a property. An inherited function acts just like any other property and when an inherited function is executed, the value of this points to the inheriting object, not to the prototype object where the function is an own property.&lt;/p&gt;

&lt;p&gt;All objects in javascript are references to an object and that object has a prototype of its own and this chain goes on till it is referenced to a null&lt;/p&gt;

&lt;p&gt;We can get and set propertytype by Object.getPrototypeOf() and Object.setPrototypeOf(), as well as with non standard proto property. While modifying a prototype you might even come across warnings like&lt;/p&gt;

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

&lt;p&gt;This is because when navigating through a property object, we basically hop from an object to its [[prototype ]] then its object [[prototype]] until we reach the end of the chain to null. In ES6, there were ways introduced to mutate [[prototype] but they harm the performance in all modern javascript engines. When you set proto, we reduce the future optimizations from Ion on that object, but you also force the engine to go crawling around to all the other pieces of type inference, which involves further deoptimization.&lt;/p&gt;

&lt;p&gt;Changing the prototype of an object in the middle of execution is really not a good practice and cause huge performance issue.   &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>inheritance</category>
      <category>es6</category>
    </item>
    <item>
      <title>Must Read blogs</title>
      <dc:creator>Tether</dc:creator>
      <pubDate>Sat, 07 May 2022 02:09:08 +0000</pubDate>
      <link>https://dev.to/tarunsankhla/must-read-blogs-4df5</link>
      <guid>https://dev.to/tarunsankhla/must-read-blogs-4df5</guid>
      <description>&lt;p&gt;Just a bunch of really great blog collection&lt;br&gt;
I am trying to make a blog for collection of blog or docs which i would recommend to read &lt;/p&gt;

&lt;p&gt;1) &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects"&gt;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2) &lt;a href="https://react-typescript-cheatsheet.netlify.app/docs/advanced/patterns_by_version/"&gt;https://react-typescript-cheatsheet.netlify.app/docs/advanced/patterns_by_version/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>node</category>
    </item>
    <item>
      <title>JavaScript Interview questions</title>
      <dc:creator>Tether</dc:creator>
      <pubDate>Tue, 26 Apr 2022 02:50:25 +0000</pubDate>
      <link>https://dev.to/tarunsankhla/javascript-interview-questions-4igd</link>
      <guid>https://dev.to/tarunsankhla/javascript-interview-questions-4igd</guid>
      <description>&lt;p&gt;The blog is regarding popular and unique interview question which I come across during interview or from other candidates.&lt;br&gt;
This might include tech stack of web dev related to Vanilla Javascript majourly and also include React js, Node js, TypeScript, Angular, HTML and CSS&lt;/p&gt;

&lt;p&gt;Lets go!!!&lt;/p&gt;

&lt;p&gt;-&amp;gt;  Java Script&lt;br&gt;
1) Event bubbling and event capturing and event delegation &lt;br&gt;
    sol: Event delegation refers to the process of using event &lt;br&gt;
         propagation (bubbling) to handle events at a higher level &lt;br&gt;
         in the DOM than the element on which the event originated&lt;/p&gt;

&lt;p&gt;2) Function Borrowing =&amp;gt;  call , apply, bind =&amp;gt; create your own call, apply, bind prototype&lt;br&gt;
3) Create your own map in js&lt;br&gt;
4) strict mode&lt;br&gt;
5) inspect tab&lt;br&gt;
6) create your own Flat method &lt;br&gt;
7) Object.is() vs === vs ==&lt;br&gt;
8) type of Nan and Number.Nan&lt;/p&gt;

&lt;p&gt;-&amp;gt; React js&lt;br&gt;
1) control component and uncontrol components&lt;br&gt;
2)  create your own custom hook&lt;br&gt;
3) diff usememo , usecallback and memo &lt;br&gt;
4) side effect in react&lt;br&gt;
5) React Virtualisation&lt;br&gt;
6) React fiber&lt;br&gt;
7) diffing reconcilation&lt;br&gt;
8) useref and memoisation&lt;br&gt;
9) bundle.js&lt;br&gt;
10) suspense , server render&lt;/p&gt;

&lt;p&gt;-&amp;gt; CSS&lt;br&gt;
1) Create elipsis (Hi i am ...)&lt;br&gt;
2) Create a Clock with js and css like actual non digital clocks with minutes and hour hand ticking&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>interviewquestion</category>
      <category>react</category>
    </item>
    <item>
      <title>Tech Hacks discovered dailly</title>
      <dc:creator>Tether</dc:creator>
      <pubDate>Thu, 21 Apr 2022 04:35:19 +0000</pubDate>
      <link>https://dev.to/tarunsankhla/tech-hacks-discovered-dailly-2flf</link>
      <guid>https://dev.to/tarunsankhla/tech-hacks-discovered-dailly-2flf</guid>
      <description>&lt;p&gt;List of all Tech hacks I find dailly while reading a blog or while reviewing code of peers.&lt;/p&gt;

&lt;p&gt;Mostly will be related JavaScript, React JS, Node JS, Angular, TypeScript, GIT , HTML and CSS&lt;/p&gt;

&lt;p&gt;Just making a list:&lt;/p&gt;

&lt;p&gt;1) axios setting deafault header for all request&lt;br&gt;
axios.defaults.headers.common["authorization"] = encodedToken;&lt;/p&gt;

&lt;p&gt;2) Function Declarations get Hoisted to Top of the context, where as classes declarations and function Expressions are not Hoisted.&lt;/p&gt;

&lt;p&gt;3) Way to round a number&lt;br&gt;&lt;br&gt;
x = -3.45&lt;br&gt;
console.log(~~x) // -3&lt;br&gt;
console.log(x | 0) // -3&lt;br&gt;
console.log(x &amp;lt;&amp;lt; 0) // -3&lt;/p&gt;

&lt;p&gt;4)How JS can find an element in a Map object in one step?&lt;/p&gt;

&lt;p&gt;Map uses a hashtable (or a similar mechanism) as specified in the spec. Therefore, when an object is requested a hash is calculated. Then the specific location in an internal table is located. This is the basic theory about hash tables and why they are usualy O(1). Do note, that if there are many collisions performance can move towards O(N).&lt;/p&gt;

&lt;p&gt;5)&lt;br&gt;
The CSS @import directive has a major drawback due to performance issues; it creates an extra HTTP request each time you call it. However, the Sass @import directive includes the file in the CSS; so no extra HTTP call is required at runtime!&lt;/p&gt;

&lt;p&gt;6) which is faster ifelse or switch in js&lt;br&gt;
Compiler is better in optimizing switch-statement then if-else because of the order of evaluation in if is not stacked based on importance but in switch it knows the clause to be evaluated together and with more efficient order.&lt;br&gt;
-&amp;gt; Stats &lt;a href="http://www.blackwasp.co.uk/speedtestifelseswitch.aspx" rel="noopener noreferrer"&gt;http://www.blackwasp.co.uk/speedtestifelseswitch.aspx&lt;/a&gt;&lt;br&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%2F8p6x9048xvhhlnyyvpu9.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%2F8p6x9048xvhhlnyyvpu9.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;7)  Object.is() vs === &lt;br&gt;
Object.is it for comparing 2 values and default is true&lt;br&gt;
null and null&lt;br&gt;
undefined and undefined &lt;br&gt;
are equal&lt;br&gt;
but in non primitive data type if not referencing to same instance in memory then not not equal like&lt;br&gt;
Object.is({},{}) or Object.is([],[])&lt;/p&gt;

&lt;p&gt;but then what is the difference between === and Object.is()&lt;br&gt;
the difference is signed 0 and Nan&lt;br&gt;
so &lt;br&gt;
 a) Object.is(NaN,Nan) =&amp;gt; true&lt;br&gt;
    NaN === NaN =&amp;gt; false&lt;br&gt;
 b) Object.is(NaN,0/0) =&amp;gt; true&lt;br&gt;
    NaN === 0/0 =&amp;gt; false&lt;br&gt;
 c) Object.is(NaN,Number.NaN) =&amp;gt; true&lt;br&gt;
    NaN === Number.Nan =&amp;gt; false&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>react</category>
      <category>css</category>
    </item>
  </channel>
</rss>
