Articles on Trending Technologies

Technical articles with clear explanations and examples

How to avoid inserting NULL values to a table with JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 663 Views

When building dynamic tables with JavaScript, it's important to validate user input and prevent NULL values from being inserted. This ensures data integrity and provides a better user experience. Understanding NULL Validation In JavaScript, we need to check for null, undefined, and empty strings before inserting values into a table. The basic condition structure is: while (!(variable1 == null || variable2 == null || variable3 == null)) { // Insert values only when none are null } Complete Example with Validation ...

Read More

Joining two strings with two words at a time - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 220 Views

We are required to write a JavaScript function that takes in two strings, creates and returns a new string with first two characters of first string, next two characters of second string, then first, then second and so on. For example: If the strings are: const str1 = 'Hello world'; const str2 = 'How are you btw'; Then the output should be: 'HeHollw o arwoe rlyodu btw' Approach The algorithm alternates between the two strings, taking two characters at a time. When one string is exhausted, it appends the ...

Read More

Sum all similar elements in one array - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 479 Views

We are required to write a JavaScript function that takes in an array of numbers and sums all the identical numbers together at one index, removing duplicates while preserving the first occurrence position. For example, if we have repeated numbers in an array, we want to combine them into a single sum at the position where they first appear. Problem Statement If the input array is: const arr = [20, 10, 15, 20, 15, 10]; Then the output should be: const output = [40, 20, 30]; Here, 20 appears ...

Read More

How to use the tag to define a relationship to an external resource?

Johar Ali
Johar Ali
Updated on 15-Mar-2026 320 Views

The tag is used in HTML to define a relationship to an external resource. It is most commonly used to link external style sheets to HTML documents. The tag is placed inside the section and is a self-closing tag, meaning it does not require a closing tag. Syntax Key Attributes The tag uses several important attributes: rel - Specifies the relationship between the current document and the linked resource href - Specifies the URL of the external resource type - Specifies the media type of the linked resource ...

Read More

How to Add New Value to an Existing Array in JavaScript?

Saurabh Jaiswal
Saurabh Jaiswal
Updated on 15-Mar-2026 4K+ Views

To add new value to an existing array in Javascript, it can be achieved using various ways. We will be understanding seven different approaches for adding a new element to existing array. In this article we are having an array of numbers and our task is to add new value to an existing array in JavaScript. Approaches to Add New Value to Existing Array Here is a list of approaches to add new value to an existing array in JavaScript which we will be discussing in this article with stepwise explanation and complete example codes. ...

Read More

How to catch any JavaScript exception in Clojurescript?

Sravani Alamanda
Sravani Alamanda
Updated on 15-Mar-2026 295 Views

ClojureScript is a dialect of the Clojure programming language that compiles to JavaScript, allowing developers to use Clojure's functional programming paradigms in web browsers and Node.js environments. When building ClojureScript applications, proper exception handling is crucial for maintaining application stability and user experience. What is ClojureScript? ClojureScript is a compiler that transforms Clojure code into optimized JavaScript. Originally, Clojure only compiled to Java Virtual Machine bytecode, but ClojureScript emerged in 2011 to bring Clojure's powerful features to client-side development. ClojureScript operates at a higher abstraction level than JavaScript. While JavaScript deals with variables, loops, conditions, and objects, ...

Read More

What is the usage of onsearch event in JavaScript?

Abhinanda Shri
Abhinanda Shri
Updated on 15-Mar-2026 424 Views

The onsearch event triggers when a user interacts with a search input field by pressing ENTER or clicking the "x" (clear) button. This event only works with elements and provides a convenient way to handle search operations. Syntax // Or using addEventListener element.addEventListener("search", myFunction); Example Here's how to implement the onsearch event to capture user search input: OnSearch Event Example Write what you want to search below and press "ENTER" or click the "x" to clear: ...

Read More

How to set the bottom margin of an element with JavaScript?

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

The marginBottom property in JavaScript allows you to dynamically set the bottom margin of an element. This property is part of the element's style object and accepts values in pixels, percentages, or other CSS units. Syntax element.style.marginBottom = "value"; Where value can be in pixels (px), percentages (%), em units, or other valid CSS margin values. Example: Setting Bottom Margin Here's how to set the bottom margin of an element when a button is clicked: ...

Read More

How to prevent text select outside HTML5 canvas on double-click?

Smita Kapse
Smita Kapse
Updated on 15-Mar-2026 394 Views

When users double-click on or near an HTML5 canvas element, browsers may inadvertently select surrounding text. This creates a poor user experience, especially in interactive applications. Here's how to prevent this behavior. The Problem Double-clicking near a canvas element can trigger text selection in surrounding elements, highlighting unwanted text and disrupting the user interface. Solution: Disable Text Selection Set the onselectstart event handler to return false, which prevents the browser from starting text selection on the canvas element. var canvas = document.getElementById('myCanvas'); // Prevent text selection on double-click canvas.onselectstart = ...

Read More

Upload directly to Amazon S3 using Plupload HTML5 runtime

Lakshmi Srinivas
Lakshmi Srinivas
Updated on 15-Mar-2026 198 Views

Amazon S3 supports cross-origin resource sharing (CORS), enabling direct HTML5 file uploads from web browsers using Plupload. This eliminates the need for server-side proxies and provides a more efficient upload experience. What is CORS in Amazon S3? Cross-Origin Resource Sharing (CORS) allows web applications running on one domain to make requests to Amazon S3 buckets on a different domain. Without CORS, browsers block these cross-origin requests for security reasons. Setting Up CORS Configuration First, configure your S3 bucket's CORS policy to allow uploads from your domain: { "CORSRules": [ ...

Read More
Showing 18031–18040 of 61,297 articles
Advertisements