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 285 of 801
What are the different use cases of remainder operator (%) in JavaScript?
In this tutorial, we will explore the different use cases of the remainder operator (%). The % operator returns the remainder when one number is divided by another and takes the sign of the dividend (the first operand). What is Remainder? When dividing two numbers, if the dividend is not completely divisible by the divisor, there is always a remainder. The remainder is what's left over after the division. 10 ÷ 2 = 5 (remainder 0, completely divisible) 6 ÷ 4 = 1 (remainder 2, not completely divisible) The remainder operator works as: dividend ...
Read MoreHow to create a string by joining the elements of an array in JavaScript?
In this tutorial, we will see how to create a string by joining the elements of an array in JavaScript. We will explore two different approaches: using the addition operator (+) to manually concatenate elements, and using the built-in join() method, which is the recommended approach. Using the Addition Operator (+) In this approach, we manually loop through the array and concatenate each element with a separator using the addition operator. While this works, it's more verbose than using the built-in join() method. Algorithm STEP 1 − Create an array with ...
Read MoreHow to create an element from a string in JavaScript?
In this tutorial, we will explore various methods to create HTML elements from strings in JavaScript. Creating elements dynamically from strings is essential for building interactive websites, such as to-do list apps where items are added, deleted, and edited on the fly. Using createElement() Method The createElement() method is the standard way to create HTML elements dynamically in JavaScript. This method takes a string parameter representing the tag name and returns a new HTML element. Syntax document.createElement(tagName) Where tagName is a string representing the HTML tag (like "div", "p", "h1", "img"). The method ...
Read MoreHow to check if the value is primitive or not in JavaScript?
In JavaScript, data types are divided into two categories: primitive and non-primitive. Understanding how to check if a value is primitive is crucial for proper data handling. Primitive data types: String, number, undefined, boolean, null, symbol, and bigint. Non-primitive data types: Objects (including arrays, functions, and dates). Primitive values are immutable and represent data at the lowest level of the language. When you "change" a primitive value, you're actually creating a new value and reassigning it to the variable. Using Object() Constructor The Object() constructor converts primitive values to objects. By comparing the original value with ...
Read MoreHow to open a webcam using JavaScript?
In this tutorial, we will learn how to open a webcam using JavaScript. This can be accomplished using WebRTC (Web Real-Time Communication), which allows us to access and capture webcam and microphone devices on the user's system. Understanding getUserMedia() We can access the user's webcam and microphone using the navigator.mediaDevices.getUserMedia() method. This function requires user permission and returns a Promise that resolves when access is granted. Basic Implementation Steps Follow these steps to implement webcam access: STEP 1 − Create HTML elements including a video element for the webcam stream and a ...
Read MoreHow to call promise inside another promise in JavaScript?
When working with JavaScript, you may find yourself needing to call a promise inside another promise. While this may seem like a daunting task, it is actually quite simple once you understand the basics of promises. In this article, we will discuss how to call a promise inside another promise in JavaScript. The Basics of Promises In order to understand how to call a promise inside another promise, it is important first to understand the basics of promises. A promise is an object that represents the eventual result of an asynchronous operation. Promises are used in JavaScript to ...
Read MoreHow to invoke a function with partials prepended arguments in JavaScript?
JavaScript provides several ways to invoke functions with partial arguments prepended. This technique is particularly useful when you want to create specialized versions of existing functions or implement partial application patterns. Using the bind() Method (Recommended) The bind()
Read MoreHow to invoke a function with its arguments transformed in JavaScript?
In JavaScript, we can create functions that take other functions as arguments and invoke them with transformed arguments. This is a powerful technique that can be used to create higher-order functions, which can take a function and return a new function with different behavior. What are Transforming Function Arguments To transform function arguments, we can use several approaches including the built-in methods map() and reduce(), or create custom transformation functions. These methods can be used on arrays to transform the elements in the array, and we can use them on functions to transform the arguments that are passed ...
Read MoreHow to create Expanding Cards using HTML, CSS, and JavaScript
In this tutorial, we will learn how to create Expanding Cards using HTML, CSS and JavaScript. Expanding cards provide an interactive way to display content with smooth animations and enhanced user experience. What are Expanding Cards? Expanding cards are interactive UI elements that scale up or reveal additional content when clicked. They are commonly used to display information in a compact format while providing an engaging way to access more details on demand. HTML Structure To create expanding cards, we need the following HTML elements: Card container element: Contains all cards ...
Read MoreHow to create Frame by Frame Animation using CSS and JavaScript?
Frame by frame animation is a technique used in animation to produce motion by displaying a series of static images which are sequentially displayed. The appearance of motion is achieved by displaying the images in rapid succession. The followings are needed before we go to create the frame by frame animation: A series of images (frames) A web page with CSS and JavaScript Approach The process of creating frame by frame animation using CSS and JavaScript is relatively simple: STEP 1 – First, you need to create ...
Read More