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
Articles on Trending Technologies
Technical articles with clear explanations and examples
How do you make synchronous HTTP request in JavaScript?
Making synchronous HTTP requests in JavaScript blocks code execution until the response arrives. While generally discouraged, certain scenarios may require this approach. This article explores methods to create synchronous HTTP requests in JavaScript. Why Synchronous Requests? Synchronous requests pause execution until completion, which can freeze the browser. However, they're sometimes needed for: Critical data required before proceeding Sequential API calls with dependencies Legacy code compatibility Algorithm The basic steps for making synchronous HTTP requests: Create an HTTP request object ...
Read MoreHow to throw an error when using a property of an object?
In JavaScript, objects contain properties in key-value format. When accessing non-existent properties, JavaScript returns undefined instead of throwing an error. However, you can implement custom error handling to throw errors when invalid properties are accessed. Default Behavior: Accessing Non-existent Properties By default, JavaScript returns undefined for non-existent properties: Default behavior when accessing object properties let content = document.getElementById('content'); let object = { ...
Read MoreJavaScript Program To Add Two Numbers Represented By Linked Lists- Set 1
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 MoreAdvanced Techniques for Debugging JavaScript Applications
Debugging is an essential skill for every JavaScript developer. It helps identify and fix errors, optimise performance, and improve the overall quality of code. While basic debugging techniques like console logging are widely used, advanced techniques can greatly enhance your debugging capabilities. In this article, we will explore some advanced debugging techniques and learn how they can be effectively used to debug JavaScript applications. Using Breakpoints Breakpoints allow us to pause the execution of our code at a specific line and inspect the program's state. Modern browsers provide powerful debugging tools that enable setting breakpoints directly in the ...
Read MoreHow to Add onclick in a Button using javascript?
The onclick event generally occurs when the user clicks on an element. It enables the programmer to run a JavaScript function when an element is clicked. This event can be used to validate a form, display warning messages, and much more. This event can be added dynamically to any element using JavaScript. Except for , , , , , , , , , , and , it supports all HTML elements. In HTML, we can use the onclick attribute and associate it with a JavaScript function. For greater flexibility, we can also use JavaScript's addEventListener() method and pass ...
Read MoreHow to check if the clicked element is a div or not in JavaScript?
When building interactive web applications, you often need to detect clicks on specific elements like divs. This is particularly useful for modals, dropdowns, or any clickable containers. This tutorial explores three effective methods to check if a clicked element is a div. Using the onClick Attribute The onClick attribute is the simplest way to detect clicks on a specific div element. You assign a function that executes when the div is clicked. Syntax This is a div! function clickFunction() { // perform operation on click ...
Read MoreHow to hide span element if anchor href attribute is empty using JavaScript?
In web development, it's common to hide elements based on certain conditions. One specific requirement is hiding a element when its associated element has an empty href attribute. This is useful for navigation menus or dynamically generated links. This article explores multiple JavaScript approaches to achieve this functionality, giving you the flexibility to choose the method that best fits your needs. Understanding the Problem We want to hide a element if its associated element has an empty href attribute. To accomplish this, we need to: Select the elements that need ...
Read MoreJavaScript Program for Finding Length of a Linked List
To find the length of a linked list in JavaScript, we need to count how many nodes are present. A linked list is made up of nodes, where each node contains data and a reference to the next node. The length is determined by starting at the head and counting each node until the end of the list. If the list is empty, the length should be 0. Our task is to write a JavaScript program that calculates the length of a linked list. In other words, we need to find out how many nodes are in the list. ...
Read MoreHow to create form dynamically with the JavaScript
Creating HTML forms dynamically with JavaScript allows you to build interactive web pages that generate content based on user interactions. This approach uses DOM methods like createElement(), setAttribute(), and appendChild() to construct form elements programmatically. Key DOM Methods The essential methods for dynamic form creation: createElement() Creates any HTML element dynamically: document.createElement(tagName); setAttribute() Adds attributes to elements using key-value pairs: element.setAttribute(attributeName, value); appendChild() Inserts created elements into the DOM: parentElement.appendChild(childElement); Basic Dynamic Form Example Here's a simple example that creates a contact form when a button is ...
Read MoreHow do you receive server-sent event notifications in JavaScript?
Server-sent events (SSE) provide a unidirectional communication channel between server and client. When you only need to send data from server to client, SSE offers an efficient alternative to polling or WebSockets. Server-sent events work by establishing a persistent connection where the server pushes data to the client. The server can be any backend technology like Node.js, PHP, or Ruby. When the server sends data, a 'message' event fires on the client-side, which can be handled with event listeners. How Server-Sent Events Work The process involves three main steps: Client establishes connection using ...
Read More