Articles on Trending Technologies

Technical articles with clear explanations and examples

How to set the style of the bottom border with JavaScript?

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

To set the style of the bottom border, use the JavaScript borderBottomStyle property. It allows you to add a bottom border with different styles like solid, dashed, dotted, and more. Syntax element.style.borderBottomStyle = "value"; Common Border Style Values Value Description solid Creates a solid line dashed Creates a dashed line dotted Creates a dotted line double Creates a double line none Removes the border Example The following example demonstrates how to set different bottom border styles on button ...

Read More

HTML5 tag not working in Android Webview

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

When HTML5 audio/video tags don't work in Android WebView, you can bridge JavaScript with native Android MediaPlayer functionality. This approach allows HTML content to trigger native audio playback through JavaScript interfaces. Setting Up JavaScript Interface First, create a WebView with a JavaScript interface that exposes Android's MediaPlayer to your HTML content: WebView wv = (WebView) findViewById(R.id.webview); wv.getSettings().setJavaScriptEnabled(true); wv.addJavascriptInterface(new WebAppInterface(this), "Android"); public class WebAppInterface { Context mContext; MediaPlayer mediaPlayer; WebAppInterface(Context c) { ...

Read More

How to hide e-mail address from an unauthorized user in JavaScript?

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

Hiding email addresses from unauthorized users helps protect privacy and reduce spam. JavaScript provides several methods to obfuscate email addresses while keeping them readable for legitimate users. Method 1: Partial Masking with Asterisks This approach replaces part of the username with asterisks, keeping the domain visible: function hideEmail(email) { var parts = email.split("@"); var username = parts[0]; var domain = parts[1]; if (username.length 2 ? ...

Read More

How to get the length of an object in JavaScript?

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

In JavaScript, objects don't have a built-in length property like arrays and strings. When you try to access object.length, it returns undefined. To get the number of properties in an object, you need to use specific methods. Why Objects Don't Have a Length Property The length property only works for arrays and strings, not plain objects: var object = {prop1: 1, prop2: 2}; document.write("Object length: " + object.length); Object length: undefined Arrays and Strings Have Length For comparison, ...

Read More

What is the importance of str.padStart() method in JavaScript?

vineeth.mariserla
vineeth.mariserla
Updated on 15-Mar-2026 245 Views

The padStart() method in JavaScript pads a string at the beginning to reach a specified length. It's particularly useful for formatting numbers, creating aligned text, and adding prefixes with consistent string lengths. Syntax string.padStart(targetLength, padString) Parameters targetLength: The desired length of the resulting string after padding. padString (optional): The string to use for padding. Defaults to a space character if not provided. Return Value Returns a new string padded at the beginning. The original string remains unchanged. Basic Example ...

Read More

Memory Management in JavaScript

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 2K+ Views

Memory management is an essential task when writing effective programs. In JavaScript, unlike low-level languages like C and C++, memory allocation and deallocation are handled automatically. However, understanding memory management concepts helps developers write more efficient code and avoid memory leaks. Memory management in any programming language involves three important phases, termed as memory life-cycle: Allocating the memory which is required in our program. Utilize the allocated memory unit. After completion, clear the memory block. Memory Allocation Strategies in JavaScript Value Initialization In JavaScript, ...

Read More

Reverse index value sum of array in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 283 Views

Suppose we have an array of numbers like this: const arr = [3, 6, 7, 3, 1, 4, 4, 3, 6, 7]; This array contains 10 elements, so the index of the last element is 9. We need to write a function that calculates the sum of each element multiplied by its reverse index position. The reverse index means we multiply each element by (array.length - currentIndex - 1). For our example: // Element at index 0: 3 * (10-0-1) = 3 * 9 = 27 // Element at index 1: 6 * ...

Read More

How to detect the screen resolution with JavaScript?

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

To detect the screen resolution in JavaScript, you can use the window.screen object, which provides properties to access display dimensions and available screen space. Screen Properties Overview The window.screen object offers several useful properties: screen.width and screen.height - Total screen dimensions screen.availWidth and screen.availHeight - Available screen space (excluding taskbars) Basic Screen Resolution Detection Screen Resolution Detection ...

Read More

Flattening an array with truthy/ falsy values without using library functions - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 195 Views

We need to write a JavaScript function that takes a nested array containing falsy values and returns a completely flattened array. This means converting a multi-dimensional array into a single-dimensional array while preserving all elements, including falsy values like false, null, and 0. For example, if the input is: const arr = [[1, 2, 3], [4, 5, [5, false, 6, [5, 8, null]]], [6]]; The output should be: [1, 2, 3, 4, 5, 5, false, 6, 5, 8, null, 6] Method 1: Using Recursive Function with Array.prototype Extension We can ...

Read More

Find a form feed character with JavaScript RegExp.

Sravani Alamanda
Sravani Alamanda
Updated on 15-Mar-2026 1K+ Views

Form feed character is a page breaking ASCII control character commonly used for page separators. When you want to insert a page break, text editors can use this form feed. It is defined as \f and has an ASCII code value of 12 or 0x0c. RegExp is an object that specifies the pattern used to perform search and replace operations on strings or for input validation. RegExp was introduced in ES1 and is fully supported by all browsers. Now, we will check how to find the form feed (\f) character in given text using RegExp. Syntax ...

Read More
Showing 18851–18860 of 61,297 articles
Advertisements