<?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: Imran Latif</title>
    <description>The latest articles on DEV Community by Imran Latif (@ilatif).</description>
    <link>https://dev.to/ilatif</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%2F1172462%2F59ad9e94-35ba-4f4e-bdda-3dfdc2dc01c7.jpeg</url>
      <title>DEV Community: Imran Latif</title>
      <link>https://dev.to/ilatif</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ilatif"/>
    <language>en</language>
    <item>
      <title>Key JavaScript Concepts I Mastered During LeetCode’s 30-Day Challenge</title>
      <dc:creator>Imran Latif</dc:creator>
      <pubDate>Thu, 26 Oct 2023 15:48:27 +0000</pubDate>
      <link>https://dev.to/ilatif/key-javascript-concepts-i-mastered-during-leetcodes-30-day-challenge-27f5</link>
      <guid>https://dev.to/ilatif/key-javascript-concepts-i-mastered-during-leetcodes-30-day-challenge-27f5</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F7230%2F0%2A92evsvmUZXN8wjgK" 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%2Fcdn-images-1.medium.com%2Fmax%2F7230%2F0%2A92evsvmUZXN8wjgK" alt="Photo by [AltumCode](https://unsplash.com/@altumcode?utm_source=medium&amp;amp;utm_medium=referral) on [Unsplash](https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral)"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;LeetCode is one of the most famous coding platforms and is considered to be the best for preparing for algorithms, data structures, interview preparation, and everything in between. Recently, they announced a &lt;a href="https://leetcode.com/discuss/study-guide/3458761/Open-to-Registration!-30-Days-of-LC-JavaScript-Challenge" rel="noopener noreferrer"&gt;30-day JavaScript coding challenge&lt;/a&gt;, which was entirely focused on solving problems using JavaScript concepts and constructs. The best part was their in-depth editorial for each problem, explaining everything down to the very minor detail.&lt;/p&gt;

&lt;p&gt;For me personally, JavaScript is my go-to programming language for solving problems as I feel most comfortable with it. I have successfully solved over 150+ problems on LeetCode (&lt;a href="https://leetcode.com/ilatif/" rel="noopener noreferrer"&gt;https://leetcode.com/ilatif/&lt;/a&gt;) before taking up this challenge, and almost all of them were in JavaScript. While I still have reservations about choosing JavaScript to solve problems in coding competitions and similar scenarios, which I will discuss in a separate article, it remains my preferred language. I have been using JavaScript for over a decade in my day job, and I am quite familiar with most of the concepts. However, there were still some concepts that I was missing, and we will be discussing them one by one&lt;/p&gt;

&lt;h2&gt;
  
  
  Function Arity
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Challenge&lt;/strong&gt;: &lt;a href="https://leetcode.com/problems/curry/solution/" rel="noopener noreferrer"&gt;https://leetcode.com/problems/curry/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Consider we’ve defined a function like below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2080%2F1%2AIv0G0juMnsjF7U5-YK3fIA.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%2Fcdn-images-1.medium.com%2Fmax%2F2080%2F1%2AIv0G0juMnsjF7U5-YK3fIA.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At runtime, how can we determine the number of arguments/parameters a function receives? While we can typically deduce this by examining the code, accessing this information during runtime becomes essential. So, what exactly is arity? I’m glad you asked. &lt;strong&gt;Arity&lt;/strong&gt; refers to the number of arguments a function can accept. For instance, if a function accepts &lt;strong&gt;three arguments&lt;/strong&gt;, we can say its &lt;strong&gt;arity&lt;/strong&gt; is &lt;strong&gt;3&lt;/strong&gt;. Accessing this information plays a crucial role in solving this LeetCode challenge&lt;/p&gt;

&lt;p&gt;I thought that’s not possible, as even though we can define the number of arguments/parameters a function can accept, we can still pass more arguments/parameters to it, and JavaScript won’t complain. For example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2080%2F1%2A3buT9BETddcRkNwFj5SN9w.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%2Fcdn-images-1.medium.com%2Fmax%2F2080%2F1%2A3buT9BETddcRkNwFj5SN9w.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is perfectly valid code, and JavaScript won’t complain due to its dynamic nature. I based my solution on the misconception I mentioned above, namely, the belief that we cannot obtain the number of arguments/parameters a function can receive during runtime. It was only after I submitted my solution and opened the Editorial to review it that I realized it is indeed possible to determine a function’s arity at runtime.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2080%2F1%2Aui3H5ym9cPMX1pdNsC1I7Q.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%2Fcdn-images-1.medium.com%2Fmax%2F2080%2F1%2Aui3H5ym9cPMX1pdNsC1I7Q.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Every defined function has a length property that can be used to retrieve the arity of the function.&lt;/p&gt;

&lt;h2&gt;
  
  
  5 instanceof Number?
&lt;/h2&gt;

&lt;p&gt;Challenge: &lt;a href="https://leetcode.com/problems/check-if-object-instance-of-class/solution/" rel="noopener noreferrer"&gt;https://leetcode.com/problems/check-if-object-instance-of-class/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Consider following code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2080%2F1%2ALAk7NZJibUfpHk-KMV-SOQ.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%2Fcdn-images-1.medium.com%2Fmax%2F2080%2F1%2ALAk7NZJibUfpHk-KMV-SOQ.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What do you think the output would be? If your answer is true, then congratulations, your answer is incorrect. You might be wondering, how so? Essentially, instanceof in JavaScript determines whether an object is an instance of a particular class. It does this by checking if the object contains Class.prototype, and if so, it returns true. In the example above, 5 and name are primitive values, which means they are values themselves and not actual objects. When we use them in code, JavaScript temporarily coerces them to objects internally (a process known as &lt;a href="https://javascript.plainenglish.io/javascript-boxing-wrappers-5b5ff9e5f6ab" rel="noopener noreferrer"&gt;Boxing&lt;/a&gt;). We are calling instanceof on them directly, and since they are not objects at that time, instanceof would return false.&lt;/p&gt;

&lt;p&gt;To obtain the correct results, we can utilize the Object constructor around primitive values, which will convert them to objects of Numberand String, respectively&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2132%2F1%2AeOapFox6e21unsFmvSgszg.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%2Fcdn-images-1.medium.com%2Fmax%2F2132%2F1%2AeOapFox6e21unsFmvSgszg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  typeof Person === “class”?
&lt;/h2&gt;

&lt;p&gt;Challenge: &lt;a href="https://leetcode.com/problems/check-if-object-instance-of-class/solution/" rel="noopener noreferrer"&gt;https://leetcode.com/problems/check-if-object-instance-of-class/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Consider the following code. What do you think output of typeof Person would be?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2080%2F1%2A9DElZIxE8teU8nlSPfDSzw.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%2Fcdn-images-1.medium.com%2Fmax%2F2080%2F1%2A9DElZIxE8teU8nlSPfDSzw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes" rel="noopener noreferrer"&gt;Classes&lt;/a&gt; were introduced in ES6, providing a convenient syntax for declaring properties and methods. Initially, when I encountered typeof Person, I had the notion that it would output class despite being aware that classes are internally converted to function syntax by the JavaScript compiler (something similar to the example below)."&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2132%2F1%2AHMH-DlqV0jR1kaEAiJahhw.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%2Fcdn-images-1.medium.com%2Fmax%2F2132%2F1%2AHMH-DlqV0jR1kaEAiJahhw.png" alt="Transpiled with TypeScript Playground"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So the correct result for typeof Person is function. It serves as a gentle reminder that it's perfectly normal to overlook minor details at times.&lt;/p&gt;

&lt;h2&gt;
  
  
  Generator functions
&lt;/h2&gt;

&lt;p&gt;Challenge: &lt;a href="https://leetcode.com/problems/generate-fibonacci-sequence" rel="noopener noreferrer"&gt;https://leetcode.com/problems/generate-fibonacci-sequence&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Generator functions allow the execution of a function to pause and resume based on how it’s being called. The basic syntax of a generator function looks like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2080%2F1%2AEAGhrsVHV9wOi0Kfq28xfw.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%2Fcdn-images-1.medium.com%2Fmax%2F2080%2F1%2AEAGhrsVHV9wOi0Kfq28xfw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The * after the function keyword is what declares a generator function. yield is used to return a value from the generator function and pauses the execution until the next invocation.&lt;/p&gt;

&lt;p&gt;I had a vague understanding of generator functions: 1) that they can only yield a single value and 2) that they are always (re)executed from the beginning. Additionally, since I had never used them in production code, I had no chance to improve or refine my knowledge about them. Fortunately, this JavaScript challenge provided me with the opportunity to delve deep into generators and expand my understanding.&lt;/p&gt;

&lt;p&gt;Consider the following example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2080%2F1%2AZEYurznlHwccnhzCDksmOQ.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%2Fcdn-images-1.medium.com%2Fmax%2F2080%2F1%2AZEYurznlHwccnhzCDksmOQ.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This generator function yields three values, and in order to obtain all of them, we need to call the function three times. Each function invocation will resume from where the last yield statement left off and continue executing statements until it encounters the next yield statement. At that point, it will pause execution and return the generated output. To explore generators in detail, please refer to &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The best challenge?
&lt;/h2&gt;

&lt;p&gt;For me, the most exciting challenge throughout the entire 30-day challenge was the &lt;a href="https://leetcode.com/problems/array-of-objects-to-matrix/" rel="noopener noreferrer"&gt;19th-day challenge&lt;/a&gt;. It tasked us with converting an array of objects into a matrix. In my opinion, it is the ideal problem-solving question for JavaScript developers. It tests your capability to comprehend a problem statement, construct a mental model around it, and then implement a solution using JavaScript constructs. It doesn’t involve any fancy data structures or algorithms, just pure JavaScript skills are required. This makes it a perfect question to ask in JavaScript interviews.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus
&lt;/h2&gt;

&lt;p&gt;I have open-sourced all of my submissions/solutions to the challenge. You can find them at &lt;a href="https://github.com/ilatif/gravity" rel="noopener noreferrer"&gt;https://github.com/ilatif/gravity&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It has been a fun and exciting experience to participate in &lt;a href="https://leetcode.com/discuss/study-guide/3458761/Open-to-Registration!-30-Days-of-LC-JavaScript-Challenge" rel="noopener noreferrer"&gt;LeetCode’s 30-day JavaScript Challenge&lt;/a&gt;. I have learned a lot from it. Feel free to share your thoughts and let me know in the comments how useful you found this article. Thank you!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>coding</category>
      <category>algorithms</category>
      <category>leetcode</category>
    </item>
    <item>
      <title>How I Achieved 10x Productivity at Remote Work</title>
      <dc:creator>Imran Latif</dc:creator>
      <pubDate>Wed, 25 Oct 2023 19:38:51 +0000</pubDate>
      <link>https://dev.to/ilatif/how-i-achieved-10x-productivity-at-remote-work-1040</link>
      <guid>https://dev.to/ilatif/how-i-achieved-10x-productivity-at-remote-work-1040</guid>
      <description>&lt;h2&gt;
  
  
  How I Achieved 10x Productivity at Remote Work
&lt;/h2&gt;

&lt;p&gt;Remote work is an established term these days, but back in the days i.e. prior to COVID or a few more years back, this term was quite alien in the developer community. Even though there were organizations like &lt;a href="https://basecamp.com/"&gt;Basecamp&lt;/a&gt; which were &lt;a href="https://basecamp.com/remote-resources#:~:text=On%20top%20of%20writing%20*the,for%20more%20than%2020%20years."&gt;working remotely for more than 20 years&lt;/a&gt;, the developer ecosystem was not built around the concept of working remotely or to put it in simple words, separately from your colleagues. Just like other industries, it was sort of mandatory to share the physical space with your peers in-order to achieve some work. So if you‘ve asked HR in 2014 about remote work, they would definitely have raised an eyebrow.&lt;/p&gt;

&lt;h3&gt;
  
  
  Remote Work is Here To Stay
&lt;/h3&gt;

&lt;p&gt;As per &lt;a href="https://survey.stackoverflow.co/2023/#section-employment-work-environment"&gt;Stackoverflow’s yearly survey&lt;/a&gt;, remote work is getting popular each year. Quoting them:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Return to office initiatives aside, coding easily lends itself to fully remote work and one third or more of all organization sizes are still fully remote.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  First Encounter with Remote Work
&lt;/h3&gt;

&lt;p&gt;I first started working remotely in early 2014 when I was working as a Senior Full-Stack Developer at &lt;a href="https://jumpshare.com/"&gt;Jumpshare&lt;/a&gt;. I found it different yet intuitive from the very beginning. While working in the same physical space as your peers has its advantages, in remote work however you’ve full control of your environment and surroundings and the best part (for me) is the silence which helps in staying focused. Even though remote work was something new to me at that time, I’ve thoroughly enjoyed it so far.&lt;/p&gt;

&lt;h2&gt;
  
  
  Actions to Improve Remote Work Productivity
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Avoid Procrastination&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;One of the biggest challenges which revolve around remote work is &lt;a href="https://en.wikipedia.org/wiki/Procrastination"&gt;procrastination&lt;/a&gt; i.e. &lt;strong&gt;the act of delaying or postponing things&lt;/strong&gt;. And that makes perfect sense because with no managers around and no colleagues looking at your screen, you can easily fall into the trap of delaying things by assuming you’ve plenty of time, only to find out later that you’ve wasted all of your time doing nothing. While there are countless articles and apps on the internet on how to avoid procrastination, the activity which kept me focused towards work is the daily stand-ups we do every morning before starting work. Everyone is supposed to send them, even the CTO and company’s founder are no exception. Having a daily stand-up means, people will be looking at what you did yesterday, what you are going to work on today and this makes one accountable (in a good way) of their time in-hand. What if I didn’t post a daily stand-up? Or what if I have nothing to write about? are the questions which keep popping up into one’s mind and they feel focused towards their work.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Choose the Correct Work Hours&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;When working on-site, one is bound to work and stay in the office during particular hours. With remote work, you sometimes have the flexibility to choose the working hours which suit you. Choose the time when you feel most productive. For some it’s the day time, but for some they are more leaned towards late-night hours. Either is fine, as long as you’re choosing the suitable time based on your situation.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Communicate Asynchronously&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;This is definitely the area where people going remote feel more concerned about. While you are present in the office asking for feedback, pushing for a meeting, exchanging thoughts on an urgent bug etc. is quite easy, instant and efficient. But doing the same in a remote work environment is a bit of a hassle to do. Which app to use to call someone? What if another person’s internet connection is broken? What if I am unable to clear my intent over the call? are some valid concerns. Honestly there is no universally applicable solution to this. Every team has to tackle such issues as per their own work culture. The way I’ve approached this at work is I don’t normally call (both audio and video) the other person unless really necessary. I tend to rely on text chat on Slack as it’s a perfect medium and doesn’t require massive internet bandwidth. Plus, the other person doesn’t have to answer immediately and can answer at their own pace. And best of all, everything they are writing down is automatically getting documented so they can come back and reference it later at any time in future.&lt;/p&gt;

&lt;h3&gt;
  
  
  Final Thoughts
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Remote work is a two-edged sword. &lt;a href="https://github.com/ilatif"&gt;Imran Latif&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It’s both fascinating and challenging to keep up with. Fascinating due to the flexibility and power it gives you. Challenging due to the dynamics that revolve around it. If you do it right, it would be the most delightful work experience you have ever had, but if you took it lightly or didn’t do it right then it would quickly turn out to be the most frustrating work experience ever.&lt;/p&gt;

&lt;p&gt;Remote work is a great way to manage work-life balance. While it works for others, it might not work well for you, so make sure to consider all the pros &amp;amp; cons thoroughly before you opt to do it. But let me make you sure of one thing, once you do remote work the right way, you will always wonder why you didn’t choose it earlier.&lt;/p&gt;

&lt;p&gt;I shared tips I’ve been using personally for almost a decade in enhancing my remote work experience. I hope you’ve enjoyed them. Please let me know in the comments your tips around remote work.&lt;/p&gt;

</description>
      <category>workplace</category>
      <category>remote</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
