Remove or omit object properties without mutation in JavaScript
March 1, 2021 — Since immutability in JavaScript is important for predictability and performance of your application, we often find ourselves in situations where we need to achieve some of the operations without mutating the original object/array.
Difference between React.Component and React.PureComponent
January 16, 2021 — Currently, there are two ways if you want to create ES6 class components in React.
Deep copying objects using JSON.stringify and JSON.parse
January 13, 2021 — There are a lot of reasons where you would want to “deep copy” objects in your application. For instance, when working with React.js, you might have used the shouldComponentUpdate
life-cycle method. In this method, you would determine if the component has the same props and state as it had previously by shallow or deep copying objects.
Why You Should Use JavaScript for Game Design
December 15, 2020 — There are several different coding languages that can be used in the design of online video games. Per Code Digest, some of the most common among them are HTML5, C++, Java, C#, and JavaScript. Each of these languages has been used successfully to produce games, and each one can be used for this purpose even by a relative beginner (so long as he or she is willing to learn during the process).
Named function arguments in JavaScript
September 4, 2020 — A function in JavaScript is a set of statements that performs a task or calculates a value and return it based on the input which is been given to it.
The difference between for...in & for...of in JavaScript
August 19, 2020 — There are two ways of many using which you can loop over the iterables in JavaScript.
How to check if the API call is failing using Fetch in JavaScript
August 4, 2020 — The Fetch API as we all know is the modern replacement to the good old XHRHttpRequest AKA Ajax as it’s much simpler and uses promises. It’s great to make API calls without adding any third-party library overhead.
Things to consider before using arrow functions in JavaScript
July 29, 2020 — Although the Arrow functions in JavaScript are a great way to make your code concise and more readable than the regular functions, there are some important things that you should consider before using arrow functions which can even break your application if you’re not aware of this.
Remove event listener once it's invoked in JavaScript
July 28, 2020 — The usual way of adding event-listener on certain elements is using the addEventListener
method on the element. For instance, if you want to register a click event on an element with id checkoutBtn
, you can do it like so.
Freeze scroll on arrow key up or down using JavaScript
July 27, 2020 — I was working on implementing the Konami code easter egg on this blog and there was this need where I need to stop the scrolling only when the previous two presses by the user are ArrowUp
.
How I implemented a Konami easter egg on my blog
July 24, 2020 — So, the other day, I was going through my Twitter feed and I saw this tweet. This user had explored an easter egg on the newly designed Stripe.com’s website.
Make function parameters required in vanilla JavaScript
July 14, 2020 — You might be aware of how to set default values for function parameters in JavaScript. For instance, if you want to set the default value for a parameter, you can do it like so.
Change URL query parameters using JavaScript
June 23, 2020 — While working on Your First Commit Ever, there arised a requirement in which I had to update/change the URL’s query paramter based on the user input.
Detect device's OS in JavaScript
June 2, 2020 — There comes a scenario when you might want to check which operating system the device is running. For instance, when you want to set device-specific download links. For windows, .exe
file, for macOS, .dmg
file and so on.
Convert long numbers to short and compact form in JavaScript
May 25, 2020 — JavaScript amazes me everyday when I find something can be done using native JavaScript instead of using heavy-weight libraries or inventing my own functions.
Detecting if device is online or offline using plain JavaScript
May 19, 2020 — There might be cases where you would like to check if the device on which the website is loading is connected to the internet or not. For instance, this can be used to show the user the message if their device is offline or to disable some functionality of the application if the device is offline.
Drag and drop files using only JavaScript
May 18, 2020 — You’ve probably seen or have used this feature where you can upload files by dropping the selected files into the specific area. For example, how Gmail handles this while drafting emails.
Detecting device color scheme automatically in JavaScript
May 11, 2020 — Implementing a Dark mode in applications is all the rage these days. And you can provide a toggle to switch between Dark/Light mode to users like the one I’ve implemented on my Notepad app.
What's the use of Blob object in JavaScript?
April 8, 2020 — I was working on polishing my Notepad app this fine quarantine afternoon. One feature that I was planning to add was an ability to download the content of the notes/text as a text file when user click the specified download button.
Asynchronous for loops in JavaScript
January 4, 2020 — There are several ways to iterate over things in JavaScript. Most notable way is to use loops. Loop constructs includes for
, forEach
, do...while
, while
, for...in
and for...of
. All these constructs loops over synchronous iterables such as arrays, objects, strings etc.
Type checking props using PropTypes in React
December 23, 2019 — JavaScript is not a statically typed language. A language is a statically typed if the type of a variable is known at compile-time instead of at run-time. Common examples of statically-typed languages include Java, C, C++, Swift, Kotlin and Scala.
Automatically bind ES6 class functions in callbacks in React
December 22, 2019 — When using React component using ES6 classes, you must have encountered this phenomenon where you have to explicitly bind the class function and then pass it to the even such as onClick
. For instance, take the following example.
Supercharge array operations using Set in JavaScript
August 29, 2019 — Working with Arrays in JavaScript is sometimes painful as there aren’t a lot of native functions/methods available to carry out common operations on arrays. For instance, an operation as simple as removing an element from an array takes a lot of amount of code. Check this.
A look into Getters and Setters in JavaScript
August 8, 2019 — There are always multiple ways of doing things. Programming is no different. For instance, in JavaScript, what would you do if you want to get the property of an object running some operation before returning it? Take this example.
JavaScript functions' implementation inspired by PHP and Laravel
March 29, 2019 — A sometime ago I tried my hands on implementing some of the PHP’s native functions in native JavaScript. The result is quite interesting list of JavaScript functions you’ve never asked about.
TIL - How to fix embedded scripts in Progressive Web Apps
September 3, 2018 — Progressive Web Apps are great when you need to achieve things like offline capabilities, push notifications, background-sync and to give your website an overall app-like experience. While, the PWAs are great at implementing all of the above things and are the obvious choice, there are certain things which can be broken when you use ServiceWorker(which are the building blocks of any PWA) to make your webaite a PWA.
TIL - Using "Box Model" of Chrome Dev Tools
March 21, 2017 — We all know how good is Chrome Dev Tools when it comes to the web debugging capabilities. There are number of features in the Dev Tools which are very useful but we are unaware of.
Handling time intervals in JavaScript
March 15, 2017 — While working on an Electron app Pomolectron, I needed to handle different time intervals through setInterval() function of JavaScript. I basically needed to implement three timers in my app:
Building a simple offline-capable Notepad app using ServiceWorker
November 15, 2016 — Today, We are going to build a progressive Notepad app which can very well be used in offline mode, be responsive on all available devices, and saves the content locally on the device itself. So, the core functionality of this Notepad here is to make it work offline. To fulfill this requirement, we’ll use ServiceWorkers which I’m going to cover next.
Getting started with Electron
June 22, 2016 — Have you ever wanted to develop desktop apps while being a true web developer without even caring about the native architecture or the language most of the applications build for different platforms likes of Windows, macOS or Linux? Or you just wanted to get started with building desktop apps? Isn’t it great if you are able to build desktop apps using the technologies you already knows i.e. HTML, JavaScript and CSS? I was in the same urge to dive into world of desktop apps. So, I have been stuck on to GitHub’s Electron lately.