Front End Technology Articles

Page 278 of 652

How to find the sum of all elements of a given array in JavaScript?

Imran Alam
Imran Alam
Updated on 15-Mar-2026 1K+ Views

In JavaScript, finding the sum of all elements in an array is a common operation. This tutorial covers different methods to achieve this, from traditional loops to modern array methods. Using the for Loop The for loop is the most straightforward approach to sum array elements. It provides full control over the iteration process and is easy to understand. Example Sum Array Elements Finding sum using for loop: ...

Read More

JavaScript: How to remove the key-value pairs corresponding to the given keys from an object?

Imran Alam
Imran Alam
Updated on 15-Mar-2026 12K+ Views

In JavaScript, objects store data as key-value pairs. You can access object data using dot notation (obj.key) or bracket notation (obj["key"]). Sometimes you need to remove specific key-value pairs from an object. Here are three effective methods to accomplish this. Using the delete Operator The delete operator is the most straightforward way to remove a property from an object. It permanently removes both the key and its value. Delete Operator Example ...

Read More

How to create a moving div using JavaScript?

Imran Alam
Imran Alam
Updated on 15-Mar-2026 12K+ Views

A moving div is a web page element that can be animated to move across the screen by modifying its position properties. Creating a moving div using JavaScript requires HTML for structure, CSS for positioning, and JavaScript for the animation logic. In this tutorial, we will learn how to create a moving div using JavaScript. HTML Structure First, we need a div element with a unique ID that we can target with JavaScript: This is my moving div! CSS Styling The CSS sets the initial position and appearance. We use position: relative to ...

Read More

How to Create a Currency Converter in JavaScript?

Imran Alam
Imran Alam
Updated on 15-Mar-2026 10K+ Views

In this tutorial, we will be discussing how to create a currency converter in JavaScript. We will be discussing the various steps involved in creating such a converter. What is a Currency Converter? A currency converter is a tool that helps you convert one currency to another. For example, if you are from the United States and you are traveling to Europe, you will need to use a currency converter to convert your US dollars into Euros. Why Use JavaScript to Create a Currency Converter? JavaScript is a versatile programming language that can be used to ...

Read More

How to check if a value is object-like in JavaScript?

Imran Alam
Imran Alam
Updated on 15-Mar-2026 295 Views

In JavaScript, an object-like value is any non-primitive value that has a type of "object". This includes objects, arrays, dates, and regular expressions, but excludes primitives like strings, numbers, booleans, null, and undefined. Understanding how to identify object-like values is crucial for data validation and type checking. What Makes a Value Object-Like? Object-like values share these characteristics: They are not primitive types (string, number, boolean, null, undefined, symbol) They can hold properties and methods They are reference types, not value types Method 1: Using the typeof ...

Read More

How to remove elements from an array until the passed function returns true in JavaScript?

Imran Alam
Imran Alam
Updated on 15-Mar-2026 511 Views

In JavaScript, there are various ways to remove elements from an array until the passed function returns true. This tutorial explores three different approaches with practical examples. Understanding "Remove Until Function Returns True" This operation means collecting elements from the beginning of an array, stopping when a condition is met. It's similar to "taking elements while a condition is false" or "dropping elements until a condition is true". Using Array.prototype.filter() The filter() method creates a new array with elements that pass a test function. For removing elements until a condition is met, we filter elements that ...

Read More

What is difference between Microtask Queue and Callback Queue in asynchronous JavaScript?

Imran Alam
Imran Alam
Updated on 15-Mar-2026 3K+ Views

In asynchronous JavaScript, there are two ways to schedule tasks – microtask queue and callback queue. Both queues are handled differently by the JavaScript engine, with microtasks having higher priority than callbacks. Event Loop Overview The event loop processes tasks in this order: call stack → microtask queue → callback queue. Understanding this priority system is crucial for predicting execution order in asynchronous code. Call Stack (Synchronous) Highest Priority Microtask Queue ...

Read More

How to return true if the parent element contains the child element in JavaScript?

Imran Alam
Imran Alam
Updated on 15-Mar-2026 7K+ Views

In this tutorial, we are going to look at how we can return true if the parent element contains the child element in JavaScript. Assuming you have two HTML elements, a parent element, and a child element, and you want to know if the parent element contains the child element. Using the Node.contains() method The Node interface's contains() method returns a Boolean value, indicating whether a node is a descendant of a given node or not. If you want to know if the parent element contains the child element, you can use the Node.contains() method. Syntax ...

Read More

How to convert a string into an integer without using parseInt() function in JavaScript?

Imran Alam
Imran Alam
Updated on 15-Mar-2026 2K+ Views

The parseInt() is a built-in function in JavaScript that parses a string and returns an integer. However, there are times when we want to convert a string into an integer without using this function. In this article, we'll explore several alternative methods to achieve this conversion. Using the Unary Plus Operator One way to convert a string into an integer is by using the unary plus operator (+). This operator converts its operand into a number. For instance, the following program converts the string "123" into the number 123: Unary Plus ...

Read More

How to convert a 2D array to a CSV string in JavaScript?

Imran Alam
Imran Alam
Updated on 15-Mar-2026 1K+ Views

The CSV (Comma Separated Values) file format is a popular way of exchanging data between applications and data stores. The CSV file format is simple and easy to understand, and many applications and programming languages support it. In JavaScript, there are several ways to convert a 2D array into a CSV string. In this tutorial, we'll look at effective methods: using Array.map() with join(), and a manual approach for handling special cases. Using Array.map() with join() (Recommended) The most straightforward approach is to use Array.map() to process each row and join() to combine elements with commas. ...

Read More
Showing 2771–2780 of 6,519 articles
« Prev 1 276 277 278 279 280 652 Next »
Advertisements