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
HTML form action and onsubmit validations with JavaScript?
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 MoreFind Second most frequent character in array - JavaScript
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 MoreWhat is onmouseleave event in JavaScript?
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 MoreHow to set font size using CSS Measurement Unit vmin?
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 MoreSharedArrayBuffer.byteLength Property in JavaScript
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 MoreDifference between push() and unshift() methods in javascript
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 MoreExplain Enumerated Types in JavaScript.
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 MoreForm Object from string in JavaScript
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 MoreDivide a string into n equal parts - JavaScript
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 MoreWhat is pica? How to set the font size in CSS using pica?
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