Object Oriented Programming Articles

Page 189 of 589

JavaScript Regex to remove text after a comma and the following word?

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

When working with strings in JavaScript, you might encounter scenarios where you need to clean or format text by removing specific portions. A common task is to remove text after a comma and the following word. This can be achieved efficiently using JavaScript Regular Expressions (Regex). In this article, we'll show you how to do it step-by-step. Why Use Regex for Text Manipulation? Regex, short for Regular Expressions, is a powerful tool for pattern matching and text processing. It allows you to identify and manipulate text patterns with precision, making tasks like cleaning data or reformatting strings much ...

Read More

JavaScript merge multiple Boolean arrays with the OR || operator

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 686 Views

There are times when you need to merge multiple Boolean arrays into a single array in JavaScript. One common approach is to combine the corresponding elements from each array using the OR (||) operator. This operation returns true if at least one of the elements being compared is true; otherwise, it returns false. In this article, we'll learn how to merge multiple Boolean arrays into a single array using JavaScript, specifically by applying the OR operator on corresponding elements. Problem Definition We are given an array of arrays of Boolean values, like this: Input: const ...

Read More

JavaScript Submit textbox on pressing ENTER?

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

In this article, we will learn to Submit a textbox by pressing ENTER in JavaScript. Submitting a textbox form by pressing the ENTER key is a common requirement in web development, enhancing the user experience by making interactions smoother and more intuitive. Why Enable Form Submission on ENTER Key Press? Allowing users to submit a form by pressing the ENTER key is an efficient way to enhance usability and reduce friction in the user interface. Whether you're building a search bar, login form, or any other type of text input, implementing this feature saves time and makes interactions ...

Read More

JavaScript map value to keys (reverse object mapping)

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

In JavaScript, there are scenarios where we need to reverse the mapping of keys and values in an object, creating a new object where the original values become keys, and the keys become their corresponding values. For example, cities can be grouped by their states. In this article, we'll learn two approaches to achieve this: using Object.keys with iteration and reduce. Using Object.keys() with forEach The first approach involves iterating over the keys of the original object using Object.keys() of Object properties and populating a new object. If multiple keys in the original object share the same value, ...

Read More

JavaScript - convert array with null value to string

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 640 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 930 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 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
Showing 1881–1890 of 5,881 articles
« Prev 1 187 188 189 190 191 589 Next »
Advertisements