<?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 Dixit Patel on Medium]]></title>
        <description><![CDATA[Stories by Dixit Patel on Medium]]></description>
        <link>https://medium.com/@dixitk13?source=rss-be4fc18ce241------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*OhKGNFKixVEgRzrIWx9ayg@2x.jpeg</url>
            <title>Stories by Dixit Patel on Medium</title>
            <link>https://medium.com/@dixitk13?source=rss-be4fc18ce241------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 11:10:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dixitk13/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[One liner chats?]]></title>
            <link>https://medium.com/@dixitk13/one-liner-chats-3c7ed611bd48?source=rss-be4fc18ce241------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c7ed611bd48</guid>
            <category><![CDATA[communication]]></category>
            <category><![CDATA[slack]]></category>
            <dc:creator><![CDATA[Dixit Patel]]></dc:creator>
            <pubDate>Sat, 23 May 2020 05:23:07 GMT</pubDate>
            <atom:updated>2020-05-23T05:23:07.859Z</atom:updated>
            <content:encoded><![CDATA[<p>Hit a paywall? Also published in <a href="https://dixitk13.github.io/one-liner-chats">here</a></p><p>The entire world is hooked on messaging and being connected digitally.</p><p>Our world revolves around notifications and checking them or needing to check them due to on-call duties or maybe you are just the kind of person who replies to chats instantly.</p><p>The notification sound of iMessage is just iconic or has become iconic. But do multiple notifications irritate you?</p><p>Do you get irritated by 5 notifications grouped under the same application by a single friend of yours?</p><h4><strong>Scenario 1</strong></h4><pre>[10:15 AM] John Parker: Hi Dixit<br>[10:15 AM] John Parker: About that PR<br>[10:16 AM] John Parker: Did you get a chance to look at it<br>[10:16 AM] John Parker: ?<br>[10:17 AM] John Parker: Its just a small change from the ticket TKT-123<br>[10:17 AM] John Parker: Here’s a link for the same<br>[10:18 AM] John Parker: <a href="https://github.com/TKT/pulls/321">https://github.com/TKT/pulls/321</a><br>[10:20 AM] Dixit Patel: Nope, totally forgot. Lemme do it right away!<br>[10:25 AM] John Parker: Also, that PR doesn’t fix 123 completely,<br>[10:25 AM] John Parker: its a sub-task<br>[10:25 AM] John Parker: jira stuff you know …<br>[10:26 AM] John Parker: but boss signed off<br>[10:26 AM] John Parker: gotta ship it<br>[10:30 AM] Dixit Patel: Right, on it.</pre><h3><strong>I do! There, I said it! 🙈</strong></h3><p>Most of people in this world might have used one or another form of chat/messaging like iMessage, Jabber, Slack, Teams, etc. Today, at most workplaces revolve around messaging and are primary forms of communication for most people working w/ each other.</p><p>Software engineers all have a habit of writing code and using the most popular version control to manage their code called GIT.</p><p>Can you follow that with your chats? — Absolutely!</p><p>Here’s what I do, or rather how my pings look like:</p><pre>[10:15 AM] Dixit: Hi John, about that PR, did you get a chance to look at it? Its just a small change from the ticket TKT-123. Here’s a link for the same: <a href="https://github.com/TKT/pulls/321">https://github.com/TKT/pulls/321</a></pre><p>Further on if John wants to say “He’s looking at it”, he either reacts with an “ACK” reaction/emoji on the same message or says in a straight one liner, and the conversation could maybe be something like:</p><h3><strong>Scenario 2</strong></h3><pre>[10:15 AM] Dixit Patel: Hi John, about that PR, did you get a chance to look at it? Its just a small change from the ticket TKT-123. Here&#39;s a link for the same: https://github.com/TKT/pulls/321 &lt;👌&gt;</pre><pre>[10:16 AM] John Parker: Nah, I didn&#39;t get a chance mate. Lemme do that right away.</pre><pre>[10:17 AM] Dixit Patel: Also, that PR doesn&#39;t completely fix TKT-123, but attempts a sub-task for it. Boss says ship it and complete the TKT-123 later in the day.</pre><pre>[10:18 AM] John Parker: Right, on it. Also The TKT-331 kinda needs some priority. Seems to me like its breaking on Chrome 83 due to downloads being blocked in iframe, before customers report. Should be a small fix.</pre><p>Now one would ask, what does this benefit me with?</p><p>Well, I’ll say why maintain commit history with 52th word mark and wrap the rest of the commit message at 72th word mark?</p><h3><strong>📜 HISTORY 📜</strong></h3><p>Its’s a powerful thing. Commit history is a very important thing!</p><p>It helps understand the how the code has been developing and what churn has been happening in the codebase, etc etc.</p><p>To me scenario 1 looks like a commit history which is shown below:</p><pre>* 5d53d5a - complete<br>* 3b97cf3 - wip<br>* 8c2e4b8 - pull from master<br>* 4407227 - boss called wip<br>* 70cdc42 - typo<br>* 329f368 - fix padding/margin<br>* 18007ad - #ABC321 in progress</pre><p>Where as the scenario 2 looks like:</p><pre>* 6e53924 - Fix TKT-333 bug found via review w/ @jparker<br>* 844b34c - Fix TKT-331 chrome 83 iframe download<br>* 57152ff - Feat TKT-322 allowing i18n for only the menus</pre><p>Which one do you like more?</p><p>Retrospection is the key, scroll two pages up and you’ll have conversations which kinda helps remember the status of things.</p><h3>Use threads.</h3><p>Threads will let you condense/group those conversations into singular items.</p><p>Together we can make “chat-history-great”!🍻</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c7ed611bd48" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Typescript discriminator]]></title>
            <link>https://medium.com/@dixitk13/typescript-discriminator-a3158f292ef0?source=rss-be4fc18ce241------2</link>
            <guid isPermaLink="false">https://medium.com/p/a3158f292ef0</guid>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Dixit Patel]]></dc:creator>
            <pubDate>Sat, 28 Mar 2020 02:22:42 GMT</pubDate>
            <atom:updated>2020-03-28T02:25:23.842Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*23yHhFHP23Omf72d" /><figcaption>Photo by <a href="https://unsplash.com/@jipy32?utm_source=medium&amp;utm_medium=referral">Jean-Philippe Delberghe</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Very often we have use-cases where we would like to use a single type Union Type but still, be sure about the properties inside them.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/624773018262bcac5e7286e3ddf6ffe5/href">https://medium.com/media/624773018262bcac5e7286e3ddf6ffe5/href</a></iframe><p>But under the hood Typescript unions are more of “common” properties inside them instead of “having all the properties”.</p><p>So when you try and use it like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a6888d6c38cfa0d97375f5cc5671d5f/href">https://medium.com/media/6a6888d6c38cfa0d97375f5cc5671d5f/href</a></iframe><p>whereas you would expect person to have {name, salary} or {name, power} and choose between them depending on what the person is.</p><p>This is where discriminators come in power-play. Bear with my variable nomenclature:</p><p>Let&#39;s define an enum to contain both the use-cases of Person’s we have, calling it PersonType and then define a type combining HumanResource and Employee.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f3d81936ee586605895b7d1d870d468c/href">https://medium.com/media/f3d81936ee586605895b7d1d870d468c/href</a></iframe><p><em>Originally published at </em><a href="https://gist.github.com/ce569403094ab662bbf229a63b7d119d"><em>http://github.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a3158f292ef0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A simple react countdown timer]]></title>
            <link>https://medium.com/@dixitk13/a-simple-react-countdown-timer-dfae288b6b48?source=rss-be4fc18ce241------2</link>
            <guid isPermaLink="false">https://medium.com/p/dfae288b6b48</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[ux]]></category>
            <dc:creator><![CDATA[Dixit Patel]]></dc:creator>
            <pubDate>Wed, 24 Apr 2019 19:09:54 GMT</pubDate>
            <atom:updated>2019-04-24T19:09:54.337Z</atom:updated>
            <content:encoded><![CDATA[<p>I was recently trying to make a simple countdown timer which counts from a specific time-interval and “finishes” itself</p><p>I just found it amazing that a few lines of code could bring in such a thing!</p><p>the code just uses a state called “minutes<em>”</em> which gets initialized with the total number of seconds for which the timer stays.</p><p>The component accepts minutes till which it must stay alive, converts that into seconds, runs the countdown and then clears the internal logic.</p><pre>&lt;Timer classNames=&quot;time-text&quot; minutes={Number(10)} /&gt;</pre><p>and here’s the entire code</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c46c1a28d3343351487a5a3992fdccc/href">https://medium.com/media/7c46c1a28d3343351487a5a3992fdccc/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dfae288b6b48" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Answers to Front-end JavaScript in 2018–19 — Basic JavaScript questions]]></title>
            <link>https://medium.com/@dixitk13/answers-to-front-end-javascript-in-2018-19-basic-javascript-questions-6fd121afc9eb?source=rss-be4fc18ce241------2</link>
            <guid isPermaLink="false">https://medium.com/p/6fd121afc9eb</guid>
            <category><![CDATA[es6]]></category>
            <category><![CDATA[ecmascript]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Dixit Patel]]></dc:creator>
            <pubDate>Mon, 10 Dec 2018 05:22:57 GMT</pubDate>
            <atom:updated>2018-12-10T05:22:46.517Z</atom:updated>
            <content:encoded><![CDATA[<h3>Answers to Front-end JavaScript in 2018–19 — Basic JavaScript questions</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZXixptvL4rzkx3EDuj38xw.jpeg" /><figcaption><a href="https://unsplash.com/photos/ieic5Tq8YMk">https://unsplash.com/photos/ieic5Tq8YMk</a></figcaption></figure><p>Trying out my own answers to the article: <a href="https://blog.webf.zone/front-end-javascript-interviews-in-2018-19-e17b0b10514">https://blog.webf.zone/front-end-javascript-interviews-in-2018-19-e17b0b10514</a></p><h3>Section 1: Basic JavaScript questions*</h3><p>*for now. I’ll be giving references to the answers which I find, and they are by no means perfect!</p><h3>Basic JavaScript questions</h3><h4>1. Make the following code work:</h4><pre>const a = [1, 2, 3, 4, 5];</pre><pre><strong>// Implement this<br>a.multiply();</strong></pre><pre>console.log(a); // [1, 2, 3, 4, 5, 1, 4, 9, 16, 25]</pre><p>Answer: There are multiple ways to implement the function “multiply”, one of which is a function added to the prototype of an Array and call it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d7057d3f1279ba76ba49c0babcddc173/href">https://medium.com/media/d7057d3f1279ba76ba49c0babcddc173/href</a></iframe><h4>2. Following code returns `false` in JavaScript. Justify why it happens:</h4><pre>// false<br>0.2 + 0.1 === 0.3</pre><p><strong>Answer: </strong>JavaScript has numbers which are represented as binary because of which floating point cannot be accurate.</p><p>+(0.1 + 0.2).toFixed(12) // 0.3</p><p>references:</p><ol><li><a href="http://adripofjavascript.com/blog/drips/avoiding-problems-with-decimal-math-in-javascript.html">http://adripofjavascript.com/blog/drips/avoiding-problems-with-decimal-math-in-javascript.html</a></li><li><a href="https://stackoverflow.com/questions/10473994/javascript-adding-decimal-numbers-issue">https://stackoverflow.com/questions/10473994/javascript-adding-decimal-numbers-issue</a></li></ol><h4>3. What are the different Data types in JavaScript?</h4><p><em>Hint: Only two types — primitive data types and reference types (objects). There are six primitive types.</em></p><p><strong>Answer: </strong>the six primitive types are as follows:</p><ol><li><strong>Number:</strong> Numbers can be both integers and floating point. Special numbers include Infinity, -Infinity and NaN.</li></ol><pre>let n = 123;<br>n = 12.345;</pre><p>2. <strong>String:</strong> String must have been enclosed in either of the three types of quotes viz. Double &quot;Hello&quot;, Single &#39;Hello&#39; and backticks `Hello`.</p><p>examples:</p><pre>let str = &quot;Hello&quot;;<br>let str2 = &#39;Single quotes are ok too&#39;;<br>let phrase = `can embed ${str}`; // can embed Hello</pre><p>3. <strong>Boolean</strong>: Either of true or false</p><p>4. <strong>Null: </strong>The null type is used for unknown values. It isvery similar to other languages having a “null” value.</p><pre>let something = null;</pre><p>5. <strong>Undefined</strong>: The undefined has its own type. If a variable is declared, but not assigned, then its value is exactly undefined:</p><pre>let somethingElse;</pre><pre>console.log(somethingElse); // &lt;-- this is undefined</pre><p>6. <strong>Arrays</strong>: I believe Arrays don’t need explanations :)</p><pre>let arr = [1,2,3];<br>let arr2 = [&quot;apple&quot;, &quot;ball&quot;];<br>let arr3 = [&quot;aero&quot;, 1];</pre><p>The non-primitives one is Object:</p><p><strong>Objects</strong>: Objects are key:value pairs which are written/separated by commas.</p><pre>let person = { firstName: &quot;steve&quot;, lastName: &quot;Jobs&quot; };</pre><p>There’s a new type called Symbols, which are considered as primitive now.</p><p><strong>Symbols</strong>: Symbols are new primitives in ECMAScript 6. I like to think of them as private keys which don’t clash with the keys present in the objects. They have to be created with the factory method “Symbol()”. Also, every symbol is unique.</p><pre>const symbol1 = Symbol();</pre><pre>Symbol() === Symbol(); // false - every symbol is unique</pre><pre>// Symbols are property keys<br>const MY_KEY = Symbol();<br>const obj = {MY_KEY: 456};<br><br>obj[MY_KEY] = 123;<br>console.log(obj[MY_KEY]); // 123<br>console.log(obj[&quot;MY_KEY&quot;]); // 456</pre><p>references:</p><ol><li><a href="https://javascript.info/">https://javascript.info/</a></li><li><a href="https://developer.mozilla.org/en-US/docs/Glossary/Symbol">https://developer.mozilla.org/en-US/docs/Glossary/Symbol</a></li><li><a href="http://exploringjs.com/es6/ch_symbols.html#sec_primitive-type-symbol">http://exploringjs.com/es6/ch_symbols.html#sec_primitive-type-symbol</a></li></ol><h4>4. Solve the following asynchronous code problem.</h4><p>Answer: Under construction!</p><h4>5. Implement a simple data binding using JavaScript Proxy</h4><p><em>Hint: ES Proxy allows you to intercept a call to any object property or method. To start with, DOM should be updated whenever an underlying bound object is changed.</em></p><p>Answer: Proxies can help us get interact in-directly instead of directly operating on the target. Here’s a simple example where you deal with the personProxy instead of using the properties of the person itself.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/48b634784d94f2dab3775e0e7a3d1d0b/href">https://medium.com/media/48b634784d94f2dab3775e0e7a3d1d0b/href</a></iframe><p>For two way binding with DOM element, the Sitepoint link explains it really well. Do go thru it!</p><p>Also, check out the<a href="https://repl.it/@dixitk13/two-way-es6-proxy?language=html"> repl.it</a> for the same.</p><p>References: <a href="https://www.sitepoint.com/es6-proxies/">https://www.sitepoint.com/es6-proxies/</a></p><h4>6. Explain JavaScript concurrency model</h4><p><em>Are you familiar with any other concurrency model that is used in other programming languages like Elixir, Clojure, Java, etc?</em></p><p><em>Hint: Look for Event loop, task queue, call stack, heap, etc.</em></p><p>Answer: JavaScript is async and single threaded. It uses the event loop to execute functions which might take time, like network requests or file-system operations.</p><p>There are a few <em>“keywords”</em> to know in the JavaScript model: <br><strong>Heap</strong>: Its very similar to the heap everyone knows from Java. Objects are stored/allocated on to the heap.</p><p><strong>Call Stack</strong>: A call stack is LIFO (last in first out) data structure which keeps track of function calls. When two functions one inside the other are called — it pushes the first function in, then pushes the second function on top of the first one and executes them in order from the top.</p><p><strong>Callback Queue</strong>: Any network requests which might take time are pushed to the callback queue by Event Loop. The items are removed and added to call stack when the requests are finished.</p><p><strong>Event Loop</strong>: The only job of the event loop is to keep push items on to the call stack when its empty(no functions on the stack) and it does so by taking the oldest callback and pushing on-to the call-stack.</p><p>Together all these structures form the single threaded async Javascript model. Please do read the below references, they have visual and detailed examples.</p><p>References:</p><ol><li><a href="https://flaviocopes.com/javascript-event-loop/#queuing-function-execution">https://flaviocopes.com/javascript-event-loop/#queuing-function-execution</a></li><li><a href="https://guide.freecodecamp.org/javascript/concurrency-model-and-event-loop/">https://guide.freecodecamp.org/javascript/concurrency-model-and-event-loop/</a></li></ol><h4>7. What does `new` keyword do in JavaScript?</h4><p><em>Hint: In JavaScript, </em><em>new is an operator used to instantiate an object. The aim here is to understand what is happening in terms of scope and memory.</em></p><p><em>Also, lookout for </em><em>[[Construct]] and </em><em>[[Call]].</em></p><p>Answer: The new keyword automatically invokes the constructor function to:</p><ol><li>Create a new object</li><li>binds this to the object</li><li>The constructor function’s prototype object becomes the __proto__ property of the new object. For differences between proto and prototype, highly recommended read: <a href="https://hackernoon.com/understand-nodejs-javascript-object-inheritance-proto-prototype-class-9bd951700b29">https://hackernoon.com/understand-nodejs-javascript-object-inheritance-proto-prototype-class-9bd951700b29</a></li><li>It returns the object from the function.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0b5036741d7f49b61bfce14151dde88b/href">https://medium.com/media/0b5036741d7f49b61bfce14151dde88b/href</a></iframe><h4>8. What are the different function invocation patterns in JavaScript? Explain in detail.</h4><p><em>Hint: There are four patterns, function call, method call, </em><em>.call()and </em><em>.apply()</em></p><p>Answer: inside the code block</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c27c51b687e3b4d38378a9617803597/href">https://medium.com/media/3c27c51b687e3b4d38378a9617803597/href</a></iframe><p>ref: <a href="https://medium.com/javascript-everyday/javascript-theory-function-invocation-patterns-55dbe7aedb7e">https://medium.com/javascript-everyday/javascript-theory-function-invocation-patterns-55dbe7aedb7e</a></p><h4>9. Explain any new upcoming ECMAScript proposal.</h4><p>Answer: Promise.try</p><p>references:</p><ol><li><a href="http://bluebirdjs.com/docs/api/promise.try.html">http://bluebirdjs.com/docs/api/promise.try.html</a></li><li><a href="https://github.com/tc39/proposal-promise-try">https://github.com/tc39/proposal-promise-try</a></li></ol><h4>10. What are iterators and iterables in JavaScript? Any built-in iterators that you know?</h4><p>Answer: An <strong>Iterables</strong> are “objects” which have the Symbol.iterator method implemented. This implementation of iterator method makes the object an iterable.</p><p>An <strong>iterator</strong>, on the other hand, will traverse over the elements of an iterable. I’ll cite @devGson article example here, reference below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/52a88498fbcf0cf456bd490f2b2ccb11/href">https://medium.com/media/52a88498fbcf0cf456bd490f2b2ccb11/href</a></iframe><p>Here’s a bigger example: <a href="https://github.com/dixitk13/js-practice/blob/master/misc/customIterator.js">customIterator.js</a></p><p>references:</p><ol><li><a href="https://scotch.io/@devGson/understanding-iterators-and-iterables-in-javascript">https://scotch.io/@devGson/understanding-iterators-and-iterables-in-javascript</a></li><li><a href="http://exploringjs.com/es6/ch_iteration.html">http://exploringjs.com/es6/ch_iteration.html</a></li></ol><h4>11. Why JavaScript classes are considered bad or an anti-pattern?</h4><p>Is it a myth? Has it suffered Chinese-whispers syndrome? Are there any use cases where they are useful?</p><p>Answer: I don’t think I am qualified enough to answer this question :)</p><h4>12. How to serialize the following object in JSON?</h4><p>If we convert the following object to JSON string, what would happen?</p><pre>const a = {<br>    key1: Symbol(),<br>    key2: 10<br>}</pre><pre><strong>// What will happen?</strong><br>console.log(JSON.stringify(a));</pre><p>Answer: All <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol">Symbol</a>-keyed properties are completely ignored, even when using the replacer function.</p><pre>{ &quot;key2&quot; : 10 } // the output of the above statement</pre><p>Using a replacer function also(which can be a function for replacing the value), we see that for number type it has incremented the value, but for Symbol, it doesn’t do anything.</p><pre>function replacer(key, value) {<br>   if (typeof value === &#39;symbol&#39;) {<br>     return Symbol.for(&#39;apple&#39;);<br>   } else if (typeof value === &#39;number&#39;) {<br>     return value + 1;<br>   }<br>   return value;<br>}</pre><pre>const a = {<br>   key1: Symbol(&#39;apple&#39;),<br>   key2: 10<br>}</pre><pre>console.log(JSON.stringify(a, replacer)); // {&quot;key2&quot;:11}</pre><p>ref: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify</a></p><h4>13. Are you familiar with Typed Arrays? If yes, explain their need and differences as compared to traditional arrays in JavaScript?</h4><p>Answer: The StackOverflow reference explains this better than me writing it.</p><p>references:</p><ol><li><a href="https://stackoverflow.com/questions/13328658/are-the-advantages-of-typed-arrays-in-javascript-is-that-they-work-the-same-or-s">https://stackoverflow.com/questions/13328658/are-the-advantages-of-typed-arrays-in-javascript-is-that-they-work-the-same-or-s</a></li><li><a href="http://2ality.com/2015/09/typed-arrays.html">http://2ality.com/2015/09/typed-arrays.html</a></li></ol><h4>14. How does default argument work?</h4><p><em>If we have to use the default value of the </em><em>timeout when calling </em><em>makeAPIRequest function, what is the correct syntax?</em></p><pre>function makeAPIRequest(url, timeout = 2000, headers) {<br>   // Some code to fetch data<br>}</pre><p>Answer: I personally like to keep default ones at the end but the below code is self-explanatory.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0549067d18a1baaa532e27e04aa6491a/href">https://medium.com/media/0549067d18a1baaa532e27e04aa6491a/href</a></iframe><h4>15. Explain TCO — Tail Call Optimization. Is there any JavaScript engine that supports Tail Call Optimization?</h4><p><em>Hint: As of 2018, there are none.</em></p><p>Answer: Personally I only knew C++ does tail call optimization. Apparently, there are more languages which do, like Scheme.</p><p>In Simple words, TCO lets the compiler is able to ‘not-allocate’ space on the stack when the function will return the same value as its receiving.</p><p>Quote from StackOverflow: <em>“Tail-call optimization is where you are able to avoid allocating a new stack frame for a function because the calling function will simply return the value that it gets from the called function. The most common use is tail-recursion, where a recursive function written to take advantage of tail-call optimization can use constant stack space.”</em></p><p>references: <a href="https://stackoverflow.com/questions/310974/what-is-tail-call-optimization">https://stackoverflow.com/questions/310974/what-is-tail-call-optimization</a></p><p><strong>Disclaimer</strong>: I don’t assume I wrote all these answers, just compiling from multiple sources :)</p><p>References to every piece of code and articles are given below the answers themselves.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6fd121afc9eb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>