Yaswanth Varma has Published 279 Articles

Substitute random items in a JavaScript array?

Yaswanth Varma

Yaswanth Varma

Updated on 21-Apr-2023 17:26:42

217 Views

To substitute random items with items from an array with different ones in JavaScript. Let’s look at the instance; the array is − Var array=[m, n, o, p] Let's choose two random items to be replaced with a, while the others remain in their original positions. If m and ... Read More

How to detect and replace all the array elements in a string using RegExp in JavaScript? 

Yaswanth Varma

Yaswanth Varma

Updated on 21-Apr-2023 17:24:34

871 Views

An array is an ordered list of values in JavaScript. The term "element designated by an index" refers to each value: The following traits describe a JavaScript array: An array can initially store values of many sorts. You could, for instance, store elements of the number, string, Boolean, and null ... Read More

Make strings in array become keys in object in a new array in JavaScript?

Yaswanth Varma

Yaswanth Varma

Updated on 21-Apr-2023 17:23:05

1K+ Views

The task we are going to perform in this article is make strings in array become keys in object in a new array in JavaScript. Let’s consider a simple array − let array= ['bike', 'car'] Now, we are going to use map() to convert the above array to a ... Read More

How to count number of occurrences of repeated names in an array - JavaScript?

Yaswanth Varma

Yaswanth Varma

Updated on 21-Apr-2023 17:05:26

1K+ Views

An array in JavaScript is a group of identically typed elements that are stored in adjacent memory locations and may each be separately referred to using an index to a special identifier. Let’s consider an array consisting of occurrences of repeated names. The array looks like this − var details ... Read More

Is it possible to create a new data type in JavaScript?

Yaswanth Varma

Yaswanth Varma

Updated on 21-Apr-2023 17:03:31

2K+ Views

The task we are going to perform in this article is it possible to create a new data type in JavaScript. For instance, let’s consider we have variable student − var student = "username" console.log(typeof student) Now, I want to declare the type of that variable and print that ... Read More

How do I change a tag's inner HTML based on their order in JavaScript?

Yaswanth Varma

Yaswanth Varma

Updated on 21-Apr-2023 17:01:34

529 Views

The innerHTML property of an element in JavaScript allows you to access or modify any HTML or XML markup that is there. Use the method insertAdjacentHTML () to insert HTML into the page as opposed to changing an element's content. In JavaScript to change a tag’s innerHTML based on their ... Read More

How to format date value in JavaScript?

Yaswanth Varma

Yaswanth Varma

Updated on 21-Apr-2023 16:59:26

315 Views

To obtain dates in JavaScript, use either the new Date() or Date() function Object() { [native code] } (either current date or a specific date). While the Date() function Object()produces a string containing the current date and time, the new Date() function Object()creates a new Date object. Let’s dive into ... Read More

Capitalize a word and replace spaces with underscore - JavaScript?

Yaswanth Varma

Yaswanth Varma

Updated on 21-Apr-2023 16:58:12

1K+ Views

We will try to develop a method to change text with spaces and lowercase letters into text with underscores, where the initial letter of each word is capitalized. Let's examine the equation in its entirety. tutorials point = Tutorials_Point //expected output Let’s dive into article for getting better understanding ... Read More

Get current date/time in seconds - JavaScript?

Yaswanth Varma

Yaswanth Varma

Updated on 21-Apr-2023 16:50:21

11K+ Views

In JavaScript, there are built-in methods for getting the current date and time in seconds. We are going to perform this in two ways − Using the Date.now() method Using a new date getTime() method Let’s dive into the article for getting better understanding on getting current date ... Read More

How to remove all blank objects from an Object in JavaScript?

Yaswanth Varma

Yaswanth Varma

Updated on 21-Apr-2023 16:46:59

2K+ Views

The task at hand is to learn how to remove all blank objects from a JavaScript object. Let’s consider the following object − const details = { name: 'John', age: {}, marks: { marks: {} } } We need to ... Read More

Advertisements