Articles on Trending Technologies

Technical articles with clear explanations and examples

Detect area of a PNG that is not transparent with HTML

Lakshmi Srinivas
Lakshmi Srinivas
Updated on 15-Mar-2026 593 Views

To detect the non-transparent area of a PNG image in HTML, you need to use the Canvas API to access pixel data and scan for opaque pixels. This technique is useful for cropping images, collision detection, or optimizing sprite sheets. How It Works The process involves loading the image onto a canvas, getting the pixel data as a buffer, and scanning for non-transparent pixels to find the bounding box: Load the PNG image onto a canvas element Get the 32-bit RGBA pixel data using getImageData() Scan from ...

Read More

Change the style of top border with CSS

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 195 Views

The border-top-style property in CSS defines the line style of an element's top border. It accepts various values like solid, dashed, dotted, double, and more. Syntax border-top-style: value; Common Values Value Description solid Single solid line dashed Dashed line dotted Dotted line double Two solid lines groove 3D grooved effect ridge 3D ridged effect none No border Example Here's how to apply different top border styles: ...

Read More

What is the importance of _isEqual() method in JavaScript?

vineeth.mariserla
vineeth.mariserla
Updated on 15-Mar-2026 1K+ Views

The _.isEqual() method from Underscore.js and Lodash libraries provides deep equality comparison for JavaScript objects. Unlike native JavaScript comparison operators, it performs value-based comparison rather than reference-based comparison. Why _.isEqual() is Important JavaScript's native equality operators (== and ===) only check if two objects are the same reference in memory, not if they have the same content. The _.isEqual() method solves this by performing deep comparison of object properties, regardless of property order. Syntax _.isEqual(object1, object2); It accepts two values as parameters and returns true if they are equivalent, false otherwise. Example: ...

Read More

How to add form validation for empty input fields with JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 2K+ Views

Form validation ensures users provide required information before submitting. JavaScript allows client-side validation to check for empty input fields and provide immediate feedback. Basic Empty Field Validation Here's a complete example that validates empty input fields: Form Validation Example JavaScript Empty Input Field Validation Name: ...

Read More

Check if three consecutive elements in an array is identical in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 905 Views

We are required to write a JavaScript function, say checkThree() that takes in an array and returns true if anywhere in the array there exists three consecutive elements that are identical (i.e., have the same value) otherwise it returns false. Therefore, let's write the code for this function − Example const arr = ["g", "z", "z", "v" ,"b", "b", "b"]; const checkThree = arr => { const prev = { element: null, count: 0 ...

Read More

Separate odd and even in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 830 Views

In JavaScript, separating odd and even numbers means rearranging an array so that all even numbers appear before all odd numbers. This is commonly achieved using custom sorting functions or array methods like filter(). Using Custom Sort Function The most efficient approach uses Array.sort() with a custom comparator that prioritizes even numbers: const arr = [2, 6, 3, 7, 8, 3, 5, 4, 3, 6, 87, 23, 2, 23, 67, 4]; const isEven = num => num % 2 === 0; const sorter = (a, b) => { if(isEven(a) && !isEven(b)){ ...

Read More

Create increment decrement plus minus buttons programmatically for HTML input type number in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 16K+ Views

In JavaScript, you can create increment and decrement buttons for HTML input type number using the stepUp() and stepDown() methods. This approach provides better user experience by allowing precise control over numeric inputs. On clicking Increment (+), the number in the input field increases by the step value On clicking Decrement (-), the number in the input field decreases by the step value The buttons respect the min/max constraints of the input field Basic Implementation Here's how to create increment/decrement buttons programmatically: ...

Read More

Partially reversing an array - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 526 Views

Suppose, we have an array of literals like this: const arr = [3, 5, 5, 2, 23, 4, 7, 8, 8, 9]; console.log("Original array:", arr); Original array: [3, 5, 5, 2, 23, 4, 7, 8, 8, 9] We are required to write a JavaScript function that takes in such an array and a number, say n (n must be less than or equal to the length of array). And the function should reverse the first n elements of the array within. For example, if for this array, the number is 4, then ...

Read More

How to Delete Bookmarks in your Browser (Firefox, Chrome)

Rahul Sharma
Rahul Sharma
Updated on 15-Mar-2026 345 Views

Bookmarks in web browsers allow you to save and quickly access your favorite websites. You can create a bookmark by visiting a page and pressing Ctrl+D, or by clicking the star icon in the address bar. However, over time you may want to delete bookmarks that are no longer needed. This tutorial will show you how to delete bookmarks in both Firefox and Chrome browsers using different methods. Method 1: Delete from Address Bar The quickest way to delete a bookmark is directly from the address bar when visiting the bookmarked page: In Firefox ...

Read More

How to convert Number to Boolean in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 2K+ Views

This tutorial will teach us to convert a number to a Boolean in JavaScript. The variable of Boolean data type can contain only two values, true and false. When we convert the variables of any other data type to Boolean, it returns true for all non-falsy values and false for all falsy values. Let's understand the falsy values. JavaScript contains 6+ falsy values, and some of them are as below. Null 0 NaN False Undefined ' ' (empty string) ...

Read More
Showing 17081–17090 of 61,297 articles
Advertisements