Shubham Vora

Shubham Vora

793 Articles Published

Articles by Shubham Vora

Page 24 of 80

How do you Convert a String to a Character Array in JavaScript?

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

Converting a string to a character array in JavaScript is useful when you want to iterate over each character or manipulate individual characters. JavaScript provides several built-in methods and techniques to accomplish this transformation. In this article, we'll explore five different approaches to convert a string to a character array in JavaScript, each with its own advantages and use cases. Approaches to Convert String to Character Array Here are the five methods we'll cover with complete examples and explanations: Using split() Method Using Array.from() Method ...

Read More

How to get the largest of zero or more numbers in JavaScript?

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

In this tutorial, we will look at how to get the largest of zero or more numbers in JavaScript. The maximum of multiple numbers can be found using different techniques. The first technique we will introduce is the Math.max() method. The second technique will be the for-loop method. Following are the methods to get the largest of zero or more numbers in JavaScript − Using the Math.max() Method We can use the Math.max() method to find the largest of many numbers. It returns the largest value from the given multiple values. The input parameters should be ...

Read More

How to convert epoch Date to meaningful JavaScript date?

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

In this tutorial, we will learn to convert the epoch Date to a meaningful JavaScript date. The epoch date is a representation of the date in milliseconds, and it is a total number of milliseconds since 1st January 1970 since the UNIX epochs started. Users can convert the total number of milliseconds into the meaningful date string using various approaches explained below. Using the new Date() Object In this approach, we will create the object of the Date class. The constructor of the Date() class takes the total number of milliseconds since the epoch started and converts ...

Read More

How to compare only date part without comparing time in JavaScript?

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

While developing applications, you often need to compare only the date parts of two Date objects, ignoring the time components. For example, in a subscription system, you might want to check if a user's payment was made on or before the subscription deadline, regardless of what time the payment was processed. In this tutorial, we will learn to compare only the date part without comparing the time in JavaScript. Using the setHours() Method The most straightforward approach is to set the time components (hours, minutes, seconds, milliseconds) to zero for both date objects. This ensures that when ...

Read More

How to get the tangent of a number in JavaScript?

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

In this tutorial, we will learn how to get the tangent of a number in JavaScript. The tangent of an angle is defined by the ratio of the length of the opposite side to the length of the adjacent side. It can also be defined as the ratio of sine and cosine function of an acute angle where the value of cosine function should not be zero. Mathematically: tan θ = opposite side / adjacent side also, tan θ = sin θ / cos θ Where θ = angle in radians The tangent of a ...

Read More

How to convert a date object to string with format hh:mm:ss in JavaScript?

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

We will learn to convert the date object to a string with the format hh:mm:ss in JavaScript. Working with dates and times is common in web development, and formatting them according to specific requirements is an essential skill. The default date object returns a complete date string, which might contain more information than needed. Here, we will explore different approaches to extract and format just the time portion in hh:mm:ss format. Using toTimeString() Method The toTimeString() method returns the time portion of a Date object as a human-readable string. We can then extract the first 8 characters ...

Read More

How to differentiate between Manual and Automated Animation in JavaScript?

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

Generally, animation in JavaScript is done to get different effects and make the object move around the page. You can move and animate any type of HTML element using manual or automated animations in JavaScript. In this tutorial, we will learn how to differentiate between manual and automated animation in JavaScript. Manual Animation Manual animation requires user interaction to trigger movement or changes. The animation process is not automated and depends on events like button clicks or mouse actions. The following implementation demonstrates a simple manual animation using DOM object properties and JavaScript functions: ...

Read More

How do I subtract minutes from a date in JavaScript?

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

In this tutorial, we will learn to subtract minutes from a date in JavaScript. Working with dates is a common requirement in web development, and JavaScript provides built-in Date class methods to handle date manipulations effectively. We'll explore three approaches: using native JavaScript methods getMinutes() and setMinutes(), working with milliseconds, and using the Moment.js library for more convenient date operations. Using the getMinutes() and setMinutes() Methods This approach uses the Date object's built-in methods to extract current minutes, subtract the desired amount, and update the date object. Syntax let date = new Date(set_date); let ...

Read More

How to play a multimedia file using JavaScript?

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

In this tutorial, we will learn how to play a multimedia file using JavaScript. The multimedia file is the audio and video files. The multimedia files can be of different formats. wav and mp3 are two examples of audio file formats, whereas mp4 and mkv are examples of video file formats. In HTML, multimedia files can be shown easily using different tags. We use the video tag for showing a video, and for audio, we use the audio tag. These two tags are quite similar, and many attributes are the same in both tags. The "src" attribute defines ...

Read More

How to convert a negative number to a positive one in JavaScript?

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

This tutorial will teach us to convert negative numbers to positive ones. Sometimes, programmers need to perform operations with the unsigned value of a number, and in such cases, they need to convert negative numbers to positive numbers. We will explore three different methods to convert negative numbers to positive numbers in JavaScript: Using the Math.abs() Method Multiplying the negative number with -1 Using the Bitwise Not Operator Using the Math.abs() Method The Math.abs() method is the most commonly used approach. It ...

Read More
Showing 231–240 of 793 articles
« Prev 1 22 23 24 25 26 80 Next »
Advertisements