Articles on Trending Technologies

Technical articles with clear explanations and examples

parseFloat() function in JavaScript

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

The parseFloat() function parses a string and returns a floating-point number. It reads the string from left to right until it encounters a character that cannot be part of a number. Syntax parseFloat(string) Parameters The function takes only one parameter: string - The string to be parsed into a floating-point number Return Value Returns a floating-point number parsed from the string. If the first character cannot be converted to a number, it returns NaN. Example: Basic Usage JavaScript parseFloat Example ...

Read More

Difference between regular functions and arrow functions in JavaScript

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

According to MDN, an arrow function expression is a syntactically compact alternative to a regular function expression, although without its own bindings to the this, arguments, super, or new.target keywords. Arrow function expressions are ill suited as methods, and they cannot be used as constructors. There are three key differences between regular functions and arrow functions in JavaScript that affect how they behave in your code. No Own this Bindings Arrow functions do not have their own this value. The value of this inside an arrow function is always inherited from the enclosing scope, while regular functions ...

Read More

How to disable mouse event on certain elements using JavaScript?

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

In JavaScript, you can disable mouse events on specific elements using the CSS pointer-events property. This technique prevents elements from receiving mouse clicks, hover effects, and other pointer interactions. Using pointer-events CSS Property The most effective method is setting pointer-events: none via JavaScript. This disables all mouse interactions on the target element. Disable Mouse Events body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .result { font-size: 18px; ...

Read More

Find Max Slice Of Array | JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 279 Views

In JavaScript, finding the maximum slice of an array with at most two different numbers is a common problem that can be efficiently solved using the sliding window technique. This approach maintains a dynamic window that expands and contracts to find the longest contiguous subarray containing no more than two distinct elements. How It Works The sliding window algorithm uses two pointers (start and end) to define a window boundary. We track distinct elements using a map and adjust the window size when the distinct count exceeds two. Example const arr = [1, 1, 1, ...

Read More

How to get key name when the value contains empty in an object with JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 891 Views

To find keys with empty values in a JavaScript object, you can use Object.keys() combined with find() or filter(). This is useful for form validation or data cleaning. Let's say we have the following object: var details = { firstName: 'John', lastName: '', countryName: 'US' }; Using Object.keys() with find() To find the first key with an empty value, use Object.keys() along with find(): var details = { firstName: 'John', lastName: '', countryName: 'US' ...

Read More

Getting tomorrow and day after tomorrow date in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 869 Views

Using the Date class in JavaScript, we can easily calculate tomorrow and the day after tomorrow from the current date. The new Date() constructor returns a JavaScript Date object for the current day. Getting Today's Date First, let's get today's date using the Date constructor: const today = new Date(); console.log("Today:", today.toDateString()); Today: Thu Aug 13 2020 Method 1: Using setDate() with Date Copying We can create new Date objects by copying today's date and then adding days using the setDate() method: // Getting today's date const today ...

Read More

Which property is used in CSS to control the repetition of an image in the background?

Samual Sam
Samual Sam
Updated on 15-Mar-2026 2K+ Views

To control the repetition of an image in the background, use the background-repeat property. You can use no-repeat value for the background-repeat property if you do not want to repeat an image, in this case, the image will display only once. Syntax background-repeat: repeat | repeat-x | repeat-y | no-repeat | space | round; Common Values Value Description repeat Repeats both horizontally and vertically (default) repeat-x Repeats horizontally only repeat-y Repeats vertically only no-repeat Displays image only once Example: Basic Background ...

Read More

Why is javascript called Richer Interface?

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

JavaScript is called a "Richer Interface" because it enables developers to create highly interactive and feature-rich web applications that go far beyond simple static content. Unlike basic HTML and CSS, JavaScript provides access to powerful APIs that can interact with multimedia, device hardware, and user data. Key Features that Make JavaScript Rich Graphics and Animation JavaScript can draw and manipulate graphics through Canvas API and WebGL, allowing developers to create games, data visualizations, and interactive animations directly in the browser. const canvas = document.getElementById('myCanvas'); const ctx = canvas.getContext('2d'); // Draw a colorful rectangle ...

Read More

Replace a letter with its alphabet position JavaScript

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

We are required to write a function that takes in a string, trims it off any whitespaces, converts it to lowercase and returns an array of numbers describing corresponding characters positions in the english alphabets, any whitespace or special character within the string should be ignored. Problem Example Input → 'Hello world!' Output → [8, 5, 12, 12, 15, 23, 15, 18, 12, 4] How It Works The algorithm processes each character by: Converting to lowercase to handle both cases uniformly Getting ASCII code using charCodeAt() ...

Read More

How can I show image rollover with a mouse event in JavaScript?

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

This tutorial will teach us to show image rollover with a mouse event in JavaScript. The meaning of the image rollover is to either change the image style or the whole image when the user rollovers the mouse on the image. To build an attractive user interface, developers often add image rollover features to the website and applications. Here, we will see to apply image rollover differently. Change the Style of the Image on Mouse Rollover In this method, to create the image rollover, we will use the onmouseover and onmouseout event of JavaScript. When users take ...

Read More
Showing 18631–18640 of 61,297 articles
Advertisements