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
Splitting an array based on its first value - JavaScript
Suppose we have an array of arrays of numbers like this: const arr = [[1, 45], [1, 34], [1, 49], [2, 34], [4, 78], [2, 67], [4, 65]]; console.log(arr); [ [ 1, 45 ], [ 1, 34 ], [ 1, 49 ], [ 2, 34 ], [ 4, 78 ], [ 2, 67 ], [ 4, 65 ] ] Each subarray contains exactly two elements. We need to write a function that constructs a new array where all second elements of subarrays with the same first value are grouped together. For the ...
Read MoreHow to change the font color of a text using JavaScript?
This tutorial teaches us to change the font color of text using JavaScript. While working with JavaScript and developing the frontend of an application, you may need to change the font color of text when an event occurs. For example, if you have an application that can turn a device on or off with a button, you might want the button text to be green when the device is on and red when it's off. JavaScript provides several methods to accomplish this dynamic color changing. Using the style Property The most common approach is to access an ...
Read MoreHow to set the style of the line in a text decoration with JavaScript?
In this tutorial, we shall learn to set the style of the line in a text decoration with JavaScript. To set the style of the line in JavaScript, use the textDecorationStyle property. You can set underline, double, or overline, etc. for the line style. Using the Style textDecorationStyle Property We can set or return the line style in a text decoration with this property. The major browsers support this property. Firefox adds support with an alternate property named MozTextDecorationStyle. Syntax object.style.textDecorationStyle = "solid" | "double" | "dotted" | "dashed" | "wavy" | "initial" | "inherit"; ...
Read MoreHow to secretly copy to clipboard JavaScript function in Chrome and Firefox?
In JavaScript, you can programmatically copy text to the clipboard without user interaction using different methods. This tutorial shows how to implement "secret" clipboard copying that works silently in the background. We'll explore both the legacy execCommand() method and the modern Clipboard API for copying text to clipboard programmatically. Using execCommand() Method (Legacy) The execCommand() method was traditionally used for clipboard operations. Here's a basic implementation: Copy text ...
Read MoreHTML5 validity of nested tables
The HTML5 validator considers nested tables valid when properly structured. Here's how to create valid nested table markup in HTML5. Valid Nested Table Structure A nested table must be placed inside a or element of the parent table. The validator considers the following structure valid: Nested Table Example ...
Read MoreUsage of color property in CSS
The color property in CSS is used to set the color of text content. It accepts various color formats including color names, hexadecimal values, RGB, and HSL values. Syntax color: value; Color Value Formats The color property accepts several formats: Color names: red, blue, green, etc. Hexadecimal: #ff0000, #00ff00, #0000ff RGB: rgb(255, 0, 0) RGBA: rgba(255, 0, 0, 0.5) with transparency HSL: hsl(0, 100%, 50%) Example: Using Color Names ...
Read MoreRemoving an element from an Array in Javascript
Removing an element from an array in Javascript can be achieved using various approaches. Removal of an element can be done from the beginning, end or from any specific position. We will be understanding various approaches for removing elements from an array in Javascript based on our needs. In this article, we are working with an array of numbers and our task is to remove elements from an array in Javascript using different methods. ...
Read MoreArrayBuffer.byteLength Property in JavaScript
ArrayBuffer object in JavaScript represents a fixed-length binary data buffer. The byteLength property of the ArrayBuffer returns an unsigned, 32-bit integer that specifies the size/length of the ArrayBuffer in bytes. Syntax arrayBuffer.byteLength Return Value Returns a number representing the length of the ArrayBuffer in bytes. This value is established when the ArrayBuffer is constructed and cannot be changed. Example: Basic Usage JavaScript ArrayBuffer Example var arrayBuffer = new ArrayBuffer(8); ...
Read MoreFlat a JavaScript array of objects into an object
To flatten a JavaScript array of objects into a single object, we can create a function that iterates through each object in the array and combines their properties. This technique is useful when you need to merge multiple objects while preserving unique property names by appending indices. Basic Approach The most straightforward method is to loop through the array and create new property names by appending the array index to each original property name. // Example array of objects const notes = [{ title: 'Hello world', id: 1 ...
Read MoreJavaScript fetch a specific value with eval()?
The eval() function in JavaScript allows the execution of code stored as a string. It can be used to fetch specific values dynamically, but be careful, as it can have security risks and affect performance. This article will guide you on how to use eval() to get specific values and why you should generally avoid using eval(). How eval() Works The eval() function takes a string as an argument and evaluates it as JavaScript code. For example: console.log(eval("2 + 2")); // Output: 4 console.log(eval("'Hello' + ' World'")); // Output: Hello World 4 Hello World ...
Read More