Found 6710 Articles for Javascript

Express Cookie-Parser – Signed and Unsigned Cookies

Shubham Vora
Updated on 17-Mar-2023 12:34:03

2K+ Views

We can use cookies to store the user information on the client side in the web browser. For example, whenever a user opens any website in the browser, it requests some information to the server, and once the client gets the information, it stores it in the browser with the expiry time. It makes the website faster for users, as it doesn’t need to request the server for information every time users come back to the site. However, once cookies expire, the client requests the server again for that information. In this tutorial, we will learn about the express cookie-parse ... Read More

Explain the role of callback function in AJAX

Shubham Vora
Updated on 17-Mar-2023 11:41:05

3K+ Views

AJAX (Asynchronous JavaScript and XML) is not a programming language but a technique for creating more interactive web applications. Unlike conventional web applications, which direct us to a new page when interacting with the server, AJAX loads data onto the screen without letting the user know that the request was even made. Advantages Displays content dynamically without reloading the HTML page. Faster interaction with the users. Updates the data within the page without redirecting the user. Users were allowed to use the website while communication with the server went in the background. What is meant by Callback Function? ... Read More

Explain the MUL() function in JavaScript

Shubham Vora
Updated on 17-Mar-2023 11:25:32

807 Views

In this tutorial, we will learn to implement MUL() function in JavaScript. This function is a very small kind of multiplication function. Basically, we use the concept of nested functions to implement MUL( ) function. Nested functions are used for creating closures and decorators. And we can achieve privacy using nested functions. There are two ways to implement MUL() function using nested functions − Using nested function with name By currying a function Using nested Function With Name In JavaScript, we can use nested functions to get the multiplication result. We need to write n nested functions to ... Read More

Advantages of CoffeeScript Over JavaScript

Shubham Vora
Updated on 04-Apr-2023 12:32:16

286 Views

What is JavaScript? It is a loosely typed language that is mainly used in development. We can use javascript both in frontend as well as backend development. The nature of programs is synchronous and executed line by line. You can run javascript on any system or browser as it contains a javascript engine. What is CoffeeScript? CoffeeScript is a subset of javascript in a naive way and is compiled into javascript internally. It is a lightweight language in nature, having user-friendly syntaxes which are contrary to the complex syntax of JavaScript. Many languages like Perl, Python, and Ruby, along with ... Read More

JavaScript program to generate all rotations of a number

Alshifa Hasnain
Updated on 03-Mar-2025 18:49:09

538 Views

In this article, we will learn to generate all rotations of a number in JavaScript. Producing a primary common problem such as all its rotations comprises the creation of all possible permutations of the digits by rotating its digits. Problem Statement The goal is that if we have given a number, we need to generate all possible rotations of its digits. A rotation is defined as moving the first digit to the end of the number. For exampleInput  123 Explanation  123 (original number) 231 (first rotation: move 1 to the ... Read More

JavaScript Program to Generate a matrix having sum of secondary diagonal equal to a perfect square

AmitDiwan
Updated on 15-Mar-2023 15:17:28

235 Views

We will write a JavaScript program that generates a matrix with the sum of the secondary diagonal being a perfect square. Our program will use nested loops to traverse the matrix and calculate the sum of the secondary diagonal elements. We will then use the Math.sqrt() method to find the square root of the sum and check if it is a whole number. If it is, we will consider the sum to be a perfect square. Approach The approach to generate a matrix with the sum of secondary diagonal equal to a perfect square is as follows − Create ... Read More

JavaScript Program to Form coils in a matrix

AmitDiwan
Updated on 15-Mar-2023 15:15:13

225 Views

We will be using JavaScript to form coils in a matrix. The process involves manipulating the elements of the matrix to create a spiral pattern. This can be achieved by changing the direction of traversal, keeping track of the visited elements, and adjusting the indices accordingly. We will be continuously working on the logic to make sure that the program runs smoothly and efficiently to produce the desired output. Approach One approach to form coils in a matrix using JavaScript would be the following − Define the size of the matrix. Initialize the matrix with zeros. Use nested loops ... Read More

JavaScript Program to Find the subarray with least average

AmitDiwan
Updated on 15-Mar-2023 15:13:18

196 Views

We are going to write a program that will find the subarray with the least average. To do this, we will iterate through the array and keep track of the current subarray and its sum. For each element, we will calculate the average of the current subarray and compare it with the minimum average we have seen so far. If it is lower, we will update the minimum average and the start and end indices of the subarray. At the end of the iteration, we will return the subarray with the least average. Approach To find the subarray with the ... Read More

JavaScript Program to Find the Longest Bitonic Subsequence | DP-15

AmitDiwan
Updated on 15-Mar-2023 15:10:30

401 Views

We will be finding the longest bitonic subsequence in each array using dynamic programming. A bitonic subsequence is a sequence which is first increasing, then decreasing. To find the longest bitonic subsequence, we will use a two-step approach. First, we will find the longest increasing subsequence in the given array, then we will find the longest decreasing subsequence in the reverse of the given array. Finally, we will add the lengths of both the subsequences and subtract 1 to exclude the common element in the middle. Approach A bitonic sequence is a sequence that first increases and then decreases. The ... Read More

JavaScript Program to Find Simple Interest

AmitDiwan
Updated on 29-Nov-2024 15:09:38

9K+ Views

To find simple interest in javascript, we will find the product of principal amount, rate of interest(%) and time period. Simple intrest is a quick and easy method to find the intrest charge or extra amount paid by borrower to lender on certain amount of principal within a time period. In this article we are given a data of principal, rate and time, our task is to write a JavaScript program to find simple interest. Users must be familiar with the formula to calculate the simple interest, arithemetic operators in javascript and javascript functions. Formula: Simple ... Read More

Advertisements