
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 6710 Articles for Javascript

376 Views
We are given a sorted array of distinct non-negative integers, here we have to find the smallest missing number. Hence in this tutorial, we will explore different methods to solve this problem and discuss their time complexities with various examples. Understanding the Problem The problem statement is quite simple. Given a sorted array of distinct non-negative integers, we need to find the smallest missing number in it. Let's take an example to understand the problem. Example Let’s say that we have an array [1, 2, 4, 5, 6]. Here, We can see that there is a space between the ... Read More

1K+ Views
To find the lost element from a duplicated array in JavaScript, we will be discussing various approaches.Prerequisite to solve this problem requires an understanding of JavaScript arrays, loops, set object and binary search. In this article we are having two arrays where one array is duplicate of other with a missing element, our task is to find the lost element from a duplicated array in JavaScript. Example Input: array1 = [1, 2, 3, 4, 5, 6] array2 = [1, 2, 3, 5, 6] Output: Missing element: 4 Approaches to Find the Lost Element Here ... Read More

324 Views
To find k pairs with smallest sums in two arrays in Javascript, we will be using sorted arrays in ascending order. We are going to discuss two different approaches with stepwise explanation and examples. In this article we are having two arrays and a value of k, our task is to find k pairs with smallest sums in two arrays. Users must be familiar with JavaScript arrays, loops and conditional statement. Example Input: arr1 = [1, 7, 11], arr2 = [2, 4, 6] k = 3 Output: [[1, 2], [1, 4], [1, 6]] Input: arr1 = [1, 4, ... Read More

780 Views
To write a JavaScript program for equilibrium index of an array, we are going to discuss three different approaches with detailed explanation and example codes. The equilibrium index of an array is the position where the sum of the elements to its left and right equals one another. In this article we are having an array of integers, our task is to to write a JavaScript program for equilibrium index of an array. Example Input: arr = [-7, 1, 5, 2, -4, 3, 0] Output: Equilibrium index: 3 At index 3, left sum = -7 + ... Read More

236 Views
Diagonally dominant matrix refers to square matrix having magnitude of diagonal element in a row greater than or equal to the sum of magnitude of non-diagonal elements in that row. In this article we are having a square matrix, our task is to write JavaScript program for diagonally dominant matrix. Users must be familiar with 2D matrix, nested for loop and conditional statement. Formula: $$\mathrm{|\:a_{ii}\:|\:\geq\:\displaystyle\sum\limits_{j ≠ i}\:|\:a_{ij}|}$$ for all i Where aij denotes the entry in the ith row and jth column Example Input: [A] = ... Read More

1K+ Views
The meaning of image classification is to extract as much information from the image as possible. For example, when you upload an image to Google photos, it extracts information from the image and suggests the location based on that. We can use OpenCV to detect every small information from the image and predict the image. Training and testing models from scratch using JavaScript requires lots of effort, and also, it requires the proper dataset containing the different images. So, in this tutorial, we will use the pre-trained model of ml5.js to classify the image. The ml5.js library contains various pre-trained ... Read More

12K+ Views
In JavaScript, sometimes, we are required to use the variables as an object key. For example, when fetching data from the API and not sure about all the response data attributes, we must iterate through the response object and store every property of it. However, we can’t use the variables as a key while creating the object, but after creating, we can add the variable properties to the object. Syntax Users can follow the syntax below to use a variable for a key in a JavaScript object. object[key] = value; In the above syntax, ‘key’ is a variable containing ... Read More

2K+ Views
Java and JavaScript are two programming languages that are often compared and pitted against each other, thanks to their similar names. However, they are fundamentally different languages, with their own unique strengths and applications. Java is a mature language that has been around for over two decades and is widely used for enterprise-level software development. It is known for its stability, security, and cross-platform compatibility. Java's static type checking system makes it a safer option for larger software projects. On the other hand, JavaScript is a dynamic language that is primarily used for front-end web development. It enables developers to ... Read More

626 Views
In JavaScript, an object contains the properties in the key-value format. We can access any property of an object using the property name by taking the object as a reference. Sometimes, we try to access the object property that doesn’t exist in the object. In such cases, we get the undefined value. Let’s understand it by the example below. Example (Accessing the Object Properties) In the example below, we have created the object and added some properties. Also, we have added some nested properties. After that, we try to access the ‘prop5’ property which is a nested property of the ... Read More

2K+ Views
The code often throws an error, and handling errors is more important. JavaScript also allows users to throw a custom error using the ‘throw’ keyword. We can catch the errors in the catch block. We can use the try-catch syntax to catch errors thrown by normal functions. Let’s understand it by the example below. Example 1 (Throw Errors in Regular Function) In the example below, we have created the throwError() regular function, which uses the throw keyword to throw an error with the custom error message. We have executed the function inside the try block. If the function throws any ... Read More