Articles on Trending Technologies

Technical articles with clear explanations and examples

Bootstrap Contextual classes

Arjun Thakur
Arjun Thakur
Updated on 15-Mar-2026 2K+ Views

Bootstrap contextual classes allow you to change the background color of table rows or individual cells to convey different meanings and states. These classes provide visual feedback to users about the status or importance of data. Available Contextual Classes Class Description Visual Effect ...

Read More

How to remove the last digit of a number and execute the remaining digits in JavaScript?

vineeth.mariserla
vineeth.mariserla
Updated on 15-Mar-2026 5K+ Views

In JavaScript, you can remove the last digit from a number using different approaches. The most common methods involve string manipulation or mathematical operations like bitwise operations. When working with numbers, you typically need to convert the number to a string to use string methods, or use mathematical operations to avoid type conversion altogether. Method 1: Using String substring() The substring() method extracts characters from a string between two specified indices. Syntax str.substring(startIndex, endIndex) To remove the last digit, use str.substring(0, str.length - 1) where the first parameter is the starting index ...

Read More

Passing empty parameter to a method in JavaScript

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

In JavaScript, you can pass empty parameters to a method by simply omitting them when calling the function. This is useful when working with functions that have default parameters or when you want to rely on the function's default behavior. Understanding Default Parameters Default parameters allow functions to have fallback values when no arguments are provided or when undefined is passed. Passing Empty Parameters body { ...

Read More

Find and return array positions of multiple values JavaScript

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

We have to write a function, say findPositions() that takes in two arrays as argument. And it should return an array of the indices of all the elements of the second array present in the first array. For example − If the first array is ['john', 'doe', 'chris', 'snow', 'john', 'chris'], And the second array is ['john', 'chris'] Then the output should be − [0, 2, 4, 5] Therefore, let's write the code for this function. We will use a forEach() loop here. Example const values = ['michael', ...

Read More

Compare two arrays and get those values that did not match JavaScript

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

We have two arrays of literals that contain some common values, our job is to write a function that returns an array with all those elements from both arrays that are not common. For example − // if the two arrays are: const first = ['cat', 'dog', 'mouse']; const second = ['zebra', 'tiger', 'dog', 'mouse']; // then the output should be: const output = ['cat', 'zebra', 'tiger'] // because these three are the only elements that are not common to both arrays Let's write the code for this − We will spread the two ...

Read More

Finding how many time a specific letter is appearing in the sentence using for loop, break, and continue - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 176 Views

We are required to write a JavaScript function that finds how many times a specific letter is appearing in the sentence using for loop, break, and continue statements. Using continue Statement The continue statement skips the current iteration and moves to the next one. Here's how we can use it to count character occurrences: const string = 'This is just an example string for the program'; const countAppearances = (str, char) => { let count = 0; for(let i = 0; i < str.length; i++){ ...

Read More

Is there a way to print all methods of an object in JavaScript?

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

In JavaScript, methods are object properties that contain functions. Sometimes you need to inspect an object to discover all its available methods. This tutorial shows how to print all methods of an object using different approaches. A method is simply a function stored as an object property. When you call obj.methodName(), you're executing the function stored in that property. JavaScript provides several ways to discover these function properties. Using Object.getOwnPropertyNames() Method The Object.getOwnPropertyNames() method returns an array of all properties (including non-enumerable ones) found directly on an object. We can filter this array to find only function ...

Read More

How to preselect a list item using JavaScript?

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

In this tutorial, we will learn how to preselect a select list item using JavaScript. This is useful when you want to set a default selection dynamically based on user preferences or application state. The HTML element creates dropdown menus where users can choose from multiple options. Each element represents a selectable choice. You can preselect options either by adding the selected attribute in HTML or programmatically using JavaScript. Understanding Select Elements A select element consists of: id attribute - Associates with labels for accessibility name attribute - ...

Read More

How to get Natural logarithm of 2 in JavaScript?

Paul Richard
Paul Richard
Updated on 15-Mar-2026 573 Views

To get the natural logarithm of 2 in JavaScript, use the Math.LN2 property. This built-in constant returns the natural logarithm of 2, which is approximately 0.693. Syntax Math.LN2 Return Value The Math.LN2 property returns a number representing the natural logarithm of 2, approximately 0.6931471805599453. Example Here's how to access the natural logarithm of 2: JavaScript Math LN2 Property ...

Read More

What is onerror() Method in JavaScript?

Abhinaya
Abhinaya
Updated on 15-Mar-2026 2K+ Views

The onerror event handler was the first feature to facilitate error handling in JavaScript. The error event is fired on the window object whenever an exception occurs on the page. Syntax window.onerror = function(message, source, lineno, colno, error) { // Handle the error return true; // Prevents default browser error handling }; Parameters The onerror handler receives five parameters: message: Error message source: URL of the script where error occurred lineno: Line ...

Read More
Showing 18411–18420 of 61,297 articles
Advertisements