Articles on Trending Technologies

Technical articles with clear explanations and examples

How can we invoke the parent's method, when a child has a method with the same name in JavaScript?

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

When both parent and child classes have methods with the same name, JavaScript provides several ways to invoke the parent's method from the child class or externally. Syntax To call a parent method when overridden by a child class: // From within child class super.methodName() // From outside using call() ParentClassName.prototype.methodName.call(childObject) Using super Keyword (Recommended) The super keyword is the modern way to call parent methods from within a child class: class Parent { constructor(value) { this.value = ...

Read More

Building a Map from 2 arrays of values and keys in JavaScript

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

In JavaScript, you can create a Map from two separate arrays containing keys and values. This is useful when you have parallel arrays where each index corresponds to a key-value pair. Problem Setup Suppose we have two arrays: const keys = [0, 4, 2, 3, 1]; const values = ["first", "second", "third", "fourth", "fifth"]; We need to create a Map where each key from the first array maps to the corresponding value from the second array at the same index. Using a for Loop The most straightforward approach is to iterate through ...

Read More

What is the difference between custom and built-in functions in JavaScript?

Anvi Jain
Anvi Jain
Updated on 15-Mar-2026 920 Views

JavaScript functions are divided into two main categories: custom (user-defined) functions and built-in functions. Understanding the difference helps you leverage JavaScript's capabilities effectively. Custom Functions (User-Defined) Custom functions are created by developers to perform specific tasks. You define the logic, parameters, and return values according to your needs. Syntax function functionName(parameter1, parameter2) { // Your custom logic here return result; } Example: Custom Function Custom Function Example ...

Read More

How to change the value of an attribute in javascript?

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

In JavaScript, changing attribute values dynamically allows you to create interactive web pages. Whether you need to modify styles, swap images, or update element properties, JavaScript provides several methods to manipulate HTML attributes. To change an attribute value, you first need to access the HTML element using methods like getElementById(), then modify the attribute directly or use methods like setAttribute(). Syntax Here are the main approaches to change attribute values: // Direct property access element.attribute = new_value; // Using setAttribute method element.setAttribute("attribute", "value"); Parameters attribute − The name of the ...

Read More

How to listen to Keydown-Events in a KineticJS-managed HTML5-Canvas?

Rishi Rathor
Rishi Rathor
Updated on 15-Mar-2026 269 Views

To listen to keydown events in a KineticJS-managed HTML5 canvas, you need to make the canvas focusable and attach event listeners. KineticJS canvases don't receive keyboard events by default since they're not focusable elements. Making the Canvas Focusable First, get the canvas element and make it focusable by setting the tabindex attribute: // Create KineticJS stage and layer ...

Read More

What is the usage of and elements? Why they were introduced?

Nitya Raut
Nitya Raut
Updated on 15-Mar-2026 366 Views

The HTML5 and elements are semantic tags that provide meaningful structure to web content. They improve accessibility for screen readers and help visually impaired users navigate content more effectively. These elements are also beneficial for eBook readers and search engines. The Element The element represents a thematic grouping of content, typically with its own heading. It's used to divide content into distinct sections within a document. Syntax Section Title Section content goes here... Example ...

Read More

Loop through a Set using Javascript

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

In JavaScript, you can loop through a Set using several methods. The most common approaches are using the forEach() method, for...of loop, or converting to an array. Using forEach() Method The forEach() method executes a provided function for each value in the Set: const mySet = new Set([1, 2, 5, 8]); mySet.forEach(value => { console.log(`Element is ${value}`); }); Element is 1 Element is 2 Element is 5 Element is 8 Using for...of Loop The for...of loop provides a cleaner syntax for iterating over Set values: ...

Read More

JavaScript – Getting Coordinates of mouse

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 658 Views

In JavaScript, you can get the coordinates of the mouse cursor using mouse event properties. The most common approach is to use the mousemove event listener along with event properties like clientX, clientY, pageX, and pageY. Mouse Coordinate Properties Different properties provide coordinates relative to different reference points: clientX, clientY - Coordinates relative to the viewport (visible browser window) pageX, pageY - Coordinates relative to the entire document (includes scrolled areas) screenX, screenY - Coordinates relative to the user's screen offsetX, offsetY - Coordinates ...

Read More

Object de-structuring in JavaScript.

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 214 Views

Object destructuring is a JavaScript feature that allows you to extract multiple properties from an object and assign them to variables in a single statement. It provides a clean and concise way to work with object properties. Syntax const { property1, property2, property3 } = object; Basic Example Object Destructuring Object Destructuring Example ...

Read More

Sorting JavaScript object by length of array properties.

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 596 Views

In JavaScript, you can sort objects by the length of their array properties using the sort() method with a custom comparison function. This is useful when organizing data based on array sizes. Syntax array.sort((a, b) => a.property.length - b.property.length); Example: Sorting Students by Number of Subjects Sort by Array Length body { ...

Read More
Showing 17901–17910 of 61,299 articles
Advertisements