Articles on Trending Technologies

Technical articles with clear explanations and examples

Tutorix - AI Tutor

Reduce an array to the sum of every nth element - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 365 Views

We are required to write a JavaScript function that takes in an array of numbers and returns the cumulative sum of every number present at the index that is a multiple of n from the array. Let's write the code for this function − Example const arr = [1, 4, 5, 3, 5, 6, 12, 5, 65, 3, 2, 65, 9]; const num = 2; const nthSum = (arr, num) => { let sum = 0; for(let i = 0; i < arr.length; i++){ ...

Read More

How to create a table caption with JavaScript DOM?

Jai Janardhan
Jai Janardhan
Updated on 15-Mar-2026 715 Views

To create a table caption using JavaScript DOM, use the createCaption() method on a table element. This method adds a element to the table, which displays as a title above the table content. Syntax table.createCaption() Return Value Returns the newly created element, which can be styled or modified with text content. Example Here's how to create a table caption dynamically using JavaScript: function captionFunc(x) { ...

Read More

parseFloat() function in JavaScript

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 285 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 935 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 319 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 917 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 938 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 318 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
Showing 18631–18640 of 61,298 articles
Advertisements