logo

Javascript

Javascript

Intersection of 2 Javascript Arrays Made Easy with Sets

The intersection() method of the Set object has made it very easy to get intersection of 2 arrays. This method is supported in all browsers now.
21 July 2024
Web Development Updates

Firefox 127 Released, Adds New Methods for Comparison of Sets

Firefox 127 was released on 11th June 2024. It has added many updates, however the best part is that it has implemented multiple Set methods for comparison of two Sets.
17 June 2024
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.
29 March 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.
27 March 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.
24 March 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.
22 March 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.
12 March 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.
10 March 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.
25 February 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.
16 February 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..
11 February 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.
10 February 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.
3 February 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.
2 February 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.
28 January 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.
13 January 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.
12 January 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.
9 January 2021
Javascript

Record Video From Camera using Javascript

Videos can be recorded from the user camera using MediaDevices & MediaRecorder APIs.
7 January 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.
4 January 2021