Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by karthikeya Boyini
Page 37 of 143
DOMException Failed to load because no supported source was found
The "DOMException Failed to load because no supported source was found" error occurs when media elements (video, audio) cannot load their source files. This is commonly caused by CORS restrictions, incorrect file paths, or unsupported formats. Common Causes This error typically happens due to: Cross-Origin Resource Sharing (CORS) restrictions Incorrect file paths or missing media files Unsupported media formats Server configuration issues Method 1: Setting crossOrigin for CORS When loading media from different domains, set the crossOrigin attribute to handle CORS restrictions: const ...
Read MoreBlending two images with HTML5 canvas
To blend two images using HTML5 canvas, you need to manipulate pixel data from both images and combine them in equal proportions (50-50). This technique uses the canvas getImageData() and putImageData() methods. HTML Structure First, set up the HTML elements with the images and canvas: Blended image: window.onload = function () { var myImg1 = document.getElementById('myImg1'); var myImg2 = document.getElementById('myImg2'); var myCanvas = document.getElementById("canvas"); var ctx = myCanvas.getContext("2d"); // ...
Read MoreThe Doubly Linked List class in Javascript
A doubly linked list is a data structure where each node contains references to both the next and previous nodes, allowing bidirectional traversal. Here's a complete implementation of a DoublyLinkedList class in JavaScript. Complete Implementation class DoublyLinkedList { constructor() { this.head = null; this.tail = null; this.length = 0; } insert(data, position = this.length) { let node = new this.Node(data); ...
Read MoreHow to draw large font on HTML5 Canvas?
To draw large font text on HTML5 Canvas, you need to set the font size using the font property and use fillText() or strokeText() methods to render the text. Basic Syntax context.font = "size family"; context.fillText(text, x, y); context.strokeText(text, x, y); Example: Drawing Large Text Large Font Canvas var myCanvas = document.getElementById("myCanvas"); var ...
Read MoreJSON. stringify( ) function in JavaScript
The JSON.stringify() method converts a JavaScript object or value to a JSON string. This is the reverse of JSON.parse() which converts JSON strings back to JavaScript objects. Syntax JSON.stringify(value, replacer, space) Parameters value: The JavaScript value to convert to JSON string (required) replacer: Function or array to transform values (optional) space: Number of spaces or string for indentation (optional) Basic Example JSON.stringify Example var obj = {Tutorial: "JavaScript", Version: "ES6", ...
Read MoreSet Data Structure in Javascript
A Set is a built-in data structure in JavaScript that stores unique values of any type. Unlike arrays, Sets automatically prevent duplicate values and don't maintain insertion order for iteration purposes, making them ideal for storing collections of unique items. Creating a Set You can create a Set using the Set constructor: // Empty Set let emptySet = new Set(); console.log(emptySet); // Set with initial values let numbers = new Set([1, 2, 3, 4, 5]); console.log(numbers); // Set automatically removes duplicates let duplicates = new Set([1, 2, 2, 3, 3, 4]); console.log(duplicates); ...
Read MoreCreating a Set using Javascript
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 MoreHow to set the boldness of the font with JavaScript?
Use the fontWeight property in JavaScript to set the font boldness. This CSS property accepts values like "normal", "bold", "bolder", "lighter", or numeric values from 100 to 900. Syntax element.style.fontWeight = value; Parameters The fontWeight property accepts the following values: Value Description "normal" Default weight (equivalent to 400) "bold" Bold weight (equivalent to 700) "bolder" Bolder than parent element "lighter" Lighter than parent element 100-900 Numeric values (100 = thinnest, 900 = boldest) Example: Setting Font Weight with ...
Read MoreIs their a cross-origin attribute in HTML5?
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 MoreRemove elements from a Set using Javascript
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