event.target Points to element, which triggers the event.

event.currentTarget Points to element, to which the Event Listener is attached to.


Let’s consider this example, where a button is nested inside a paragraph and both button and paragraph having click event.

As our server has multiple API endpoints, our need for creating routes increases, along with increased demand of creating these routing files.

Traditionally, we were importing every single file that pertains to a specific route, to the root file as a middle ware. This can however be cumbersome if we have hundreds of routes.

To resolve this issue, let me show you a trick we can apply to auto-reload the express routes easily, so that you don't have to worry about importing them one by one in the root file of your Node JS application.

We can achieve it using…

Before Node version 13, we were using the esm npm package and run our app.js using the commandnode -r esm app.js

With recent updates of Node, this is natively supported now. There are two ways we can achieve it

  • Save the file with .mjs extension.
  • Add { "type": "module" } in the nearest package.json.

Note that we only have to do one thing from the above mentioned.

If we are using Node.js version 8–12, save the file with ES6 modules with .mjs extension and run it like:

node --experimental-modules app.mjs

Leaving a clap will motivate me to write more useful tips related to JS.

[Interview Question] — Find the largest and smallest word in a sentence!

Input — “This is a sentence and I am about to find out the largest and smallest word occurring in this line”

Output —

Largest Word — occurring

Smallest Word — a

Try on your own and leave a reply containing your way of doing so!

Solution — Used Decoder (an Android app) to create this solution because I was lazy enough to not to turn on the laptop 😁


Step 1: Declare two variables to store largest and smallest word. Here assign the first word to the smallest variable because we want to make a comparison between words…

[Interview Question] — Get the product of all the elements of an array except the current Element and return the result as an array!

Input — [2, 3,4,5]

Output — [60, 40,30,24]

Try on your own and leave a reply containing your way of doing so!

Solution — Used Decoder (an Android app) to create this solution because I was lazy enough to not to turn on the laptop 😁


Step 1: Loop through the entire Array using map and not forEach. As I need to return an array (Remember, map() in JavaScript always returns an array and forEach doesn’t)

Step 2: Create a copy of the array for each iteration (Here I have used the Array.slice() but you can use Modern Spread…

This article will be explaining about the React Hooks. Working as a Software Engineer at SimbaQuartz, I use React as the frontend with React Hooks in Projects every other day. So I thought why don’t I try to put up a short summary about the popular newly introduced “Hooks” in React.

Since React v0.14, we’ve had two ways to create components — classes or functions. The difference was that if our component had state or needed to utilize a life-cycle method, we had to use a class based component. …

As working with Angular Material 8 DatePicker Component, i was not able to set the Date in a specific format. After spending 2 hours of researching, i achieved the Goal by following multiple articles. Later thought why don’t i make it easy for others, who might get into the same situation.

So here i am, Back with another problem solving magical thing, Here i was using Template-Driven Approach to build forms.


<mat-form-field><input matInput placeholder=”Select Date” [matDatepicker]=”datepickerRef” name=”datepicker” ngModel #dateCtrl=”ngModel” required readonly/><mat-datepicker-toggle [for]=”datepickerRef” matSuffix></mat-datepicker-toggle><mat-datepicker #datepickerRef></mat-datepicker>
<mat-error *ngIf=”dateCtrl.errors?.required && deptCtrl.touched”>Choose a Date</mat-error>

The HELPER Function

This is the functionthat will translate…

After Jumping from React to Angular, The First thing i fall in love was TypeScript. I loved it so much that i have planned it to use in React instead of normal JavaScript.

While importing a module called Busboy as like this:

import * as Busboy from “busboy”;

The Error was like this:

Could not find a declaration file for module ‘busboy’. ‘f:/firebase-cloud-functions/functions/node_modules/busboy/lib/main.js’ implicitly has an ‘any’ type.
Try `npm install @types/busboy` if it exists or add a new declaration (.d.ts) file containing `declare module ‘busboy’;`

Solution: All you have to do is edit your TypeScript Config file (tsconfig.json) and add a new key value pair as

"noImplicitAny": false

I am posting this tiny piece of information because I am sure there will be others who…

ES10 is not as significant as ES6 in terms of new language features but it does add several interesting ones.

1. String.matchAll()

const matchIterator = str.matchAll(regExp);

Given a string and a regular expression, matchAll() returns an iterator for the match objects of all matches.

2. Array.flat() & Array.flatMap()

The flat() method creates a new array with all sub-array elements concatenated into it recursively up to the specified depth.

The flatMap() method maps each element using a mapping function and flattens the result into a new array.

In this Story, lets talk about how we can find out if a variable holds array or object values? Lets declare two separate variables named array and obj.

const array = [1,2,3,4,5];
const obj = {id: 1, name: “Josh”};

Now, you might be thinking that we can use typeof operator to find out whether its an array or object, Right? Lets see

console.log(typeof array);
console.log(typeof obj);

Using jsbin we can test our javascript code very easily

What???? Is typeof operator is mad? How it cannot differentiate between an object and an array? I am sure this question must be hitting your mind if you have just started exploring JavaScript world.

Amandeep Kochhar

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store