Filter Out Non-Unique Values from an Array in JavaScript

Disha Verma
Updated on 25-Feb-2025 14:51:10

1K+ Views

To filter out non-unique values from an array in JavaScript, you can use the filter() method, a for loop, the set and filter() method, and the reduce() method. In this article, we will filter out non-unique values and return an array that only contains unique non-repeating elements. Arrays are data structures used to store data in a structured format. We can store the data in an array and retrieve them using their indexes. These indexes serve as a key for these values. Table of Content Filtering non-unique values from an array can be done in the following ways: ... Read More

Find Nth Term of Arithmetic Progression (AP) in JavaScript

Disha Verma
Updated on 25-Feb-2025 14:50:36

1K+ Views

To find the nth term of an arithmetic progression in JavaScript, we need to write a function that will calculate the nth term. 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 in three numbers as arguments (the first two numbers are supposed to be the starting two consecutive terms of an arithmetic progression). And the third number, say n, is the 1 index-based element of the series whose value we must calculate. If the input is 2, 5, 7 Then ... Read More

Check If Value Is a Percentage in JavaScript

Disha Verma
Updated on 25-Feb-2025 14:50:05

1K+ Views

To check the value for percentage, use a regular expression. When dealing with user input or processing data in JavaScript, it's important to make sure a value is a valid percentage. This article shows you how to check if a value is a percentage using JavaScript, highlighting a useful method that involves regular expressions. Let's say the following is our value var value="97%"; To check the value for percentage, we are using a regular expression. Using Regular Expression The best way to check if a string is in the correct percentage format is by using regular expressions. ... Read More

Call Function of a Module from String in Python

SaiKrishna Tavva
Updated on 25-Feb-2025 11:23:09

1K+ Views

In Python, you can dynamically call a function from a module by using its name as a string. This is useful in scenarios where function names are not known until runtime. Below are several methods to achieve this. Using getattr() Function Using globals() Function Using locals() Function Using importlib Module Using 'getattr()' Function The getattr() function is a built-in Python function that allows you to retrieve an attribute from an object using a string representing the attribute's name. This is particularly useful ... Read More

Limitations of JavaScript

Alshifa Hasnain
Updated on 24-Feb-2025 18:28:00

5K+ Views

JavaScript is a lightweight, interpreted programming language. It is designed for creating network-centric applications. It is complementary to and integrated with Java. It is very easy to implement because it is integrated with HTML. It is open and cross-platform. Limitations We cannot treat JavaScript as a full-fledged programming language. It lacks the following important features: Client-side JavaScript does not allow the reading or writing of files. It has been kept for security reasons. JavaScript could not used for networking applications because there is no such support available. ... Read More

Basic Array Methods in JavaScript

Alshifa Hasnain
Updated on 24-Feb-2025 18:27:46

763 Views

In this article, we will learn about different basic array methods in JavaScript. Adding and Removing Elements Some basic JavaScript array methods for adding and removing elements − Method Description ... Read More

Divide a Number into Smaller Random Integers in Java

Alshifa Hasnain
Updated on 24-Feb-2025 18:27:35

622 Views

In this article, we will learn to divide a number into smaller random ints in Java. Dividing a number into smaller random integers is a useful technique in various applications such as resource allocation, gaming, and randomization processes Divide a Number into Random Parts The approach relies on generating unique random dividers within the given number and then computing the differences between consecutive dividers to form the final parts.  Following are the steps to divide a number into smaller random ints in Java Create a HashSet to ... Read More

Java DatabaseMetaData getProcedures Method with Example

Alshifa Hasnain
Updated on 24-Feb-2025 18:27:23

699 Views

In this article, we will learn the DatabaseMetaData getProcedures() method in Java. In Java, the DatabaseMetaData.getProcedures() method is used to retrieve information about stored procedures available in a database. What is getProcedures()? The getProcedures() method of the DatabaseMetaData interface returns a ResultSet containing metadata about stored procedures available in a database. This allows developers to query the database for procedure names, catalog information, procedure types, and specific names. Syntax ResultSet procedures = metaData.getProcedures(null, null, "myprocedure"); This method retrieves the description of the stored procedures of a database/catalog. It accepts 3 parameters − catalog: The catalog name ... Read More

Java DatabaseMetaData getTypeInfo Method with Example

Alshifa Hasnain
Updated on 24-Feb-2025 18:27:12

621 Views

In this article, we will learn the DatabaseMetaData getTypeInfo() method in Java. The DatabaseMetaData.getTypeInfo() method in Java retrieves information about the supported data types in a database. What is getTypeInfo()? The getTypeInfo() method of the DatabaseMetaData interface returns a ResultSet containing information about all the data types supported by the database. Each row in this result set describes a single data type, including details such as its name, precision, case sensitivity, and whether it supports auto-increment. Syntax ResultSet info = metaData.getTypeInfo(); This method returns a ResultSet object describing the data types supported. This object holds values for the following details ... Read More

Delete Multiple Files in a Directory in Python

SaiKrishna Tavva
Updated on 24-Feb-2025 13:23:06

3K+ Views

Python provides robust modules for file and directory manipulation, namely the OS and shutil modules. The 'OS' module provides functions for interacting with the operating system. It allows you to perform operations such as creating, removing, and manipulating files and directories, as well as retrieving information about them. On the other hand, the shutil module offers a higher-level interface for file operations, making tasks like copying, moving, and deleting entire directories straightforward. Below are several methods to delete files and folders. Deleting Multiple Files To delete multiple files, we have to loop over a list of filenames and apply the os.remove() function ... Read More

Advertisements