Vineeth.mariserla has Published 278 Answers

How to display the domain of the server that loaded a document in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 02-Jul-2020 07:54:53

Javascript has provided document object to get any detail regarding a document. It has provided document.domain to get the domain of the server in which document loaded.ExampleIn the following example, the document is loaded in "tutorialspoint" server. Therefore the domain which we will get is "www.tutorialspoint.com". Document.domain is an inbuilt function ... Read More

How to find a number of anchors in a document in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 01-Jul-2020 14:30:00

Anchor tags are very common when dealing with a document in javascript. Javascript has provided document.anchors .length to get the number of anchors in a document. This method won't affect any other line codes in the program. It only renders the length of the anchor tags.syntaxlength = document.anchors.length;It returns only ... Read More

How to get a particular anchor in a document in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 01-Jul-2020 14:28:46

Javascript anchor tags follow an array-like structure. When we try to display a particular anchor tag we have to use document.anchors.innerHTML method. This method works the same as array methods which are used to display a particular element.syntaxelement = document.anchors[i].innerHTML;Example-1In the following example, the first anchor tag, out of 2 anchor tags, ... Read More

What is the use of Higher-order functions in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 01-Jul-2020 14:06:56

Javascript has provided many built-in functions to complete a particular task. But if we try to solve any program normally with those built-in functions, the code may not be concise. Javascript has also provided some inbuilt higher-order functions. These higher-order functions decrease the length of the code, increase the readability and ... Read More

How to clone an object using spread operator in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 01-Jul-2020 13:56:30

Cloning is nothing but copying an object from one variable to another variable. Simple cloning using the assignment operator does not work as per our intentions. When cloning takes place, a change in any variable shouldn't reflect any kind of change in another variable. But in the case of assignment operator, a ... Read More

Sibling of a list element in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 01-Jul-2020 11:28:17

To find the sibling of a list element javascript has provided a method called node.nextSibling. If we know any member of a list we can find its sibling. Let's discuss it in a nutshell.syntaxnode.nextSibling;ExampleIn the following example, there are 3 list elements. Using the nextSibling property the sibling of the first element ... Read More

Insert a specified HTML text into a specified position in the JavaScript document?

vineeth.mariserla

vineeth.mariserla

Updated on 01-Jul-2020 11:01:26

Javascript has provided insertAdjacentHTML() method to insert a text as HTML, into a specified position. Those legal positions are afterbeginafterendbeforebeginbeforeendEach legal position has its own unique importance. Let's discuss some of them.ExampleIn the following example, using "insertAdjacentHTML()" method and a legal position "afterend", a new text is placed adjacent to the ... Read More

What is importance of startsWith() method in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 01-Jul-2020 10:54:31

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 ... Read More

What is the use of test() method in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 01-Jul-2020 10:52:34

The test() method is a regular expression method. It searches a string for a pattern, and returns true or false, depending on the result. If it encountered the given pattern it returns true, else returns false. It is case sensitive. Let's discuss it in detail.Example-1In the following example, a text named "Tutorix ... Read More

How to remove existing HTML elements in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 01-Jul-2020 10:15:29

To remove an existing HTML element removeChild() must be used. It removes any element from the parent element. syntaxremoveChild(element);It takes an element as a parameter and eliminates it from the DOM.ExampleIn the following example, in the div section initially we have 2 texts. But when removeChild() method is used one of those texts ... Read More

Advertisements