JavaScript Location pathname Tutorial

In this section, we will learn what the location pathname property is and how to use it in JavaScript.

JavaScript Location pathname Property

With the help of `pathname` property, we can get or change the directory and/or the filename (if any) in the URL of the currently loaded document.

Location pathname Property Syntax:


Example: window location pathname

const value = location.pathname;


Leave a Reply