Use substr:
var str = "H798asdhka80:124htg",
strpart = str.substr(0,str.indexOf(':'));
or slice
var str = "H798asdhka80:124htg",
strpart = str.slice(0,str.indexOf(':'));
or split
var strpart = "H798asdhka80:124htg".split(/:/)[0];
or match
var str = "H798asdhka80:124htg".match(/(^.+)?:/)[1];
or replace
var str = "H798asdhka80:124htg".replace(/:.+$/,'');
or create a more generic String.prototype extension
String.prototype.sliceUntil = function(str){
var pos = this.indexOf(str);
return this.slice(0, (pos>-1 ? pos : this.length));
}
var str = "H798asdhka80:124htg".sliceUntil(':124');