Javascript Articles

Page 23 of 534

JavaScript Program for Pairwise Swapping Elements of a Given Linked List

Aishwarya Mani Tripathi
Aishwarya Mani Tripathi
Updated on 15-Mar-2026 309 Views

In this tutorial, we will learn how to implement a JavaScript program for pairwise swapping elements of a given linked list. This operation swaps adjacent elements in pairs, which can be useful for reorganizing data, rearranging elements, or optimizing algorithms. We will provide a step-by-step approach to implementing the algorithm, explaining the logic and code behind it. By the end of this tutorial, you will understand how to implement pairwise swapping in a linked list using JavaScript. Problem Statement Given a linked list, the task is to swap elements pairwise. Elements at consecutive positions are swapped with ...

Read More

How to switch between multiple CSS stylesheets using JavaScript?

Mohit Panchasara
Mohit Panchasara
Updated on 15-Mar-2026 2K+ Views

In this tutorial, we will learn to switch between multiple CSS stylesheets using JavaScript. Have you ever thought that when you toggle the theme of TutorialsPoint's website, how it changes the CSS of the whole website? Here is a simple answer. When the user presses the button, it switches the CSS stylesheets for the website like it removes the stylesheet for the white theme and adds the stylesheet for the dark theme. Here, we will see examples of switching between multiple CSS files using JavaScript. Syntax Users can follow the syntax below to switch between multiple ...

Read More

JavaScript Program for Writing A Function To Get Nth Node In A Linked List

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 271 Views

Linked list is a linear data structure where nodes are connected by storing the address of the next node. Finding the nth node means retrieving the value at the nth position in the linked list, which can be accomplished using iterative or recursive methods. Problem Example Given linked list: 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> null Node to find: 3rd position Output: 3 Explanation: The value at the 3rd position is 3. Using Iterative Approach This approach traverses the linked list using a ...

Read More

JavaScript Program To Add Two Numbers Represented By Linked Lists- Set 1

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 336 Views

Adding two numbers is an easy task but could be tricky if the numbers are given in the form of the linked list. Each node of the linked list contains the digit of the number it represents in a continuous manner from the first node to the last node. We will be given two linked lists representing two different numbers and we have to add them and return the third number in the form of a linked list. Problem Statement Given two linked lists where each node contains a single digit, we need to add the numbers they ...

Read More

How to control fps with requestAnimationFrame?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 1K+ Views

The fps (frames per second) is crucial for animations and games, determining how many times the screen updates per second. JavaScript's requestAnimationFrame() typically runs at 60fps, but we can control this rate using different approaches. For example, a video is a continuous sequence of images shown at short intervals. Higher fps provides smoother animations, while lower fps can create choppy effects. Understanding fps control helps optimize performance and create desired visual effects. Using setTimeout() with requestAnimationFrame The setTimeout() function can delay requestAnimationFrame() calls to control fps. We calculate the interval as 1000/fps milliseconds. Syntax ...

Read More

What is the App Shell Model in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 825 Views

The App Shell Model is a design pattern that separates a web app's UI shell from dynamic content. The shell includes the core HTML, CSS, and JavaScript needed for the interface, while content is loaded dynamically. This approach is fundamental to Progressive Web Apps (PWAs) for improved performance and user experience. What is the App Shell? The app shell consists of the minimal HTML, CSS, and JavaScript required to power the user interface. It includes: Navigation and header components Layout structure and styling Loading indicators and placeholders ...

Read More

How to make a word count in textarea using JavaScript?

Saba Hilal
Saba Hilal
Updated on 15-Mar-2026 2K+ Views

Creating a word counter for textarea elements is a common requirement in web applications. This functionality helps users track their input length, especially useful for forms with character or word limits. We'll explore two different JavaScript approaches to implement this feature. Method 1: Counting Words by Analyzing Spaces and Newlines This approach manually iterates through each character in the textarea, counting spaces and newline characters to determine word boundaries. Implementation Steps Step 1 − Create an HTML file with a textarea element Step 2 − Add paragraph elements to ...

Read More

Which One is Better for Game Development—Python or JavaScript?

Tushar Sharma
Tushar Sharma
Updated on 15-Mar-2026 2K+ Views

Aspiring game developers often face the dilemma of choosing the right programming language for their projects. Two popular contenders in the game development realm are Python and JavaScript. In this article, we will explore the strengths and weaknesses of each language, discuss their suitability for different types of games, and help you determine which language is the better choice for your game development journey. Python: The Versatile Giant Python has earned its reputation as a flexible, beginner-friendly language with a rich ecosystem of libraries and frameworks. Its clean syntax, readability, and ease of use have made it a ...

Read More

How to Create an Animated Typing Effect using typed.js

Aman Gupta
Aman Gupta
Updated on 15-Mar-2026 3K+ Views

Overview Typed.js is a JavaScript animation library that creates realistic typing effects for web text. You can add it to your project via CDN, NPM, or Yarn. The library animates text by typing and deleting characters, simulating human typing behavior with customizable speed and effects. Syntax The basic syntax to create a Typed.js animation is: var typed = new Typed(selector, options); Where selector is the CSS selector (ID or class) of the target element, and options is an object containing configuration properties like strings, typing speed, and loop settings. Installation Add Typed.js to your project using ...

Read More

How to place cursor position at end of text in text input field using JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 12K+ Views

In HTML, the input field is used to take input from the users. Sometimes, we require to take string or long text messages in the input. In these scenarios, users may need to go to the end of the input field to add more content or message. So, we should set up something such that users can click the button, can go to the end of the input field. In this tutorial, we will learn to use JavaScript to place the cursor position at the end of the text in the input field. Using the setSelectionRange() method The ...

Read More
Showing 221–230 of 5,340 articles
« Prev 1 21 22 23 24 25 534 Next »
Advertisements