Vineeth.mariserla has Published 278 Answers

What is the importance of '/g' flag in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 01-Jul-2020 09:44:33

/g is one of the regular expressions that make a user task easy. /g searches for a provided word globally. If any word is to be replaced by another word throughout all occurrences then /g comes into the picture. Let's discuss it in a nutshell.In the following example, we need ... Read More

What is the importance of '/i' flag in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 01-Jul-2020 09:40:48

Javascript is a case sensitive language. When we try to replace a word with another word, we need to check the case of the letters whether capital or small. For a single word, the process of checking is easy but take a scenario in which there are more of number ... Read More

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

vineeth.mariserla

vineeth.mariserla

Updated on 01-Jul-2020 08:08:49

We can use some logical methods to get the values and also keys from an object, but those methods will not return the values as an array, which is very useful in many cases. Javascript has provided Object.values() method to get an array whose elements are the enumerable property values of ... Read More

How to remove all the elements from a map in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 01-Jul-2020 07:26:13

The map is basically a collection of elements where each element is stored as a Key, value pair. It can hold both objects and primitive values as either a key or a value. When we iterate over the map object it returns the key, value pair in the same order as inserted. The ... Read More

Access property as a property using 'get' in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 01-Jul-2020 07:22:10

Using getter in javascript we can able to access the property as a property in a different way. The keyword 'get' is used to make this process happen. Let's discuss it in a nutshell.ExampleIn the following example, the property 'details' is used as a function that is 'details()'. Therefore we will ... Read More

How to repeat a string in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 30-Jun-2020 15:55:39

There are two ways to repeat a string in javascript. One way is to use string.repeat() method and the other way is to use the fill() method. Let's discuss them in detail.syntaxstring.repeat(number);This method takes a number as a parameter and repeats the string those many numbers of times.syntaxArray(number).fill(string).join('');This method initially takes a ... Read More

In how many ways can we split a string in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 30-Jun-2020 15:51:27

In javascript, we can split a string in 3 ways. One is an old way in which string.split() method is used and later on, ES6 has provided 2 more ways to split a string. In the first way spread operator is used and in the second way array.from() method is used. Let's ... Read More

How to swap variables with destructuring in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 30-Jun-2020 15:46:43

Swapping variables has become very easy with destructuring. In contemporary javascript swapping takes place by using another variable. It may not be hectic but it is lengthy. But in modern javascript there is no need for the third variable. Let's discuss it in detail.Example-1In the following example, swapping has done using another variable ... Read More

How to check whether a NaN is a NaN or not in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 30-Jun-2020 15:41:12

NaN is the only value that is not equal to itself. If we check other values, they are equal to themselves but the value NaN is not equal to itself.Example-1Live Demo<html> <body>    <script>       var val = 54/"the";       document.write(val);       document.write("</br>");       if(val ... Read More

How to modify an array value of a JSON object in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 30-Jun-2020 15:33:55

Modifying an array is just like modifying an object when that array is inside the object. The normal general principles will apply here.ExampleIn the following example, Initially in the 'companies' array, the first element is 'Tesla'. But after modifying the first element is changed to 'SolarCity' and the result is ... Read More

Advertisements