karthikeya Boyini

karthikeya Boyini

1,421 Articles Published

Articles by karthikeya Boyini

Page 38 of 143

Is their a cross-origin attribute in HTML5?

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

Yes, HTML5 includes the crossorigin attribute. According to the official specification, it's defined as: The crossorigin attribute is a CORS settings attribute. Its purpose is to allow images from third-party sites that allow cross-origin access to be used with canvas. Syntax Supported Values The crossorigin attribute accepts two values: Value Description Credentials Sent? anonymous Performs CORS request without credentials No use-credentials Performs CORS request with credentials Yes Example: Canvas Image Access ...

Read More

Remove elements from a Set using Javascript

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

JavaScript Sets provide methods to remove elements efficiently. The primary method is delete(), which removes a specified value from the Set. Using the delete() Method The delete() method removes a value from the Set and returns true if the value existed, or false if it didn't. Syntax set.delete(value) Example: Removing Individual Elements const mySet = new Set([1, 2, 3, 4, 5]); console.log("Original Set:", mySet); // Remove elements console.log("Delete 3:", mySet.delete(3)); // true - existed console.log("Delete 10:", mySet.delete(10)); // false - didn't exist console.log("Updated Set:", mySet); console.log("Set size:", ...

Read More

Loop through a Set using Javascript

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 703 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

How to set the bottom margin of an element with JavaScript?

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

The marginBottom property in JavaScript allows you to dynamically set the bottom margin of an element. This property is part of the element's style object and accepts values in pixels, percentages, or other CSS units. Syntax element.style.marginBottom = "value"; Where value can be in pixels (px), percentages (%), em units, or other valid CSS margin values. Example: Setting Bottom Margin Here's how to set the bottom margin of an element when a button is clicked: ...

Read More

Creating a hash table using Javascript

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

A hash table (also called hash map) is a data structure that stores key-value pairs and provides fast lookup, insertion, and deletion operations. In JavaScript, we can implement a hash table using arrays and a hash function to map keys to array indices. Basic Hash Table Structure Let's create a hash table class with collision resolution using chaining. We'll use an array of arrays where each index can hold multiple key-value pairs in case of hash collisions. class HashTable { constructor() { this.container = ...

Read More

Add elements to a hash table using Javascript

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 1K+ Views

When adding elements to a hash table, the most crucial part is collision resolution. We're going to use chaining for the same. There are other algorithms you can read about here: https://en.wikipedia.org/wiki/Hash_table#Collision_resolution Now let's look at the implementation. We'll be creating a hash function that'll work on integers only to keep this simple. But a more complex algorithm can be used to hash every object. Hash Table Implementation First, let's create a complete hash table class with the necessary components: class HashTable { constructor(size = 11) { ...

Read More

Remove elements from Javascript Hash Table

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 1K+ Views

To remove elements from a JavaScript hash table, we need to locate the element using its key and remove it from the underlying storage structure. In hash tables that use chaining for collision resolution, this involves searching through the chain at the computed hash index. Let us look at the implementation of the remove method: Remove Method Implementation remove(key) { let hashCode = this.hash(key); for (let i = 0; i < this.container[hashCode].length; i++) { // Find the element in ...

Read More

Joining two hash tables in Javascript

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

Sometimes we need to combine hash tables together using a join function to create a new merged hash table. We'll write a static join method that takes 2 HashTables and creates a new HashTable with all the values. For simplicity, values from the second hash table will override values from the first one if there are duplicate keys. Syntax static join(table1, table2) { // Implementation logic return newHashTable; } Implementation Here's the complete implementation of the join method: class HashTable { ...

Read More

Tree Data Structure in Javascript

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

The tree data structure represents hierarchical relationships like organization charts, file systems, and DOM elements. A tree consists of nodes connected in a parent-child relationship, where each node has a value and references to its children, with no duplicate references. Tree Terminology Understanding key tree terms is essential: Root: The top node with no parent Parent: A node that has children Child: A node connected to a parent above it Leaf: A node with no children Height: Maximum depth from root to any leaf Depth: Number of edges from root to a specific node ...

Read More

Binary Search Tree in Javascript

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

A Binary Search Tree (BST) is a specialized data structure where each node follows a specific ordering rule. A node's left child must have a value less than its parent's value, and the node's right child must have a value greater than its parent's value. 8 3 10 1 6 14 ...

Read More
Showing 371–380 of 1,421 articles
« Prev 1 36 37 38 39 40 143 Next »
Advertisements