Front End Technology Articles

Page 362 of 652

Using client side XSLT transformations in HTML5

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

Client-side XSLT transformations allow you to convert XML data into HTML directly in the browser using JavaScript's XSLTProcessor API. This is useful for displaying XML data in a formatted way without server-side processing. Browser Support The XSLTProcessor API is supported by most modern browsers, including Chrome, Firefox, Safari, and Edge. Android 4.0+ and iOS 2.0+ also support XSLT transformations. Basic Syntax const processor = new XSLTProcessor(); processor.importStylesheet(xslDocument); const result = processor.transformToFragment(xmlDocument, document); Complete Example Here's a working example that transforms XML book data into HTML: ...

Read More

Joining two Arrays in Javascript

Sharon Christine
Sharon Christine
Updated on 15-Mar-2026 331 Views

In JavaScript, there are multiple ways to join two arrays. The method you choose depends on whether you want to create a new array or modify an existing one. Using concat() Method (Creates New Array) The concat() method creates a new array without modifying the original arrays: let arr1 = [1, 2, 3, 4]; let arr2 = [5, 6, 7, 8]; let arr3 = arr1.concat(arr2); console.log("Original arr1:", arr1); console.log("Original arr2:", arr2); console.log("New combined array:", arr3); Original arr1: [1, 2, 3, 4] Original arr2: [5, 6, 7, 8] New combined array: [1, 2, ...

Read More

Peeking elements from a Queue in Javascript

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

Peeking a Queue means getting the value at the head of the Queue without removing it. This allows you to inspect the next element that would be dequeued without modifying the queue structure. Syntax peek() { if (this.isEmpty()) { console.log("Queue Underflow!"); return; } return this.container[0]; } Complete Queue Implementation with Peek class Queue { constructor(maxSize) { ...

Read More

Clearing the elements of the Queue in Javascript

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

We can clear all elements from a queue by reassigning the container to an empty array. This is the most efficient way to remove all queue elements at once. Syntax clear() { this.container = []; } Example Here's a complete example showing how the clear method works with a queue implementation: class Queue { constructor(maxSize = 10) { this.container = []; this.maxSize = maxSize; ...

Read More

Clearing the elements of the PriorityQueue using Javascript

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

In JavaScript, clearing a PriorityQueue can be accomplished by resetting the container array that holds the queue elements. This is a simple but effective approach. Clear Method Implementation The most straightforward way to clear a PriorityQueue is to reassign the container to an empty array: clear() { this.container = []; } Complete Example Here's a working example demonstrating the clear functionality with a basic PriorityQueue implementation: class PriorityQueue { constructor() { this.container = []; ...

Read More

Creating a Set using Javascript

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

In JavaScript, a Set is a collection of unique values. You can create sets using the native ES6 Set class or implement a custom set class. Let's explore both approaches. Creating Sets with ES6 Set Class The simplest way to create a set is using the built-in Set constructor: // Create empty set const set1 = new Set(); // Create set with initial values const set2 = new Set([1, 2, 5, 6]); console.log(set1); console.log(set2); Set(0) {} Set(4) { 1, 2, 5, 6 } Custom Set Implementation You can ...

Read More

Clearing the set using Javascript

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

In JavaScript, the clear() method removes all elements from a Set. For built-in Sets, you can use the native clear() method. For custom Set implementations, you reassign the container to an empty object. Using Built-in Set clear() Method const mySet = new Set(); mySet.add(1); mySet.add(2); mySet.add(5); console.log("Before clear:", mySet); mySet.clear(); console.log("After clear:", mySet); console.log("Size:", mySet.size); Before clear: Set(3) { 1, 2, 5 } After clear: Set(0) {} Size: 0 Custom Set Implementation For a custom Set class, the clear method reassigns the container to a new empty object: ...

Read More

Loop through a Set using Javascript

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

Adding two Sets in Javascript

Samual Sam
Samual Sam
Updated on 15-Mar-2026 3K+ Views

The operation of adding 2 sets is known as a union. You need to add every element from one set to another while checking for duplicates. JavaScript's built-in Set class doesn't include a union method, but we can implement it using several approaches. Method 1: Using Spread Operator (Recommended) The most concise way to combine two sets is using the spread operator: let setA = new Set([1, 2, 3, 4]); let setB = new Set([2, 3, 5, 6]); // Create union using spread operator let unionSet = new Set([...setA, ...setB]); console.log(unionSet); console.log("Size:", unionSet.size); ...

Read More

Subtract two Sets in Javascript

Samual Sam
Samual Sam
Updated on 15-Mar-2026 3K+ Views

Set subtraction (difference) removes all elements from the first set that exist in the second set. JavaScript doesn't provide a built-in difference method, but we can create one using forEach or modern Set methods. Using forEach Method We can create a static method to subtract one Set from another: Set.difference = function(s1, s2) { if (!(s1 instanceof Set) || !(s2 instanceof Set)) { console.log("The given objects are not of type Set"); return null; ...

Read More
Showing 3611–3620 of 6,519 articles
« Prev 1 360 361 362 363 364 652 Next »
Advertisements