Articles on Trending Technologies

Technical articles with clear explanations and examples

How to create domain-based cookies using JavaScript?

Anvi Jain
Anvi Jain
Updated on 15-Mar-2026 418 Views

To create a domain-based cookie, set the domain and path attribute on your cookie. Domain-based cookies are accessible across all subdomains of the specified domain. Syntax document.cookie = "cookieName=value; domain=.example.com; path=/"; Domain Cookie Format domain=.example.com The dot prefix (.) makes the cookie available to all subdomains like www.example.com, api.example.com, etc. Example: Setting Domain-Based Cookie function WriteCookie() { if( document.myform.customer.value == "" ...

Read More

Set whether the table border should be collapsed into a single border or not with JavaScript?

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

In this tutorial, let us look at how to set whether the table border should collapse into a single table border or not with JavaScript. We can use the borderCollapse property in JavaScript to accomplish this. This property controls how table borders are displayed - either as separate borders for each cell or collapsed into a single unified border. Using the Style borderCollapse Property The borderCollapse property defines whether the table border should collapse into a single table border or separate into a double table border. The value 'separate' is the default. The borderCollapse is a read-and-write ...

Read More

Usage of font-size property in CSS

usharani
usharani
Updated on 15-Mar-2026 212 Views

The font-size property in CSS controls the size of text elements. It accepts various units and keywords to specify how large or small text should appear on a webpage. Syntax font-size: value; Font Size Values The font-size property accepts several types of values: Absolute keywords: xx-small, x-small, small, medium, large, x-large, xx-large Relative keywords: smaller, larger Length units: pixels (px), em, rem, points (pt) Percentage: relative to parent element's font size Example: Different Font Size Values ...

Read More

Determining happy numbers using recursion JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 851 Views

A happy number is a number which eventually reaches 1 when replaced by the sum of the square of each digit. Whereas if during this process any number gets repeated, the cycle will run infinitely and such numbers are called unhappy numbers. For example − 13 is a happy number because, 1^2 + 3^2 = 10 and, 1^2 + 0^2 = 1 On the other hand, 36 is an unhappy number. We are required to write a function that uses recursion to determine whether or not a number is a happy number. Algorithm ...

Read More

How to subtract date from today's date in JavaScript?

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

To subtract dates in JavaScript, you can work with Date objects directly or extract specific components like day, month, or year. The most common approach is to subtract one Date object from another to get the difference in milliseconds. Syntax var dateDifference = date1 - date2; // Returns difference in milliseconds var daysDifference = Math.floor((date1 - date2) / (1000 * 60 * 60 * 24)); Example 1: Subtracting Full Dates var currentDate = new Date(); var pastDate = new Date("2024-01-01"); // Get difference in milliseconds var timeDifference = currentDate - pastDate; console.log("Difference ...

Read More

Comparing forEach() and reduce() for summing an array of numbers in JavaScript.

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 498 Views

When summing arrays in JavaScript, both forEach() and reduce() are common approaches. This article compares their performance to help you choose the right method. Since we can't demonstrate with truly massive arrays here, we'll simulate the performance impact by running the summing operation many times in a loop. The Two Approaches Here's how each method works for summing an array: const arr = [1, 4, 4, 54, 56, 54, 2, 23, 6, 54, 65, 65]; // Using reduce() - functional approach const reduceSum = arr => arr.reduce((acc, val) => acc + val); // ...

Read More

Code to find the center of an array without using ES6 functions - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 394 Views

We are required to write an array function midElement() that returns the middlemost element of the array without accessing its length property and without using any kind of built-in loops. If the array contains an odd number of elements, we return the one middlemost element, or if the array contains an even number of elements, we return an array of two middlemost elements. How It Works The solution uses recursion to count array elements by incrementing an index until reaching undefined, then calculates the middle position(s) based on whether the count is odd or even. Example ...

Read More

How to check whether a value is a safe integer or not in JavaScript?

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

In this tutorial, we will learn to check whether a value is a safe integer or not in JavaScript. A safe integer in JavaScript is any number that can be accurately represented under the IEEE-754 double-precision format. Safe integers are all numbers between -(2^53 - 1) and (2^53 - 1) inclusive. JavaScript provides a built-in method for this check, but we can also implement custom logic. Here are the approaches we'll explore: Using the Number.isSafeInteger() Method (Recommended) Using Custom if-else Logic Using Number.isSafeInteger() Method The Number.isSafeInteger() ...

Read More

How to set the width of the bottom border with JavaScript?

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

In this tutorial, we shall learn to set the width of the bottom border with JavaScript. To set the width of the bottom border, we can use the borderBottomWidth property in JavaScript. It allows you to change the width. Let us discuss our topic in brief. Using the borderBottomWidth Property With this property, we can set or return the width of an element's bottom border. Width is a floating point number with either a relative units designator (cm, mm, in, pt, or pc) or an absolute units designator (em, ex, or px). Syntax Following is ...

Read More

How to enable a strict mode in javascript?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 188 Views

In JavaScript, there are two different programming paradigms. The sloppy mode, sometimes referred to as the simple mode, is activated by default. We don't have to write the code strictly according to guidelines in this manner. On the other side, there is also the strict mode. This setting allows the environment to have some rigid constraints. Strict mode has different semantics than regular code and is not a subset of sloppy mode. This article will explain how to enable strict mode in JavaScript and will also go over some of the features of "Strict" Mode. Syntax Different scopes ...

Read More
Showing 18761–18770 of 61,297 articles
Advertisements