String.substr() 會從指定起始位置擷取指定長度的字串。
var str = 'JavaScript'; str.substr(4, 6);
若起始位置為負數,會從字串尾端開始計算。
這個方法較舊,新專案可优先考虑 substring() 或 slice()。