Wouldn’t it be great if we could use the for…of loop
to iterate over our own data structures? In this article, we will learn how to do this by creating our own Iterable Range
and Queue
data structures to understand iterables in JavaScript better.
One of the fundamental problems computers solve is automating tedious and repetitive tasks. If you’re a programmer and have solved at least one non trivial problem in your life, I’m sure you’ve used Iteration.
Iteration is the repetition of a given set of instructions in order to generate an outcome. For loops
, while loops
, do…while loops
…
Sometimes we’d like to split third-party external styles or legacy styles into a separate CSS bundle on building our angular application. This can be done quite easily. Keep reading to know more.
As commonly known, we can include any external styles in our angular application by adding it to the styles array in our angular.json file:
"styles": [
"styles/bootstrap.scss",
"styles/app.scss",
"styles/some-other-style.scss"
]
This would generate a single CSS file after the ng-cli build goes through (ng build) :
dist/styles.<some-random-hash>.css
In Production build, angular generates a random hash in for browser cache busting purposes. If something changes in our bundle, a…
Books are wormholes to wonderland. Without reading, life would be a mistake. But reading and not remembering what you read is worse. It is time wasted!
I used to find myself reading an amazing book and then miserably failing to articulate the ideas of the book while telling a friend about it. Here are some tips to read better and remember what you read.
Pick a book that interests you. Read the blurb and decide if it resonates with you. Not everyone would find Sapiens by Yuval Noah Harari “Thrilling And Breath Taking”. If you don’t like non-fiction, read fiction…
Simpler, succinct code is always better than complex and quirky solutions. It can be a challenge to find the right balance between short and readable solutions. Here are some tips to help you write JavaScript more productively.
The optional chaining operator (?.
) allows us to do nested property lookups in an object without having to perform multiple null checks.
Inspired by C#, Nullish Coalescence made it to ES2020. It is a really handy binary operator that returns the first defined value.
You must be familiar with using the ||
operator to perform default value assignments like so:
But…
Hi friend, hope you’re well!
Here are some articles that I think would be worth your time:
Wouldn’t it be great if we could use the for…of loop to iterate over our own data structures? In this article, we will learn how to do this…
Read more
Reactive forms are not reactive enough in Angular. Especially when dealing with async observable data to pre-populate a form. Having to subscribe and call methods like setValue
and patchValue
seems very imperative and can be a recipe for data races and memory leaks. It can especially get messy when bulk editing an array of domain models. In this article we explore a different approach to reactive forms. Keep reading to know more
That’s right! We can think of forms as a stream of UI input elements. Since forms can be thought of reactive setters that a user uses to set
…
If you are lazy like me, you know it can get a little annoying having to type the issue number in every commit message. We can easily automate this using the git prepare-commit-message hook which can prepend commit messages with JIRA issue number to the commit message extracted from the git branch name (and get the benefits of Smart Commits). You can use this trick for any issue tracker you might use. Read more to know how to do this.
TICKET-123 — a useful commit message
For this technique to work, you need to make sure that you include the…
Sometimes, we need to extend third party library reducers and add additive features on top of it. This can be done easily with the help of a simple trick.
NGRX is a reactive implementation of Redux architecture where reducers act as reactive setters to add data to our application’s Observable Store on listening to Actions.
Alliteration Alert! (see what I did there)
Since we need to extend an existing reducer by adding additive features to it, we need to essentially concatenate
the reducers. …
TypeScript gives us the ability to improve the architecture of our JavaScript application with type safety and code documentation. However, it doesn’t turn on `strict mode` by default in order to keep the barrier to entry low for new adapters. Angular takes the same approach. It does not turn the strict mode when generating a new Angular Application unless explicitly specified. This can hinder us from taking full advantage of TypeScripts strongly typed nature which allows us to detect a whole class of bugs at compile time.
There is a way to reap the benefits of the strict mode immediately…
It can very quickly get annoying having to manually switch node versions each time you open up a terminal in your project root. Wouldn’t it be great if you could automatically switch your node version based on your project’s requirements? This simple trick will make your dev experience even better:
For this tutorial, we’re assuming that you have node version manager (nvm) installed on your linux/macOS system.
We can simply write a shell script that runs each time we open a terminal in a directory or when we change a directory. The script looks for a .nvmrc
file in the…
Software Engineer living a polymath lifestyle in Adelaide, Australia