<?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 Mohanraj Venkatachalam on Medium]]></title>
        <description><![CDATA[Stories by Mohanraj Venkatachalam on Medium]]></description>
        <link>https://medium.com/@mohanrajvengi?source=rss-4b7980ffc684------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*7Wh7KDZEqyR3ag8nY5D05w.png</url>
            <title>Stories by Mohanraj Venkatachalam on Medium</title>
            <link>https://medium.com/@mohanrajvengi?source=rss-4b7980ffc684------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 15:25:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mohanrajvengi/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[Playwright: High-Level understanding of browser automation testing]]></title>
            <link>https://culture.kissflow.com/playwright-high-level-strategies-for-end-to-end-testing-054ecbed6833?source=rss-4b7980ffc684------2</link>
            <guid isPermaLink="false">https://medium.com/p/054ecbed6833</guid>
            <dc:creator><![CDATA[Mohanraj Venkatachalam]]></dc:creator>
            <pubDate>Thu, 25 Jan 2024 02:18:28 GMT</pubDate>
            <atom:updated>2024-01-25T02:44:30.836Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2ugdrkZIgX_No8ocJejG6g.png" /><figcaption>Playwright library</figcaption></figure><p>In our organization, we conduct regular <strong>Frontend Chapter sessions</strong> where we delve into new technologies, tools, testing methodologies, and <strong>development practices</strong>. I recently took the initiative to lead a session on Playwright. I explored the intricacies of Playwright and shared valuable insights with the team, highlighting its significance. This session proved beneficial in equipping our team with the knowledge required to utilize the Playwright Library effectively.</p><h3>What is the importance of End-to-End testing?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vxqNEOsFYwHjyz-JxYMu8A.png" /><figcaption>End-to-End Testing</figcaption></figure><p>End-to-end testing is essential for validating user functionalities and is important in minimizing bugs in the production environment. Its primary focus is on thorough regression testing, contributing to the enhancement of large-scale products with cost-efficient measures.</p><h3>What is Playwright</h3><p>Playwright is an open-source browser automation library and tool developed by <strong>Microsoft</strong>. It allows developers to automate browser-related tasks, such as interacting with web pages, testing web applications, and performing browser automation.</p><h3>High-Level Architecture</h3><p>Playwright distinguishes itself from other testing libraries through its unique approach. Unlike traditional testing tools, Playwright doesn’t consume the entire browser; instead, it leverages the APIs of browser engines, which is notably efficient. This allows for the easy creation of contexts for pages, supporting multiple programming languages for test case creation. Additionally, Playwright facilitates communication between the test runner and the browser engine through WebSockets rather than traditional HTTP request and response methods. The test runner, written in Node.js, contributes to swift execution, thanks to its utilization of <strong>contexts</strong> and <strong>web workers</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*enec4A5Enq3V_AeOnJTGEQ.png" /></figure><h3><strong>Key Features</strong></h3><ol><li>One API , Any Browser, Any Api</li><li>Resilient, No Flaky tests</li><li>Full Isolation, Fast Execution</li></ol><h4>One API, Any Browser, Any Platform</h4><p>users can execute a single test case across various browsers, versions, or resolutions. This flexibility extends to configuring browser specifications such as resolution, timezone, languages, and themes. The configuration options are made possible through the creation of browser contexts. Furthermore, developers can write test cases in any of the four supported languages</p><ul><li>JavaScript/TypeScript</li><li>Java</li><li>Python</li><li>C#</li></ul><h4>Resilient, No Flaky tests</h4><p>Automatic waiting (<strong>Autowait</strong>) and <strong>tracing</strong> are vital for achieving these features.</p><p>Autowait runs our tests asynchronously, making testing asynchronous actions in applications easier. It significantly reduces test failures by incorporating auto-retries, ensuring <strong>robustness</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Z8KiPDzfJgh0VE_6hYszw.png" /><figcaption>Tracing</figcaption></figure><p>Tracing is invaluable for backtracking issues by identifying what failed and where. It provides the ability to analyze screenshots offering a comprehensive view. Users can examine failed cases on a browser basis, checking details such as networks, console logs, and source code.</p><p>This comprehensive approach enhances trust in the Playwright.</p><h4>Full Isolation, Fast Execution</h4><p>Playwright generates a <strong>new context</strong> for each test, and the process of creating a context is notably faster than the typical browser creation. The uniqueness of <strong>multiple browser sessions</strong> is a distinctive feature of Playwright.</p><p>Naturally, Playwright exhibits <strong>fast execution</strong> owing to its utilization of multiple workers, state sharing, context, and parallelism. Additionally, it provides the option to distribute test cases across different machines, allowing for concurrent execution, and results can be seamlessly merged for a comprehensive outcome.</p><p><strong>Why Isolation?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*E-GAx9nHByiqfJ7IiyF2YA.gif" /><figcaption>Why isolation</figcaption></figure><p><strong>No Failure Carry-Over:</strong></p><p>Failures in one test do not impact others. Each test operates independently, ensuring that issues do not cascade.</p><p><strong>Simplified Debugging:</strong></p><p>Debugging errors or flakiness becomes more straightforward. Individual tests can be run multiple times, facilitating focused and efficient debugging.</p><p><strong>Order Independence:</strong></p><p>Running tests in parallel, sharding, or similar scenarios doesn’t require consideration of order. Each test stands alone, enhancing flexibility in test execution</p><h3>Tooling</h3><p>Playwright provides a convenient feature known as code generation, allowing you to create test cases by recording your browser actions.</p><p>Run the following command:</p><pre>npx playwright codegen https://example.com</pre><p>Perform any desired actions in the browser, and Playwright will automatically convert those actions into a generated test case. This streamlined process simplifies the creation of test scripts based on your interactions with the web application.</p><p>Other tools like Trace Viewer and Playwright Inspector are very useful for debugging.</p><h3>Add-on</h3><p>In addition to its core testing capabilities, Playwright offers support for various testing types and experimental features</p><ol><li>Accessibility testing</li><li>Component testing ( Experimental )</li><li>API testing</li><li>Performance Testing with external libraries (ex: artillery )</li><li>Android ( Experimental )</li><li>Electron ( Experimental )</li></ol><h3>Limitations of Playwright:</h3><p><strong>Learning Curve:</strong></p><p>Playwright’s rich feature set may result in a steeper learning curve, especially for users new to browser automation tools.</p><p><strong>Community and Ecosystem:</strong></p><p>While Playwright’s community is growing, it may not be as extensive as some other tools like Selenium. This could affect the availability of third-party plugins, extensions, and community resources.</p><p><strong>Resource Consumption:</strong></p><p>Running multiple browser instances concurrently can consume significant system resources. Effective resource management is crucial, particularly in environments with limited resources.</p><p><strong>JS Execution Context Issues with Iframe and Sandbox:</strong></p><p>Accessing the JavaScript execution context of a browser page might be limited in certain scenarios, especially when dealing with cross-origin iframes or sandboxed iframes. This could pose challenges in certain testing scenarios.</p><p>These limitations highlight considerations that users should be aware of when adopting Playwright for their testing needs. It’s important to weigh these factors against the benefits and specific requirements of your project.</p><h3>Conclusion</h3><p>In conclusion, diving into the world of Playwright has been an enlightening journey, uncovering the depths of its capabilities and innovative features. Playwright has emerged as a reliable and efficient companion for browser automation and end-to-end testing.</p><p>Its unique architecture, resilient testing strategies, and the flexibility to work with any browser on any platform make Playwright a standout choice.</p><p>While Playwright presents a powerful set of tools, it’s crucial to be mindful of its learning curve and the evolving nature of its community. Additionally, understanding resource consumption and addressing JS execution context issues are key considerations for successful implementation. Whether you’re a seasoned tester or just embarking on your testing journey, Playwright offers a toolkit that empowers you to automate with confidence.</p><p>Happy testing !!</p><h3><strong>Reference</strong>:</h3><p>For a deep dive into browser automation and cutting-edge testing strategies, explore the capabilities of Playwright on their official</p><p>website: <a href="https://playwright.dev/">Playwright</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=054ecbed6833" width="1" height="1" alt=""><hr><p><a href="https://culture.kissflow.com/playwright-high-level-strategies-for-end-to-end-testing-054ecbed6833">Playwright: High-Level understanding of browser automation testing</a> was originally published in <a href="https://culture.kissflow.com/">Kissflow Culture | Explore Our Butterfly Effect</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enhancing CSS Optimization: LightningCSS vs. CSSnano]]></title>
            <link>https://culture.kissflow.com/enhancing-css-optimization-lightningcss-vs-cssnano-fdddfa4cd670?source=rss-4b7980ffc684------2</link>
            <guid isPermaLink="false">https://medium.com/p/fdddfa4cd670</guid>
            <dc:creator><![CDATA[Mohanraj Venkatachalam]]></dc:creator>
            <pubDate>Mon, 25 Sep 2023 19:07:49 GMT</pubDate>
            <atom:updated>2023-09-25T19:12:44.304Z</atom:updated>
            <content:encoded><![CDATA[<h4>Introduction:</h4><p>In the world of web development, optimizing CSS is a crucial step in improving website performance. One tool that has garnered attention recently is <strong>LightningCSS</strong>, a <strong>lightning-fast CSS</strong> <strong>optimizer</strong>. In this article, we’ll explore what LightningCSS has to offer and how it compares to the popular CSSnano. But before diving into the comparison, let’s take a moment to understand some fundamental concepts.</p><h4><strong>Understanding the Basics:</strong></h4><ul><li><strong>Webpack</strong>: Webpack is a module bundler used to bundle JavaScript files for web applications. While it primarily deals with JavaScript, it plays a significant role in optimizing CSS as well.</li><li><strong>CSS Minification</strong>: CSS minification is the process of reducing the file size of CSS code by removing unnecessary spaces, characters, and formatting. This not only reduces the file size but also speeds up the loading and execution of code in web browsers.</li><li><strong>Minification vs. Compression</strong>: It’s essential to distinguish between minification and compression. Minification alters the content of code by stripping out unwanted elements, while compression focuses on compacting files before serving them to the browser.</li></ul><h4>Introducing LightningCSS:</h4><p><strong>LightningCSS</strong> is a powerful CSS optimizer written in <strong>Rust</strong>. It boasts high-speed parsing, transformation, and minification capabilities. What sets it apart from other tools like esbuild and CSSnano is its exceptional <em>performance</em>, <em>reduced build times</em>, <em>smaller file sizes</em>, and <em>superior browser</em> compatibility.</p><p><em>An extremely fast CSS parser, transformer, and minifier written in Rust.</em></p><h4>Advantages of LightningCSS</h4><p><strong>1. Speed: Faster Than a Bolt of Lightning</strong></p><p>LightningCSS lives up to its name by delivering lightning-fast results. This tool is capable of optimizing large CSS files in a matter of seconds. In a production environment where every millisecond counts, LightningCSS shines, ensuring your web applications run at top speed. Say goodbye to sluggish load times and hello to snappy user experiences.</p><p><strong>2. Size Matters: Compact and Efficient CSS Code</strong></p><p>One of the most significant advantages of LightningCSS is its ability to produce highly optimized CSS code. This optimization translates to smaller file sizes for your web pages. The result? Faster loading times and an overall improved user experience. Smaller CSS files mean less bandwidth usage, which is especially crucial for mobile users and those on slower internet connections.</p><p><strong>3. Compatibility: A Perfect Fit for Your CSS Toolbox</strong></p><p>LightningCSS plays well with others. It seamlessly integrates with a wide range of CSS features, including CSS variables, nested rules, and media queries. Whether you’re starting from scratch or enhancing existing code, LightningCSS adapts to your needs. This compatibility ensures a smooth transition, saving you time and effort in the development process.</p><h4><strong>Replacing CSSnano with LightningCSS:</strong></h4><p>Incorporating LightningCSS into your project is straightforward. By updating your Webpack configuration to utilize the CSSMinimizerPlugin with the LightningCSS minifier, you can achieve significant improvements in CSS build size and performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oQL2amcBOnQnTlqHIOMdVw.png" /></figure><p>I made adjustments to my Webpack configuration by substituting the OptimizeCSSAssetsPlugin with the CSSMinimizerPlugin and configuring it to employ the lightningCssMinify minification tool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*46NOjNRSErzDi8Pwv0G3HA.png" /><figcaption>CSSNano vs LightningCSS</figcaption></figure><h4><strong>Performance Comparison:</strong></h4><p>In a real-world scenario, we implemented LightningCSS in our project and compared it to CSSnano. The results were impressive. LightningCSS generated a smaller build size (<strong>11MB vs. 12MB</strong>) in less time (<strong>459s vs. 539s</strong>), showcasing its efficiency and speed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vB4-pAWZEfuhuY3F" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OemhWbyRd_rHggUT" /></figure><h4><strong>Uncovering Limitations:</strong></h4><p>While LightningCSS shines in many aspects, we encountered a limitation related to <strong>CSS variables.</strong> Within the LightningCSS minifier, there was a peculiar issue with CSS variables. Specifically, a variable named -container-width was set at 80% with a fallback value of 100% and used in the width property of a class named .container. Surprisingly, even after changing the value of -container-width to 50%, the width of the .container element remained fixed at 80%.</p><p>To address this limitation, we recommend exploring alternative CSS minification tools, as the LightningCSS minifier is known to exhibit compatibility issues with CSS variables. Alternatively, you can use the !important flag to override the default value of the -width-context CSS variable. However, be cautious as this approach can complicate CSS maintenance.</p><h4>Conclusion:</h4><p>LightningCSS is undoubtedly a powerful CSS optimization tool with remarkable speed and performance benefits. When used in the right context, it can outshine CSSnano. However, as with any tool, it’s essential to be aware of its limitations and use it judiciously in your projects.</p><h4>References:</h4><ul><li><a href="https://webpack.js.org/">Webpack</a></li><li><a href="https://lightningcss.dev/">Getting Started — Lightning CSS</a></li><li><a href="https://cssnano.co/">CSSnano — PostCSS Based CSS Optimizer</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fdddfa4cd670" width="1" height="1" alt=""><hr><p><a href="https://culture.kissflow.com/enhancing-css-optimization-lightningcss-vs-cssnano-fdddfa4cd670">Enhancing CSS Optimization: LightningCSS vs. CSSnano</a> was originally published in <a href="https://culture.kissflow.com/">Kissflow Culture | Explore Our Butterfly Effect</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding JavaScript Mental Models?]]></title>
            <link>https://culture.kissflow.com/understanding-javascript-mental-models-eaaa0c391b3?source=rss-4b7980ffc684------2</link>
            <guid isPermaLink="false">https://medium.com/p/eaaa0c391b3</guid>
            <category><![CDATA[js]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[browsers]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web]]></category>
            <dc:creator><![CDATA[Mohanraj Venkatachalam]]></dc:creator>
            <pubDate>Fri, 16 Jun 2023 18:09:15 GMT</pubDate>
            <atom:updated>2023-09-25T08:26:28.764Z</atom:updated>
            <content:encoded><![CDATA[<p>To make intelligent decisions</p><h4><strong>The problem</strong></h4><p>When I encountered an error, I initially had a funny thought that something inappropriate was happening on my computer 😅. I believed it couldn’t be caused by my code 🖥️ because I thought I was familiar with it (specifically, JavaScript). However, after carefully examining and fixing the errors in my code, I realized that the problem was indeed caused by my own mistakes.</p><p>The problem here is feeling trapped in my limited knowledge, I received a book recommendation from a colleague called “<a href="https://justjavascript.com/">Just JavaScript</a>” by <strong>Dan Abramov</strong>. As I delved into the book, I came to the realization that my understanding of JavaScript was flawed. Despite my initial belief that I was familiar with it, I had actually been mistaken</p><h4>What are Mental Models?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K_rA4NtwZS5lQXmfj8_r2A.png" /><figcaption>Mental Model</figcaption></figure><p>Upon closer examination of the provided image, it appears to convey the idea that we possess a specific piece of information, the accuracy of which remains uncertain. We proceed to analyze and evaluate this information in order to make a decision, yet we remain unaware of whether the outcome of our decision is correct or incorrect</p><p>I’ve finally learned a few important things about JavaScript mental models, which have helped me gain a better understanding of how it works.</p><ol><li>Fast and slow</li><li>Values, Variables, Code</li><li>Primitive Values and Object</li><li>Properties</li><li>Mutation</li><li>Prototypes</li></ol><h4><strong>Fast and Slow</strong></h4><p>Before diving into the topics, let’s quickly review or summarize the information</p><pre>function duplicateSpreadsheet(original) {<br>  if (original.hasPendingChanges) {<br>    throw new Error(&#39;You need to save the file before you can duplicate it.&#39;);<br>  }<br>  let copy = {<br>    created: Date.now(),<br>    author: original.author,<br>    cells: original.cells,<br>    metadata: original.metadata,<br>  };<br>  copy.metadata.title = &#39;Copy of &#39; + original.metadata.title;<br>  return copy;<br>}</pre><p>Perhaps you didn’t notice (but kudos if you did!) that this function accidentally changed the name of the original student. It’s common for programmers to overlook bugs like this, as it happens frequently in their day-to-day work.</p><p>There are two systems: <strong>a fast one and a slow one.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0sbgjCnOlf7sxbY7lFwD5A.png" /></figure><p>When you read the description that mentions quickly reviewing the code, your brain tends to go through it swiftly. As a result, you might not notice that the original value gets overwritten.</p><p>To gain a better understanding of the flow or identify errors, it’s helpful to go through the code slowly. Taking your time allows you to grasp the context more effectively and facilitates thorough debugging.</p><p>When attempting to solve <strong>complex logic</strong>, it’s better to use a <strong>slower system</strong></p><h4>Values, Variables, and Code</h4><p>In JavaScript code, we work with values. These values can be imagined as stars in the sky, while the code itself is like the Earth. Just as meteorites are far away in outer space, values are separate from the code. Values in JavaScript are divided into two categories:<strong> primitive values and non-primitive values</strong> will discuss this later</p><p>Note: Primitive values are immutable</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5su9z8LiD7nfcExaVLVzzA.png" /><figcaption>Value, Variable, Code</figcaption></figure><p>Variables are like <strong>wires</strong>. The variables are pointing to a value<br>look at the below example</p><pre>let john = &#39;traveler&#39; + 6;</pre><p>Keep in mind that the variable should be on the left-hand side, while the right-hand side should consist of an <strong>expression or a value</strong>. This understanding will prove useful in upcoming topics, particularly when dealing with <strong>properties</strong></p><pre>let john = &#39;traveler&#39;;<br>john = &#39;developer&#39;;<br>console.log(john);</pre><p>We understand that string values, being primitive, cannot be changed. However, the ‘<em>traveler</em>’ variable does change to ‘<em>developer</em>’. This may seem contradictory, but it’s not. While primitive values themselves cannot change, it doesn’t mean variables cannot change. To clarify, we need to separate two concepts: variables are not the same as values, and variables simply point to values.</p><h4>Primitive Values and Object</h4><p><strong>Primitive Values</strong></p><p>We’ve discussed values previously, and it’s worth noting that primitive values cannot be changed once they are assigned. In JavaScript, a string represents a series of characters, while an array represents a series of items. Both have their own characteristics. An array can be modified by accessing and modifying specific items within it, whereas a string cannot be directly modified at individual character positions. Understanding the distinction between arrays and strings as sequences are important when working with primitive values in JavaScript.</p><pre>let array = [1, 5, 10];<br>let strings = &#39;welcome&#39;;</pre><p>We can use a similar method to access the first item of an array and the first character of a string. This similarity creates a sense that strings can be treated like arrays</p><pre>console.log(array[1]); // 5<br>console.log(strings[0]); // &quot;w&quot;</pre><p>However, that is not the case. Let’s examine this more closely. We have the ability to modify the second item of an array</p><pre>array[0] = 22;<br>console.log(array); // [22, 5, 10]</pre><p>It is natural to assume that we can apply the same modification to a string</p><pre>strings[0] = &#39;q&#39;; // welcome </pre><p>However, that assumption is incorrect. It’s crucial to understand this important detail: strings are primitive values, and all primitive values are immutable</p><p><strong>Object</strong></p><p>Finally, we have reached the topic of objects! This category encompasses <strong>arrays, dates, RegExps, and other non-primitive values</strong>. Unlike the previously discussed values, objects are not considered primitive.</p><pre><br>console.log(typeof({})); // &quot;object&quot;<br>console.log(typeof([])); // &quot;object&quot;<br>console.log(typeof(new Date())); // &quot;object&quot;<br>console.log(typeof(/\d+/)); // &quot;object&quot;<br>console.log(typeof(Math)); // &quot;object&quot;</pre><p>Consequently, they are mutable by default, meaning we can modify them. We can access the properties of objects using the dot notation (.) or square brackets.</p><pre>let john = {<br>  name: &#39;cena&#39;,<br>  address: { city: &#39;uk&#39; },<br>  detail: {<br>    occupation : &#39;actor&#39;<br>  }<br>};</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oodYYQuaeJp2U9J7JvDnBQ.png" /><figcaption>Datatypes in js</figcaption></figure><p>The distinguishing factor of objects is their ability to be created in <strong>multiple instances</strong>. Whenever we utilize the {} object literal, unlike string, it generates a completely new object value. The same principle applies to arrays, dates, and other objects — each time we create them, we produce a distinct object.</p><p>Let’s delve into the significance of <strong>equality in JavaScript</strong> and why it holds importance.</p><p>Equality is a fundamental concept in JavaScript that involves comparing values. There are different ways to perform equality comparisons in JavaScript, each serving a specific purpose. Let’s explore a few common approaches:</p><ol><li><strong>Strict Equality (===)</strong>: This comparison operator checks if two values are both equal in value and type. If they are <strong>identical</strong>, it returns true.</li><li><strong>Loose Equality (==):</strong> The double equals operator performs a comparison after applying type coercion if the operands are of different types. It tries to convert the values to a common type and then checks for equality. However, it can lead to unexpected results due to<strong> automatic type conversions</strong>, so it’s generally recommended to use strict equality instead.</li><li><strong>Same Value Equality (Object.is())</strong>: The Object.is() method compares two values and determines if they have the same value. It behaves similarly to strict equality (===) but with some differences. For instance, it considers <strong>NaN</strong> values as equal and treats <strong>-0 </strong>and<strong> +0</strong> as not equal.</li></ol><p>Understanding these different approaches to equality can help you write more reliable and predictable JavaScript code.</p><h4><strong>Properties</strong></h4><p>We have previously discussed objects. As an example, let’s consider a variable named ‘john’ that refers to an object value. By using the curly braces {} notation, we can create a new object value.</p><pre>let john = {};</pre><p>In the realm of JavaScript, both variables and properties function as “<em>wires</em>” that facilitate the flow of data</p><p>A key consideration to remember when naming a property is that within a single object, it’s not possible to have two properties with the same name. For instance, it’s not permissible in our object to have two properties named “<em>name</em>.”</p><pre>let john = { name : &quot;cena&quot;};<br>console.log(john.name)</pre><p>Let’s consider a scenario where we attempt to access a property that does not exist:</p><pre>let john = { surname: &#39;Cena&#39;, age: 45 };<br>console.log(john.isBack); </pre><p>When encountering such a situation, we may wonder how JavaScript determines the value it should provide us with. In our JavaScript, a set of rules is followed, which can be summarized as follows:</p><ol><li>Evaluate the value before the dot (.) operator.</li><li>If that value is either null or undefined, an error is immediately thrown.</li><li>Check if the object has a property with the specified name if the property exists, return the value associated with it or if the property does not exist, return the value undefined.</li></ol><p>What would be the outcome if you try to access a property called toWrestling?</p><pre>let john = { surname: &#39;Cena&#39;, age: 45 };<br>console.log(john.isBack.toWrestling); </pre><p>In this case, if you try to access <strong>john.isBack.toWrestling</strong>, it would result in an error being thrown because <strong>undefined.toWresting</strong> is not an expression</p><h4>Mutation</h4><p>Let’s summarize the first example to understand what is actually happening. Throughout our discussion, we have been considering variables as “<em>wires</em>” that hold values. Multiple variables can point to the same value. In the case of changing the variable <strong>updatedStudent.studentInfo.name</strong>, it also changes <strong>student.studentInfo.name</strong> This occurs because there are no multiple references involved; both variables point to the same value.</p><pre>function updateStudentName(student, newName) {<br> let updatedStudent = {<br>    studentInfo = student.studentInfo<br>    parentInfo : {<br>    }<br>  }<br>  updatedStudent.studentInfo.name = newName;<br>  return updatedStudent;<br>}</pre><p>what’s the point here?</p><p><strong>Mutation</strong> is a term used to describe the action of “<em>changing</em>” something. It refers to modifying an object or its property. Essentially, when we say that we changed an object’s property, we can also say that we mutated the object (and its property). Both expressions convey the same meaning.</p><p>Simply we can say “Changing an object’s property is also called <em>mutating</em>”</p><h4>Prototype</h4><p>In the previous modules, we covered topics such as object properties and mutation. However, there is still one more crucial aspect to discuss prototypes!</p><p>Check the example below and use your slow system to check the output.</p><pre>let john = { name : &quot;cena&quot; }<br>console.log(john.age) // 65 or undefined</pre><p>If you guessed that the answer is “<em>undefined</em>,” wow, you did a great job! However, I’m sorry to say that you are incorrect. Hilariously enough, the actual output for this code is 65.</p><p>But is it possible? yes it is</p><p>Here are two variables that are associated with two objects.</p><pre>let john = {<br>  name : &quot;cena&quot;<br>}<br>let johnAge = {<br>  age : 65<br>}</pre><p>Here both are different objects connecting with two different wires (Variables) and It doesn&#39;t have a connection either.</p><p>In our mental model, we initially assumed that if an object property doesn’t exist, it throws <strong>undefined</strong>. However, we can establish an invisible connection between the <em>john</em> and <em>johnAge</em> objects by utilizing <strong>__proto__</strong> in the john object. This way, if a property is missing in the john object, it will automatically search for and return the property from the invisibly connected johnAge object if it exists.</p><pre>john = {<br>  __proto__ : johnAge<br>  name : &quot;cena&quot;<br>}<br>console.log(john.johnAge) // 65</pre><p>The concept of a prototype in JavaScript refers to the ability of any JavaScript object to select another object as its <strong>prototype</strong>.</p><p>The prototype chain in JavaScript is not a distinct entity but rather a relationship between objects. In JavaScript, an object can establish a connection to another object as its <strong>prototype</strong>.</p><pre>let john = {<br>  <br>}<br>console.log(john.__proto__) </pre><p>Let’s consider an object called <strong>John</strong> created using empty curly braces {}. If we examine its prototype using <strong>john.__proto__</strong>, we might expect it to be null or undefined. However, surprisingly, it will display an intriguing object with various properties, including <strong>hasOwnProperty , assign, entries …</strong>” due to the inbuilt prototypes in javascript it was showing.</p><p>The <strong>__proto__</strong> property of an object can be modified or reassigned, which can lead to <strong>potential issues </strong>that are called<strong> prototype polluting</strong>. Setting it to <strong>null</strong> or <strong>undefined</strong> is not recommended. This is why the <strong>new</strong> keyword is often used to create instances of objects, ensuring a more reliable and structured approach.</p><p>Example</p><pre>class Wrestler {<br>    constructor() {<br>        this.name = &#39;john&#39;;<br>    }<br>    age() {<br>        console.log(&#39;65&#39;);<br>    }<br>};<br>let wrestler1 = new Wrestler(); // __proto__: Wrestler.prototype<br>let wrestler2 = new Wrestler(); // __proto__: Wrestler.prototype<br>wrestler1.age();<br>wrestler2.age();</pre><p>In practical coding scenarios, you are unlikely to directly utilize prototypes in your code. In fact, it is discouraged to even use the <strong>__proto__</strong> syntax.</p><p><strong>Prototypes</strong> are considered somewhat unconventional, and most frameworks have not adopted them as a prevalent paradigm. Nevertheless, you may encounter prototypes operating behind the scenes, influencing other features and behaviors within JavaScript.</p><p>With these mental models in place, you should feel more equipped to make informed and intelligent decisions. Understanding the intricacies of JavaScript and having a solid mental model of its concepts will help you navigate the language with confidence and make effective choices in your code.</p><h4>Reference</h4><p>Just Javascript by <strong>I’m Dan Abramov</strong> — This series of books dives deep into the workings of JavaScript, helping you develop a solid mental model of the language.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eaaa0c391b3" width="1" height="1" alt=""><hr><p><a href="https://culture.kissflow.com/understanding-javascript-mental-models-eaaa0c391b3">Understanding JavaScript Mental Models?</a> was originally published in <a href="https://culture.kissflow.com/">Kissflow Culture | Explore Our Butterfly Effect</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>