Repeated function calls using an abstract pattern in Javascript
· ☕ 1 min read
Use this if you want to repeatedly call a function for known arguments, or in case you just need a IIFE. If you want a repeatedly called functions, you would typically - Call function in a loop Use recursion For e.g. - 1 2 3 4 5 6 7 8 9 10 11 function printStr(str) { console.

Flatten Those Arrays in Javascript
· ☕ 2 min read
Flatten arrays easily with a single command. Or, go further than that by using a map function while flattening arrays. Consider below example - 1 const nums = [[0, 2], [1, 3], [7, 9, 11]]; You can choose to iterate through all elements if you want to iterate through or access all numbers, or you could just use flat.

Dynamically Build Strings in Javascript
· ☕ 1 min read
You should dynamically build strings without using strings. How do you build strings when you need them conditionally built? For example, you need comma separated planets from an array of astronomical bodies. 1 2 3 4 5 6 7 8 9 10 11 12 const astroBodies = [ { name: "earth", type: "planet" }, { name: "moon", type: "satellite" }, { name: "mars", type: "planet" } ]; let planets = ""; astroBodies.

Install Scoop for Command-line Nirvana
· ☕ 1 min read
Command line in Windows. You love it when there are Powershell, Cmder and friends. And, you hate it when you cannot install simple programs quickly. Well, hate may be a strong word - but you get the gist. I have tried chocolatey and have a like-dislike relationship with that program. I have also experimented with VMs and anything that exposes more of the command line.

Require and Import in Javascript
· ☕ 3 min read
Require and import do the same thing differently. I never said to none about missin’ the good ol’ days. The days when Javascript was not golden, code could be simply included within HTML or a single file, and when smarty-pants use to go cyber without Javascript. Those were more of WTF-days.

Most Valuable Site of the Month - May 2019
· ☕ 2 min read
Featured for the millionth time as a most valuable website - a site that generates all icons for free, and for real. I am sick of tired of Google results returning “free” sites that collect all information including my dog’s name and the declare that I need to pay $99 to get darn icon with the darn size.

Object Entries and Values in Javascript
· ☕ 3 min read
Object entries and values add to the rich toolset for managing objects within Javascript. As I never tire to say - (almost) everything is an object in Javascript. So, how do you access the props / values? It is not as if you are going to count them down - pfft.

Dot Notation Gotchas in Javascript
· ☕ 2 min read
It is quite common to use dot notation to access object’s props. How can you ever go wrong? We have seen a bit of dot and bracket notations in all about Javascript objects and props post. We have learnt to use dot notations to make our code more readable -

Reload Component based on Routes in Vue
· ☕ 2 min read
If two links in your Vue application point to the same view, clicking those links one after the other may not result in data being refreshed from server. Imagine you have the same view for two different links - My account All account Both links will point to Account.

Can a clipboard editor save the day?
· ☕ 2 min read
A clipboard editor of all the things? How can it be useful in this day and age? I have tried to automate some of the most common things that I do on a regular basis. There are a bunch of tools that I use to do just that - these save keystrokes (AutoHotkey), automate regular tasks (e.

Javascript date feature that I could have lived without
· ☕ 2 min read
Be aware of hidden Javascript features that can break your code before you say “ugh..”. Consider the below code that prints today’s date - 1 2 3 const dt = new Date(); console.log("dt: ", dt); // 2019-03-31T13:56:42.552Z All looks good? Let us now create a target date for my payment - it is 1.

Concat vs. Push for Arrays in Javascript
· ☕ 1 min read
Someone once said “there shall be standards, and there were standards”. But no one said anything about consistency, uniformity, and stuff like that? The question is of course not about standards. Let me ask you this one thing - do you have any idea what’s going on with push and contact?

Gotchas of Singleton Classes in Javascript
· ☕ 3 min read
Be careful about using singleton patterns in Javascript classes. It may have unexpected side-effects and can be the most dreaded evil overlord you encounter on that day. Let us take this example of an Account class that is used by all logged-in users. Users set a role and are shown accounts based on the role.