Photo by Ashkan Forouzani on Unsplash

Sometimes, we may want to compare the date part of a date only without comparing the time in our JavaScript app.

In this article, we’ll look at how to compare the date without comparing the time with JavaScript.

Date.prototype.setHours

To compare dates without comparing the time portion, we can set both dates to midnight by using the setHours method that comes with JavaScript date objects.

For instance, we can write:

We call setHours


Photo by Alexander Shatov on Unsplash

Chakra UI Vue is a UI framework made for Vue.js that lets us add good-looking UI components into our Vue app.

This article will look at how to get started with UI development with Chakra UI Vue.

Icon Buttons

We can add icon buttons with Chakra UI Vue.

To do this, we write:

We add the icon prop to set the name of the icon to display.

aria-label has the text description of the icon.

The…


Photo by Erik Mclean on Unsplash

Oftentimes, we have to format a floating-point number into the format we want in JavaScript.

In this article, we’ll look at how to format a floating-point number into the format we want with JavaScript.

Math.round

We can use Math.round to round a number into the number of decimal places we want by multiplying the original number 10 to the power of the number of decimal places we want to round to.

Then we pass that number into Math.round , and we divide the rounded number by the same number we multiplied the original number with.

For instance, we can write:


Photo by Aylin Çobanoğlu on Unsplash

The React Query library lets us make HTTP requests easily in our React apps.

In this article, we’ll look at how to make HTTP requests with React Query.

Mutation Side Effects

We can watch for events that are emitted when mutations are being committed.

For instance, we can write:


Photo by Elena Mozhvilo on Unsplash

The React Query library lets us make HTTP requests easily in our React apps.

In this article, we’ll look at how to make HTTP requests with React Query.

Mutations

Mutations let us make HTTP requests to change data on a server by creating, updating, and deleting them.

For instance, we can write:

index.js

App.js


Photo by Sarra Marzguioui on Unsplash

Sometimes, we may want to check if a substring is in a JavaScript string in a case-insensitive manner.

In this article, we’ll check if a JavaScript string has a substring in a case-insensitive manner.

String.prototype.toLowerCase and String.prototype.indexOf

We can convert both the string and the substring we’re checking for the lower case to check if a substring is in a JavaScript string is in a case-insensitive manner.

For instance, we can write:

We call toLowerCase on 'ABCDE' and 'abc' to convert them both to lower case.

And then we call indexOf to check if “abc”.toLowerCase() to…


Photo by Laurie Gibson on Unsplash

The React Query library lets us make HTTP requests easily in our React apps.

In this article, we’ll look at how to make HTTP requests with React Query.

Placeholder Data

We can add placeholder data that are set when the request is loading.

To do this, we set the placeholderData property by writing:

We can also load placeholder data from the cache.

To do this, we write:


Photo by Yoann Boyer on Unsplash

Sometimes, we may need to detect a touchscreen device with JavaScript.

In this article, we’ll look at how to detect a touchscreen device with JavaScript.

Checking for the ontouchstart Method and maxTouchPoints

One way to check for a touch screen device is to check for the window.ontouchstart method and the navigator.maxTouchPoints property.

For instance, we can write:

We check all the items present for a touchscreen device with:

ontouchstart lets us assign a touch event listener…


Photo by Andy Brunner on Unsplash

Sometimes, we may want to get all duplicate values from a JavaScript array.

In this article, we’ll look at ways to get all non-unique values in a JavaScript array.

Array.prototype.filter

We can use the JavaScript array’s filter method to return an array that meets the given condition.

It takes a callback that returns the condition we want each returned item to have.

So we can combine this with calling the indexOf method in the callback to check whether the item is the first instance of an item.

To do this, we call indexOf on the array that filter is called on…


Photo by Thomas Griesbeck on Unsplash

The React Query library lets us make HTTP requests easily in our React apps.

In this article, we’ll look at how to make HTTP requests with React Query.

Paginated Queries

We can make paginated queries as we do with any other queries with the useQuery hook.

For instance, we can write:

index.js

App.js

John Au-Yeung

Web developer. Subscribe to my email list now at https://thewebdev.info/subscribe/. Email me at hohanga@gmail.com

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