Latest Javascript Tutorials and How-To's

javascript

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
javascript

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
javascript

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
javascript

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
css

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

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
javascript

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
javascript

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
javascript

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
javascript

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
javascript

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
javascript

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
javascript

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
javascript

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
javascript

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
javascript

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
javascript

Record Video From Camera using Javascript

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

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
javascript

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
javascript

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