Yaswanth Varma

Yaswanth Varma

307 Articles Published

Articles by Yaswanth Varma

Page 11 of 31

Setting a default variable value to undefined in a function - JavaScript?

Yaswanth Varma
Yaswanth Varma
Updated on 15-Mar-2026 1K+ Views

The task we are going to perform in this article is setting a default variable value to undefined in a function. Before we jump into the article, let's understand what are functions in JavaScript. One of the core components of JavaScript are functions. In JavaScript, a function is comparable to a procedure-a collection of statements that carry out an action or compute a value. However, in order for a process to be considered a function, it must accept an input and produce an output with an evident connection between the input and the result. Let's see how to ...

Read More

How can I show a hidden div when a select option is selected in JavaScript?

Yaswanth Varma
Yaswanth Varma
Updated on 15-Mar-2026 17K+ Views

Showing and hiding elements dynamically is a fundamental technique in JavaScript web development. One common scenario is revealing a hidden div when a specific select option is chosen, creating interactive forms and user interfaces. Methods for Showing/Hiding Elements There are two main CSS properties for controlling element visibility: display: Removes element from document flow when hidden visibility: Keeps element's space but makes it invisible Method 1: Using visibility Property The visibility property hides the element while preserving its layout space: ...

Read More

Replace whitespace in different elements with the same class in JavaScript?

Yaswanth Varma
Yaswanth Varma
Updated on 15-Mar-2026 493 Views

In this article we are going to learn about replacing whitespace in different elements with the same class in JavaScript. We'll explore multiple methods to remove spaces from text content across multiple HTML elements that share a common CSS class. Using split() and join() Methods The split() method divides a string into substrings and returns them as an array. When a separator is specified, the string is split at each occurrence of that separator. The join() method combines array elements back into a single string using a specified separator. Syntax string.split(" ").join("") Example ...

Read More

Pulling data from array into new independent variables JavaScript?

Yaswanth Varma
Yaswanth Varma
Updated on 15-Mar-2026 659 Views

In JavaScript, you can extract data from arrays and assign values to new independent variables using various techniques. This process is commonly called "destructuring" and allows you to unpack array elements into separate variables efficiently. An independent variable is a standalone variable that isn't influenced by other variables. When pulling data from arrays, these new variables become independent copies of the original array elements. Using Array Destructuring (Recommended) Array destructuring is the modern and most efficient way to extract array elements into independent variables: ...

Read More

JavaScript subtraction of two float values?

Yaswanth Varma
Yaswanth Varma
Updated on 15-Mar-2026 3K+ Views

JavaScript floating-point arithmetic can produce unexpected results due to precision limitations. To correctly subtract two float values and get accurate results, use parseFloat() to ensure proper number conversion and toFixed() to control decimal precision. The Problem with Float Subtraction Direct subtraction of floats can yield imprecise results: var result1 = 0.3 - 0.1; var result2 = 0.2 - 0.1; document.write("0.3 - 0.1 = " + result1 + ""); ...

Read More

Create a to-do list with JavaScript

Yaswanth Varma
Yaswanth Varma
Updated on 15-Mar-2026 2K+ Views

A TODO list is a simple application that helps users keep track of tasks they need to complete. It typically allows users to add new tasks, mark them as completed, edit existing tasks, and delete unnecessary ones. In this tutorial, we'll learn how to create a functional to-do list using JavaScript. Our to-do list will support the following core features: Add new tasks Delete tasks Mark tasks as completed Edit existing tasks Basic To-Do List Implementation Let's start with a simple example ...

Read More

How to stop the loop for JavaScript scroll down?

Yaswanth Varma
Yaswanth Varma
Updated on 15-Mar-2026 855 Views

JavaScript scroll down loops can be extremely annoying and disruptive to a web page. Fortunately, it is relatively easy to stop the loop if you know what steps to take. In this article, we will discuss how to stop the JavaScript scroll down loop so that your website visitors don't have to keep scrolling endlessly. We'll also provide some tips on preventing these types of issues in the future. JavaScript method scrollBy() scrolls the web page to the specific number of pixels. When used in loops or intervals, it can create continuous scrolling effects that need proper control mechanisms. ...

Read More

How to add two arrays into a new array in JavaScript?

Yaswanth Varma
Yaswanth Varma
Updated on 15-Mar-2026 2K+ Views

An ordered group of indexed elements is represented by an array, which is a type of data structure. Merging two or more arrays to create a larger array that contains all the items from the original arrays is a typical operation done on multiple arrays. In JavaScript, there are several ways to add two arrays together and create a new array. This article will go over how to properly use the concat() method and spread operator (...) to combine two separate arrays into one newly created array. Additionally, each of these methods will be discussed with examples so ...

Read More

Replacing spaces with underscores in JavaScript?

Yaswanth Varma
Yaswanth Varma
Updated on 15-Mar-2026 4K+ Views

Let us learn about "how to replace spaces with underscores in JavaScript". This is a useful technique for formatting strings that contain multiple words, commonly used for URL slugs, file names, and database fields. We'll explore different methods to achieve this transformation and discuss their use cases and performance considerations. JavaScript provides several built-in methods to replace spaces with underscores. Here are the most commonly used approaches: replace() method with regular expressions replaceAll() method split() and join() methods Using replace() Method ...

Read More

How to display value of textbox in JavaScript?

Yaswanth Varma
Yaswanth Varma
Updated on 15-Mar-2026 19K+ Views

To display value of textbox in JavaScript, you can access the user input for validation, form processing, or real-time feedback. This is essential for checking email format, password strength, and other input validation requirements. In this article, we will explore two different approaches to get and display textbox values in JavaScript using practical examples. Approaches to Display Value of Textbox Here are the main approaches to display textbox values in JavaScript that we'll cover: Using value Property Using FormData Object Using value Property The ...

Read More
Showing 101–110 of 307 articles
« Prev 1 9 10 11 12 13 31 Next »
Advertisements