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 a Dictionary using Javascript
In JavaScript, searching for elements in a dictionary (key-value pairs) can be accomplished using custom dictionary implementations or built-in ES6 Map objects. Both approaches provide efficient key-based lookups. Custom Dictionary Implementation Here's how to implement a get method that searches for a given key in a custom dictionary: get(key) { if(this.hasKey(key)) { return this.container[key]; } return undefined; } JavaScript objects are implemented like dictionaries internally, providing optimized key-value operations. This makes direct property access ...
Read MoreHow to change tabs on hover with CSS and JavaScript?
In this article, we will discuss how to change tabs on hover with CSS and JavaScript. Hover Tabs are an interactive UI pattern that allows users to switch between different content sections by simply hovering over tab buttons. When you move your cursor over a tab, its associated content is immediately displayed without requiring a click. This creates a smooth, responsive user experience where content changes dynamically as users explore different options. For example, in a product showcase, hovering over different category tabs could instantly display relevant products. How It Works The hover tab system combines ...
Read MoreHow to override derived properties in JavaScript?
In JavaScript, when an object inherits properties from its prototype, you can override those inherited properties by assigning new values directly to the child object. This creates own properties that shadow the prototype properties. Understanding Property Inheritance When you create an object using Object.create(), the new object inherits properties from its prototype. These inherited properties can be overridden by setting properties directly on the derived object. Example: Overriding Derived Properties Override Derived Properties ...
Read MoreHow to draw a circle in JavaScript?
Drawing circles in JavaScript is accomplished using the HTML5 Canvas API and the arc() method. This method allows you to create perfect circles and arcs with precise control over position, size, and styling. Basic Circle Drawing Syntax context.arc(x, y, radius, startAngle, endAngle, counterclockwise); Parameters Parameter Description x, y Center coordinates of the circle radius Circle radius in pixels startAngle Starting angle (0 for full circle) endAngle Ending angle (2 * Math.PI for full circle) Interactive Circle Example ...
Read MoreMulti-selection of Checkboxes on button click in jQuery?
Multi-selecting checkboxes is a common requirement in web forms. This can be achieved using jQuery to toggle all checkboxes with a single button click. Approach We'll use jQuery's prop() method to set the checked property of multiple checkboxes and toggleClass() to manage the button state. Example Multi-selection Checkboxes .changeColor { ...
Read MoreReturning the second most frequent character from a string (including spaces) - JavaScript
We are required to write a JavaScript function that takes in a string and returns the character which makes second most appearances in the string. Approach The solution involves counting character frequencies, sorting them by frequency, and returning the second most frequent character. Here's how it works: Create a frequency map to count each character occurrence Convert the map to an array of [character, frequency] pairs Sort the array by frequency in descending order Return the character at index 1 (second position) ...
Read MoreCreating an array using a string which contains the key and the value of the properties - JavaScript
Suppose, we have a special kind of string like this − const str = "Integer, 1 Float, 2.0Boolean, True Integer, 6Float, 3.66 Boolean, False"; We are required to write a JavaScript function that converts the above string into an array of objects, using the String.prototype.split() method − const arr = [ { "Integer": 1, "Float": 2.0 }, { ...
Read MoreWhat is the usage of oninvalid event in JavaScript?
The oninvalid event is triggered when a form field fails HTML5 validation constraints. It fires before form submission when an field with validation attributes (like required, pattern, etc.) contains invalid data. Syntax element.oninvalid = function() { // Handle invalid input }; // Or in HTML Basic Example Here's how to use oninvalid to show custom validation messages: Enter Name: ...
Read MoreHow to set the maximum height of an element with JavaScript?
Use the maxHeight property in JavaScript to set the maximum height of an element. This property controls how tall an element can grow, with content overflowing when the limit is reached. Syntax element.style.maxHeight = "value"; Parameters The maxHeight property accepts various values: Pixels: "200px" Percentage: "50%" (relative to parent) Keywords: "none" (no limit), "initial", "inherit" Example: Setting Maximum Height #box { width: 300px; background-color: gray; ...
Read MoreHTML5 tag on Android for PhoneGap application
PhoneGap is a software development framework by Adobe System, which is used to develop mobile applications. PhoneGap produces apps for all popular mobile OS platforms such as iOS, Android, BlackBerry, and Windows Mobile OS etc. HTML5 Audio support is not consistent across different devices due to codec licensing issues and OS implementation. For playing MP3 files, this can be handled by using PhoneGap's Media class that provides reliable audio programming across all platforms. Using PhoneGap Media Class The Media class provides audio recording and playback functionality. Here's how to implement basic audio playback: // Create ...
Read More