How to get the title of HTML page with JavaScript?

How can I get the title of an HTML page with JavaScript?

Answer

Use document.title:

console.log(document.title)
<title>Title test</title>

MDN Web Docs