This shows you how to get the path of the current URL and assign it to a variable. This is achieved by taking url from location object. The location object also has other properties, like host, hash, protocol, and pathname.
Source code viewer
Programming Language: jQuery