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
Web Development Articles
Page 127 of 801
Explain the MUL() function in JavaScript
In this tutorial, we will learn to implement the MUL() function in JavaScript. This function demonstrates multiplication using nested functions, which create closures that maintain access to outer function variables. The MUL() function showcases JavaScript's first-class function nature, where functions can be returned from other functions. There are two ways to implement the MUL() function using nested functions: Using nested functions with names Using function currying with anonymous functions Using Nested Functions With Names In JavaScript, we can use nested functions to create a multiplication function that takes arguments one at a time. Each ...
Read MoreExplosion Animation in Canvas
In this tutorial, we will learn to create an explosion animation effect using canvas in HTML. Canvas provides a powerful way to draw dynamic graphics and animations on web pages. We'll explore two different approaches: a basic particle explosion and an interactive mouse-triggered explosion effect. Basic Particle Explosion This creates an explosion of 50 randomly colored particles that originate from the center of the canvas and move in random directions. How It Works The animation works by creating particle objects with position, velocity, and color properties. Each frame, we update particle positions and redraw them ...
Read MoreFastest way to convert JavaScript NodeList to Array
In this tutorial, we will learn the fastest way to convert JavaScript NodeList to Array. NodeList is a similar structure to an array; it is a collection of DOM (Document Object Model) elements. However, array methods like 'map()', 'filter()', and 'slice()' cannot be used on NodeList objects. There are several ways to convert NodeList to Array, but this task can be done faster using these approaches: Using Array.from() function (Recommended) Using spread operator (...) By iterating with for loop Using Array.from() (Recommended) The Array.from() method ...
Read MoreHow to change Input box borders after filling the box using JavaScript?
The style.border property is used to change an element's border styling in JavaScript. It allows you to modify the border-color, border-style, and border-width properties dynamically. This is particularly useful for providing visual feedback when users interact with form elements. We use the onchange event to trigger border changes after filling input boxes. The onchange event occurs when the value of an HTML element changes and the element loses focus. This differs from oninput, which fires immediately as the user types. The onchange event works with various form elements including text inputs, radio buttons, checkboxes, and select dropdowns. It's ...
Read MoreHow to change font style using drop-down list in JavaScript?
In JavaScript, you can change the font style of text elements using a dropdown list by combining HTML select elements with the style.fontFamily property. This creates an interactive way for users to change text appearance dynamically. A dropdown list (select element) allows users to choose from multiple font options. When a selection is made, JavaScript captures the change event and applies the selected font to target elements. Syntax The basic syntax for changing font family using JavaScript: element.style.fontFamily = "fontName"; HTML select element with options: Arial ...
Read MoreHow to change the font-weight of a text using JavaScript?
Using JavaScript is one of the most effective ways to dynamically change the font-weight of any text on your webpage. Font weight refers to the boldness or thinness of characters, ranging from 100 (thin) to 900 (black/heavy). In this article, we will explore how to change font-weight using JavaScript for both single and multiple elements. Using the Style fontWeight Property The style.fontWeight property allows us to change the font weight of individual HTML elements. This property accepts both numeric values and keyword values. Syntax document.getElementById("elementId").style.fontWeight = "normal|lighter|bold|bolder|100-900|initial|inherit"; You can assign numeric values (100-900) ...
Read MoreHow to change the href value of tag after clicking on button using JavaScript?
The href attribute specifies the link's destination, which can be a URL or an anchor point within the same document. Changing the href attribute value allows us to dynamically update the destination of the link, which can be useful in creating interactive web applications. The tag (anchor tag) is used to create hyperlinks in HTML, linking to other web pages or specific locations within the same document. By combining JavaScript with HTML elements, we can modify these links dynamically based on user interactions. In this article, we'll explore how to change the href value of an anchor ...
Read MoreExplain Chosen and Select2 with Examples
Select2 and Chosen are popular jQuery plugins that enhance HTML select boxes with improved styling, search capabilities, and user-friendly features. Both plugins work with single and multiple select elements, making form interactions more intuitive. Chosen Plugin Chosen is a JavaScript plugin that transforms standard select boxes into user-friendly dropdown interfaces. It's available for both jQuery and Prototype frameworks. Key Features of Chosen User-friendly Interface Users can search by typing instead of scrolling through long lists. Matching is instant, and non-matching options are filtered out automatically. Progressive Enhancement Chosen gracefully degrades to standard HTML select elements ...
Read MoreExplain Implement a Memoization Helper Function
Memoization is a programming technique that improves function performance by caching previously calculated results. When a function is called with the same arguments, instead of recalculating, it returns the cached result, significantly reducing execution time for expensive operations. What is Memoization? Memoization works by storing function results in a cache (usually an object or Map). When the function is called again with identical parameters, it checks the cache first. If the result exists, it returns the cached value; otherwise, it calculates the result and stores it for future use. Basic Example: Slow Function Without Memoization Let's ...
Read MoreJavaScript Program for Clockwise rotation of Linked List
In JavaScript, a clockwise rotation of a linked list moves the last k elements to the front. This operation is commonly used in data structure manipulations and algorithm problems. Given a linked list and a rotation count k, we need to move the last k nodes to the beginning. For example, rotating 1 → 2 → 3 → 4 → 5 clockwise by 2 positions results in 4 → 5 → 1 → 2 → 3. Structure of Linked List First, we'll create a Node class and helper functions to build and display the linked list: ...
Read More