Articles on Trending Technologies

Technical articles with clear explanations and examples

How to return an array whose elements are the enumerable property values of an object in JavaScript?

vineeth.mariserla
vineeth.mariserla
Updated on 15-Mar-2026 313 Views

We can use various methods to get values and keys from an object, but those methods will not return the values as an array, which is very useful in many cases. JavaScript provides the Object.values() method to get an array whose elements are the enumerable property values of an object. Syntax Object.values(obj); This method takes an object as an argument and returns an array whose elements are the property values of the object. Parameters obj: The object whose enumerable property values are to be returned. Return Value An array containing the ...

Read More

How to Clear the JavaScript Console in Google Chrome

Aman Kumar
Aman Kumar
Updated on 15-Mar-2026 16K+ Views

In this article, we'll learn how to clear the JavaScript console in Google Chrome. When developing web applications, the console often gets cluttered with logs, errors, and debug messages, making it difficult to read new output. There are multiple ways to clear the Chrome console, each useful in different scenarios. Let's explore the most common methods. Using the console.clear() Method The console.clear() method programmatically clears the console and displays a "Console was cleared" message. Example Click the button to clear the console. Clear Console ...

Read More

How to import and export a module/library in JavaScript?

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

Note − To run this example you will need to run a localhost server. JavaScript modules allow you to break code into separate files and share functionality between them using export and import statements. This promotes code reusability and better organization. Example INDEX.html Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; ...

Read More

De-structuring an object without one key

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 213 Views

Object destructuring with the rest operator (...) allows you to extract specific properties while collecting the remaining properties into a new object. This technique is useful when you want to exclude certain keys from an object. Syntax const { keyToExclude, ...remainingKeys } = originalObject; Example: Excluding One Key Object Destructuring body { ...

Read More

Count unique elements in array without sorting JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 418 Views

When working with arrays containing duplicate values, counting unique elements is a common task. Let's explore different approaches to count unique elements in an array without sorting it first. Consider this sample array with duplicate values: const arr = ['Cat', 'Dog', 'Cat', 'Elephant', 'Dog', 'Grapes', 'Dog', 'Lion', 'Grapes', 'Lion']; console.log('Original array:', arr); Original array: ['Cat', 'Dog', 'Cat', 'Elephant', 'Dog', 'Grapes', 'Dog', 'Lion', 'Grapes', 'Lion'] Using Array.reduce() and lastIndexOf() This approach uses lastIndexOf() to identify the last occurrence of each element, ensuring each unique value is counted only once: const ...

Read More

JavaScript Create Submit button for form submission and another button to clear input

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

Form handling is a fundamental aspect of web development. A Submit button sends the form data for processing, while a Clear button allows users to reset or empty the form inputs. This functionality enhances user experience and ensures proper data entry. In this tutorial, we'll learn how to create a form with a Submit button for handling submissions and a Clear button for resetting inputs using JavaScript. We'll also handle the actions triggered by these buttons effectively. Creating a Submit Button for Form Submission ...

Read More

Make first letter of a string uppercase in JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 523 Views

To make first letter of a string uppercase, use toUpperCase() in JavaScript. With that, we will use charAt(0) since we need to only capitalize the 1st letter. Syntax string.charAt(0).toUpperCase() + string.slice(1) Example function replaceWithTheCapitalLetter(values){ return values.charAt(0).toUpperCase() + values.slice(1); } var word = "javascript" console.log(replaceWithTheCapitalLetter(word)); Javascript Multiple Examples function capitalizeFirst(str) { return str.charAt(0).toUpperCase() + str.slice(1); } console.log(capitalizeFirst("hello world")); console.log(capitalizeFirst("programming")); console.log(capitalizeFirst("a")); console.log(capitalizeFirst("")); Hello world Programming A How It Works The method breaks ...

Read More

How to make the web page height to fit screen height with HTML?

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

To make a web page height fit the screen height, you have several CSS approaches. Each method has different use cases and browser compatibility considerations. Method 1: Using Percentage Heights Set both html and body elements to 100% height to establish the full viewport height foundation: html, body { height: 100%; margin: 0; ...

Read More

Set the style of the border with CSS

Samual Sam
Samual Sam
Updated on 15-Mar-2026 113 Views

To set the style of border, use the border-style property. The border-style property allows you to select one of the following styles of the border: none: No border solid: Border is a single solid line. dotted: Border is a series of dots. dashed: Border is a series of short lines. double: Border is two solid lines. groove: Border looks as though it is carved into the page. ridge: Border looks the opposite of groove. ...

Read More

Arrays Data Structure in Javascript

Samual Sam
Samual Sam
Updated on 15-Mar-2026 613 Views

The array is a container which can hold a fixed number of items and these items should be of the same type. It stores a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type. Why do we need arrays? Let's say you want to record the average temperatures of all days of the week. You can record them as follows − let avgTempMon = 35; let ...

Read More
Showing 17221–17230 of 61,297 articles
Advertisements