下面代码中为什么splice方法返回undefined并且不移除位置4的元素:
var excludedDepartmentsList = [1, 2, 3, 4, 5, 6];
var currentDepartmentId = 5;
var position = $.inArray(currentDepartmentId, excludedDepartmentsList);
if (position > -1) {
var q = excludedDepartmentsList.splice[position, 1];
return;
}
我在这里做了一个测试:http: //jsfiddle.net/PnVEb/