get current url path in javascript from string code example Example: javascript get url path window.location.pathname