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 on Trending Technologies
Technical articles with clear explanations and examples
Why HTML5 Web Workers are useful?
JavaScript was designed to run in a single-threaded environment, meaning multiple scripts cannot run at the same time. Consider a situation where you need to handle UI events, query and process large amounts of API data, and manipulate the DOM. JavaScript will hang your browser in situations where CPU utilization is high. Let us take a simple example where JavaScript goes through a big loop: Big for loop function bigLoop(){ for (var i = 0; i
Read MoreSet image for bullet style with CSS
The list-style-image CSS property allows you to replace default bullet points with custom images, giving you complete control over list styling. Syntax list-style-image: url('path/to/image.png'); list-style-image: none; /* Default */ Basic Example Here's how to set a custom bullet image for an unordered list: .custom-bullets { list-style-image: url('/images/arrow-bullet.png'); } ...
Read MoreRemove elements from a PriorityQueue using Javascript
Dequeuing elements from a PriorityQueue means removing the element with the highest priority. Since we store elements with the highest priority at the end of the array, we can simply pop it to dequeue it. Priority Queue Structure World Priority: 2 Hello Priority: 3 Foo Priority: 8 Highest Priority ...
Read MoreHow can I trigger an onchange event manually in javascript?
In JavaScript, you can manually trigger an onchange event using the dispatchEvent() method with a custom Event object. This is useful for programmatically simulating user interactions. Basic Setup First, let's create an input element with a change event listener: document.querySelector('#test').addEventListener('change', () => { console.log("Changed!"); }); Method 1: Using Event Constructor Create a new Event object and dispatch it on the target element: Trigger Change document.querySelector('#example1').addEventListener('change', () => { console.log("Change event fired!"); }); function triggerChange1() { ...
Read MoreExplain the finally Statement in JavaScript with examples.
The finally statement in JavaScript always executes after try and catch blocks, regardless of whether an error occurred or not. This makes it ideal for cleanup operations and code that must run in all scenarios. Syntax try { // Code that may throw an error } catch (error) { // Handle error (optional) } finally { // Always executes } Example: Finally Block Always Executes ...
Read MoreImplementation of Stack in JavaScript
A stack is a Last In First Out (LIFO) data structure where elements are added and removed from the same end, called the top. This article demonstrates how to implement a stack in JavaScript using a class-based approach with basic operations like push, pop, and display. What is a Stack? A stack follows the LIFO principle - the last element added is the first one to be removed. Think of it like a stack of plates where you can only add or remove plates from the top. Item 3 ...
Read MoreHow to check existence of NaN keyword in an array JavaScript
We have an array of elements that contains both truthy and falsy values. Our job is to write a function that returns an array with indices of those elements which are NaN in the original array. NaN !== NaN The datatype of NaN is actually number. Although NaN is a falsy value, it has a peculiar property that no other datatype or variable has. It's that the expression NaN === NaN yields false. And it's only in the case of NaN that this is false. So, we can use this behavior to our advantage and pick out ...
Read MoreDetecting HTML click-to-call support in JavaScript
The tel: protocol enables click-to-call functionality on mobile devices. Most modern browsers support it, but older devices may require different protocols or detection methods. Basic tel: Protocol Support Modern mobile browsers support the tel: protocol natively: Click to Call Example Call +1 (234) 567-890 // Check if tel: links are supported function isTelSupported() { ...
Read MoreLog error to console with Web Workers in HTML5
Web Workers in HTML5 provide a way to run JavaScript in the background without blocking the main thread. When working with Web Workers, proper error handling is crucial for debugging and maintaining application stability. Error Handling with worker.onerror The worker.onerror event handler catches errors that occur within the Web Worker and allows you to log them to the console for debugging purposes. Example Here's a complete example showing how to implement error handling in Web Workers: Web Worker Error ...
Read MoreSpecify all the list properties into a single expression with CSS
The list-style property is a CSS shorthand that allows you to specify all list-related properties in a single expression. It combines list-style-type, list-style-position, and list-style-image into one convenient declaration. Syntax list-style: [list-style-type] [list-style-position] [list-style-image]; The values can be specified in any order, and any omitted values will use their default. Properties Combined Property Description Default Value list-style-type Bullet or numbering style disc (ul), decimal (ol) list-style-position Position of marker outside list-style-image Custom image for bullets none Example: Basic List Styling ...
Read More