If you want to use the Full URL of your SharePoint site in JavaScript, you can simply use the below window property. "window.location.protocol + '//' + window.location.host;"
For site collection and webs Server Relative URL use "_spPageContextInfo.siteServerRelativeUrl" and "_spPageContextInfo.webServerRelativeUrl"
Read more: Learning SharePoint