<?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: Branko Stancevic</title>
    <description>The latest articles on DEV Community by Branko Stancevic (@landb).</description>
    <link>https://dev.to/landb</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%2F429391%2F551b705b-1925-493c-94ed-6132fb323ab2.jpeg</url>
      <title>DEV Community: Branko Stancevic</title>
      <link>https://dev.to/landb</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/landb"/>
    <language>en</language>
    <item>
      <title>Mindset of a Senior Engineer</title>
      <dc:creator>Branko Stancevic</dc:creator>
      <pubDate>Mon, 20 Jan 2025 21:43:06 +0000</pubDate>
      <link>https://dev.to/landb/mindset-of-a-senior-engineer-3n6i</link>
      <guid>https://dev.to/landb/mindset-of-a-senior-engineer-3n6i</guid>
      <description>&lt;p&gt;3 words mentioned in the title of this post are needed to be exactly that – senior engineer. Let’s break it down.&lt;/p&gt;




&lt;h1&gt;
  
  
  Mindset
&lt;/h1&gt;

&lt;p&gt;Mindset is difficult to explain, and not because of its technical side. In fact, it’s the non-technical qualities that make it tricky yet essential to master. A senior engineer's mindset encompasses traits that go beyond coding skills and technical knowledge. Here are some key non-tech qualities every engineer should cultivate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Decision-Making Based on Project Context:&lt;/strong&gt; A senior engineer must evaluate project complexity, timelines, and client needs to make informed decisions. Balancing these factors ensures solutions are both practical and aligned with the bigger picture.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Clear Communication:&lt;/strong&gt; The ability to rephrase and clarify concepts so everyone, regardless of their technical expertise, can understand is a hallmark of effective engineering. This includes bridging gaps between technical and non-technical teams.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Proactivity:&lt;/strong&gt; Instead of waiting for instructions, a senior engineer anticipates challenges, identifies opportunities for improvement, and takes initiative to drive better outcomes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Empathy and Collaboration:&lt;/strong&gt; Understanding team dynamics, empathizing with colleagues, and fostering a collaborative environment are essential for creating effective solutions and achieving shared goals.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Adaptability:&lt;/strong&gt; Projects evolve, requirements change, and technologies advance. A senior engineer’s mindset embraces flexibility and sees change as an opportunity rather than a setback.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Senior
&lt;/h1&gt;

&lt;p&gt;Seniority isn’t just about years of experience. It can be summarized by this equation:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;seniority = years of experience * (knowledge + mindset)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Knowledge is built over time through hands-on experience, learning from failures, and staying updated with the latest industry trends. But mindset—as described above—is the multiplier that transforms experience into seniority. Without the right mindset, even extensive experience may fail to lead to impactful contributions.&lt;/p&gt;

&lt;h1&gt;
  
  
  Engineer
&lt;/h1&gt;

&lt;p&gt;It’s important to distinguish between an engineer and a developer. Both roles are valuable, but their approaches and perspectives differ.&lt;/p&gt;

&lt;p&gt;A developer is often task-oriented, focused on completing assigned tickets without necessarily considering the broader context. They’re like ants working diligently on individual pieces of the puzzle.&lt;/p&gt;

&lt;p&gt;An engineer, on the other hand, takes a holistic view. They consider multiple solutions, analyze trade-offs, and select the one that best meets the project’s needs. Engineers think about scalability, maintainability, and the overall architecture, ensuring their work contributes to the long-term success of the project.&lt;/p&gt;

&lt;p&gt;An engineer’s mindset elevates their role from execution to innovation, making them indispensable in driving meaningful progress.&lt;/p&gt;




&lt;p&gt;In conclusion, becoming a senior engineer requires a blend of technical expertise and a refined mindset. It’s about making thoughtful decisions, embracing responsibility, and consistently striving for excellence.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>junior</category>
      <category>senior</category>
      <category>medior</category>
    </item>
    <item>
      <title>Function boobs or how people love to call them: Higher Order Functions</title>
      <dc:creator>Branko Stancevic</dc:creator>
      <pubDate>Sun, 11 Jul 2021 07:20:31 +0000</pubDate>
      <link>https://dev.to/landb/function-boobs-or-how-people-love-to-call-them-higher-order-functions-21p0</link>
      <guid>https://dev.to/landb/function-boobs-or-how-people-love-to-call-them-higher-order-functions-21p0</guid>
      <description>&lt;p&gt;- Branko are you crazy?&lt;br&gt;
No I’m certainly not! &lt;/p&gt;

&lt;p&gt;I just love crazy stuff in JavaScript. One of those things are definitely function boobs. I’m sorry, but I couldn’t find more describable and funnier name for this phenomenon so I’m gonna call it like that.&lt;/p&gt;

&lt;p&gt;Foo()(), am I right? Hihi.&lt;/p&gt;
&lt;h2&gt;
  
  
  Let's dive in!
&lt;/h2&gt;

&lt;p&gt;In your, so far, developer life, you must have seen something like this:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;connect(mapStateToProps, mapDispatchToProps)(App);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Did you try to understand what this is and how the hell is it working?&lt;/p&gt;

&lt;p&gt;This &lt;code&gt;connect&lt;/code&gt; function is called &lt;code&gt;Higher Order Function (HOF)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;By definition HOF is a function that accepts and / or returns a function as parameter.&lt;/p&gt;
&lt;h2&gt;
  
  
  How it works you might ask?
&lt;/h2&gt;

&lt;p&gt;First boob in connect accepts several things. Couple of functions for redux state and actions and some other options which are not the topic here so I’m not gonna cover it.&lt;/p&gt;

&lt;p&gt;Second boob is basically return function from connect that accepts react component.&lt;/p&gt;

&lt;p&gt;So, main purpose of the connect function is to prepare testament for its child (child that comes from the second boob).&lt;/p&gt;

&lt;p&gt;All the information from testament (redux state and actions) is bound to the child’s props when connect is about to die. That’s why we access redux state via props.&lt;/p&gt;

&lt;p&gt;Keep in mind that this is not the definition of connect function. This is just an brief explanation how things are working by my understanding.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;actions&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="cm"&gt;/* testament preparation */&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;preparedTestament&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{...};&lt;/span&gt;
    &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;component&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;component&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="err"&gt;…&lt;/span&gt;&lt;span class="nx"&gt;preparedTestament&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, at the end, connect returns anonymous function that returns react component but with appended props as I described earlier, hence we call it with 2 pars of brackets like this: &lt;code&gt;connect()()&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why it is useful?
&lt;/h2&gt;

&lt;p&gt;While this technique is used widely with connect, withRouter, etc. HOF can be used for custom stuff as well. For e.g. When you want to attach some component (notification sidebar or something like that) to 3 pages in your react app but omit on 4th and 5th.&lt;/p&gt;

&lt;p&gt;Yes! Of course that you can use HOF outside of the react! And that’s the point where the real fun begins!&lt;/p&gt;

&lt;p&gt;Or, or, you have already used it and you don't know it! Does map, filter, sort, reduce sounds familiar? :)&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;HOF as concept is definitely something worth exploring on the deeper level so don’t be afraid to use it, don’t be afraid to understand it. It will be easier with time passed by, and with that, a new horizons will open up for you. :)&lt;/p&gt;

&lt;p&gt;Thank you for reading good people. 'til next time!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>beginners</category>
      <category>higherorderfunctions</category>
    </item>
    <item>
      <title>Lower CSS specificity as much as possible with Bem and Inuitcss</title>
      <dc:creator>Branko Stancevic</dc:creator>
      <pubDate>Sat, 12 Jun 2021 10:01:29 +0000</pubDate>
      <link>https://dev.to/landb/lower-css-specificity-as-much-as-possible-with-bem-and-inuitcss-pco</link>
      <guid>https://dev.to/landb/lower-css-specificity-as-much-as-possible-with-bem-and-inuitcss-pco</guid>
      <description>&lt;p&gt;I have to open this post with this disclaimer; in order to fully understand what's going on, you'll need couple of things sorted out.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Work with some CSS pre-processor (SCSS, LESS)&lt;/li&gt;
&lt;li&gt;Familiarity with &lt;a href="https://en.bem.info/methodology/" rel="noopener noreferrer"&gt;Bem Methodology&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Familiarity with &lt;a href="https://github.com/inuitcss/inuitcss" rel="noopener noreferrer"&gt;Inuitcss&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, considering that we have established ground rules, let's begin.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;I have worked on several big projects in the past. By big I mean projects that ware in active development 6 months and more. My first part of engagement was organization of CSS. Second part was building JS (ReactJS and Angular 2) components and RestAPI integration, but that's not important so let's focus purely on CSS.&lt;/p&gt;

&lt;h2&gt;
  
  
  Property overrides
&lt;/h2&gt;

&lt;p&gt;Every CSS tutorial I watched in the past, didn't cover very !important thing in the CSS world. Property overriding.&lt;/p&gt;

&lt;p&gt;Why we try to avoid that, you might ask? Because my friend, what callback hell represents in JS, property overriding is just equally bad in CSS. Don't get me wrong, we still need to override something sometimes, but I believe there's a better and cleaner way to do so.&lt;/p&gt;

&lt;h2&gt;
  
  
  Epic dark story
&lt;/h2&gt;

&lt;p&gt;So many unused properties lying somewhere deep inside your compiled CSS file. When project grows, you add more variants and more overrides and eventually because of CSS specificity you start using !important. Then you realize that you have overrode something that was not supposed to be overridden. Now you feel helpless and you are a one line of code from quitting but not the project. The job. Oh, and I won't even start talking about performance issues. :)&lt;/p&gt;

&lt;h2&gt;
  
  
  Show me the way!
&lt;/h2&gt;

&lt;p&gt;So, first of all let's see how specificity work.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"paragraph"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"red"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Lorem ipsum&lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&gt; 
&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's say we have this html above on our page. Now, let your inner child play with the colors for a little bit. :)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.paragraph&lt;/span&gt; &lt;span class="nc"&gt;.red&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;maroon&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.red&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We already know that CSS is executing line by line from top to the bottom. Can you guess what color will be the element with class red? Of course not! Will be maroon. I'm sorry if I assumed you said red, it's fun for me to try to predict how your mind works.&lt;/p&gt;

&lt;p&gt;Specificity took over and overrode red color. Can we somehow organize this differently so there is no overrides with no increased specificity? Of course!&lt;/p&gt;

&lt;p&gt;I present to you my ultimate combo!&lt;/p&gt;

&lt;h3&gt;
  
  
  Bem Methodology
&lt;/h3&gt;

&lt;p&gt;Actually current example is just about Bem Methodology but combo will make more sense later when we will be covering the big boys (projects).&lt;/p&gt;

&lt;p&gt;Let's rewrite example above with Bem.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"paragraph"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"paragraph__item paragraph__item—red"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How can we color it?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.paragraph&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="err"&gt;&amp;amp;__item&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;
        &lt;span class="err"&gt;&amp;amp;—red&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;
             &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="err"&gt;}&lt;/span&gt;
&lt;span class="err"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keep in mind that this example only works with some CSS pre-processor like SCSS or LESS. &lt;/p&gt;

&lt;p&gt;Watch closely how this example above will be compiled.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.paragraph__item&lt;/span&gt;&lt;span class="err"&gt;—&lt;/span&gt;&lt;span class="nt"&gt;red&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What? :O Just one line and no stacking elements? No way. &lt;/p&gt;

&lt;p&gt;&amp;amp; sign represents concatenation of strings, exactly like in JS where "2" + "2" equals "22". We exactly wanted that. Our first refactor done with lowest possible specificity.&lt;/p&gt;

&lt;h3&gt;
  
  
  Inuitcss
&lt;/h3&gt;

&lt;p&gt;Now comes into the play second part of the ultimate combo and it is Inuitcss!&lt;/p&gt;

&lt;p&gt;While Bem covers organization of html tags and their names (classes), Inuitcss gives you nicely organized, maintainable and scalable structure of CSS files.&lt;/p&gt;

&lt;p&gt;I love Inuitcss because it covers everything from pages, layout, variables and some global settings to specific elements, mixins, helpers, components. Maybe I forgot something but you got the point.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;With combination of those two paradigms and detailed planning of the project, specificity can be contained up to 2 or 3 levels maximum, while property overriding should be minimal and nicely executed. Project becomes maintainable and scalable, you don't want to kill yourself, your appetite comes back, and finally you are hungry for more.&lt;/p&gt;

&lt;p&gt;Take care good people, and thank you for reading!&lt;/p&gt;

</description>
      <category>css</category>
      <category>bemmethodology</category>
      <category>inuitcss</category>
      <category>specificity</category>
    </item>
    <item>
      <title>Why deep clone when we have stringify.</title>
      <dc:creator>Branko Stancevic</dc:creator>
      <pubDate>Sun, 06 Jun 2021 15:34:00 +0000</pubDate>
      <link>https://dev.to/landb/why-deep-clone-when-we-have-stringify-5b9d</link>
      <guid>https://dev.to/landb/why-deep-clone-when-we-have-stringify-5b9d</guid>
      <description>&lt;p&gt;Since this is my first post I just have to open it with “Don’t judge book by it’s cover”, just hear me out.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem
&lt;/h2&gt;

&lt;p&gt;I have to be honest, deepcloning objects can be really messy. Sure, it is easier with some packages like loadesh, but when you do that “by the hand”, it’s hard to track what you did or didn’t copy, especially when big complex objects are in play.&lt;/p&gt;

&lt;p&gt;Oh sorry, I forgot to explain why we have to clone objects in order to update them, and I can do that in just one word: immutability. Huh, okey, that was easy :) I’m kidding. Since I don’t know my audience yet, I will try to be as clear as blue sky, so let’s get more technical.&lt;/p&gt;

&lt;h2&gt;
  
  
  Immutability
&lt;/h2&gt;

&lt;p&gt;Immutability is very important part of every react application. Component in react app is rendered based on props and state. When props or state changes (by this I mean when reference to the object is changed), components rerenders. It’s that simple.&lt;/p&gt;

&lt;p&gt;When working with complex object which contain 3 or more levels of objects for e.g, and you want to change some property on third level, you need to copy that object where property lives, it’s parent, then parent’s parent. And that’s it, I think…? You see my point. Let’s say we have done that right, now we have an old unchanged object and a new copied object with just one property changed. Now, state can be updated and component rerenders! Hooray!&lt;/p&gt;

&lt;p&gt;All that insecurity and potential bugs where your component didn’t update can be a result of badly managed immutability.&lt;/p&gt;

&lt;p&gt;I hope I didn’t make you angry by this time but let’s get to the point.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution for all your problems
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;firstName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;“&lt;/span&gt;&lt;span class="nx"&gt;Branko&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;lastName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;“&lt;/span&gt;&lt;span class="nx"&gt;Stančević&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;location&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;city&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;“&lt;/span&gt;&lt;span class="nx"&gt;Novi&lt;/span&gt; &lt;span class="nx"&gt;Sad&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;country&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;“&lt;/span&gt;&lt;span class="nx"&gt;Serbia&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;newUser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Okay, now user and newUser have reference to the same object. If you try to do something like: &lt;code&gt;user === newUser&lt;/code&gt; you will get true, as expected.&lt;/p&gt;

&lt;p&gt;To avoid all spreading and loadash deepcloning functionalities to make new copy of the object, we can simply do this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;newUser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;user === newUser&lt;/code&gt; is no longer true, both of the constants have their own reference to the completly same data but different object. Even children objects don’t have same reference, hence you may do with that object whatever you want without worrying about immutability.&lt;/p&gt;

&lt;p&gt;Simply pinpoint property in child object, change it and your job is done.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;newUser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;location&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;city&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="err"&gt;“&lt;/span&gt;&lt;span class="nx"&gt;Belgrade&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then with that updated object update your state or do whatever you want. :)&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This idea can be explored furthermore, test performance against familiar processes of deepcloning is just one of the  many roads that we can take together.&lt;/p&gt;

&lt;p&gt;I’m frankly happy to hear out your thoughts on this topic good people.&lt;/p&gt;

&lt;p&gt;Thank you for your time. I hope you have enjoyed reading this post :)&lt;/p&gt;

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