Articles on Trending Technologies

Technical articles with clear explanations and examples

Frequency of elements of one array that appear in another array using JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 595 Views

We need to write a JavaScript function that takes two arrays of strings and returns the frequency count of each element from the second array as it appears in the first array. Problem Given two arrays, we want to count how many times each string from the second array appears in the first array. The result should be an array of counts corresponding to each element in the second array. Example Following is the code − const arr1 = ['abc', 'abc', 'xyz', 'cde', 'uvw']; const arr2 = ['abc', 'cde', 'uap']; const findFrequency = ...

Read More

How to display date and time picker in ReactNative?

Shilpa S
Shilpa S
Updated on 15-Mar-2026 9K+ Views

To display date and time picker in your React Native app, you need to install the community package as it's not included in React Native core. Installation npm install @react-native-community/datetimepicker --save Once installed, you can import and use the DateTimePicker component in your app. Import Statement import DateTimePicker from '@react-native-community/datetimepicker'; Basic Syntax Key Properties Props ...

Read More

JavaScript: How to Detect if a Website is Open on a Mobile or a Desktop?

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 9K+ Views

We can use the CSS media queries to check whether the website is opened inside a web browser or a mobile browser. This information can be fetched using the min-width and the max-width of the webpage. CSS media queries are only limited to styling the web pages but we can control the functionality of a website as per the user's device by using the navigator properties in JavaScript. The Navigator returns a set of values that includes user browser, version, operating system, and many more. Syntax navigator.userAgent Method 1: Using navigator.userAgent In ...

Read More

How to disable the centered scaling of Text using FabricJS?

Rahul Gurung
Rahul Gurung
Updated on 15-Mar-2026 484 Views

In this tutorial, we are going to learn how to disable the centered scaling of Text using FabricJS. We can display text on canvas by adding an instance of fabric.Text. Not only does it allow us to move, scale and change the dimensions of the text but it also provides additional functionality like text alignment, text decoration, line height which can be obtained by the properties textAlign, underline and lineHeight respectively. When being scaled via controls, assigning a true value to the centeredScaling property, uses the center as the object's origin of transformation. Syntax new fabric.Text(text: String, ...

Read More

How to change video playing speed using JavaScript?

Manisha Patil
Manisha Patil
Updated on 15-Mar-2026 4K+ Views

In this article, we'll learn how to control video playback speed using JavaScript's HTML5 video properties. This allows users to watch videos at different speeds for better accessibility or user experience. The playbackRate property controls video speed: values less than 1 slow down the video, values greater than 1 speed it up, and 1 returns to normal speed. Note that playbackRate is a JavaScript property, not an HTML attribute. Syntax To change the current playback speed: let video = document.querySelector('video'); video.playbackRate = newSpeed; To set the default playback speed: let video ...

Read More

How to serialize a cookie name-value pair into a Set Cookie header string in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 1K+ Views

The cookie allows us to store users' data in the web browser for quick response. For example, when a user opens the profile page in any web application, the web page receives the data from the server. The server also sends the cookies containing the data to store in the web browser. When a user goes on the profile page again, it fetches the data from the cookie rather than fetching it from the server to load the webpage quickly. To get data browser looks in the cookie first, and if it doesn't find data stored in the cookie, ...

Read More

Finding clusters of consecutive negative integers in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 288 Views

We have an array of numbers like this: const arr = [-1, -2, -1, 0, -1, -2, -1, -2, -1, 0, 1, 0]; We are required to write a JavaScript function that counts the consecutive groups of negative numbers in the array. Understanding the Problem In the example array [-1, -2, -1, 0, -1, -2, -1, -2, -1, 0, 1, 0], we have: First cluster: [-1, -2, -1] (positions 0-2) Second cluster: [-1, -2, -1, -2, -1] (positions 4-8) The function should return 2 since there are two separate groups of ...

Read More

Using JSON.stringify() to display spread operator result?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 1K+ Views

The spread operator (...) allows you to expand objects and arrays into individual elements. When combining objects with the spread operator, you can use JSON.stringify() to display the merged result as a formatted string. Syntax // Object spread syntax var result = { ...object1, ...object2 }; // Convert to JSON string JSON.stringify(result); Example Here's how to use the spread operator to merge objects and display the result: var details1 = { name: 'John', age: 21 }; var details2 = { countryName: 'US', subjectName: 'JavaScript' }; var result = { ...details1, ...details2 ...

Read More

Finding the power of a string from a string with repeated letters in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 594 Views

The power of a string is the maximum length of a non-empty substring that contains only one unique character. We are required to write a JavaScript function that takes in a string and returns its power. For example − const str = "abbcccddddeeeeedcba" Then the output should be 5, because the substring "eeeee" is of length 5 with the character 'e' only. How It Works The algorithm traverses the string and counts consecutive identical characters. It tracks the maximum count found, which represents the power of the string. ...

Read More

Filter nested object by keys using JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 1K+ Views

When working with arrays of objects in JavaScript, you often need to filter them based on specific criteria. This article demonstrates how to filter an array of objects by checking if their title property contains any of the specified search terms. Problem Statement Suppose we have an array of objects like this: const arr = [{ 'title': 'Hey', 'foo': 2, 'bar': 3 }, { 'title': 'Sup', 'foo': 3, 'bar': 4 }, { ...

Read More
Showing 15921–15930 of 61,297 articles
Advertisements