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
Javascript Articles
Page 28 of 534
JavaScript Testing Techniques: Integration Testing, E2E Testing, and Mocking
Testing plays a crucial role in ensuring the quality and reliability of JavaScript applications. While unit testing is widely adopted, advanced testing techniques such as integration testing, end-to-end (E2E) testing, and mocking are equally important in delivering robust applications. In this article, we will explore these advanced JavaScript testing techniques, providing theoretical explanations, code examples, and their benefits. Integration Testing Integration testing focuses on verifying the interactions and dependencies between different components of an application. It ensures that individual units work together harmoniously. JavaScript frameworks like Jest, Mocha, and Jasmine provide excellent support for integration testing. Example: ...
Read MoreOptimising JavaScript Bundle Sizes: Strategies for Code Splitting and Lazy Loading
In today's digital landscape, web applications have become increasingly sophisticated, offering a wide range of features and functionalities to users. However, this evolution comes at a cost: larger JavaScript bundle sizes. When a user visits a website, the browser is responsible for downloading and executing the entire JavaScript bundle, which can be a time-consuming process. This results in slower load times, increased network usage, and, ultimately, a negative impact on the user experience. To address this challenge, developers have turned to various techniques to optimize JavaScript bundle sizes. Two popular strategies that have gained traction are code splitting and ...
Read MoreParallel Programming in JavaScript with Web Workers and SIMD.js
JavaScript traditionally executes tasks in a single-threaded manner, which can limit performance for computationally intensive operations. However, modern web technologies enable parallel programming through Web Workers and SIMD.js, allowing developers to leverage multi-core processors for improved efficiency. Understanding Parallel Programming Parallel programming involves dividing tasks into smaller subtasks that execute concurrently, utilizing multiple resources to improve performance. In JavaScript, this is particularly beneficial for complex computations, data processing, and simulations without blocking the main UI thread. Web Workers Web Workers enable JavaScript code execution in separate background threads, providing true parallel processing. They operate independently from ...
Read MoreHow to prevent overriding using Immediately Invoked Function Expression in JavaScript?
JavaScript allows developers to add functionality and behaviors to the web page. Developers require to create multiple functions and variables to add functionality to different parts of the web page. While developing real-time applications, multiple developers work on the same project. So, avoiding the unintentional overriding of functions and variables while collaborating with multiple developers is necessary. In this tutorial, we will learn to prevent overriding using immediately invoked function expressions. Problem of Overriding For example, two colleagues are working on the same project, and both have defined the printAge() function inside the code and merged the ...
Read MoreHow to record and play audio in JavaScript?
Are you also willing to add a custom audio recording feature to your web application? If yes, you are in the right place, as we will learn to record and play audio using JavaScript in this tutorial. Some applications like Discord allow you to record the audio and store it inside that to play it anytime. The recorded audio can also be used as a meme for fun, alerts in the discord meetings, etc. We can also use the MediaRecorder API of JavaScript to add the recording audio feature to our web application. Here, we will learn a ...
Read MoreHow to disable button element dynamically using JavaScript?
In this article, we will learn how to disable button HTML elements dynamically using JavaScript, with the help of the "disabled" attribute. The "disabled" attribute in HTML button elements accepts a boolean value (true or false), and depending on the value, it disables the button and makes it non-functional, i.e., not clickable. We can use this attribute to disable any button in HTML by setting the "disabled" attribute to "true". Syntax Disabled Button In JavaScript, you can disable a button dynamically by setting the disabled property: // Disable button button.disabled = true; ...
Read MoreHow to display a warning before leaving the web page with unsaved changes using JavaScript?
In this article, we will learn how to display a warning message before leaving the web page with unsaved changes using JavaScript with the help of the "beforeunload" event listener. When working on web applications or forms of any kind, it becomes necessary to provide a warning message to users before they leave a page with unsaved changes. This can prevent accidental data loss and improve the overall user experience. Let's understand how we can implement this with the help of some examples − Using beforeunload Event In this example, we will have a form with multiple ...
Read MoreHow to Draw Smooth Curve Through Multiple Points using JavaScript?
Drawing smooth curves through multiple points is essential for creating visually appealing data visualizations and interactive graphics. JavaScript's Canvas API provides powerful methods to achieve this using mathematical curve algorithms. When connecting multiple points with straight lines, the result appears jagged and unnatural. Smooth curves create more elegant visualizations by using mathematical interpolation between points. Method 1: Using Quadratic Bézier Curves This approach uses quadraticCurveTo() to create smooth curves by calculating midpoints between consecutive points as curve endpoints. Smooth Curve with Quadratic Bézier ...
Read MoreHow to dynamically create new elements in JavaScript?
In this article, we will learn how to dynamically create new elements in JavaScript with the help of the createElement browser API. Dynamic element creation in JavaScript allows you to generate new HTML elements on the fly. Whether you need to add content to a web page based on user interactions or dynamically generate elements for a specific task, it can help enhance the flexibility and interactivity of web applications. Let's understand how to implement this with the help of some examples. Using createElement() and appendChild() In this example, we will have a button element and ...
Read MoreDHTML JavaScript
DHTML stands for Dynamic Hypertext Markup Language. DHTML combines HTML, CSS, and JavaScript to create interactive and dynamic web pages. It allows for customization and changes to the content based on user inputs. Earlier, HTML was used to create static pages that only defined the structure of the content. CSS helped in enhancing the page's appearance. However, these technologies were limited in their ability to create interactive experiences. DHTML introduced JavaScript and the Document Object Model (DOM) to make web pages dynamic. With DHTML, the web page can be manipulated and updated in response to user actions, eliminating the ...
Read More