Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by Saurabh Jaiswal
33 articles
How to convert Hex to RGBA value using JavaScript?
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 MoreHow to Convert CFAbsoluteTime to Date Object and vice-versa in JavaScript?
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 MoreHow to convert decimal to hex in JavaScript?
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 MoreHow to convert JavaScript datetime to MySQL datetime?
Date time manipulation in JavaScript is important while dealing with databases. JavaScript Date and time are different from the MySQL date and time. JavaScript provides multiple ways to represent Date and time none of these formats are the same as MySQL's date and time format. In this article, we will discuss some approaches to converting JS date and time into MySQL date and time format. First of all, we will understand the difference between Javascript and MySQL date and time formats. Here is an example − Javascript − ISO 8601 Date Format: YYYY-MM-DDTHH:mm:ss.sssZ MySQL ...
Read MoreHow to convert JSON data to a html table using JavaScript/jQuery?
JSON (JavaScript Object Notation) is a powerful data format to exchange data between server and client. HTML tables are essential for displaying data in a structured, readable format. Converting JSON data to HTML tables is a common requirement in web development. In this article, we will learn how to convert JSON data into HTML tables using both vanilla JavaScript and jQuery. We'll explore two practical approaches with complete examples. ...
Read MoreHow to convert Object's array to an array using JavaScript?
Converting an array of objects to a flat array is a common task in JavaScript. There are several approaches to extract all values from objects and create a single array containing those values. Let's understand the problem with an example: Given Array of Objects: let carObj = [ { name: "John", car: "Ford" }, { name: "Mark", car: "BMW" }, { name: "Ben", car: "Toyota" } ] Expected Output: ["John", "Ford", "Mark", "BMW", "Ben", "Toyota"] There are multiple ways to achieve this conversion: ...
Read MoreHow to Convert JSON String to Array of JSON Objects Using JavaScript?
To convert JSON string to array of JSON objects using JavaScript is necessary because JSON strings cannot be directly modified or manipulated, so we need this conversion which allows us to access, modify and iterate over each item. We will be discussing three different approaches for this conversion from JSON strings to array of JSON objects. In this article we are having JSON string, our task is to convert JSON string to array of JSON objects using JavaScript. Approaches to convert JSON string to objects Here is a list of approaches to convert JSON string to array ...
Read MoreHow to convert list of elements in an array using jQuery?
We can use jQuery.makeArray() method or jQuery.each() method to convert a list of elements into an array using jQuery. The makeArray() method is the most convenient way to perform this task. This method is used to convert an object into a native array. Using jQuery makeArray() Method The $.makeArray() method in jQuery converts an array-like object into a JavaScript array. It takes a single argument and converts it to an array. Syntax $.makeArray(obj) Here obj is an object that we want to convert to an array. Example In this example we ...
Read MoreHow to convert JSON results into a date using JavaScript?
JSON is a powerful data format to exchange data from server to client and vice versa. Many times JSON data is received in a String format and we need to convert it to a usable JSON object. In this process, it's an important requirement to convert string data into Date format. In this article, we will learn how to convert JSON results into a Date string using JavaScript. The JSON objects contain the date like this − { name: "John", time: '/Date(1559072200000)/' } And the result will be − ...
Read MoreHow to convert Map keys to an array in JavaScript?
In JavaScript, you can convert a Map's keys to an array using several methods. The most common approaches are using Array.from(), the spread operator, or a for...of loop with Map.keys(). Given a JavaScript Map, the task is to extract all keys and create an array from them. Here's an example: Given Map: Map { 1 => "India", 2 => "Russia", 3 => "USA", 4 => "Japan", 5 => "UK" } Resulting Array: [1, 2, 3, 4, 5] There are multiple ways to achieve this conversion: Using Array.from() and Map.keys() method ...
Read More