Articles on Trending Technologies

Technical articles with clear explanations and examples

HTML form action and onsubmit validations with JavaScript?

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

HTML form validation is essential for ensuring data integrity before submission. The onsubmit event allows you to validate form data and prevent submission if validation fails. How Form Validation Works The onsubmit event handler must return true to allow submission or false to prevent it. When validation fails, the form submission is blocked. Basic Validation Example Form Validation Example Enter "gmail" to proceed: ...

Read More

Find Second most frequent character in array - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 659 Views

We are required to write a JavaScript function that takes in an array and returns the element that appears for the second most number of times. Let's say the following is our array: const arr = [1, 34, 4, 3, 2, 1, 4, 6, 4, 6, 5, 3, 6, 6]; The most frequent element is 6 (appears 4 times), but we want the second most frequent element, which is 4 (appears 3 times). Example const arr = [1, 34, 4, 3, 2, 1, 4, 6, 4, 6, 5, 3, 6, 6]; ...

Read More

What is onmouseleave event in JavaScript?

Sreemaha
Sreemaha
Updated on 15-Mar-2026 347 Views

The onmouseleave event triggers when the mouse pointer moves out of an element. It fires only when the mouse completely leaves the element boundary. Syntax element.onmouseleave = function() { // Code to execute when mouse leaves }; // Or using addEventListener element.addEventListener('mouseleave', function() { // Code to execute }); Example: Basic Mouse Leave Event Here's how to implement the onmouseleave event: function sayHello() { ...

Read More

How to set font size using CSS Measurement Unit vmin?

mkotla
mkotla
Updated on 15-Mar-2026 256 Views

The vmin CSS unit sets font size based on the smaller dimension of the viewport (width or height). It's useful for creating responsive text that scales with screen size. What is vmin? The vmin unit represents 1% of the viewport's smaller dimension. If the viewport is 800px wide and 600px tall, 1vmin = 6px (1% of 600px). Syntax font-size: [number]vmin; Example vmin Font Size Example ...

Read More

SharedArrayBuffer.byteLength Property in JavaScript

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

The byteLength property of the SharedArrayBuffer returns an unsigned, 32-bit integer that specifies the size/length of a SharedArrayBuffer in bytes. Syntax sharedArrayBuffer.byteLength Parameters This property takes no parameters and is read-only. Return Value Returns the length of the SharedArrayBuffer in bytes as a 32-bit unsigned integer. Example JavaScript Example var sharedArrayBuffer = new SharedArrayBuffer(8); ...

Read More

Difference between push() and unshift() methods in javascript

Ayush Gupta
Ayush Gupta
Updated on 15-Mar-2026 565 Views

JavaScript arrays provide two methods for adding elements: push() adds elements at the end, while unshift() adds elements at the beginning. Both methods modify the original array and return the new array length. push() Method The push() method adds one or more elements to the end of an array and returns the new length of the array. let fruits = ['apple', 'mango', 'orange']; console.log("Original array:", fruits); let newLength = fruits.push('kiwi'); console.log("After push():", fruits); console.log("New length:", newLength); Original array: [ 'apple', 'mango', 'orange' ] After push(): [ 'apple', 'mango', 'orange', 'kiwi' ] New ...

Read More

Explain Enumerated Types in JavaScript.

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 204 Views

JavaScript doesn't support enums natively like other programming languages. However, you can implement enumerated types using objects to create named constants for better code readability and maintainability. Basic Enum Implementation The simplest way to create an enum is using a plain object with numeric values: JavaScript Enums Enumerated Types in JavaScript Show Color Values ...

Read More

Form Object from string in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 310 Views

We are required to write a function that takes in a string as the first and the only argument and constructs an object with its keys based on the unique characters of the string and value of each key being defaulted to 0. For example − // if the input string is: const str = 'hello world!'; // then the output should be: const obj = {"h": 0, "e": 0, "l": 0, "o": 0, " ": 0, "w": 0, "r": 0, "d": 0, "!": 0}; So, let's write the code for this function − ...

Read More

Divide a string into n equal parts - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 697 Views

We are required to write a JavaScript function that takes in a string and a number n (such that n exactly divides the length of string). We need to return an array of string of length n containing n equal parts of the string. Let's write the code for this function − Example const str = 'this is a sample string'; const num = 5; const divideEqual = (str, num) => { const len = str.length / num; const creds = str.split("").reduce((acc, val) => { ...

Read More

What is pica? How to set the font size in CSS using pica?

Samual Sam
Samual Sam
Updated on 15-Mar-2026 926 Views

A pica is a CSS unit of measurement primarily used in print design. One pica equals 12 points, and there are 6 picas per inch (1pc = 12pt = 1/6 inch). The pica unit is specified using "pc" in CSS. Understanding Pica Units Picas are absolute units like pixels, but they're based on traditional typography measurements: 1 pica = 12 points 6 picas = 1 inch 1pc ≈ 16 pixels (at 96 DPI) Syntax font-size: value pc; /* Examples */ font-size: 1pc; /* 12 points */ font-size: 2.5pc; ...

Read More
Showing 18601–18610 of 61,297 articles
Advertisements