Articles on Trending Technologies

Technical articles with clear explanations and examples

How to slice an array with wrapping in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 412 Views

Let's say, we are required to write an array method that overwrites the default Array.prototype.slice(). Usually the Array.prototype.slice() method takes in two arguments the start index and the end index, and returns a subarray of the original array from index start to end-1. What we wish to do is make this slice() function so it returns a subarray from index start to end and not end-1. We iterate over the array using a for loop which is faster than many array methods. Then return the required subarray, lastly we overwrite the Array.prototype.slice() with the method we just wrote. ...

Read More

How to use the map function to see if a time is in a certain time frame with JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 271 Views

In JavaScript, you can use the map() function to iterate through schedule records and check if the current time falls within a specific time frame. This is useful for determining which activity or subject you should be working on at any given moment. Example Data Structure Let's start with a simple schedule containing subject names and their study times: const scheduleDetails = [ { subjectName: 'JavaScript', studyTime: '5 PM - 11 PM' }, { subjectName: 'MySQL', studyTime: '12 AM - 4 PM' } ] Using map() ...

Read More

How to invoke a JavaScript Function with 'new' Function Constructor?

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

In this tutorial, we will learn how to invoke a JavaScript Function with the 'new' Function Constructor. Functions are a set of reusable codes that perform a specific task and may return a value. In JavaScript, functions are defined by the keyword function. A function may not have any parameters and may also not have any return statement. In JavaScript, we also have functions with no function names, called anonymous functions. Using the 'new' Function Constructor The Function constructor makes a new Function object. By using the constructor, we can create a function dynamically. It takes parameters, ...

Read More

How to get the value of the usemap attribute of an image with JavaScript?

Sravani S
Sravani S
Updated on 15-Mar-2026 262 Views

To get the value of the usemap attribute of an image, use the useMap property. This property returns the value of the usemap attribute, which specifies which image map to use with the image. Syntax let value = imageElement.useMap; Example ...

Read More

Bootstrap Form TextArea

Lakshmi Srinivas
Lakshmi Srinivas
Updated on 15-Mar-2026 3K+ Views

Bootstrap provides excellent styling for textarea elements in forms. The element is used when you need multiple lines of input from users, such as comments, descriptions, or detailed information. Basic Textarea Syntax To create a Bootstrap-styled textarea, use the form-control class: Label Text Complete Example Bootstrap Forms ...

Read More

What are the characteristics of JavaScript 'Strict Mode'?

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

JavaScript strict mode enables stricter parsing and error handling in your JavaScript code. By default, JavaScript runs in "sloppy mode" which allows certain questionable practices. Strict mode helps you write more secure and optimized code by catching common coding mistakes. Syntax Strict mode can be enabled in different scopes using the "use strict" directive: Global Strict Mode "use strict"; // All code in this script runs in strict mode Function Strict Mode function myFunction() { "use strict"; // Only this function runs in strict mode ...

Read More

Prefix sums (Creating an array with increasing sum) with Recursion in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 459 Views

Consider the following array of numbers: const arr = [10, 5, 6, 12, 7, 1]; The sum of its consecutive elements taking one less element in every go will be: [10, 5, 6, 12, 7, 1] = 10 + 5 + 6 + 12 + 7 + 1 = 41; [5, 6, 12, 7, 1] = 5 + 6 + 12 + 7 + 1 = 31; [6, 12, 7, 1] = 6 + 12 + 7 + 1 = 26; [12, 7, 1] = 12 + 7 + 1 = 20; [7, 1] ...

Read More

JavaScript how to get an alert to appear when I click on a button in a class?

Shriansh Kumar
Shriansh Kumar
Updated on 15-Mar-2026 2K+ Views

An alert in JavaScript is a dialog box that displays important information or warnings to the user. It contains a message with an OK button that dismisses the dialog when clicked. Clicking a button triggers an event handler that invokes a function instructing the browser to display the alert dialog. In this article, we will explore different ways to show an alert when a user clicks on a button in a class. For example, click on the button below to see an alert: .alerttoappear { margin: auto; width: ...

Read More

Prime numbers in a range - JavaScript

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

We are required to write a JavaScript function that takes in two numbers, say, a and b and returns the total number of prime numbers between a and b (including a and b, if they are prime). For example − If a = 2, and b = 21, the prime numbers between them are 2, 3, 5, 7, 11, 13, 17, 19 And their count is 8. Our function should return 8. Understanding Prime Numbers A prime number is a natural number greater than 1 that has no positive divisors other than 1 ...

Read More

Summing all the unique values of an array - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 348 Views

Let's say, we are required to write a JavaScript function that takes in an array of numbers with duplicate entries and sums all the duplicate entries to one index. For example − If the input array is − const input = [1, 3, 1, 3, 5, 7, 5, 4]; Then the output should be − const output = [2, 6, 10, 7, 4]; That means all the duplicate ones are summed to index 0 (1 + 1 = 2), all the duplicate threes are summed to index 1 (3 + ...

Read More
Showing 18751–18760 of 61,297 articles
Advertisements