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 sort a set in JavaScript?
A Set is a JavaScript data structure that stores unique values in insertion order. Unlike arrays, Sets cannot be sorted directly because they don't have a sort() method. To sort a Set, we must convert it to an array, sort the array, and create a new Set from the sorted results. In this article, we'll learn different approaches to sort Sets in JavaScript using array conversion and the sort() method. Why Sets Cannot Be Sorted Directly Sets maintain insertion order and focus on uniqueness rather than sorting. They lack array methods like sort(), so we need an ...
Read MoreHow to sort an array of object by two fields in JavaScript?
An array of objects is an array that contains all the elements in the form of JavaScript objects. Here, we are said to use an array of objects with two fields that means, have to use objects with two elements as elements of the array. In this article, we are going to learn about the method of sorting the array of objects by two fields in JavaScript. We can simply use the sort() method of JavaScript to sort the elements of an array and give it a cmp or the comparator function to define the order in which we ...
Read MoreHow to select all links inside the paragraph using jQuery?
jQuery is a popular JavaScript library that simplifies HTML DOM traversal, event handling, and AJAX interactions for rapid web development. It offers a wide range of built-in functions and methods that help developers to manipulate HTML elements, styles, and behaviors dynamically. In this article, we will see how to select all links inside a paragraph using jQuery. Selecting links inside a paragraph is a common requirement when we want to modify the links in a particular section of our website, such as changing styles, adding event handlers, or extracting link information. How to Select All Links Inside a ...
Read MoreHow to sort an array on multiple columns using JavaScript?
An array with multiple columns is an array that contains multiple elements at each index position. In other words, it's an array of arrays where each sub-array represents a row with multiple column values that need to be sorted based on specific criteria. In this article, we'll learn how to sort arrays with multiple columns using JavaScript's sort() method combined with custom comparator functions. We'll explore different sorting strategies for various data types. Basic Syntax The fundamental approach uses a custom comparator function with the sort() method: array.sort((a, b) => { ...
Read MoreDifference between JavaScript and C#
JavaScript and C# are two popular programming languages that serve different purposes in software development. JavaScript is primarily used for web development, creating dynamic and interactive websites that run in browsers. C# is Microsoft's object-oriented programming language used for desktop applications, web backends, mobile apps, and games. JavaScript is a client-side language that executes in web browsers, making it essential for frontend development. It's beginner-friendly with a low learning curve and can run directly without compilation. C# is a compiled, statically-typed language that requires more programming knowledge but offers better performance and structure for complex applications. What is ...
Read MoreHow to switch between multiple CSS stylesheets using JavaScript?
In this tutorial, we will learn to switch between multiple CSS stylesheets using JavaScript. Have you ever thought that when you toggle the theme of TutorialsPoint's website, how it changes the CSS of the whole website? Here is a simple answer. When the user presses the button, it switches the CSS stylesheets for the website like it removes the stylesheet for the white theme and adds the stylesheet for the dark theme. Here, we will see examples of switching between multiple CSS files using JavaScript. Syntax Users can follow the syntax below to switch between multiple ...
Read MoreHow to Create an Image Element Dynamically using JavaScript?
To create an image element dynamically using JavaScript, we can use various approaches based on our use case. We will explore three effective methods in this article with complete examples and step-by-step explanations. Approaches to Create an Image Element Here are the three main approaches to create an image element dynamically using JavaScript: Using createElement() Method Using Image() Constructor Using innerHTML Property Using createElement() Method The createElement() method is the most standard way to create DOM elements dynamically. This approach creates ...
Read MoreJavaScript Program to Check if a string can be obtained by rotating another string d places
Rotating a string means moving characters to the left or right by a specified number of positions. We'll check if one string can be obtained by rotating another string exactly d places in either direction. Problem Understanding Given two strings and a rotation count d, we need to determine if the first string can be transformed into the second string by rotating it d positions left or right. Example String 1: "abcdef", String 2: "defabc", Rotations: 3 Left rotation by 3: "abcdef" → "bcdefa" → "cdefab" → "defabc" ✓ Approach 1: Left Rotation ...
Read MoreHow to create and download CSV file in JavaScript?
JavaScript provides powerful capabilities to manipulate data and handle various file formats. When developing web applications, you often need to export data as CSV files for users to download - such as order details from e-commerce platforms or transaction records from banking applications. In this tutorial, we will learn to create CSV files from JavaScript data and automatically download them to the user's device. Syntax The basic approach involves converting data to CSV format and using a virtual anchor element for download: // Convert data to CSV format let csvData = 'Header1, Header2, Header3'; data.forEach(function ...
Read MoreHow to show some custom menu on text selection?
In text editors like Microsoft Word, selecting text reveals a custom menu with formatting options like bold, italic, color changes, and alignment controls. This tutorial demonstrates how to create a similar custom context menu that appears when users select text on a webpage. How It Works The technique involves capturing mouse coordinates during selection and positioning a custom menu at the selection point. We use the getSelection() API to detect when text is selected and getBoundingClientRect() to calculate the menu position. Implementation Steps Step 1 − Create HTML structure with content div and hidden custom ...
Read More