Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles on Trending Technologies
Technical articles with clear explanations and examples
How to check for two timestamps for the same day in JavaScript?
The Date object is essential in JavaScript applications for creating and manipulating dates according to developer requirements. A common requirement is checking whether two timestamps represent the same day, which is useful for features like daily task tracking or date-based user activity validation. In this tutorial, we will learn three different approaches to check whether two timestamps are for the same day. This is particularly useful when you need to compare a user's last activity date with the current date. Using getFullYear(), getMonth(), and getDate() Methods The most straightforward approach is to compare the year, month, and ...
Read MoreJavaScript Program to Check if all rows of a matrix are circular rotations of each other
A matrix in JavaScript is a 2-dimensional array where each row contains a fixed number of elements. In this tutorial, we'll learn how to check if all rows of a matrix are circular rotations of each other, meaning we can transform any row into another through left or right rotations. Circular rotation means shifting elements: rotating [1, 2, 3] right gives [3, 1, 2], and rotating left gives [2, 3, 1]. Problem Understanding Given a matrix, we need to determine if every row can be converted to the first row through circular rotations. Example 1 ...
Read MoreHow to Bundle up JavaScript Files using Rollup.js?
In this tutorial, we will understand how to use Rollup.js to bundle JavaScript files. Before we do that, the first step is to get familiar with the JavaScript module bundler called Rollup, which compiles files from multiple sources into a single bundle. Rollup is similar to webpack and Browserify. It is more popular than many other bundlers because of its ability to keep files small even after bundling them into a single unit. There are multiple features that Rollup brings to the table, some of them are mentioned below − Development is easier to manage when you ...
Read MoreJavaScript program for Shortest Un-Ordered SubarrayJavaScript program for Shortest Un-Ordered Subarray
The problem statement requires finding the shortest un-ordered subarray in an array of integers. In other words, we need to identify the smallest subarray in which the elements are not sorted in ascending or descending order. This problem can be solved through various approaches, but in this article, we will discuss a simple and efficient solution using JavaScript. So first we will start by defining what an un-ordered Subarray is, then understand the problem statement in detail and then proceed to explain the step-by-step solution using examples and code snippets. By the end of this article, you will have ...
Read MoreHow to Scrape a Website using Puppeteer.js?
Web scraping is one of the best ways to automate the process of data collection from the web. A web scraper, often called a "crawler, " surfs the web and extracts data from selected pages. This automation is much easier than manually extracting data from different web pages and provides a solution when websites don't offer APIs for data access. In this tutorial, we will create a web scraper in Node.js using Puppeteer.js to extract book information from a sample website. What is Puppeteer.js? Puppeteer is a Node.js library that provides a high-level API to control Chrome ...
Read MoreHow to Filter Object by Keys in Lodash?
Sometimes while working with objects in JavaScript we want to filter objects based on keys. We can easily do this by using Lodash, a popular JavaScript library that provides several inbuilt functions to achieve this easily. In this article, we are going to discuss how we can Filter Objects by Keys using Lodash. Prerequisite Lodash: Lodash is a popular JavaScript library used to deal with a variety of functions such as arrays, objects, strings, and more. Install Lodash We can install the Lodash library in the project by adding it via CDN ...
Read MoreWorking with Excel Files using Excel.js
Excel.js is a powerful Node.js library for reading, manipulating, and writing Excel files. It supports both XLSX and CSV formats, making it ideal for data processing applications. Installation To install Excel.js in your Node.js project, run the following command: npm install exceljs Once installed, you can start working with Excel files programmatically. All examples in this tutorial work with XLSX (Open XML Spreadsheet) files. Working with Excel Cells The getCell() method allows you to access individual cells by reference or coordinates. Here's how to read cell values: const Excel = ...
Read MoreHow to check whether or not a browser tab is currently active using JavaScript?
Users can open multiple tabs in the browser, and they can also check if any particular tab is currently active or not in the browser. For example, if you have given a proctored test, you can observe that it detects that tab is changed whenever you change the tab in the browser. So, there can be many applications and uses for checking whether the browser tab is active. This tutorial will teach us two methods to check whether the browser's tab is active. Using the onblur() and onfocus() methods of the window object The window object contains ...
Read MoreHow to check if a number evaluates to Infinity using JavaScript?
In JavaScript, when we divide any number by zero, we get the infinity value. Also, developers can make a mistake in writing mathematical expressions which evaluate to Infinity. Before performing any operation with the returned value from mathematical expressions, we need to check if the number value is finite. Here, we will learn three approaches to check if a number evaluates to Infinity using JavaScript. Comparing with Number.POSITIVE_INFINITY and Number.NEGATIVE_INFINITY In JavaScript, the Number object contains POSITIVE_INFINITY and NEGATIVE_INFINITY properties that represent positive and negative infinity values. We can compare our numerical value with these properties to ...
Read MoreHow to store data to DOM?
Storing data in the DOM means keeping data associated with HTML elements or in JavaScript variables that can be accessed later. This is useful for maintaining application state, form data, or temporary values without making server requests. In vanilla JavaScript, we can store data in objects or use element properties. jQuery provides the data() method for attaching data to specific DOM elements. Let's explore both approaches. Using JavaScript Objects to Store Data The most common approach is creating JavaScript objects to hold data. This keeps information organized and easily accessible. Syntax let dataObj = ...
Read More