Found 6685 Articles for Javascript

How to convert date to another timezone in JavaScript?

Saurabh Jaiswal
Updated on 21-Apr-2023 17:00:51

8K+ Views

JavaScript has a new Date() constructor which is used to create a date object to get the current date and time. This date object uses the UTC timezone or the client browser's timezone, i.e. if you are in India and use the new Date() constructor to get the date and time, you will get your local time. But sometimes, we may need to get the timezone of another country, which we can't do directly. These can be done using the toLocaleString() method or the format() method. By the end of the article, you will be able to get the date ... Read More

How to convert decimal to hex in JavaScript?

Saurabh Jaiswal
Updated on 21-Apr-2023 16:59:14

837 Views

For any computer programmer who is working with low-level language or assembly language, it is a fundamental task to convert decimal to hex or hexadecimal. In web development we use colors and to represent them it is a common practice to use hex color codes. In Javascript, it is very easy to convert decimal to hexadecimal because of the built-in functions and methods provided by ECMA. In this article, we will discuss multiple ways to convert decimal to hex in javascript with appropriate examples. Using toString() method Using Custom Function Using the toString() Method As the name suggests ... Read More

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

Saurabh Jaiswal
Updated on 21-Apr-2023 16:58:31

329 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 format. CFAabsolute time is a numeric value representing the number of milliseconds since the Unix epoch whereas a date object is an object representing a specific date and time, year, month, ... Read More

How to convert hyphens to camel case in JavaScript?

Saurabh Jaiswal
Updated on 21-Apr-2023 16:57:25

2K+ Views

As a developer, we often encounter hyphenated strings. A hyphenated string makes our code more readable when the string’s length is high and the name is very complex. To solve this problem we use a camel case. Camel case is a very popular naming convention, in which we combine multiple words and make one string by capitalizing the first letter of each string except the first string. In javascript, we can use this convention to create variables and function names while we cannot use hyphenated strings to create a variable. In this article, we will explore step by step multiple ... Read More

How to convert Hex to RGBA value using JavaScript?

Saurabh Jaiswal
Updated on 21-Apr-2023 16:56:09

2K+ 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 #RRGGBBAA 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 ... Read More

How to Use Conditional Statements On Objects?

Yaswanth Varma
Updated on 21-Apr-2023 15:51:23

610 Views

Conditional statements are used to control how an execution will proceed in response to various circumstances. You can take one action if a condition is true and another action if the condition is false. Conditional statements are the component of a computer program's logic, decision-making, or flow control. The task we are going to perform in this article was using conditional statements on objects. Let’s dive into the article for getting better understanding on conditional statements. Using if statement The if statement is the most basic type of conditional expression. If a statement is evaluated to see whether it is ... Read More

How To Show Only One V-Menu At A Time When Clicking To Show The Menu?

Yaswanth Varma
Updated on 21-Apr-2023 15:50:05

799 Views

The task we are going to perform in this article was how to show only one v-menu at a time when clicking to show the menu, let’s dive into the article for getting better understanding on v-menu. A customized version of NativeUI was used to create the server-side trainer and menu known as vMenu. It features complete permissions support, allowing the server owner to control who can do what. Displaying v-menu A user interface's menu is a flexible element. It displays a popover with a variety of uses, like presenting a menu of choices. They may be used in conjunction ... Read More

How To Modify This JavaScript Code To Grab An Image URL From A JSON File, And Display It In HTML?

Yaswanth Varma
Updated on 20-Apr-2023 17:16:40

7K+ Views

This can be done by using the JavaScript method JSON.parse() to parse through the JSON file and extract the URL of the desired image. Then, an HTML img tag can be created with a source attribute set to this URL. Finally, this img tag can be appended to an existing HTML element in order to display it on your page. This will require some knowledge of basic JavaScript syntax, as well as familiarity with how JSON is structured and parsed within it. With these skills in hand, you should have no trouble modifying your code to achieve your goal! Let’s ... Read More

JavaScript Program for Check if an array is sorted and rotated

Prabhdeep Singh
Updated on 21-Apr-2023 09:16:19

175 Views

A sorted array is an array where all the elements are present in increasing order. We have given an array of size N and an array containing the distinct integers (which means every integer is present only one time). We have to check the array is sorted and rotated in a clockwise direction. Here we have to return ‘YES’ if the array is sorted and rotated otherwise, we have to return ‘NO’. Note − Here we are talking about the sorted and rotated means at least one rotation should be present. We cannot consider a sorted array as a sorted ... Read More

JavaScript Program for Ceiling in a sorted array

Prabhdeep Singh
Updated on 21-Apr-2023 09:10:43

139 Views

An array is a linear data structure that contains the objects and in sorted array elements are present in increasing order. We have given a sorted array and an integer x. We have to print the ceiling of the integer x from the given array. The ceiling of a sorted array with value x is the smallest element larger than or equal to x, while the floor is the largest member less than or equal to x. If the ceiling of the x does not exist in the array we have to print ‘ceiling of x does not exist in ... Read More

Advertisements