api的使用场景是移除数组中某一个指定的项
关于splice的一些资料:http://zhangyaochun.iteye.com/blog/1448006
/*
*remove-remove the element from the array*
*@param {Array} source---the array*
*@param element---the element*
*@return {Array}----after removed*
*/
ZYC.array.remove = function(source,element){
var len = source.length;
while (len --){
if(len in source && source[len] === element){
/*
*based on the js.lib*
array.splice(start,deleteCount,item)
*item is the new insert items*/
source.splice(len,1);
}
}
return source;
};
本文介绍如何利用JavaScript的splice方法高效地从数组中移除指定元素,并通过示例代码展示其具体应用。
467

被折叠的 条评论
为什么被折叠?



