Articles on Trending Technologies

Technical articles with clear explanations and examples

Basic Operations supported by a list in Javascript

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

JavaScript arrays (lists) support several fundamental operations that allow you to manipulate and access data efficiently. Here are the core operations you can perform on arrays. Basic List Operations Insertion − Add elements at the beginning, middle, or end of the list Deletion − Remove elements from any position in the list Display − Show the complete list contents Search − Find elements using specific values or conditions Access − Retrieve elements by their index position Insertion Operations You ...

Read More

How to terminate javascript forEach()?

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

You can't break from the forEach method and it doesn't provide a way to escape the loop (other than throwing an exception). However, there are several alternative approaches to achieve early termination when iterating over arrays. The Problem with forEach The forEach() method is designed to iterate through all array elements. Unlike traditional loops, it doesn't support break or continue statements: // This will NOT work - break is not allowed in forEach [1, 2, 3, 4].forEach((element) => { console.log(element); if (element === 2) { ...

Read More

How to check if an object is an instance of a Class in JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 476 Views

In JavaScript, you can check if an object is an instance of a specific class using the instanceof operator. This operator returns true if the object was created by the specified constructor function or class. Syntax object instanceof Constructor Using instanceof with Constructor Functions Instance Check Example CHECK INSTANCE function Student(name, age, standard) { this.name = name; this.age = age; this.standard = standard; } let student1 = new Student("Rohan", ...

Read More

JavaScript code for recursive Fibonacci series

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 433 Views

We have to write a recursive function fibonacci() that takes in a number n and returns an array with first n elements of fibonacci series. The Fibonacci sequence starts with 0 and 1, where each subsequent number is the sum of the two preceding ones. Understanding the Fibonacci Sequence The Fibonacci sequence follows this pattern: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34... where F(n) = F(n-1) + F(n-2). Recursive Implementation Here's a recursive approach that builds the Fibonacci array: const fibonacci = (n, res = [], count = 1, last = ...

Read More

Display in console if Select list value contains a value from an array in JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 722 Views

In JavaScript, you can check if a selected dropdown value exists in an array using event listeners and array methods. This is useful for validation or conditional logic based on user selections. HTML Structure Let's start with a basic dropdown containing several names: John David Chris Mike Bob Carol Array to Check Against We'll define an array of names to compare with the selected value: ...

Read More

How to return a random number between 0 and 199 with JavaScript?

Rama Giri
Rama Giri
Updated on 15-Mar-2026 473 Views

To return a random number between 0 and 199, use the JavaScript Math.random() and Math.floor() methods together. How It Works Math.random() generates a random decimal between 0 (inclusive) and 1 (exclusive). To get integers from 0 to 199: Multiply by 200 to get range 0 to 199.999... Use Math.floor() to round down to nearest integer Example // Generate random number between 0-199 let randomNum = Math.floor(Math.random() * ...

Read More

How to set the brightness and contrast of an image with JavaScript?

Sharon Christine
Sharon Christine
Updated on 15-Mar-2026 4K+ Views

JavaScript provides the CSS filter property to adjust image brightness and contrast dynamically. You access these filters through the style.filter property on image elements. Syntax element.style.filter = "brightness(value) contrast(value)"; Parameters Filter Default Value Range Effect brightness() 100% 0% to 200%+ 0% = black, 100% = normal, 200% = very bright contrast() 100% 0% to 200%+ 0% = gray, 100% = normal, 200% = high contrast Example: Interactive Brightness and Contrast Click below to change the brightness ...

Read More

Touchmove pointer-events: none CSS does not work on Chrome for Android 4.4 / ChromeView

Lakshmi Srinivas
Lakshmi Srinivas
Updated on 15-Mar-2026 309 Views

The pointer-events: none CSS property doesn't work properly on Chrome for Android 4.4 (ChromeView) for touchmove events. This causes issues when trying to disable touch interactions on overlay elements. The Problem On Chrome for Android 4.4, elements with pointer-events: none still receive touchmove events, breaking the expected behavior where these elements should be non-interactive. Solution: Using touchstart with preventDefault() Instead of relying on CSS pointer-events: none, use JavaScript to handle and prevent touch events: Overlay Content const overlay = document.getElementById('overlay'); // Prevent all touch interactions overlay.addEventListener('touchstart', function(ev) ...

Read More

Creating a linked list using Javascript

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

A linked list is a dynamic data structure where elements (nodes) are stored in sequence, with each node containing data and a reference to the next node. Let's build a complete linked list implementation in JavaScript. Basic Structure We'll start by defining a LinkedList class and a Node structure: class LinkedList { constructor() { this.head = null; this.length = 0; } } LinkedList.prototype.Node = class { constructor(data) ...

Read More

How to create an object property from a variable value in JavaScript?

Ayush Gupta
Ayush Gupta
Updated on 15-Mar-2026 9K+ Views

JavaScript has two notations for creating object properties: dot notation and bracket notation. To create an object property from a variable value, you need to use bracket notation or ES6 computed property names. Method 1: Using Bracket Notation (Dynamic Assignment) You can assign properties to existing objects using bracket notation with variable names: const obj = {a: 'foo'}; const prop = 'bar'; // Set the property using the variable name prop obj[prop] = 'baz'; console.log(obj); { a: 'foo', bar: 'baz' } Method 2: Using ES6 Computed Property Names ES6 ...

Read More
Showing 17691–17700 of 61,297 articles
Advertisements