Suraj Sharma's Blog

Apr 2, 2023

How to cherry pick in Git

Learn how to cherry-pick a specific commit in Git and apply it to a different branch without merging the entire branch, with this step-by-step guide.

Mar 28, 2023

How to Integrate Redux Toolkit with React: A Step-by-Step Tutorial

This guide provides a beginner-friendly introduction to using Redux Toolkit with React

Mar 28, 2023

How to handle asynchronous behavior in Cypress

Learn to write tests in Cypress to handle asynchronous behavior

Mar 15, 2023

How to hover over elements in Cypress

Learn to hover over elements in Cypress

Mar 5, 2023

How to check if an element is clickable in Cypress

Learn how you can check if an element is clickable in Cypress

Mar 5, 2023

How to get text of an element in Cypress

Learn how you can get the text content of an html element in Cypress

Mar 4, 2023

How to make api calls in Golang

Learn to make GET and POST requests to external APIs in Golang

Dec 16, 2022

How to send a delete request in axios

Learn how to send a delete request in javaScript using axios

Dec 15, 2022

How to convert a positive number to negative in JavaScript

Learn to convert a postive number to a negative number in JavaScript

Oct 22, 2022

How to add a key to a map in Golang

Learn how to safely add a key to a map in Golang

Oct 21, 2022

How to find the type of a variable in Golang

Learn two ways to find the type of a variable in Golang

Oct 16, 2022

How to stop server to accept new connections in Express

Learn how to stop server from accepting new connections in Express

Oct 15, 2022

How to add a custom font in React Material UI

In this tutorial, I have discussed how you can add a custom font and override the React Material UI font.

Oct 15, 2022

How to build a dark mode theme in React Material UI

A practical guide on how to create a custom ThemeProvider component to switch between light mode and dark mode theme in React material UI

Oct 15, 2022

How to detect dark mode theme in React Material UI

You will learn to apply React material ui useMediaQuery() hook to detect dark mode theme

Oct 15, 2022

How to create a custom theme in React Material UI

Learn to create a customize theme in React Material UI

Oct 15, 2022

How to get React material ui theme object in function components

Learn to get the React Material UI theme object in function components using the useTheme hook

Oct 11, 2022

How to hide clear button of Autocomplete in React Material UI

Learn to hide the clear button of Mui Autocomplete

Oct 9, 2022

How to make API requests in Express

Learn to make API requests to external REST APIs in Express

Sep 24, 2022

How to get yesterday date in JavaScript

Get yesterday date in vanilla JavaScript using Date object

Sep 23, 2022

How to get tomorrow date in JavaScript

Get tomorrow date in vanilla JavaScript using Date object

Sep 21, 2022

How to get current date in Javascript

Get current date in Javascript using the Date.toLocaleDateString method

Sep 20, 2022

How to change button text on click in React

This tutorial is about changing the text of button when clicked on it in React

Sep 19, 2022

How to check if a map is empty in Golang

Learn two ways to check if a map is empty in Golang

Sep 17, 2022

How to get a slice of keys from a map in Golang

This tutorial is about getting a slice of keys from a map in golang

Sep 16, 2022

How to get the size of a file in React

Learn to get the size of an image file before uploading it to the server using React.js

Sep 13, 2022

How to convert an interface to a string in Golang

Convert a golang interface to a golang string using a built-in function

Sep 12, 2022

How to remove a key from a map in Golang

Remove an existing key from a map in Golang using a built-in delete function

Sep 11, 2022

How to check if a string starts with a substring in Golang

Check if a string starts with a substring in Golang

Sep 10, 2022

How to store objects in HTML5 localStorage

Use the JSON.stringify method to store objects in HTML5 localStorage

Sep 9, 2022

How to exit from the main function in Golang

Learn to exit from the main program when an error occurs inside the main func in golang

Sep 8, 2022

How to renaming an existing branch in Git

Learn to rename an existing git branch

Sep 7, 2022

How to disable a select field in React

Learn to disable a select field and its option in react using useState() hook and the disabled property

Sep 5, 2022

How to iterate through a string in JavaScript

Learn two ways to iterate through a string in JavaScript

Sep 4, 2022

How to create a new local branch in Git

Learn to create a new local branch in git

Aug 7, 2022

How to convert a float to a string in Golang

Learn to convert a float64 or float32 to a string in golang

Aug 3, 2022

How to convert a float to an int in Golang

Learn to convert a float64 or float32 to an int in golang

Aug 2, 2022

How to disable a link tag in React

Learn to use css and javascript ways to disable link tags in React

Aug 2, 2022

How to accept only image files in react file upload

This tutorial will help to develop a react file upload component that accepts only image files

Jul 29, 2022

How to join string variables in Bash

this tutorial illustrates few examples to concatenate strings variables in Bash

Jul 10, 2022

How to generate random uuid in Node and Express

Learn to generate random unique IDs in Node and Express

Jul 7, 2022

How to get current year in Golang

Learn to get the current year in Golang

Jul 6, 2022

How to get current year in JavaScript

Get current year in JavaScript using the Date object

Jun 18, 2022

How to remove all occurences of an element from an array in JavaScript

Learn to remove all occurences of an element from an array in JavaScript in O(1) space complexity

Jun 14, 2022

How to fix docker error: no space left on device in Mac

Learn to fix docker error: no space left on device in Mac

Jun 1, 2022

How to list all the installed NPM packages

Learn an NPM command to list all the installed npm packages on your system.

May 11, 2022

How to delete a non-empty directory in Node.js

Learn to delete a non-empty directory in Node using the file system module

Mar 28, 2022

How to check if a value is a number in JavaScript

Learn two ways to check if a value is of number type in JavaScript

Jan 20, 2022

How to create a csv file from response data in React

Create and export a csv file from the response data results in React using react-csv

Nov 3, 2021

How to change Typography color in React Material UI

Learn to set a different text color to the Typography component in React Material UI

Nov 2, 2021

How to add custom typography variants in React material UI

Learn to create and use your own typography custom variants in your React Material UI

Oct 31, 2021

How to get index of an item in an array in JavaScript

Learn to find index of an item in a given array in JavaScript using arrays built-in methods

Oct 9, 2021

How to upload files in React using Axios

Learn to upload files in React using Axios post method

Oct 1, 2021

How to handle and manage radio buttons state in React

Learn to handle and manage radio buttons state in React without using any 3rd party form libraries

Sep 16, 2021

How to merge two slices in Golang

Learn to merge two slices of the same type in Go using a built-in function

Sep 15, 2021

How to split a string into words in JavaScript

Learn to split a sentence into words in JavaScript using the string.split() method

Sep 6, 2021

How to initialize a slice with values in Golang

Learn to initialize a new slice with initial values in Golang using a composite literal

Aug 1, 2021

How to submit form data in post request using axios

Learn to submit form data in HTTP post request using axios

Jul 31, 2021

How to check if a slice is empty in Golang

Learn to check if a slice is empty in Golang using the len() method

Jun 30, 2021

How to randomly generate alphanumeric strings in JavaScript

Learn about generating random alphanumeric strings in JavaScript

Jun 28, 2021

How to check if a map contains a key in Golang

Learn to check if a map contains a key in Golang

Jun 27, 2021

How to reset input fields in React

Learn how you can reset input fields in controlled components and in uncontrolled components

Jun 26, 2021

How do you write multi-line strings in Golang

Learn to write multi-line strings in your Golang code

Jun 26, 2021

How to check if a file exists in Golang

Learn to check if a file with a given file path exists in Golang 1.16

Jun 25, 2021

How to read a text file in Golang

Learn to read a text file in Golang using the ioutil.ReadFile function

Jun 23, 2021

How to check if an array of int values are sorted in Golang

Learn to check if an array of int values are sorted in increasing order in Golang

Jun 22, 2021

How check if a string contains a substring in Golang

Learn to use strings.Contains function in Golang to check whether a given string contains a substring or not

Jun 20, 2021

How to create a map in Golang

Learn to create and initialize a map of key-value pairs in Golang using the built-in make function

Jun 19, 2021

How to initialize a slice in Golang

Learn to create and initialize a slice of structs in Golang using built-in make function

Jun 19, 2021

How to convert a JSON to a Struct in Golang

Learn to convert a JSON string to a struct using a package json UnMarshal function

Jun 19, 2021

How to convert a Struct to a JSON in Golang

Learn to convert a struct to a JSON using a package json Marshal function

Jun 16, 2021

How to convert a float to an integer in JavaScript

Learn to use various JavaScript Math methods to convert a float number to an integer number

Jun 15, 2021

How to set a default route in React Router

Learn to set a default route in React Router using the Redirect component

Jun 15, 2021

How to pass state data in React Router

Learn how you can pass data between the routes using the react-router-dom library

Jun 14, 2021

How to use Material UI icons in React Material UI

Learn to import and use material-ui icons in React components

Jun 14, 2021

How to conditionally disable an input field in React

Learn to conditonally disable an input field in React

Jun 13, 2021

How to sort an array of alphanumeric strings in JavaScript

Learn to sort an array of alphanumeric values in JavaScript using the String.localeCompare() method

Jun 11, 2021

How to achieve conditional routing in React

Learn to conditionally route between components in React using react-router-dom

Jun 8, 2021

How to add multiple class names in React Material UI

Learn to add multiple class names in React Material UI using clsx library

Jun 7, 2021

How to get first N elements of an array in JavaScript

Get first N number of elements of an array in JavaScript in two simple ways

Jun 6, 2021

How to pass arguments to event handlers in React

Learn to pass one or arguments to event handler functions in React

Jun 5, 2021

How to loop through an object in JavaScript

Learn two ways to iterate through an object in JavaScript

Jun 4, 2021

How to remove empty objects from an array in JavaScript

Learn to remove empty objects and empty arrays from an array in JavaScript

Jun 3, 2021

How to check for an empty object in JavaScript

Learn Two ways to check if a JavaScript object is empty

Jun 2, 2021

How to write multiple conditions with a switch case in JavaScript

Write multiple OR conditions with a single switch case statement in JavaScript

Jun 1, 2021

How to remove empty elements of an array in JavaScript

Learn to remove empty and falsy elements of an array in JavaScript using Array.filter method

May 30, 2021

How to trigger button onclick event on Enter key press in React

Learn to submit a React form by triggering submit button click on Enter key press

May 29, 2021

How to find index in an array of objects in JavaScript

Learn how you can find index of an item in an array of object in JavaScript using Array.findIndex() method

May 28, 2021

How to conditionally apply class names in React JS

A couple of approaches to condtionally apply class names in React JS

May 28, 2021

How to conditionally add props to React component

Learn to conditionally add or remove props to React components using JavaScript ternary operator

May 27, 2021

How to add google analytics to a Next.js app

In this tutorial, you will learn 3 ways to add google analytics to your Next.js app

May 27, 2021

How to return multiple values from a JavaScript function

In this tutorial, you’ll learn how you can return multiple values from a JavaScript function using Array destructuring and object destructuring.

May 26, 2021

How to check if a key exists in a JavaScript object

Learn 2 way to check if a key exists in given JavaScript object

May 25, 2021

How to set HTTP headers in Axios

Learn 2 different ways to set HTTP headers in Axios

May 23, 2021

How to get query string of a current URL in React

Learn to create a custom hook to get query string of a URL in React

May 22, 2021

How to customize 404 error page in Next.js

Create a custom page not found (404) error page in Next.js

May 21, 2021

How to update parent state from child in React

Learn to update parent component state from child components in React

May 20, 2021

How to add favicon in Next.js

Learn to add a favicon to your Next.js application

May 20, 2021

How to do a 301 server side redirect in Next.js

Do a server side redirect in Next.js and React using the nodeJS response.writeHead() method

Jan 3, 2021

How to autofocus an input element in React using useRef() hook

Learn to focus JSX elements in React function component using the useRef() hook

Dec 20, 2020

How to get query string params using Node and Express

Get the query string params in express using the Request.query property

Dec 7, 2020

How to convert ASCII code to a character in JavaScript

Convert ASCII code to sting and character and vice versa in JavaScript

Dec 5, 2020

Call parent component method in a child component in React and Typescript

How to call a parent component method in a child component in React and Typescript

Dec 2, 2020

How to embed a Youtube video in React

Embed a Youtube, Facebook, Twitch or any other external video on your React app using react-player

Nov 29, 2020

How to pass props to the makeStyles API in React Material UI

Learn how to pass a component props to the makeStyles API in React Material UI that dynamically change the style property

Nov 29, 2020

How to pass React components as props in TypeScript

Learn how you can pass an entire component as props in React and TypeScript

Nov 26, 2020

How to get the last element of an Array in JavaScript

In this tutorial, I have discussed 2 ways to get the last element of an Array in JavaScript

Nov 25, 2020

How to scroll to the bottom of JSX elements in React

How to scroll to the bottom of a JSX element using useRef() hook

Nov 22, 2020

How to scroll to top of the page in React

Scroll to the top of the page in React using useEffect() react hook

Nov 21, 2020

How to write React function components in Typescript

Learn to write strongly type React function components in TypeScript

Nov 20, 2020

How to detect if dark mode is enabled on a browser using JavaScript

In this tutorial, you will learn how you can check if dark mode is enabled on your browser using the window.matchMedia() method

Nov 18, 2020

How to check if an array is empty in JavaScript

Learn the easiest way to find whether the given array is empty or not

Nov 17, 2020

How to remove the first element of an array in JavaScript

Learn to use Array.shift() method and array destructuring to remove the first element of an array in JavaScript

Nov 16, 2020

How to check if an object is an array in JavaScript

Learn how you can use Array.isArray method to check if an object is an array in JavaScript

Nov 15, 2020

How to add an element at the beginning of an array in JavaScript

In this tutorial, you will learn how you can add a new element at the beginning of an array in JavaScript using unshift() method and array destructuring

Nov 15, 2020

How to submit a login form in React using React hook

Learn how to submit a controlled login form in React using html form onSubmit attribute

Nov 14, 2020

How to remove a particular substring from a string in javascript

Learn to use the replace() and the split() method to remove a substring from a string in JavaScript

Nov 8, 2020

How to show and hide components in React using React Hook

Learn to conditionally show and hide components in React using useState hook

Nov 7, 2020

How to import CSS from the public folder in React

Import a css file from the public folder in React

Nov 7, 2020

How to make React Material UI Typography bold

Learn to change the font-weight of the React Material UI Typography component to bold

Nov 2, 2020

How to change font family of typography in React Material UI

Learn to change the font family of React Material UI Typography

Oct 2, 2020

How to add an item to a list in React

Learn to add an item to a state Array in React using the spread operator and the concat method

Oct 2, 2020

How to render a list of items in React

Learn to render a list of items in React using the Array.map() method

Sep 30, 2020

How to convert a boolean to a string in JavaScript

Learn to convert a boolean to a string in JavaScript

Sep 27, 2020

How to convert a string to a boolean in JavaScript

Learn to convert a string to a boolean in JavaScript

Sep 26, 2020

How to set a background image from the public folder in React

In this tutorial, I have discussed what the best way to set a /public folder image as a background image in React JSX

Sep 24, 2020

How to remove the last character of a string in JavaScript

In this tutorial, you will learn to remove the last character of a JavaScript string using the substring() and the slice() methods

Sep 24, 2020

How to handle an error in async await in JavaScript

In this tutorial, you will learn to handle an error in JavaScript async await

Sep 24, 2020

How to break out of the Array forEach method in JavaScript

In this tutorial, you will learn to break out of the array.forEach method in JavaScript

Sep 24, 2020

How to get the first element of an array in JavaScript

In this tutorial, I have discussed 3 ways to get the first element of a JavaScript array

Sep 21, 2020

How to get the current URL and pathname in React

In this tutorial, I have discussed different ways to get the current URL and pathname in React - uselocation hook and window.location object

Sep 17, 2020

How to check if a value exists in an array of objects in JavaScript

2 JavaScript Array methods to check if a value is present in an array of objects; some() and find() methods.

Sep 16, 2020

How to deploy a create React app to Github pages for free

A practical guide on how to deploy or host your React app on Github Pages for free using 6 simple steps.

Sep 16, 2020

How to disable a Button when an Input field is Empty in React

In this tutorial, I have discussed how you can use disabled attribute of a button element to disable the button when an input field is empty in React

Sep 14, 2020

How to check if a string starts with substring in JavaScript

In this tutorial, I have discussed 4 ways to check if a JavaScript string starts with a substring

Sep 12, 2020

How to check if an Array includes a value in JavaScript

In this tutorial, I have discussed 5 ways to check if an JavaScript array includes a value

Sep 10, 2020

How to convert a Decimal to a Hexadecimal in JavaScript

I have discussed how you can convert a decimal to a hexadecimal and a hexadecimal to a decimal number using toString and parseInt methods respectively.

Sep 9, 2020

How to build a React Login Form with Typescript and React hooks

A practical guide on how you can create a react login form and form validation with Typescript, React hooks and Material UI

Sep 8, 2020

How to check if a string contains a substring in JavaScript

In this tutorial, I have discussed how to check if a sting contains a substring in JavaScript using includes() and indexOf() methods

Sep 7, 2020

How to merge two or more arrays in JavaScript

In this tutorial, I have discussed two ways to merge two or more arrays in JavaScript

Sep 7, 2020

How to change the default port of a Svelte.js app

I have discussed two ways to change the default port of a Svelte app

Sep 7, 2020

How to uppercase the First Letter of a String in JavaScript

Uppercase the first letter of a sting in JavaScript using slice() and toUpperCase() methods

Sep 6, 2020

How to dynamically set Meta Title Tag in React

Created a custom React component with React Helmet to dynamically set a page meta title tag.

Sep 5, 2020

How to Repeat a String in JavaScript

4 best ways to repeat a string for N number of times in JavaScript, using Array.join(), string.repeat(), for loop, and recursion

Sep 3, 2020

How to convert an Array to a String in JavaScript

4 different ways to convert an array to a string in JavaScript - forEach, join, reduce, and toString methods.

Aug 29, 2020

How to conditionally render React components using React hooks

You will learn 3 ways to conditionally render components in React

Aug 26, 2020

How to loop through an array of objects in React

for-of loop and array.map() method, a practical guide on how to loop through an array of objects in React

Aug 21, 2020

4 best free website hosting sites for Javascript developers (no credit card required)

From Github Pages to Netlify, 4 best free websites hosting sites for Javascript developers.

Apr 12, 2020

Personal Blog Built using Nextjs and TypeScript

Things to consider when building a personal blog website with React