JavaScript - Page 3
How to Detect Scroll Direction on a Page Using JavaScript
Last updated: 02.04.2026
Views: 264
Sometimes it is necessary to detect the direction of vertical scrolling on a website in order to dynamically change the behavior of interface elements. For example, this can be useful when working with a header or footer — hiding them while scrolling down to save screen space, and showing them again when the user scrolls up.
Scroll direction detection can also improve user experience in other s...
How to Сlone (Copy) Object and Array in JavaScript
Last updated: 21.02.2026
Views: 226
Cloning objects and arrays is not as simple a topic as it may seem at first glance. Cloning objects and arrays in JavaScript can be done using various methods depending on the complexity (shallow vs. deep cloning).
Cloning an Array
1. Using the Spread Operator (...):
[js]
const originalArray = [1, 2, 3];
const clonedArray = [...originalArray];
console.log(clonedArray); // Output: [1, 2, 3]...
Countdown Timer in JavaScript
Last updated: 02.04.2026
Views: 309
Countdown timers are commonly used on websites that promote products, services, or special offers. You can often see them on landing pages or in online stores, where they are used to highlight limited-time deals and create a sense of urgency. By showing how much time is left until a specific event or deadline, such timers can help increase user engagement and encourage faster decision-making.
I...
Swipe Events on Touch Devices in JavaScript
Last updated: 21.02.2026
Views: 151
Every day sensory devices are being introduced into our lives. These devices have specific events, unlike the desktop. One of these events is the swipe. Especially often have to deal with it when developing a mobile version of the site.
Swipe events on touch devices allow developers to detect gestures like swiping left, right, up, or down, commonly used for navigation or interaction. These even...
How to Get Max Value in JavaScript Array
Last updated: 21.02.2026
Views: 182
A short note about finding the maximum value in a JavaScript array with numeric values. The Array object in JS does not have its own max method.
To find the maximum value in a JavaScript array, you can use several methods. Here are the most common and efficient approaches:
1. Using Math.max() with the spread operator
The Math.max() function returns the largest number from a set of numbers...