Tutorialspoint
Drag to reposition
Contributed Answers (190)
Filter

What is importance of startsWith() method in JavaScript?

Answered 2d 7h ago, 0 Views

To know Whether a string starts with a particular character or a string indexOf() method is used. But in the advanced applications, this method is obsolete. So, ES6 has provided us with startsWith() method to perform those advanced tasks. In the following example, the IndexOf() method is used to find whether the string is started with a particular character or not. Live Demo , , In the fol.....

How to remove existing HTML elements in JavaScript?

Answered 2d 9h ago, 0 Views

To remove an existing HTML element removeChild() must be used. It removes any element from the parent element.  , It takes an element as a parameter and eliminates it from the DOM. In the following example, in the div section initially we have 2 texts. But when removeChild() method is used one of those texts is removed and only one text remains in the section. That text is displayed in.....

How to add a new element to HTML DOM in JavaScript?

Answered 2d 9h ago, 0 Views

To add a new element to the HTML DOM, we have to create it first and then we need to append it to the existing element. 1) First, create a div section and add some text to it using <p> tags.  2) Create an element <p> using document.createElement("p"). 3) Create a text, using document.createTextNode(), so as to insert it in the above-created element("p"). 4) Using .....

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

Answered 2d 11h ago, 0 Views

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 words to check. So to make this process easy "/i" comes into the picture. It replaces the word with another word irrespective of th.....

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

Answered 2d 12h ago, 0 Views

/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 to replace all the provided blue words with red and we have applied the normal str.replace() method to ac.....

How to get the available height and available width of a screen in JavaScript?

Answered 2d 14h ago, 0 Views

The window.screen object has provided many features to get the information regarding the browser screen. It has provided screen.availWidth and screen.availHeight to get the available height and available width of the screen. Let's discuss them individually. The screen.availWidth property returns the true width of the visitor's screen that means it subtracts the width of interface featu.....

How to find the inner height and inner width of a browser window in JavaScript?

Answered on 18th Jul, 2019, 0 Views

Javascript window object simply represents the browser window. This method is supported by all browsers. To get the inner height and inner width this method has provided some properties such as window.innerHeight and window.innerwidth respectively. Using these properties, it is easy to find the height and width of a browser window. Let's discuss them individually. In the following exam.....

How to get the pixel depth and color depth of a screen in JavaScript?

Answered on 18th Jul, 2019, 0 Views

Javascript window object has provided many methods to get various kinds of information regarding the browser.  It has provided screen.colorDepth and screen.pixelDepth to get the color depth and pixel depth of browser screen respectively. Let's discuss them individually. The window object has provided screen.colorDepth method to return the color depth. Color depth is nothing but the num.....

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

Answered on 18th Jul, 2019, 0 Views

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 map has provided a method called map.clear() to remove the values inside a map. This method will remo.....

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

Answered on 18th Jul, 2019, 0 Views

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 an object. , This method takes an object as an argument and returns an array whose elements a.....

1 2 3 4 5 6 7 ... 19 Next
loader
Advertisements
Contribution

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.