Disha Verma has Published 63 Articles

JavaScript: How to check if a number is NaN or finite?

Disha Verma

Disha Verma

Updated on 07-Mar-2025 13:01:54

566 Views

Checking whether a number is NaN (Not a Number) or finite is important while working with numerical computations in JavaScript. NaN (Not a Number) indicates a value that can't be represented as a number, often occurring from invalid operations like dividing zero by zero (0/0). Finite numbers are all real ... Read More

JavaScript getPrototypeOf with Example

Disha Verma

Disha Verma

Updated on 07-Mar-2025 12:57:36

153 Views

In JavaScript, the Object.getPrototypeOf() method is used to get the prototype of a specified object. This method is used to check prototype of user created object and is often used to compare if the two given objects have the same prototype or not. This method is important for JavaScript's prototype-based ... Read More

Call a function with onclick() – JavaScript?

Disha Verma

Disha Verma

Updated on 07-Mar-2025 12:56:12

4K+ Views

The onclick event is a useful feature for calling a function in JavaScript. The onclick event allows you to execute a function when a user interacts with an element, such as clicking a button. This article will guide you on how to use the onclick event to call a JavaScript ... Read More

Extract unique values from an array - JavaScript

Disha Verma

Disha Verma

Updated on 07-Mar-2025 12:54:20

4K+ Views

Extracting unique values from an array means finding and getting only the different elements from a given array, eliminating duplicates. An array is a data structure that stores the same type of data in a linear form. Sometimes it contains duplicate items also. To extract unique values from an array ... Read More

JavaScript: replacing object keys with an array

Disha Verma

Disha Verma

Updated on 07-Mar-2025 12:49:32

2K+ Views

Replacing object keys with an array is a common task every developer does while working with data transformations. An object is a data structure that stores data in the form of key-value pairs, and an array stores values of the same data type in a linear form. Sometimes, developers need ... Read More

JavaScript: Computing the average of an array after mapping each element to a value

Disha Verma

Disha Verma

Updated on 25-Feb-2025 15:03:24

888 Views

Computing the average of an array after mapping each element to a value in JavaScript can be done by using the forEach() loop, the parseInt() method, the reduce() method, and the for..of loop. In this article, we are going to fetch all the values from an array and after mapping ... Read More

JavaScript Array fill() function

Disha Verma

Disha Verma

Updated on 25-Feb-2025 14:58:27

392 Views

The fill() function is a built-in function of JavaScript which is used to fill all the elements of an array with a static value. This function modifies the original array and returns the modified array. The fill() function of JavaScript is a simple and basic function used to fill an ... Read More

JavaScript Trigger a button on ENTER key

Disha Verma

Disha Verma

Updated on 25-Feb-2025 14:58:00

1K+ Views

To trigger a button on the Enter key in JavaScript, you can do it by using JavaScript keyboard events. Keyboard interactions are very essential in web development, and developers must use them effectively for a better user experience. This is especially helpful for forms, search boxes, and places where you ... Read More

JavaScript to push value in empty index in array

Disha Verma

Disha Verma

Updated on 25-Feb-2025 14:57:30

1K+ Views

To push value in an empty index in an array, we must write an array function pushAtEmpty() that takes in an element and pushes it at the first empty index it finds in the array it is used in the context of. If there are no empty spaces, the element ... Read More

JavaScript Sum of two objects with same properties

Disha Verma

Disha Verma

Updated on 25-Feb-2025 14:57:12

2K+ Views

Obtaining the sum of two objects in JavaScript having the same properties Obtaining the sum of two objects in JavaScript having the same properties is a basic implementation with JavaScript objects. To do this, we are required to write a JavaScript function that takes in two such objects. The function ... Read More

Advertisements