Javascript

Semantic Versioning with npm

Semantic Versioning, often referred to as SemVer, is a crucial convention within the Node.

Read More

Understanding Peer Dependencies in Node Modules

When working with Node.js and managing packages for your projects, you’re likely familiar with the dependencies and devDependencies sections in a package.

Read More

Programming Languages Series

1. Introduction Welcome to our Programming Languages Series! In this series, we’ll explore various programming languages, understand their purposes, provide code examples, and discuss when to use each one.

Read More

React State Balancing: A Guide to State Management

As React apps grow, managing shared and app-wide state can become challenging.

Read More

React + Node: Beginner's Guide to Full Stack Dev

React excels at building fast, dynamic frontends. Node.js shines for server-side APIs and microservices.

Read More

Optimal React Patterns: Beginner's Guide

As with any framework, React comes with its own set of best practices and optimal patterns.

Read More

Debugging React Apps: Beginner's Guide

Bugs are inevitable in complex React applications. Thankfully, React provides great tools to squash bugs quickly.

Read More

Advanced React Patterns: Compound Components & More

As React apps scale, you’ll want to structure components for greater reusability and composability.

Read More

React Animation Guide: Libraries and Techniques

Animation brings interfaces to life. Thankfully, React has great open source libraries for animation.

Read More

Testing React Apps: Beginner's Guide to TDD

Testing is crucial for ensuring React apps are stable and bug-free.

Read More

Data Fetched Fast - A Beginner's Guide to React Query

Fetching data in React often means using stale state and complex caching logic.

Read More

Forms Simplified, A Beginner's Guide to Managing React Forms

Forms are a common need for many React apps. However, managing form state and validation can be tricky.

Read More

Optimizing React Performance: Beginner's Guide

As React apps grow, you may notice performance starting to lag - sluggish interactions, choppy animations, janky scrolling.

Read More

State Management 101 - A Beginner's Guide to React State

State management is a crucial concept in React. State allows components to dynamically update UI based on data changes.

Read More

Accessible React Apps: Beginner's Guide to Accessibility

Accessibility is an important consideration when building modern web apps. React provides useful tools to make accessible, inclusive products.

Read More

Mystery Boxes - A Beginner's Guide to React Fragments

When returning multiple elements from a component’s render method, they must be wrapped in a single parent DOM node:

Read More

Unidirectional Data Flow in React: Beginner's Guide

A key advantage of React is its unidirectional data flow. This makes the flow of data predictable, and helps avoid unexpected side effects from data changing unexpectedly.

Read More

Event Handling in React: Beginner's Guide

Responding to user events is a crucial part of building interactive UIs.

Read More

Hooked on React - A Beginner's Guide to React Hooks

When React was first released, class components were the standard way to build complex UIs.

Read More

Lifting State in React: Beginner's Guide

As React apps grow in complexity, managing shared state between components can become tricky.

Read More

Looping in JSX with React Keys: Beginner's Guide

Looping over arrays to render lists of elements is a common need in React apps.

Read More

Conditional Rendering in React

In React apps, you’ll often need to render different UI components conditionally based on certain state.

Read More

Passing Data Between React Components with Props

One of React’s core concepts is reusability through composable components. Components allow splitting complex UI into separate, reusable pieces.

Read More

How to Download a File in NodeJS without any Third Party Libraries

If you need to download a file in NodeJS without using any third party libraries, then you can do the following.

Read More

How to Execute a Shell Script in NodeJS

If you need to execute a shell script in NodeJS, then you can use the exec keyword.

Read More

How to Convert Milliseconds to Date in Javascript

If you need to convert Milliseconds to Date in Javascript, then you can do the following:

Read More

How to Convert String to Title Case in Javascript

If you need to convert a String to Title Case in Javascript, then you can do one of the following:

Read More

How to Deploy React App to S3 and CloudFront

If you would like to deploy a React App to AWS S3 and AWS CloudFront, then you can follow this guide.

Read More

[Solved] export ‘Switch’ (imported as ‘Switch’) was not found in ‘react-router-dom’

In react-router-dom v6, Switch is replaced by routes Routes. You need to update the import from:

Read More

How to get all checked checkboxes in Javascript

If you need to get all the checked checkboxes using Javascript, then you can do the following:

Read More

How to Create a Hashtag Generator in Javascript

If you want to create a hashtag generator in Javascript, then you can do the following:

Read More

How to Confirm before Leaving Page in Javascript

You can implement a function to be called before the user leaves a page with Javascript as follows:

Read More

How to Style an Element using Javascript

If you need to style an element using Javascript then you can use the style object to support all your CSS needs.

Read More

How to Wait 1 Second in Javascript

If you need your Javascript code to wait one (1) second (or more) while executing, then there are a couple of ways to achieve this.

Read More

How to use forEach method in Javascript

Arrays come with a useful forEach function that allows you to loop through the array.

Read More

How to Remove an Element from an Array in Javascript

If you need to remove an element from an array in Javascript, then you can use one of the following five (5) options:

Read More

How to get the Alphabet as Array in Javascript

If you need to get an array of alphabetical letters in Javascript then you can use one of the following:

Read More

How to get the Screen Width in Javascript

Javascript gives a few options to determine the screen width.

Read More

How to Reset Udemy Progress

If you need to redo a Udemy course and you would like to reset the course’s progress, then you can use the following Javascript snippet below.

Read More

How to Sort an Array of Objects by Property in Javascript

If you need to sort an array of objects by their property values using Javascript, then you don’t need to look further than the built-in sort functionality.

Read More

[Solved] npm ERR! could not determine executable to run

If you get the following message, then there’s a very easy fix:

Read More

[Solved] npm ERR! path node_modules/node-sass

If you get the following error and need a solution, then look no further!

Read More

How to Install Lodash through Yarn for React

You can install lodash through yarn as follows: Step 1 – Install Lodash to get the Library yarn add lodash Step 2 – Get the Typescript info yarn add --dev @types/lodash

Read More

How to update each dependency in package.json to the latest version

You have 2 options: Option 1 – Recommended (Using npx) npx npm-check-updates -u npm install Option 2 – Older way (Using npm globally) npm i -g npm-check-updates ncu -u npm install

Read More

How to Convert IPv4 to int32 in Javascript

The challenge Take the following IPv4 address: 128.32.10.1 This address has 4 octets where each octet is a single byte (or 8 bits).

Read More

How to Solve the Grouped by Commas Challenge in Javascript

The challenge Finish the solution so that it takes an input n (integer) and returns a string that is the decimal representation of the number grouped by commas after every 3 digits.

Read More

How to Create a Pyramid Array in Javascript

The challenge Write a function that when given a number >= 0, returns an Array of ascending length subarrays.

Read More

How to Create a Reverse Polish Notation Calculator in Javascript

The challenge Your job is to create a calculator which evaluates expressions in Reverse Polish notation.

Read More

How to declare a global variable in React?

If you need to declare a global variable in React, then you can do the following:

Read More

How to Find the Missing Term in an Arithmetic Progression in Javascript

The challenge An Arithmetic Progression is defined as one in which there is a constant difference between the consecutive terms of a given series of numbers.

Read More

How to Count Characters in a Javascript String

The challenge The main idea is to count all the occurring characters in a string.

Read More

How to Increment/Decrement a value in React/NextJS

Use the following code block to get started: function GetCount() { const [count, setCount] = useState(1); const incrementCounter = () => { setCount(count+1) } const decrementCounter = () => { if (count>1) setCount(count-1) } return <div className="_counterWrapper"> <span className="_dec" onClick={() => decrementCounter()}>-</span> <span className="_val">{count}</span> <span className="_inc" onClick={() => incrementCounter()}>+</span> </div> } Then in your HTML code, add it like this:

Read More

Fixing: ImmutableService requires getRowNodeId() callback to be implemented, your row data need IDs

If you have gotten this error before, then you have been trying to implement a rowData mapping onto Ag-Grid.

Read More

Automatically Resize All Columns to Fit in Ag-Grid

If you have an Ag-Grid, and want to automatically resize all the columns to fit the width of the viewport, you can use this hack.

Read More

How to Get All Rows in Ag-Grid

The easiest way to get the content of all rows’ data, back into a Javascript/Typescript array, is as follows.

Read More

How to Download a CSV file using Javascript

Ever wanted to generate a CSV (comma separated values) file directly from the browser, using Javascript?

Read More

How to Format Numbers by Prepending 0 to single-digit numbers in Javascript

If you have a single-digit number, and you need to format it to always have at-least two digits, then you can use the below function to solve your problem:

Read More

Validate Email Address in Javascript

Below is a nice little Javascript RegularExpression to validate email addresses.

Read More

Remove hash from window.location in Javascript

E.g. URL:<br>http://example.com/?option=1&task=2&listing_id=36&layout=4&table=5#some_hash_value_here So how would you get the current URL using Javascript?

Read More

How to use Google Analytics in AngularJS

It seems to be quite a popular question with not as many answers to hold the weight.

Read More

Comparing Java and Javascript

Perhaps the first thing that most people ask when they hear the names of these two programming languages are.

Read More

Convert URL String into a Javascript Object

Sometimes you find yourself with a String, something like and you want to repeatably access elements of it correctly.

Read More

How to fix a Javascript Uncaught ReferenceError

Sometimes you may get an error that looks something like this:

Read More

uncaught typeerror: $ is not a function

The dollar-sign ($) in Javascript has for many years now been associated with jQuery.

Read More

Another WTF Javascript Moment

Javascript is a powerful language, but sometimes it doesn’t always do what you expect it to.

Read More

How to Format a Number as a Currency in Javascript

There are quite a few ways to format a number as a currency value in Javascript.

Read More

How to Host an AngularJS site on AWS S3

AngularJS is a Javascript Framework that allows you to create dynamic front-end web applications easily.

Read More

Generate a random number between two numbers in JavaScript

If you need to generate a random number between two numbers in JavaScript, then you are in the right place!

Read More

How to tell if a String contains a Substring in Javascript

Javascript comes with some pretty good support for determining if a string contains a substring.

Read More

How to write Anonymous Functions in Javascript

There is a lot of power in Javascript syntax. One of those powerful things is that of Javascript Anonymous Functions.

Read More

What is Fizz Buzz?

Fizz buzz is a common programming interview question. The problem statement usually reads something like this:

Read More

How to safely parse JSON in Javascript

JSON stands for Javascript Object Notation and has become wildly popular to transport and store data between application, databases and more.

Read More

Check if an HTML Checkbox is checked using Javascript

While processing forms in web development, it’s a common requirement to be able to tell if a checkbox has been checked or not.

Read More

How to Merge Javascript Objects

A Javascript Object – now just called JSON – is a collection of values and properties stored as a map.

Read More

Introduction to NPM

What is NPM? NPM stands for Node Package Manager, and is the default way to extend your Node applications.

Read More

How to replace all occurrences of a string in Javascript

I have pretty much resigned myself to the fact that in Javascript, there are really only two ways to do a proper search and replace.

Read More

Keep Google Map v3 centered when browser is resized

Using Google Maps V3 Javascript API you can keep the map centered to the browser’s window by using the following trick when resizing the window.

Read More

jQuery limit fields to alphanumeric characters only

I was trying to restrict a form’s field from only allowing the user to enter alphanumeric characters into it.

Read More

Disable Cache in jQuery

I usually run into this problem when dealing with good ol’ Internet Explorer (.

Read More

How to break out of an iframe

So someone’s trying to make their site better by opening a page on your site inside of their site using an iframe?

Read More

jQuery Colorbox not showing but background shows

I was using Colorbox for some lightbox type effects to show larger images when clicking on thumbnails, but for some reason the background was showing up but the pretty little box in the middle where the larger image is supposed to show never showed up, so this is how I made it finally appear after many failed attempts!

Read More

Get Value of Checkbox using jQuery

This one is quite an easy one, but a good one to mention non-the-less as it does definitely come in really handy.

Read More

Ternary Operation

If you do not know what the Ternary operator is, or do not use it while you are coding, let me be the first to tell you how much you are missing out!

Read More

IE6 PngFix in Javascript

As a web developer you will know just how much we all love hate Internet Explorer 6 – one of the most dreaded browsers and browser versions that still exists in the deep dark corners of the interwebs – and you will probably have figured out that it doesn’t play well with PNG images.

Read More

How to get ‘how many days in February’ using Javascript?

It is quite handy to have a function that can tell you how many days there are in February due to the leap year shift of either 28 or 29 days.

Read More

Search and Replace Anchor Href using Javascript

I have a site that is under development and it was made really badly so I needed a quick way to replace all anchors on page to the relevant path.

Read More

Swap HTML Elements Using Javascript

It is quite easy to use javascript to swap between divs or any other html dom elements.

Read More

[Exception… “Could not convert JavaScript” nsresult: “0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)”

What the heck is.. uncaught exception: [Exception… “Could not convert JavaScript argument arg 0 [nsIDOMHTMLDivElement.

Read More

Firefox error in FeedProcessor.js

[Exception… “Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIChannel.contentType]” nsresult: “0x80040111 (NS_ERROR_NOT_AVAILABLE)” location: “JS frame :: file:///C:/Program%20Files/Mozilla%20Firefox/components/FeedProcessor.

Read More

TypeError: node is null message=node is null

The following error message occurs in Firefox 3 when using Firebug.

Read More

How to Temporarily Edit the Text of Any Website

Have you ever wanted to temporarily edit a webpage displayed in Chrome or another browser?

Read More

Sending data from javascript to php

If you ever find yourself needing to do some ajax and in turn sending strings of characters via javascript then you should really try encodeURIComponent() to wrap your strings in.

Read More

What is Eb in firebug?

Gmail produces the following error/warning in firebug. Eb is not defined

Read More

Add TinyMCE code button

I had quite a few problems adding the htmlCode button to a fairly old copy of TinyMCE (I think around version 2.

Read More