How to get the current page url in javascript

use below method to get current url in javascript:
var hrf = window.location;
console.log(hrf);