Found 6685 Articles for Javascript

Higher Order Functions and Currying in JavaScript

Rushi Javiya
Updated on 10-Mar-2023 16:28:56

189 Views

In any programming language, functions are a very useful feature. Developers might be able to find any programming language which doesn’t contain the function. Also, when we start learning any programming language, we definitely learn the function, a block of code that provides the code reusability. In this tutorial, we will learn about higher-order functions and currying. Higher Order Functions Before we start currying in JavaScript, let’s first learn about the higher-order function. The simple definition of the higher order function is A function that takes another function as an argument or returns a function. Have you ever ... Read More

Hide the cursor on a webpage using CSS and JavaScript

Rushi Javiya
Updated on 10-Mar-2023 16:27:22

4K+ Views

In this tutorial, we will learn to hide the cursor in a webpage using CSS and JavaScript. Sometimes, we need to create our style cursor, and then we need to hide the cursor. Maybe it also needed to hide the cursor for a particular HTML element. There are two ways to hide the cursor on the Webpage. One uses CSS, and another uses JavaScript. We will learn both approaches one by one in this tutorial. Use the CSS to hide the cursor on the Webpage The CSS allows us to change the style of the cursor. We can ... Read More

Handling Promise rejection with a catch while using await in JavaScript

Rushi Javiya
Updated on 10-Mar-2023 16:25:24

1K+ Views

In JavaScript, users can perform particular actions using the Promise. For example, we can create the promise to fetch data from the database using the API. If the promise gets the data from the database successfully, that means the promise is a success, or the promise gets an error, which means the promise is rejected. Let’s look at the syntax to create the promise first. Syntax Users can follow the syntax below to create a promise in JavaScript. let testPromise = new Promise((res, rej) => { // perform some operation }); ... Read More

Get the YouTube video ID from a URL using JavaScript

Rushi Javiya
Updated on 19-Jul-2023 10:39:52

968 Views

Every YouTube video has a unique URL through which we can access it in the browser. Every YouTube video contains a unique video id, which makes the URL unique. Sometimes, developers need to extract the video id from the YouTube URL. We need to play with the YouTube URL string to extract the video id from the URL, which we will do in this tutorial. We will learn different approaches to getting the video id from a full URL. Use the split() method JavaScript contains the built-in split() method, which allows users to split the string into multiple ... Read More

Insert a character after every n characters in JavaScript

Pranay Arora
Updated on 09-Mar-2023 16:38:08

3K+ Views

Insertion of a specific character after every n characters in Javascript is an easy to understand concept and gives us a better understanding about Javascript's functions. Here n can be any whole number ranging from 1 to less than the length of the string. In this article we will deal with a variable inputString = "abcdefghijklmnopqrstuvwxyz, " and aim to append a "-" character after every 5 characters. There are several ways to accomplish this with JavaScript, which are as follows − Making use of the slice() method In JavaScript, the slice() function is used to extract a portion of ... Read More

Increment a given date in JavaScript

Pranay Arora
Updated on 09-Mar-2023 16:31:13

2K+ Views

In this article, we are going to discuss how to increment a given date using JavaScript. First, we will analyse and understand what is meant by this. Given a certain date x = “05-02-2023”, we want to add y = 7 days to this date and print the resulting date which is “12-02-2023”. As a human we can manually add 7 days to 5th February and get the resultant. But we need JavaScript to do this programmatically for us. There are few techniques to do so which we shall be discussing in this article. Using addDays() function The addDays function ... Read More

Implementation of LinkedList in Javascript

Pranay Arora
Updated on 10-Mar-2023 11:41:26

6K+ Views

A linked list is a data structure that consists of a sequence of elements, each of which contains a reference (or "link") to the next element in the sequence. The first element is called the head and the last element is called the tail. Linked lists have many advantages over other data structures. Now we shall look at how to implement Linked list using JavaScript. Defining the Node Class and the LinkedList class This is basically the prerequisite in order to implement a linked list in JavaScript. In this step, 2 classes namely one for the nodes and the other ... Read More

How to upload file without form using JavaScript?

Mohit Panchasara
Updated on 09-Mar-2023 12:55:06

5K+ Views

Sometimes, developers may require to upload a file without using the form in JavaScript. Generally, we create a form to get the data and files from the users, but in this tutorial, we will learn to get the file from users without a form and send it to the backend. Use the FormData() object and Ajax Request The FormData object allows us to store the form data in the key value pair. We need to initialize the variable with a constructor. We can allow users to upload files using HTML input and store that file in form data. After ... Read More

How to uniquely identify computers visiting web site in JavaScript?

Mohit Panchasara
Updated on 09-Mar-2023 12:52:49

524 Views

Whenever we create any application or website, we require to identify computers visiting the website uniquely. There are a lot of benefits to uniquely identifying computers. For example, you are providing some services to your users. By uniquely identifying the computer, you can give free service for a trial purpose when a user visits your website for the first time from a new device. When a user visits again, you can ask users to buy premium or subscribe to your application. Here, we will use cookies to identify the computer visiting web site. What are cookies? The ... Read More

How to Understand Recursion in JavaScript?

Mohit Panchasara
Updated on 09-Mar-2023 12:49:13

147 Views

What is Recursion? The word recursion came from the recurring, meaning comes back to again and again. The recursion function is the function calling itself again and again by changing the input step by step. Here, changing the input by one step means decreasing or increasing the input by one step. Whenever a recursive function hits the base condition, it stops its execution of itself. Let’s understand what is the base condition by one example. For example, we need to find the factorial of a number. We call the factorial function by decreasing the input by 1, and we ... Read More

Advertisements