var phone = '13312341234';
function substrPhone(phone, replace, num1, num2) {
var start = phone.substring(0, num1);
var end = phone.substring(phone.length - num2, phone.length);
console.log(end);
return start + replace + end;
}
var newPhone = substrPhone(phone, '********', 3, 0);
console.log(newPhone) // 133********