Javascript Articles

Page 22 of 534

How to convert Hex to RGBA value using JavaScript?

Saurabh Jaiswal
Saurabh Jaiswal
Updated on 15-Mar-2026 4K+ Views

While designing web pages we use colors to make web pages more appealing and engaging. We commonly use hex code to represent colors but sometimes we need to add transparency to the colors which can be achieved by RGBA values. Hex color values are represented by #RRGGBB and The RGBA color values are represented by rgba(red, green, blue, alpha). Here are a few examples of RGBA and hex values: Input: #7F11E0 Output: rgba(127, 17, 224, 1) Input: #1C14B0 Output: rgba(28, 20, 176, 1) In this article, we will discuss multiple ways to ...

Read More

How to Convert CFAbsoluteTime to Date Object and vice-versa in JavaScript?

Saurabh Jaiswal
Saurabh Jaiswal
Updated on 15-Mar-2026 561 Views

CFAbsoluteTime is the elapsed time since Jan 1, 2001, 00:00:00 UTC. This is a standard time format on Apple devices. On the other hand, a date object is a built-in object in JavaScript used to represent date and time values. It has many methods for providing formatting and converting date & time from one form to another. The main difference between CFAbsolute Time and JavaScript Date objects is their reference epoch. CFAbsoluteTime counts seconds since January 1, 2001, whereas JavaScript Date objects count milliseconds since January 1, 1970 (Unix epoch). In this tutorial we will learn how to: ...

Read More

How to convert decimal to hex in JavaScript?

Saurabh Jaiswal
Saurabh Jaiswal
Updated on 15-Mar-2026 2K+ Views

Converting decimal numbers to hexadecimal is a fundamental programming task, especially in web development where hex color codes are widely used. JavaScript provides built-in methods and allows custom implementations for this conversion. Using toString() method Using Custom Function Using the toString() Method The toString() method converts a number to its string representation in the specified base. Every JavaScript number has this method available. Syntax Number.toString(radix) Parameters radix (optional): An integer between 2 and 36 specifying the base. For hexadecimal conversion, use 16. Return Value Returns a string ...

Read More

How do you receive server-sent event notifications in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 862 Views

Server-sent events (SSE) provide a unidirectional communication channel between server and client. When you only need to send data from server to client, SSE offers an efficient alternative to polling or WebSockets. Server-sent events work by establishing a persistent connection where the server pushes data to the client. The server can be any backend technology like Node.js, PHP, or Ruby. When the server sends data, a 'message' event fires on the client-side, which can be handled with event listeners. How Server-Sent Events Work The process involves three main steps: Client establishes connection using ...

Read More

Text to Voice conversion using Web Speech API of Google Chrome

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

Nowadays, audiobooks are more preferred by readers over traditional books as they can absorb knowledge while multitasking. Many websites also include audio versions of articles, allowing users to listen instead of reading. To convert text to speech, we use the Web Speech API available in modern browsers. In this tutorial, we will learn how to use the Web Speech API to convert text to voice with practical examples. Syntax Users can follow the syntax below to use the Web Speech API for text-to-speech conversion. var synth = window.speechSynthesis; var speechObj = new SpeechSynthesisUtterance(text); synth.speak(speechObj); ...

Read More

What is tree shaking in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 386 Views

What is Tree Shaking? Tree shaking is a technique used in modern JavaScript development to eliminate unused or "dead" code from your application bundle. The term comes from the metaphor of shaking a tree to remove dead leaves and branches, keeping only what's alive and necessary. This process analyzes your code during the build process and removes any imported functions, variables, or modules that are never actually used in your application, resulting in a smaller, more efficient bundle. Why Do We Need Tree Shaking? Tree shaking provides several key benefits for web applications: Reduced ...

Read More

Using data in JSON format in Snack

Saba Hilal
Saba Hilal
Updated on 15-Mar-2026 806 Views

There are many ways to use data with apps made with Snack Expo. Sometimes the data is stored as JSON (JavaScript Object Notation). In this format, data can be easily stored as key-value pairs and can also be converted to CSV files. This article demonstrates how to use JSON data in Snack using JavaScript, including reading JSON data and displaying it as a table, plus converting JSON to CSV format for download. Sample JSON Data Structure For our examples, we'll use a products.json file containing product information: { "products": [ ...

Read More

JavaScript program for Minimum Product Subset of an Array

Aishwarya Mani Tripathi
Aishwarya Mani Tripathi
Updated on 15-Mar-2026 339 Views

JavaScript Program for Minimum product subset of an array is a common problem that arises in the field of computer science and programming. The problem statement requires us to find the minimum product that can be obtained from any subset of the given array. A minimum product subset of an array is a subset of array elements that yields the smallest possible product. Several algorithms are available for identifying this subset, including dynamic programming, greedy algorithms, and branch and bound. The selection of the algorithm is determined by the particular constraints and specifications of the problem at hand. ...

Read More

JavaScript Program for Number of unique triplets whose XOR is zero

Aishwarya Mani Tripathi
Aishwarya Mani Tripathi
Updated on 15-Mar-2026 491 Views

JavaScript Program for the Number of unique triplets whose XOR is zero is a common programming problem that requires finding the number of unique triplets in a given array whose XOR is equal to zero. The XOR operation is a bitwise operator that takes two bits and returns 1 if the bits are different, and 0 if they are the same. In this problem, we need to find all possible combinations of three numbers in the array, where the XOR of the triplet is zero. Problem Statement We are required to find the number of unique triplets in ...

Read More

JavaScript Program for Pairs such that one is a power multiple of other

Aishwarya Mani Tripathi
Aishwarya Mani Tripathi
Updated on 15-Mar-2026 219 Views

JavaScript Program for pairs such that one is a power multiple of the other is a problem that involves finding pairs of numbers where one number can be expressed as a power of another number. In this tutorial, we will explore how to write a JavaScript program to solve this problem using different approaches and algorithms. A power multiple relationship exists when one number is equal to another number raised to some integer power. For example, 8 is a power multiple of 2 because 2³ = 8. Problem Statement Given an array of integers, we need to ...

Read More
Showing 211–220 of 5,340 articles
« Prev 1 20 21 22 23 24 534 Next »
Advertisements