Articles on Trending Technologies

Technical articles with clear explanations and examples

Tutorix - AI Tutor

isFinite() function in JavaScript

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 126 Views

The isFinite() function accepts a value and determines whether the given value is a finite number or not. If so, this method returns true, else it returns false. You can also invoke this method using the Number object as Number.isFinite(). Syntax isFinite(value) Number.isFinite(value) Parameters value: The value to be tested for finiteness. Return Value Returns true if the value is a finite number, false otherwise. Example: Basic Usage JavaScript Example ...

Read More

How to add a number and a string in JavaScript?

vineeth.mariserla
vineeth.mariserla
Updated on 15-Mar-2026 11K+ Views

In JavaScript, when you use the + operator with a number and a string, JavaScript performs concatenation instead of mathematical addition. This is because the presence of a string changes the operation from addition to string concatenation. How It Works JavaScript follows these rules when using the + operator: Number + Number: Mathematical addition String + Number: String concatenation (number is converted to string) Number + String: String concatenation (number is converted to string) Example var a = 5 + 5; ...

Read More

How to encode a string in JavaScript?

Lokesh Yadav
Lokesh Yadav
Updated on 15-Mar-2026 27K+ Views

In JavaScript, string encoding converts text into different formats for various purposes like URL handling, Base64 encoding, or data transmission. JavaScript provides several built-in methods for encoding strings depending on your specific needs. Encoding is the process of converting data from one format to another. Unlike encryption, encoding doesn't require keys and is primarily used to ensure data remains usable across different systems and protocols. Using btoa() Method The btoa() method encodes a string into Base64 format, which is commonly used for data transmission and storage. Syntax btoa(string) Where string is the text ...

Read More

JavaScript program to get a variable to count up/down on keyboard press.

Disha Verma
Disha Verma
Updated on 15-Mar-2026 724 Views

When working with JavaScript, handling keyboard events and creating a program that gets a variable to count up/down on keyboard press can be an essential skill. Keyboard events such as keydown and keyup in JavaScript are actions that occur when a user interacts with the keyboard. This article explains how to create a JavaScript program that increments or decrements a variable based on specific keyboard key presses. This feature can be helpful in interactive websites, like games or tools that check user input. Table of Content You can create a JavaScript program to get a variable to count ...

Read More

How to add a character to the beginning of every word in a string in JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 987 Views

We need to write a function that takes two strings and returns a new string with the second argument prepended to every word of the first string. For example: Input → 'hello stranger, how are you', '@@' Output → '@@hello @@stranger, @@how @@are @@you' If the second argument is not provided, we'll use '#' as the default character. Solution Using split() and map() The most straightforward approach is to split the string into words, prepend the character to each word, and join them back: const str = 'hello stranger, how are ...

Read More

How to convert comma separated text in div into separate lines with JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 3K+ Views

Converting comma-separated text in a div into separate lines is a common requirement in web development. This can be achieved using JavaScript's string manipulation methods along with DOM manipulation. Let's say we have the following comma-separated text in a div: This, is, the, first, JavaScript, program To convert comma-separated text into separate lines, we need to use trim() along with split() based on the comma separator. Method 1: Converting to List Items This approach splits the comma-separated text and converts each item into a list element: ...

Read More

Program to append two given strings such that, if the concatenation creates a double character then omit one of the characters - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 277 Views

We are required to write a JavaScript function that takes in two strings and concatenates the second string to the first string. If the last character of the first string and the first character of the second string are the same then we have to omit one of those characters. Let's say the following are our strings in JavaScript − Problem Example const str1 = 'Food'; const str2 = 'dog'; // Expected output: 'Foodog' (last 'd' of 'Food' matches first 'd' of 'dog') Solution Let's write the code for this function − ...

Read More

How to detect all active JavaScript event handlers?

Nishtha Thakur
Nishtha Thakur
Updated on 15-Mar-2026 912 Views

JavaScript doesn't provide a built-in method to detect all active event handlers on a page. However, there are several approaches to identify event listeners attached to DOM elements. Using jQuery to Detect Event Handlers jQuery provides a convenient way to access event data for elements that have jQuery event handlers attached. Demo Text // Attach jQuery event handler ...

Read More

What is onkeydown event in JavaScript?

Priya Pallavi
Priya Pallavi
Updated on 15-Mar-2026 542 Views

The onkeydown event in JavaScript triggers when a user presses down a key on the keyboard. This event occurs before the key is released and before the character appears in the input field, making it useful for intercepting keystrokes and implementing custom keyboard behaviors. Syntax element.onkeydown = function(event) { // Handle keydown event }; // Or using addEventListener element.addEventListener('keydown', function(event) { // Handle keydown event }); Basic Example Onkeydown Example ...

Read More

How to style background image to no repeat with JavaScript DOM?

Abhishek
Abhishek
Updated on 15-Mar-2026 3K+ Views

In this tutorial, we will learn to style the background image to no repeat with JavaScript DOM. To style the background image to no repeat with JavaScript, use the backgroundRepeat property. It allows you to set whether the background image repeats or not on a page. The use of images in the background really makes the page attractive. But before using the image in the background, one must completely understand the properties used to set the images as the background. Otherwise, it will create problems like not showing the full image in the background, repeating the image horizontally or ...

Read More
Showing 18651–18660 of 61,298 articles
Advertisements