Javascript
Find user's country without Geolocation and IP Lookup
· ☕ 2 min read
I have this nagging problem of determining an end user’s country/region in my web apps. The reasons for doing that are many - Automatic conversion of an event date/time Display regional news Show prices in user’s currency .. and so on We could do two things to determine a user’s region -

Multiple Ways to Define Functions in Javascript
· ☕ 3 min read
We have looked at functions quite a bit on this blog over the last two years. We have seen many avatars of a function including a function object, a function’s method, function of functions, and so on. But, what we have not done is to document all the ways in which we can define functions.

Using Nullish Coalescing Operator
· ☕ 6 min read
ES2020 introduced nullish coalescing operator. We will see just how and where can you find use for it? What it is? Nullish coalescing operator (??) is introduced in the newest Javascript specification. It’s primary design goal is quite simple - provide a way to check for nulls to return true or false values from an expression.

Javascript - A Beginner Guide
· ☕ 30 min read
Here’s a good guide to get you started on Javascript in a practical way. Why another guide? Practical - don’t learn for the sake of learning, learn for the sake of doing! Tactical - learn what matters, fast (yes, that’s what everyone says) Strategic - see the big picture This guide will get you started from the beginning, graduate you to using industry standard tools, and point you towards the right direction for learning even more than what can be offered in one guide or course.

Fastode Server Framework
· ☕ 2 min read
Fastode is an experimental boilerplate / framework based on Fastify. Why another boilerplate? Well, I just wanted to experiment with technologies to create MVP products. Although I have used NestJS, AdonisJS and friends before, those frameworks, while being great, bring their structure and overhead to any project. I wanted to check how difficult or easy it is to just start with a bunch of basic features and leave everything else to the project.

Use Packages Locally Without Publishing Them
· ☕ 2 min read
How can you use packages being developed locally in other projects - without publishing them to npm repository? NPM Packages Make Life Exciting NPM makes it really easy to create packages and reuse them across projects. I am not even talking about big, useful libraries like Vue, Loadash etc. - just the routine problems across our projects.

Refer Project Folder from NPM Package
· ☕ 1 min read
You can refer to other files/folders using a simple require or using basic node libraries. But, how can you do that with npm packages? The Problem When creating a bunch of Javascript files, here’s what you can do to refer other files - 1 const awe = require("../plugins/awesome.js"); This fetches awesome.

Fastify and its plugins are great
· ☕ 3 min read
I had been meaning to use more of Fastify for work, but only made that a reality recently. So far I have had a great experience on the server framework. What is Fastify? Fastify is a low-overhead server framework built on top of NodeJS. Fastify was started in late 2016 and jumped to v1.

npm run does nothing at Svelte startup
· ☕ 2 min read
I was getting back to Svelte for a small project and ran into a strange issue. npm run dev did not run the svelte app as expected - no output or errors. First I create a new project. 1 2 3 4 npx degit sveltejs/template awesome-project-1 cd awesome-project-1 npm i npm run dev And, I get greeted with nothing.

Asserts are not just for testing
· ☕ 2 min read
Assert is a general-purpose validator and should not be used in the context of testing alone. An assert in Javascript simply checks for truthy values and produces an error otherwise. We use it quite a bit in automated testing when checking for correctness of output for pre-defined inputs. We use asserts like so -

Three quick ways to convert objects to arrays
· ☕ 2 min read
Easily convert objects to arrays and iterate to your heart’s content. There are multiple ways of converting an object to an array (which, also is an object but a different one at that.) Method 1: A simple Object.values() method The first idea that comes to mind is to just use Object.

A Different IIFE Syntax
· ☕ 1 min read
Here’s a different syntax for our favourite IIFE’s. Immediately invoked function expressions enable us to write functions without using “functions”. Well - just kidding. They are functions but with a different syntax. A typical IIFE looks like this - 1 2 3 4 5 6 7 8 9 10 11 const x = 1, y = 9; var sum = 0; (function() { sum = x + y; console.

Conditionally copy props to new object in Javascript
· ☕ 2 min read
Here’s a shorter, readable way to copy props from one object to another subject to defined conditions. The shortest way to copy object (when you don’t quite care about copying sub objects by reference) - 1 2 3 4 5 const planet = { name: "earth", position: 3 }; const newPlanet = { .