Now, the question is why we need to create a query parameter using JavaScript. Let’s understand it via real-life examples. For example, if you go on amazon’s website and search for any product, you will see that it automatically appends your search query to the URL. It means we require to generate the query params from the search query. Also, we can allow users to select any value from the dropdown option. We can generate query parameters and redirect users to a new URL based on the selected value to get results. We will learn to create a query parameter ... Read More
In this article, you will understand how to calculate local time in Node.js. The Date object works with dates and times. Date objects are created with new Date(). JavaScript will use the browser's time zone and display a date as a full text string. Node.js is an open-source and cross-platform JavaScript runtime environment.As an asynchronous event-driven JavaScript runtime, Node.js is designed to build scalable network applications. Example 1 In this example, we use the toDateString and toTimeString function const dateTimeObject = new Date(); console.log("A date-time object is created") console.log(`Date: ${dateTimeObject.toDateString()}`); console.log(`Time: ${dateTimeObject.toTimeString()}`); Output A date-time object is created ... Read More
Before we start, let’s understand the hash in JavaScript. The hash is also a string, but it's encrypted using a particular algorithm. Generally, we use the hash for security purposes. For example, Google stores users' emails and passwords in their database. Now, Google’s employees can access their database for development purposes. But can they get the user’s email and password from the database? No, because the password is stored in the hash form, and to decrypt the password, the employee needs the key which we used while creating the hash from the password string. So, in such a way, we ... Read More
In this article, you will understand how to add a property to a JavaScript object using a variable as the name. Adding property to an object can be achieved by two methods. The first is the dot (.) notation and the second is using the brackets([]). Example 1 In this example, let’s use the dot (.) notation. var inputObject = {a: "value1"}; console.log("An object is created with properties: ", inputObject) inputObject.b = "value2"; console.log("After adding properties, the object now contains: ", inputObject) console.log(inputObject) Explanation Step 1 − Define an object namely inputObject. Step 2 − Add an ... Read More
In JavaScript, arrays are always dynamic in length. Like other programming languages, we don’t need to define the array's length while creating the array. So, we can create an array and push whatever number of elements we want in the JavaScript array. Here, we will create the dynamic length of the array and add numbers to that. After that, we will sum up all numbers. This tutorial will teach us to create a dynamic length array with numbers and sum the numbers using JavaScript. Use the for loop to sum all elements of the dynamic array We can iterate over ... Read More
We will learn to create a dropdown list using HTML and JavaScript below. Before starting with the article, let’s understand the dropdown list and why we need to use it. The dropdown list gives multiple choices to users and allows them to select one value from all options. However, we can do the same thing using multiple radio buttons, but what if we have hundreds of choices? Then we can use the dropdown menu. When users click the dropdown button, it opens all the choices, and users can select anyone. Also, the dropdown provides a better user experience than the ... Read More
In this article, you will understand how to add float numbers using JavaScript. Float values in JavaScript are defined as parseFloat(string). Example 1 In this example, let’s understand adding float values without using functions. let inputFloat1 = parseFloat(2.3) let inputFloat2 = parseFloat(3.5) console.log("The two float values are defined as ", inputFloat1 ,"and", inputFloat2) let result = inputFloat1 + inputFloat2 console.log("The sum of the float values is: ", result) Explanation Step 1 − Define two float values inputFloat1 and inputFloat2. Step 2 − Add the two float values using addition operator (+). Step 3 − Display the result. ... Read More
In this article, you will understand how to add a parameter to the URL in JavaScript. There are two methods to add parameters to an url: append() method and set() method. The append() method is used to specifically add key-value pairs to the url. The set() method adds the value to a specific key. If the key doesn't exist, a new key is created. If several keys exist, the value is updated for one of them and others are deleted. Example 1 Let's look at the append() method in this example let inputUrl = new URL('https://urlExample.com?key1=value1'); let inputParams = new ... Read More
The dialog box is a popup box like a modal in ReactJS. In vanilla JavaScript, maybe you have used the alert() method, which allows us to show an alert message in the alert box. Also, vanilla JavaScript provides the confirm box and prompt box to take user input. The dialog box also allows us to perform all operations. We can add the normal HTML to the dialog box according to our requirements, and it works as a popup box. In this tutorial, we will use the various libraries to create a dialog box. Use the Material-Ui library The Material-Ui library ... Read More
The date picker allows users of the application to pick a date. If we take data in the string format from the users, they can make a mistake while entering the date and enter the wrong format of the date. So, the best way to take a correct date input from the users is using the date picker. In this tutorial, we will use various libraries of ReactJS and create a date picker allowing users to pick any date, month, year, or decade. Use the ‘react-date-picker’ NPM package The react provides various libraries and npm packages to manipulate the date ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP