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
Search Element in an Javascript Hash Table
JavaScript hash tables use a get method to search for elements by their key. The method calculates the hash code and searches through the chain at that index to find the matching key-value pair. The get() Method Implementation The search operation involves computing the hash code for the given key and then iterating through the chain at that bucket to find the exact match: get(key) { let hashCode = hash(key); for(let i = 0; i < this.container[hashCode].length; i ++) { ...
Read MoreExplain touch events in JavaScript
Touch events in JavaScript are fired when a user interacts with a touchscreen device. These events provide a way to handle touch-based interactions on mobile devices, tablets, and other touch-enabled screens. Touch Event Types JavaScript provides four main touch events for handling different stages of touch interaction: Event Description ...
Read MoreThe image() object in JavaScript.
The Image object in JavaScript represents an HTML element and allows you to create, manipulate, and load images dynamically without adding them directly to the HTML. Creating Image Objects You can create an Image object using the new Image() constructor, optionally specifying width and height: // Basic image creation let img = new Image(); // With dimensions let imgWithSize = new Image(300, 200); Properties The Image object has several important properties: src - Sets or gets the image URL width - Sets or ...
Read MoreJavaScript outsider function call and return the result
In JavaScript, you can call functions from outside their defining scope by using the return keyword to return inner functions. This creates closures that maintain access to outer variables. Syntax function outerFunction() { // Outer variables var outerVar = value; // Inner function var innerFunction = function() { // Can access outerVar return result; } ...
Read MoreFinding special type of numbers - JavaScript
In the decimal number system, all the real numbers can be divided into two groups: Rational Numbers Irrational Numbers For the scope of this problem we will only discuss the rational numbers. All those numbers which can be written in the p/q form (where q ≠ 0) are called rational numbers, like 14, 4.6, 3.33333... and many more. The rational numbers can further be divided into two groups: Terminating decimal numbers Repeating decimal numbers This categorization is made on the basis ...
Read MoreHow to get the smallest integer greater than or equal to a number in JavaScript?
In this tutorial, we will learn how to get the smallest integer greater than or equal to a number in JavaScript. To get the smallest integer greater than or equal to a number, use the JavaScript Math.ceil() method. This method returns the smallest integer greater than or equal to a given number by rounding up to the nearest integer. The Math.ceil() method is a static function of the Math object and must be invoked as Math.ceil(). It always rounds numbers upward, making it perfect for finding the ceiling value of any number. Syntax Math.ceil(value) ...
Read MoreHow to set the maximum width of an element with JavaScript?
The maxWidth property in JavaScript allows you to set the maximum width of an element dynamically. This property controls how wide an element can grow, which is particularly useful for responsive layouts and content that needs width constraints. Syntax element.style.maxWidth = "value"; The value can be specified in pixels (px), percentages (%), em, rem, or other valid CSS units. Example: Setting Maximum Width #box { ...
Read MoreHTML5 File API readAsBinaryString reads files as much larger and different than files on disk
When using HTML5 File API's readAsBinaryString() method, the resulting binary string can appear much larger than the original file due to character encoding issues and inefficient string representation of binary data. The Problem with readAsBinaryString The readAsBinaryString() method converts binary data to a string format, which can cause size inflation and encoding problems. This is especially problematic when manually creating multipart/form-data requests. Recommended Solution: Use FormData with File Objects Instead of reading files as binary strings, use FormData with the original File objects. This preserves the file's binary integrity and size. ...
Read MoreRemove elements from Javascript Hash Table
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 MoreHow to remove existing HTML elements in JavaScript?
This article discusses how to delete existing HTML elements in JavaScript. To remove HTML elements, you first need to select the element from the document, then use methods like remove() and removeChild() to delete them from the DOM. Using the remove() Method The remove() method directly removes an element from the DOM. It's the simplest approach for modern browsers. Syntax element.remove(); Example Remove Element Example This heading will be removed This paragraph will remain ...
Read More