Web Development Articles

Page 514 of 801

JavaScript - convert array with null value to string

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 677 Views

In this article, we will learn to convert an array with a null value to a string in Javascript. Handling arrays containing null, undefined, and falsy values in JavaScript is a frequent challenge. The default methods might not behave as expected when converting such arrays to strings, requiring custom solutions for meaningful string representations. Problem Statement Given an array containing null, undefined, empty strings, and other values, the task is to concatenate its elements into a single string while excluding the unwanted values. Following is our array, with some null and undefined values − Input ...

Read More

JavaScript: How to loop through all DOM elements on a page and display result on console?

Alshifa Hasnain
Alshifa Hasnain
Updated on 15-Mar-2026 1K+ Views

In this article, we will learn how to iterate through all DOM elements on a webpage using JavaScript. By doing so, we can easily access and manipulate various elements of the page, whether for debugging, gathering information, or applying changes to the page's structure and content. We'll walk through a step-by-step process to loop through all elements and display the results in the console, helping you better understand how to interact with the DOM. What is the DOM? The Document Object Model (DOM) is a representation of the structure of a webpage. It treats each part of the ...

Read More

JavaScript equivalent of Python\'s zip function

Alshifa Hasnain
Alshifa Hasnain
Updated on 15-Mar-2026 1K+ Views

In this article, we will learn the JavaScript equivalent of Python's zip function. In Python, the zip() function is a convenient way to combine multiple arrays into a single iterable of tuples. However, JavaScript does not have a built-in equivalent for this functionality, so we need to implement our own. Problem Statement Given two or more arrays of equal length, implement a function in JavaScript that combines these arrays into a single array of arrays, where each inner array contains the elements from the input arrays at ...

Read More

JavaScript Narcissistic number

Alshifa Hasnain
Alshifa Hasnain
Updated on 15-Mar-2026 937 Views

In this article, we will learn to check if a number is Narcissistic in JavaScript. A Narcissistic number is a number that equals the sum of its digits, each raised to the power of the total number of digits. We will explore two approaches to solve this problem: an iterative method and a concise string manipulation technique. What is a Narcissistic Number? A narcissistic number (also known as an Armstrong number) in a given number base is a number that equals the sum of its digits each raised to the power of the number of digits. For ...

Read More

How to Find the action Attribute and method of a Form in JavaScript?

Lokesh Yadav
Lokesh Yadav
Updated on 15-Mar-2026 3K+ Views

In HTML forms, the action and method attributes control where form data is sent and how it's transmitted. JavaScript provides properties to access and modify these attributes dynamically. The action attribute specifies the URL where form data should be sent when submitted, while the method attribute determines the HTTP method used for submission (GET, POST, or dialog). Using the action Property The action property allows you to get or set the form's action attribute value. Syntax // Get action attribute let actionValue = document.getElementById('formID').action; // Set action attribute document.getElementById('formID').action = 'newURL'; ...

Read More

How to Hide a div in JavaScript on Button Click?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 7K+ Views

To hide a div in JavaScript on button click we will be discussing three different approaches with example codes. We will hide the div upon clicking the button and similarly display the hidden div upon clicking the button. In this article we are having a div element. Our task is to hide the div on clicking the button using JavaScript. Approaches to Hide div on Button Click Here is a list of approaches to hide a div in JavaScript on button click which we will be discussing in this article with stepwise explanation and complete example codes. ...

Read More

Filter array with filter() and includes() in JavaScript

Revathi Satya Kondra
Revathi Satya Kondra
Updated on 15-Mar-2026 14K+ Views

In this article, using the filter() and includes() methods in JavaScript, we can filter an array based on the elements presence in another array or specific conditions. For example, if we have two arrays as array1 and array2, we want to filter array1 to include only the elements that are present in array2. To have a clear idea about the filter() and includes() methods in JavaScript, let's discuss them individually. JavaScript filter() and includes() Methods filter(): Creates a new array that includes only the elements that satisfy the condition provided by the callback function. includes(): ...

Read More

JavaScript - Converting array of objects into object of arrays

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 1K+ Views

In this article, we will learn to convert an array of objects into an object of arrays in JavaScript. When working with JavaScript, it's common to handle arrays of objects representing structured data. A frequent challenge is grouping these objects based on a shared property and transforming the result into a new data structure. Problem Statement The goal is to convert an array of objects into an object of arrays where the keys represent a specific property (e.g., roles) and the values are arrays of corresponding data (e.g., player names). Input const team = [ ...

Read More

What is the difference between JavaScript undefined and void(0)?

Alshifa Hasnain
Alshifa Hasnain
Updated on 15-Mar-2026 901 Views

In this article, we will learn the difference between JavaScript undefined and void(0). Though they may appear similar, they serve distinct purposes and can be used in different scenarios. What is JavaScript undefined? undefined means a variable declared, but no value has been assigned. It is a primitive value automatically assigned to variables that have been declared but not initialized. For Example − var demo; console.log(demo); // shows undefined console.log(typeof demo); // shows undefined undefined undefined It is a global property that represents a variable ...

Read More

JavaScript code to find nth term of a series - Arithmetic Progression (AP)

Disha Verma
Disha Verma
Updated on 15-Mar-2026 1K+ Views

To find the nth term of an arithmetic progression in JavaScript, we need to write a function that calculates the nth term using the AP formula. In this article, we will explore how to find the nth term of an AP using JavaScript. We are required to write a JavaScript function that takes three parameters: the first two consecutive terms of an arithmetic progression, and the position n of the term we want to find. If the input is 2, 5, 7 (first term = 2, second term = 5, position = 7): Then the series will ...

Read More
Showing 5131–5140 of 8,010 articles
« Prev 1 512 513 514 515 516 801 Next »
Advertisements