捕获数组值的简单函数,用“:”分隔并创建一个新数组
<!-- language: lang-js -->
function sumArrayHours( arrayHr )
{
var hr, min, hours;
$.each(arrayHr, function(key, element) {
hours = element.split(':');
hr = parseInt(hours[0], 10);
min = parseInt(hours[1], 10);
console.log('hr: ' + key + ' ' + 'min: ' + element);
});
}
var arrayHr = ["04:38", "05:49", "12:47"];
sumArrayHours( arrayHr );
回归: 未捕获的TypeError:无法读取未定义的属性“split”