Latest Javascript Tutorials and How-To's


Wait for Multiple AJAX Requests to Finish

Waiting for multiple simultaneous AJAX requests to be finished has become quite easy by using the concept of Promises. We change each AJAX call to return a Promise. Promises from all AJAX calls are then passed to the Promise.all() method to find when all Promises are resolved.
March 29, 2021

Get Date & Time For a Given Timezone with Javascript

Date & time for a given IANA timezone (such as America/Chicago, Asia/Kolkata etc) can be found by using the Date.toLocaleString() method.
March 27, 2021

Convert Object to Array with Javascript

A Javascript object can be converted to an array using Object.keys(), Object.values() or Object.entries() methods.
March 24, 2021

Remove Property from a Javascript Object (2 Ways)

This tutorial discusses two ways of removing a property from an object. The first way is using the delete operator, and the second way is object destructuring which is useful to remove multiple object properties in a single line of code.
March 22, 2021

Play, Pause & Restart CSS Animations

Playing & pausing a CSS animation can be done by using the animation-play-state property. Completely restarting the animation can be done by first removing the animation and then applying it again.
March 12, 2021

CSS Animation on Element Dynamically Inserted to DOM

Animation can be done on an element which is dynamically inserted to page using CSS animation property. This property allows to give an initial and the final state of an element, and perform an animation between those states.
March 10, 2021

Insert HTML String As Text in Javascript

The append() & prepend() methods can be used to insert HTML string inside a given element. Both methods parse given HTML string as text and create Text node.
February 25, 2021

Using External CSS Stylesheets for Custom Elements

While creating a custom element, it is perfectly fine to use an external stylesheet for defining the element's CSS.
February 16, 2021

Check If Custom Element is Registered in Page

The customElements.get() method can be used to check whether a given custom element has already been registered in the page..
February 11, 2021

Knowing When a Custom Element Gets Defined

The customElements.whenDefined() method can be used to know when a given custom element has been registered.
February 10, 2021

Creating a Custom Element Using Anonymous Class

While creating a new custom element, it is not necessary to give a name to the defining class. The custom element can be created using an anonymous class also.
February 3, 2021

Naming Rules for Custom Elements

A custom element's tag name must contain a dash character. The name must start with a lowercase ASCII character, and cannot have an uppercase ASCII character anywhere.
February 2, 2021

How to Create a HTML Custom Element

A custom element is a new HTML element that we can create ourselves. This tutorial explains how to create a simple custom element.
January 28, 2021

Detect If Element Removed from DOM with Javascript

We can detect whether an element has been removed DOM using the MutationObserver object. This provides the ability to observe for changes being made to the DOM tree.
January 13, 2021

Detect If Element Added to DOM with Javascript

We can detect if an element has been added to DOM using a MutationObserver object. This provides the ability to observe for changes being made to the DOM tree.
January 12, 2021

Getting Camera Resolution with Javascript

There is no direct method to find out the maximum resolution supported by the camera. Instead we can specify the required width & height using the ideal property to find the closest possible resolution.
January 9, 2021

Record Video From Camera using Javascript

Videos can be recorded from the user camera using MediaDevices & MediaRecorder APIs.
January 7, 2021

Uploading Canvas Image to a Server

Canvas images can be uploaded to server-side as a data URL string, base64 string or as a file.
January 4, 2021

Capture Photo From Camera using Javascript

Photos can be captured from a camera using a combination of MediaDevices & Canvas Javascript APIs. Video frame of the camera stream can be captured as an image.
January 2, 2021

Replacing All String Instances With replaceAll()

All instances of a given string can be replaced by using the replaceAll() method. This method newly added to Javascript is now supported in all modern browsers.
December 26, 2020