Hello @kartik,
Use:
var host = window.location.hostname;
or possibly
var host = "http://"+window.location.hostname;
or if you like concatenation
var protocol = location.protocol;
var slashes = protocol.concat("//");
var host = slashes.concat(window.location.hostname);
Hope it helps!!
Thank You!!