Articles on Trending Technologies

Technical articles with clear explanations and examples

Sorting or Arranging an Array with standard array values - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 226 Views

We are required to sort a dynamic JavaScript array. The condition is that we are required to sort it according to the values stored in a particular order in a standard predefined array. Let's say the following is our dynamic array − const dbArray = ['Apple', 'Banana', 'Mango', 'Apple', 'Mango', 'Mango', 'Apple']; And suppose the standard array against which we have to sort the above array is like − const stdArray = ['Mango', 'Apple', 'Banana', 'Grapes']; So, after sorting the dbArray, my resultant array should look like − const ...

Read More

Filter one array with another array - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 401 Views

In JavaScript, filtering one array based on another array is a common task. This technique is useful when you need to keep only certain elements from an array based on criteria stored in another array. Problem Setup Consider the following arrays: const main = [ {name: "Karan", age: 34}, {name: "Aayush", age: 24}, {name: "Ameesh", age: 23}, {name: "Joy", age: 33}, {name: "Siddarth", age: 43}, {name: "Nakul", age: 31}, ...

Read More

How to use the submit button in HTML forms?

mkotla
mkotla
Updated on 15-Mar-2026 5K+ Views

Submit button automatically submits a form on click. Using HTML forms, you can easily take user input. The tag is used to get user input, by adding the form elements. Different types of form elements include text input, radio button input, submit button, etc. Let's learn about how to use the submit button in HTML forms. It is created using HTML tag with the type attribute set to "submit". HTML Form with Submit Button ...

Read More

How to get first and last date of the current month with JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 35K+ Views

In this tutorial, we will look at how to get the first and last date of the current month using JavaScript. Working with dates is common in web development, especially when building calendars, date pickers, or time-based features. JavaScript provides built-in methods to handle dates, and there are also external libraries that make date manipulation easier. Following are the approaches to get the first and last date of the month using JavaScript − Using a Date Object Using the Moment.js Library Using a Date Object JavaScript's built-in ...

Read More

How can I add debugging code to my JavaScript?

Krantik Chavan
Krantik Chavan
Updated on 15-Mar-2026 255 Views

To add debugging code to JavaScript, you can use several methods to track program execution and variable values. Here are the most effective approaches. Using console.log() (Recommended) The console.log() method is the modern standard for debugging JavaScript. It outputs messages to the browser's developer console without interrupting program flow. var debugging = true; var whichImage = "widget"; if (debugging) { console.log("Calls swapImage() with argument: " + whichImage); } // Simulate function call function swapImage(image) { console.log("Processing image: " + image); return ...

Read More

How [ ] is converted to Boolean in JavaScript?

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

In JavaScript, an empty array [] is considered a truthy value when converted to Boolean. This might seem counterintuitive, but it follows JavaScript's type coercion rules for objects. Converting [] to Boolean Use the Boolean() method to explicitly convert an empty array to Boolean: Convert [] to Boolean var myVal = []; document.write("Boolean: " + Boolean(myVal)); ...

Read More

AngularJS and HTML5 date input value - how to get Firefox to show a readable date value in a date input?

Ankith Reddy
Ankith Reddy
Updated on 15-Mar-2026 318 Views

The elements of type date allow users to enter dates using a text box or date picker. With the ng-model directive, you can bind AngularJS application data to HTML input controls. However, Firefox has limited support for type="date" and converts values to strings, which can cause display issues. Since you want the date to be a real Date object and not a string, we need to create additional variables and link them together using watchers. The Problem Firefox doesn't fully support HTML5 date inputs and may not display dates in a readable format. The browser treats ...

Read More

Escape characters in JavaScript

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

Escape characters are special characters that require a backslash (\) prefix to be displayed literally in JavaScript strings. Without escaping, these characters have special meanings that could break your code or produce unexpected results. Common Escape Characters Code Result Description ' Single quote Allows single quotes inside single-quoted strings " Double quote Allows double quotes inside double-quoted strings \ Backslash Displays a literal backslash character New Line Creates a line break \t Tab Creates horizontal spacing \r Carriage Return Returns ...

Read More

How to do Butterfly Shuffle in JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 446 Views

A butterfly shuffled array in JavaScript is an array of Numbers that is sorted such that the numbers decrease as we approach the center of array and increase as we approach the end of array. The biggest number is placed at the very first index. Another variation of butterfly shuffled array is where the numbers increase towards the center and decrease towards the end. In this case the smallest number is placed at the very first index. For people who come from a Mathematics background, it's somewhat relatable to the Gaussian distribution. Example Suppose we have ...

Read More

How to determine if date is weekend in JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 876 Views

In JavaScript, you can determine if a date falls on a weekend by using the getDay() method. This method returns 0 for Sunday and 6 for Saturday, making weekend detection straightforward. How getDay() Works The getDay() method returns a number representing the day of the week: 0 = Sunday 1 = Monday 2 = Tuesday 3 = Wednesday 4 = Thursday 5 = Friday 6 = Saturday Basic Weekend Check Here's how to check if a specific date is a weekend: var givenDate = new Date("2020-07-18"); var currentDay = givenDate.getDay(); var ...

Read More
Showing 11801–11810 of 61,304 articles
Advertisements